Jeff
Jeff

Reputation: 36573

Windsor Registration Child Container Visibility

I have some (sort of) Singletons which exist in three context:

  1. Per AppDomain

  2. Per HttpApplication

  3. Per Web Request

Right now, I'm creating a child container per HttpApplication and another child per Web Request. This is necessary because some components SHOULD actually share singleton instances across the three layers. For security and other reasons, there are certain registrations that SHOULD NOT actually share the singleton (one per container).

Does anyone have a suggestion as to how to implement this or how I can limit the visibility of registrations within a container hierarchy?

Thanks.

Upvotes: 0

Views: 216

Answers (2)

Mauricio Scheffer
Mauricio Scheffer

Reputation: 99730

As Stuart says, lifestyles are the correct extension point to do this. Child containers are not necessary. Per web request comes out of the box in Windsor, and IIRC the Singleton lifestyle (the default one) works per appdomain. The per-HttpApplication lifestyle is implemented in the Castle.Windsor.Lifestyles contrib project.

Upvotes: 2

Stuart Lange
Stuart Lange

Reputation: 4089

Have you tried using lifestyles to solve this problem? A combination of the Singleton and PerWebRequest lifestyles may satisfy your requirements, without requiring child containers.

Upvotes: 1

Related Questions