proxy - What is the expected LifeStyle of a Castle Windsor component activator? -
i'm using castle windsor , dynamicproxy implement persistence lazy loading scratch (i know nhibernate alternative etc.) have implemented custom component activator instantiate business classes proxies. found default mixin proxies automatically created when using interceptors not beingness used when class methods called within class itself, problem. inherited defaultcomponentactivator , overriding createinstance() i'm calling createclassproxy() proxy inherits business class, in respect works fine.
now expecting 'proxycomponentactivator' activator of mine instantiated castle once, new instance beingness created each class type. correct?
current registration this:
public void install( iwindsorcontainer container, castle.microkernel.subsystems.configuration.iconfigurationstore store) { container.register( classes .fromassemblycontaining(typeof(oneofmybusinessclasses)) .innamespace(typeof(oneofmybusinessclasses).namespace) .withservice.defaultinterfaces() .configure(reg => reg.activator<proxycomponentactivator>()) .lifestyletransient(), etc. ); );
the activator implementation following:
public class proxycomponentactivator : defaultcomponentactivator { protected castle.dynamicproxy.proxygenerator proxygenerator { get; set; } protected persistenceinterceptor persistenceinterceptor { get; set; } public proxycomponentactivator(componentmodel model, castle.microkernel.ikernelinternal kernel, componentinstancedelegate oncreation, componentinstancedelegate ondestruction) : base(model, kernel, oncreation, ondestruction) { this.proxygenerator = kernel.resolve<castle.dynamicproxy.proxygenerator>(); this.persistenceinterceptor = kernel.resolve<persistenceinterceptor>(); } protected override object createinstance(creationcontext context, constructorcandidate constructor, object[] arguments) //, type[] signature) { object instance; type impltype = this.model.implementation; proxygenerationoptions p = new proxygenerationoptions(); ipersistent ip = new persistent(); p.addmixininstance(ip); seek { instance = this.proxygenerator.createclassproxy(impltype, null, p, arguments, this.persistenceinterceptor); } grab { throw new componentactivatorexception("componentactivator: not proxy " + impltype.fullname, model); } homecoming instance; } }
i have tried register activator this, no avail...
component.for<proxycomponentactivator>() .implementedby<proxycomponentactivator>() .lifestylesingleton()
thanks in advance help, luis
every component in windsor own activator instance
proxy castle-windsor castle activator
No comments:
Post a Comment