WCF Integration: injecting dependencies into custom AuthorizationPolicy

37 views
Skip to first unread message

Dan B

unread,
Aug 17, 2011, 7:31:02 AM8/17/11
to castle-pro...@googlegroups.com
Hi,

I've inherited a legacy application which used/abused Unity (instantiating a Unity container on every request, then stashing things in it that needed to be scoped to the lifetime of the request - ouch!) This all seems a bit wasteful to me, when I could just use Castle Windsor with the PerWcfRequest lifestyle.

The legacy system uses a custom ServiceHostFactory to add an IAuthorizationPolicy implementation to the ServiceHost and to instantiate and hook up the Unity container.

The AuthorizationPolicy has a concrete dependency on another class which does all the database lookups + caching information about the user. Is there an elegant way to inject this dependency in the constructor of the AuthorizationPolicy without having to introduce a dependency on the IOC container and using the Service Locator AntiPattern?
Or should I stop worrying and just implement the damn thing?

Thanks,

Dan

Dan B

unread,
Aug 17, 2011, 9:16:38 AM8/17/11
to castle-pro...@googlegroups.com
Aha!

I implemented the Created method of IServiceHost aware, that did the trick!
Reply all
Reply to author
Forward
0 new messages