BTW my assumption is that a factory method is to be called whenever it
can satisfy a dependency.
I tried implementing IDisposable on the Create method output but that
didn't help.
I reverted in using Property Setter injection of the factory class and
calling Create method there.

Daniel

On 23 Mar, 14:37, Daniel Fernandes <[email protected]> wrote:
> I am developing a Web application using ASP.Net MVC and CastleProject
> 1.0 RC3 amongst other things.
> In the bootstrap I set up the usual stuff, facilities, controllers,
> services and here factories.
> Most of the registered components in the container are set as
> Transient.
> I have a breakpoint at the end of the bootstrap and if I resolve a
> component that has got a property-based dependency that is resolved
> using a factory it's all well. Factory is created once and Create
> method is called each time the dependency needs resolving. In this
> case the dependency that is provided by a factory is a security
> context that implementes IPrincipal.
>
> So I have :
> public class MyService : IService {
>
> public MyService(IOtherService otherService) {
> ...}
>
> public IPrincipal SecurityContext {get;set;}
>
> }
>
> MyService.SecurityContext (just after the bootstrap has finished
> setting up the application and before letting the first page to get
> rendered) will always cause a call to the factory that provides
> IPrincipal.
>
> Factory facility has been registered like this:
> container.AddFacility("FactorySupportFacility", new
> FactorySupportFacility());
> and here is the registration for the factory class and the dependency
> it's providing :
>
> container.AddComponent<IPrincipalFactory>
> ("PrincipalFactory.factory");
> container.Register(
>                 Component.For<IPrincipal>().AddAttributeDescriptor
> ("factoryId", "PrincipalFactory.factory").AddAttributeDescriptor
> ("factoryCreate", "Create"));
>
> Now, if I load the page up and then do a refresh, IService will be
> correctly resolved via constructor injection but somehow IPrincipal
> property setter will too be called but WITHOUT having called the
> Create method on the Factory.
> If I call the container from anywhere in the application and resolve
> the service it will, too, no longer call the Create method.
>
> It's all very puzzling!
>
> Cheers
> Daniel Fernandes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to