I had a similar problem, I believe you have a "leaking this" problem:
http://kozmic.pl/2009/10/30/castle-dynamic-proxy-tutorial-part-xv-patterns-and-antipatterns The proxy is an interface proxy, which works with composition, wrapping calls to the implementation, so by the time the Operation() gets called, you are already in your class, and calling MyTransactionalMethod() from there will call the method on the class bypassing the proxies. Don't know if there is a solution to this. Mayebe someone else can advise. On Sat, Jan 29, 2011 at 10:34 AM, clinamen <[email protected]> wrote: > have a WCF service instance activated through a ServiceBehavior that > configures Castle Windsor as IoC container as uses it to resolve the > service implementation (and so all its dependency graph). > > Windsor container is configured with NHibernateFacility set up through > configuration and these facilities set up in code: > TransactionFacility, TypedFactoryFacility. > > The trouble here is that the TransactionInterceptor does not get > invoked around the call to MyTransactionalMethod() made in the body of > Operation() method. If I set the 'Transaction' attribute on the > Operation() method the interceptor gets invoked as expected. It seems > to me as the proxy is created against service interface only. > Moreover, stepping through TransactionFacility code can be noted that > the interceptor is correctly added to the component model during model > inspection. As a note, attached to this service I have also a custom > interceptor registered as last, but I think it is not influent at all. > > I'm rather new to Castle Windsor and probably I'm missing something > about DynamicProxy and interceptors implementation, so I ask here for > an explanation to this behavior and how I can obtain the one I need. > > Below a skeleton of the components involved. For brevity I omit > explaining the reason why I cannot annotate Operation() with > 'Transaction', but it is due to the fact that I need to "do stuff" > after the transaction is closed. > > Thanks in advance, Andrea > > // Code skeleton > [ServiceContract] > public interface IService { > [OperationContract] > void Operation(); > } > > [Transactional] > public class ServiceImpl : IService { > public void Operation() { > MyTransactionalMethod(); > // do stuff out of transaction scope > } > > [Transaction(TransactionMode.Requires)] > protected virtual void MyTransactionalMethod(){ > // stuff that deals with Dao(s). > } > } > > -- > 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. > > -- 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.
