Lifetime management in mvc turbine?

290 views Asked by At

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?

1

There are 1 answers

2
Javier Lozano On BEST ANSWER

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.