Author: alessio.soldano(a)jboss.com
Date: 2012-02-03 06:42:51 -0500 (Fri, 03 Feb 2012)
New Revision: 15588
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/NsCtxSelectorStoreInterceptor.java
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java
Log:
[AS7-3581] Reverting Richard's changes on SoapTransportFactoryExt and leveraging
NamespaceContextSelectorWrapper abstraction
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2012-02-03
11:41:03 UTC (rev 15587)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2012-02-03
11:42:51 UTC (rev 15588)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -73,6 +73,7 @@
import org.apache.cxf.service.Service;
import org.apache.cxf.service.invoker.Invoker;
import org.apache.cxf.service.model.BindingOperationInfo;
+import org.jboss.ws.api.util.ServiceLoader;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
@@ -80,6 +81,7 @@
import org.jboss.wsf.spi.invocation.Invocation;
import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.NamespaceContextSelectorWrapperFactory;
import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
/**
@@ -96,7 +98,14 @@
private static final Object[] NO_ARGS = new Object[]{};
private Object targetBean;
private WebServiceContextFactory contextFactory;
+ private NamespaceContextSelectorWrapperFactory nsCtxSelectorFactory;
+ public JBossWSInvoker() {
+ ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
+ nsCtxSelectorFactory = (NamespaceContextSelectorWrapperFactory)
ServiceLoader.loadService(
+ NamespaceContextSelectorWrapperFactory.class.getName(), null, cl);
+ }
+
public void setTargetBean(Object targetBean)
{
this.targetBean = targetBean;
@@ -110,6 +119,7 @@
Map<String, Object> handlerScopedStuff = removeHandlerProperties(ctx);
WebServiceContextImpl.setMessageContext(ctx);
+ setNamespaceContextSelector(exchange);
Object retObj = null;
try
@@ -125,6 +135,8 @@
{
//clear the WebServiceContextImpl's ThreadLocal variable
WebServiceContextImpl.clear();
+ //also cleanup namespace context selector
+ clearNamespaceContextSelector(exchange);
}
return new MessageContentsList(retObj);
@@ -336,6 +348,21 @@
}
}
+ protected void setNamespaceContextSelector(Exchange exchange) {
+ if (exchange.isOneWay() && nsCtxSelectorFactory != null)
+ {
+ nsCtxSelectorFactory.getWrapper().setCurrentThreadSelector(exchange);
+ }
+ }
+
+ protected void clearNamespaceContextSelector(Exchange exchange)
+ {
+ if (exchange.isOneWay() && nsCtxSelectorFactory != null)
+ {
+ nsCtxSelectorFactory.getWrapper().clearCurrentThreadSelector(exchange);
+ }
+ }
+
protected synchronized WebServiceContextFactory getWebServiceContextFactory()
{
if (contextFactory == null)
@@ -346,5 +373,5 @@
}
return contextFactory;
}
-
+
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2012-02-03
11:41:03 UTC (rev 15587)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2012-02-03
11:42:51 UTC (rev 15588)
@@ -40,6 +40,7 @@
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.interceptor.EnableOneWayDecoupledFaultInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
+import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
/**
* A wrapper of the Bus for performing most of the configurations required on it by
JBossWS
@@ -125,6 +126,7 @@
//with the proper spi Endpoint retrieved in CXFServletExt
bus.getInInterceptors().add(new EndpointAssociationInterceptor());
bus.getInInterceptors().add(new EnableOneWayDecoupledFaultInterceptor());
+ bus.getInInterceptors().add(new NsCtxSelectorStoreInterceptor());
}
protected static void setResourceResolver(Bus bus, ResourceResolver resourceResolver)
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/NsCtxSelectorStoreInterceptor.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/NsCtxSelectorStoreInterceptor.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/NsCtxSelectorStoreInterceptor.java 2012-02-03
11:42:51 UTC (rev 15588)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.interceptor;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.OneWayProcessorInterceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.jboss.ws.api.util.ServiceLoader;
+import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
+import org.jboss.wsf.spi.invocation.NamespaceContextSelectorWrapperFactory;
+
+/**
+ * An interceptor for storing the NamespaceContextSelector association into the Exchange
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-Feb-2012
+ *
+ */
+public class NsCtxSelectorStoreInterceptor extends
AbstractPhaseInterceptor<Message>
+{
+ private NamespaceContextSelectorWrapperFactory factory;
+
+ public NsCtxSelectorStoreInterceptor()
+ {
+ super(Phase.PRE_LOGICAL);
+ addBefore(OneWayProcessorInterceptor.class.getName());
+ ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
+ factory = (NamespaceContextSelectorWrapperFactory) ServiceLoader.loadService(
+ NamespaceContextSelectorWrapperFactory.class.getName(), null, cl);
+ }
+
+ @Override
+ public void handleMessage(Message message) throws Fault
+ {
+ Exchange exchange = message.getExchange();
+ if (exchange.isOneWay() && !isRequestor(message) && factory !=
null)
+ {
+ factory.getWrapper().storeCurrentThreadSelector(exchange);
+ }
+ }
+}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java 2012-02-03
11:41:03 UTC (rev 15587)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java 2012-02-03
11:42:51 UTC (rev 15588)
@@ -27,7 +27,6 @@
import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.binding.soap.jms.interceptor.SoapJMSConstants;
import org.apache.cxf.binding.soap.model.SoapBindingInfo;
-import org.apache.cxf.interceptor.OneWayProcessorInterceptor;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.ServiceInfo;
@@ -86,10 +85,6 @@
}
}
}
- // [AS7-3581] make sure @Oneway annotated webservice methods are executed
- // in the same thread associated with current servlet to ensure that manual
- // JNDI lookups are visible to the @OneWay method body
- info.setProperty(OneWayProcessorInterceptor.USE_ORIGINAL_THREAD, Boolean.TRUE);
return info;
}