Author: alessio.soldano(a)jboss.com
Date: 2010-08-27 12:38:33 -0400 (Fri, 27 Aug 2010)
New Revision: 12871
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
Modified:
stack/cxf/trunk/modules/endorsed/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
Log:
- [JBWS-3103] Endpoint.publish(..) can't use the deployment bus for starting a new
endpoint on a standalone http server
- Make sure the correct thread bus is still set when coming back from endpoint business
methods
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2010-08-27
16:38:33 UTC (rev 12871)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.client;
+
+/**
+ * JBossWS-CXF integration constants
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Aug-2010
+ *
+ */
+public class Constants
+{
+ public static final String DEPLOYMENT_BUS = "deployment-bus";
+}
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2010-08-27
16:38:33 UTC (rev 12871)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.client;
+
+import javax.xml.ws.WebServiceFeature;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * A custom javax.xml.ws.spi.Provider implementation
+ * extending the CXF one while adding few customizations
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Aug-2010
+ *
+ */
+public class ProviderImpl extends org.apache.cxf.jaxws22.spi.ProviderImpl
+{
+ @Override
+ protected org.apache.cxf.jaxws.EndpointImpl createEndpointImpl(Bus bus, String
bindingId, Object implementor,
+ WebServiceFeature... features)
+ {
+ Boolean db = (Boolean)bus.getProperty(Constants.DEPLOYMENT_BUS);
+ if (db != null && db)
+ {
+ Logger.getLogger(ProviderImpl.class).info(
+ "Cannot use the bus associated to the current deployment for starting
a new endpoint, creating a new bus...");
+ bus = BusFactory.newInstance().createBus();
+ }
+ return super.createEndpointImpl(bus, bindingId, implementor, features);
+ }
+}
Modified:
stack/cxf/trunk/modules/endorsed/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider
===================================================================
---
stack/cxf/trunk/modules/endorsed/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider 2010-08-26
10:45:37 UTC (rev 12870)
+++
stack/cxf/trunk/modules/endorsed/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider 2010-08-27
16:38:33 UTC (rev 12871)
@@ -1 +1 @@
-org.apache.cxf.jaxws22.spi.ProviderImpl
+org.jboss.wsf.stack.cxf.client.ProviderImpl
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java 2010-08-26
10:45:37 UTC (rev 12870)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java 2010-08-27
16:38:33 UTC (rev 12871)
@@ -54,6 +54,8 @@
import javax.xml.ws.handler.MessageContext.Scope;
import javax.xml.ws.soap.SOAPFaultException;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
import org.apache.cxf.attachment.AttachmentImpl;
import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.SoapMessage;
@@ -156,6 +158,7 @@
inv.setArgs(params);
Object retObj = null;
+ Bus threadBus = BusFactory.getThreadDefaultBus();
try
{
invHandler.invoke(ep, inv);
@@ -188,6 +191,8 @@
}
finally
{
+ //make sure the right bus is restored after coming back from the endpoint
method
+ BusFactory.setThreadDefaultBus(threadBus);
// JBWS-2486
if (ep.getAttachment(Object.class) == null)
{
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 2010-08-26
10:45:37 UTC (rev 12870)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2010-08-27
16:38:33 UTC (rev 12871)
@@ -71,6 +71,7 @@
*/
public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer)
{
+ bus.setProperty(org.jboss.wsf.stack.cxf.client.Constants.DEPLOYMENT_BUS, true);
busHolderListener = new BusHolderLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(busHolderListener);