You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2011/05/11 01:55:30 UTC
Re: svn commit: r1100921 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java
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 ffang@apache.org 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
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com
Re: svn commit: r1100921 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java
Posted by Freeman Fang <fr...@gmail.com>.
Hi Dan,
Thanks for your clarification.
I'll revert my change, and Willem's 1100162 commit already store
application context classloader for spring bus and your 1087406 commit
already set correct application context classloader which retrieved
from SpringBus or BlueprintBus for MessageObservers, so we should be
fine with SpringBus or BlueprintBus with you two's change . But I'm
not sure if it's ok when we use java code directly to publish
endpoint, no SpringBus or BlueprintBus get involved at all in this
case and I think
bus.getExtension(ClassLoader.class);
would be null(is my assumption correct?) and so we have no chance to
reset TCCL with correct classloader, that's the major reason why I set
TCCL in AbstractInvoker as there's the place I can get ServiceObject's
classloader. Though in OSGi container we mostly publish webservice
endpoint through spring-dm/blueprint per the nature that OSGi bundle
isn't a standalone process, but I'm still a lit bit concern about the
case that not use SpringBus nor BlueprintBus.
Regards
Freeman
On 2011-5-11, at 上午7:55, Daniel Kulp wrote:
>
> 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 ffang@apache.org 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
> dkulp@apache.org
> http://dankulp.com/blog
> Talend - http://www.talend.com
---------------------------------------------
Freeman Fang
FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
Connect at CamelOne May 24-26
The Open Source Integration Conference