I have to -1 this commit as it breaks a few use cases. Primarily, the STS server we now have as part of the CXF bundle. In the case of the STS, the classloader that loads the STS class will likely be the CXF bundle classloader, not the application context. However, the user code will likely need to have the thread context loader set to the application contexts loader in order to get all the security information and credentials. There are other similar issues. In all the cases, the TCCL should be set to t he class loader for the Application (likely from the ApplicationContext for Spring). It should be set prior to calling the chain,, likely by the transport itself or the message listener. After that, it shouldn't need to be reset. Anyway, now for both Spring and Blueprint, the proper classloader is saved as bus.getExtension(ClassLoader.class) and we should make sure we always use that.
Dan On Monday, May 09, 2011 4:54:00 AM [email protected] wrote: > Author: ffang > Date: Mon May 9 08:54:00 2011 > New Revision: 1100921 > > URL: http://svn.apache.org/viewvc?rev=1100921&view=rev > Log: > [CXF-3503]CXF should set the TCCL to the one of the service being invoked > prior any invocation > > Modified: > > cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInv > oker.java > > Modified: > cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInv > oker.java URL: > http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cx > f/service/invoker/AbstractInvoker.java?rev=1100921&r1=1100920&r2=1100921&vi > ew=diff > ========================================================================== > ==== --- > cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInv > oker.java (original) +++ > cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInv > oker.java Mon May 9 08:54:00 2011 @@ -80,7 +80,9 @@ public abstract class > AbstractInvoker im > > protected Object invoke(Exchange exchange, final Object serviceObject, > Method m, List<Object> params) { Object res; > + ClassLoader oldCL = > Thread.currentThread().getContextClassLoader(); try { > + > Thread.currentThread().setContextClassLoader(serviceObject.getClass().getC > lassLoader()); Object[] paramArray = new Object[]{}; > if (params != null) { > paramArray = params.toArray(); > @@ -131,6 +133,8 @@ public abstract class AbstractInvoker im > checkSuspendedInvocation(exchange, serviceObject, m, params, > e); exchange.getInMessage().put(FaultMode.class, > FaultMode.UNCHECKED_APPLICATION_FAULT); throw createFault(e, m, params, > false); > + } finally { > + Thread.currentThread().setContextClassLoader(oldCL); > } > } -- Daniel Kulp [email protected] http://dankulp.com/blog Talend - http://www.talend.com
