Question

How can I manage the lifetime of my services in mvc turbine (using Unity)?

I have an ISearchService implementation LuceneSearchService that takes an IConfigurationService and ILoggerService.

Currently my searchservice registration looks like this:

public class SearchServiceRegistration: IServiceRegistration
{
    public void Register(IServiceLocator locator)
    {
        locator.Register<ISearchService, LuceneSearchService>();
    }
}

I would like to keep the responsibility of creating the instance in Turbine, but I want it to be a singleton.

Or in other words, how can I define the lifetime?

Was it helpful?

Solution

Currently the Turbine bits don't allow for lifetime management since I felt that was best suited work for your container. If you're interested, you can use something like what I define on this blog post: Injecting Your Favorite IoC Into MVC Turbine

If you're OK with exposing your container with your within your IServiceRegistration implementation you can do something like this: HACK to expose your specific SL within your registration

If I get a lot of requests for the need of lifetime management, I will add it to V3 of Turbine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top