Author: alessio.soldano(a)jboss.com
Date: 2012-08-06 09:51:18 -0400 (Mon, 06 Aug 2012)
New Revision: 16574
Added:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/
stack/cxf/branches/jbossws-cxf-4.0.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml
Log:
[JBPAPP-9650] Server side Bus used for creating JAX-WS clients in endpoint business logic
Merged revisions 16407-16408 via svnmerge from
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk
.......
r16407 | alessio.soldano(a)jboss.com | 2012-06-13 16:27:55 +0200 (Wed, 13 Jun 2012) | 2
lines
[JBWS-3513] Clean-up thread default bus before handing control over to ws endpoint
business methods
.......
r16408 | alessio.soldano(a)jboss.com | 2012-06-13 16:32:04 +0200 (Wed, 13 Jun 2012) | 2
lines
[JBWS-3513] Adding testcase + fixing existing one to avoid assuming the thread bus is
the deployment one
.......
Property changes on: stack/cxf/branches/jbossws-cxf-4.0.x
___________________________________________________________________
Modified: svnmerge-integrated
-
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk:1-15635,15658,15668,1...
+
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk:1-15635,15658,15668,1...
Modified: svn:mergeinfo
- /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/trunk:15658,15668,15674-15675,15682,15695-15697,15708,15711,15713,15719,15723-15730,15738,15743,15748,15750-15751,15754-15757,15765-15766,15768,15773,15780-15781,15784,15794,15806-15808,15824,15835,15837-15857,15859,15866,15879-15881,15886-15889,15896,15900-15920,15936,15965,15967,15973,16067,16071,16086-16087,16096,16176,16183,16204-16205,16227,16230,16244-16245,16315,16323,16530-16532
+ /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/trunk:15658,15668,15674-15675,15682,15695-15697,15708,15711,15713,15719,15723-15730,15738,15743,15748,15750-15751,15754-15757,15765-15766,15768,15773,15780-15781,15784,15794,15806-15808,15824,15835,15837-15857,15859,15866,15879-15881,15886-15889,15896,15900-15920,15936,15965,15967,15973,16067,16071,16086-16087,16096,16176,16183,16204-16205,16227,16230,16244-16245,16315,16323,16407-16408,16530-16532
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2012-08-06
13:33:46 UTC (rev 16573)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2012-08-06
13:51:18 UTC (rev 16574)
@@ -178,6 +178,7 @@
Bus threadBus = BusFactory.getThreadDefaultBus(false);
try
{
+ BusFactory.setThreadDefaultBus(null);
invHandler.invoke(ep, inv);
retObj = inv.getReturnValue();
} catch (InvocationTargetException e) {
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-08-06
13:33:46 UTC (rev 16573)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-08-06
13:51:18 UTC (rev 16574)
@@ -41,9 +41,14 @@
<!-- jaxws-cxf-bus -->
<war warfile="${tests.output.dir}/test-libs/jaxws-cxf-bus.war"
webxml="${tests.output.dir}/test-resources/jaxws/cxf/bus/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.class"/>
<include name="org/jboss/test/ws/jaxws/cxf/bus/Endpoint.class"/>
<include
name="org/jboss/test/ws/jaxws/cxf/bus/EndpointImpl.class"/>
</classes>
+ <manifest>
+ <attribute name="Dependencies"
value="org.apache.cxf"/>
+ </manifest>
</war>
<!-- jaxws-cxf-bus-ejb3-client -->
<jar
destfile="${tests.output.dir}/test-libs/jaxws-cxf-bus-ejb3-client.jar">
@@ -193,7 +198,7 @@
<include name="**/*" />
</metainf>
<manifest>
- <attribute name="Dependencies"
value="org.apache.cxf"/>
+ <attribute name="Dependencies"
value="org.apache.cxf,org.jboss.ws.cxf.jbossws-cxf-server"/>
</manifest>
</jar>
Copied:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java
(from rev 16408,
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java)
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java
(rev 0)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java 2012-08-06
13:51:18 UTC (rev 16574)
@@ -0,0 +1,39 @@
+/*
+ * 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.test.ws.jaxws.cxf.bus;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService(name = "Endpoint", targetNamespace =
"http://org.jboss.ws/bus")
+public interface ClientEndpoint
+{
+ @WebMethod
+ public String testClient(String input, String host) throws Exception;
+
+ @WebMethod
+ public String testCachedPort(String input, String host) throws Exception;
+
+ @WebMethod
+ public String testCachedService(String input, String host) throws Exception;
+
+}
Copied:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java
(from rev 16408,
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java)
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java
(rev 0)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java 2012-08-06
13:51:18 UTC (rev 16574)
@@ -0,0 +1,76 @@
+/*
+ * 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.test.ws.jaxws.cxf.bus;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * A test case that verifies a client running inside and endpoint business method
+ * does not use the deployment bus.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 13-Jun-2012
+ *
+ */
+public class ClientEndpointBusTestCase extends JBossWSTest
+{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-cxf-bus/ClientEndpointService/ClientEndpoint";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(ClientEndpointBusTestCase.class,
"jaxws-cxf-bus.war");
+ }
+
+ public void testClient() throws Exception
+ {
+ ClientEndpoint port = getPort();
+ assertEquals("Foo", port.testClient("Foo", getServerHost()));
+ }
+
+ public void testCachedPort() throws Exception
+ {
+ ClientEndpoint port = getPort();
+ assertEquals("Foo", port.testCachedPort("Foo",
getServerHost()));
+ }
+
+ public void testCachedService() throws Exception
+ {
+ ClientEndpoint port = getPort();
+ assertEquals("Foo", port.testCachedService("Foo",
getServerHost()));
+ }
+
+ private ClientEndpoint getPort() throws Exception {
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://org.jboss.ws/bus",
"ClientEndpointService");
+ Service service = Service.create(wsdlURL, serviceName);
+ QName portQName = new QName("http://org.jboss.ws/bus",
"ClientEndpointPort");
+ return (ClientEndpoint) service.getPort(portQName, ClientEndpoint.class);
+ }
+}
Copied:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java
(from rev 16408,
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java)
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java
(rev 0)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java 2012-08-06
13:51:18 UTC (rev 16574)
@@ -0,0 +1,91 @@
+/*
+ * 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.test.ws.jaxws.cxf.bus;
+
+import java.net.URL;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.BusFactory;
+
+@WebService(name = "ClientEndpoint", serviceName =
"ClientEndpointService", targetNamespace = "http://org.jboss.ws/bus")
+public class ClientEndpointImpl
+{
+ @WebMethod
+ public String testClient(String input, String host) throws Exception
+ {
+ if (BusFactory.getThreadDefaultBus(false) != null) {
+ throw new Exception("Expected null thread default bus, but got " +
BusFactory.getThreadDefaultBus(false));
+ }
+ Endpoint endpoint = getPort(getWsdlURL(host));
+ return endpoint.echo(input);
+ }
+
+ @WebMethod
+ public String testCachedPort(String input, String host) throws Exception
+ {
+ if (BusFactory.getThreadDefaultBus(false) != null) {
+ throw new Exception("Expected null thread default bus, but got " +
BusFactory.getThreadDefaultBus(false));
+ }
+ Endpoint port = getPort(getWsdlURL(host));
+ BusFactory.setThreadDefaultBus(null);
+ return port.echo(input);
+ }
+
+ @WebMethod
+ public String testCachedService(String input, String host) throws Exception
+ {
+ if (BusFactory.getThreadDefaultBus(false) != null) {
+ throw new Exception("Expected null thread default bus, but got " +
BusFactory.getThreadDefaultBus(false));
+ }
+ Service service = getService(getWsdlURL(host));
+ BusFactory.setThreadDefaultBus(null);
+ Endpoint port = getPort(service);
+ return port.echo(input);
+ }
+
+ private static URL getWsdlURL(String host) throws Exception
+ {
+ return new URL("http://" + host +
":8080/jaxws-cxf-bus/EndpointService/Endpoint?wsdl");
+ }
+
+ private static Endpoint getPort(URL wsdlURL)
+ {
+ Service service = getService(wsdlURL);
+ return getPort(service);
+ }
+
+ private static Endpoint getPort(Service service)
+ {
+ QName portQName = new QName("http://org.jboss.ws/bus",
"EndpointPort");
+ return (Endpoint) service.getPort(portQName, Endpoint.class);
+ }
+
+ private static Service getService(URL wsdlURL)
+ {
+ QName serviceName = new QName("http://org.jboss.ws/bus",
"EndpointService");
+ return Service.create(wsdlURL, serviceName);
+ }
+}
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-08-06
13:33:46 UTC (rev 16573)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-08-06
13:51:18 UTC (rev 16574)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.
*
@@ -23,17 +23,20 @@
import java.util.concurrent.atomic.AtomicInteger;
+import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.WebServiceContext;
import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
import org.apache.cxf.workqueue.AutomaticWorkQueue;
import org.apache.cxf.workqueue.WorkQueueManager;
import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@@ -42,12 +45,15 @@
{
private static AtomicInteger count = new AtomicInteger(0);
+ @Resource
+ WebServiceContext ctx;
+
@WebMethod
public String echo(String input)
{
- Bus bus = BusFactory.getThreadDefaultBus(false);
+ //this is just a verification, so going the dirty way...
+ Bus bus =
EndpointAssociation.getEndpoint().getService().getDeployment().getAttachment(BusHolder.class).getBus();
AutomaticWorkQueue queue =
bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
- //this is just a verification, so going the dirty way...
Long qs = null;
Integer it = null;
try
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml 2012-08-06
13:33:46 UTC (rev 16573)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml 2012-08-06
13:51:18 UTC (rev 16574)
@@ -9,8 +9,18 @@
<servlet-class>org.jboss.test.ws.jaxws.cxf.bus.EndpointImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>Ep2Servlet</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.cxf.bus.ClientEndpointImpl</servlet-class>
+ </servlet>
+
<servlet-mapping>
<servlet-name>EpServlet</servlet-name>
<url-pattern>/EndpointService/Endpoint</url-pattern>
</servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Ep2Servlet</servlet-name>
+ <url-pattern>/ClientEndpointService/ClientEndpoint</url-pattern>
+ </servlet-mapping>
</web-app>
\ No newline at end of file