Author: jim.ma
Date: 2014-08-06 03:18:31 -0400 (Wed, 06 Aug 2014)
New Revision: 18825
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpoint.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/WEB-INF/web.xml
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java
stack/cxf/trunk/modules/testsuite/pom.xml
Log:
[JBWS-3514]:Support cxf @FactoryType annotation
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 2014-07-29
18:00:00 UTC (rev 18824)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/JBossWSInvoker.java 2014-08-06
07:18:31 UTC (rev 18825)
@@ -126,9 +126,13 @@
} else if (o != null) {
params = new MessageContentsList(o);
}
+ if (factory != null)
+ {
+ targetBean = this.getServiceObject(exchange);
+ }
return invoke(exchange, targetBean, adjustMethodAndParams(md.getMethod(bop),
exchange, params, targetBean.getClass()), params);
}
-
+
/**
* This overrides org.apache.cxf.jaxws.AbstractInvoker in order for using the JBossWS
integration logic
* to invoke the JBoss AS target bean.
@@ -139,8 +143,10 @@
{
Endpoint ep = exchange.get(Endpoint.class);
final InvocationHandler invHandler = ep.getInvocationHandler();
- final Invocation inv = createInvocation(invHandler, ep, m, paramArray);
-
+ final Invocation inv = createInvocation(invHandler, serviceObject, ep, m,
paramArray);
+ if (factory != null) {
+ inv.getInvocationContext().setProperty("forceTargetBean", true);
+ }
Bus threadBus = BusFactory.getThreadDefaultBus(false);
BusFactory.setThreadDefaultBus(null);
setNamespaceContextSelector(exchange);
@@ -155,12 +161,12 @@
}
}
- private Invocation createInvocation(InvocationHandler invHandler, Endpoint ep, Method
m, Object[] paramArray) {
+ private Invocation createInvocation(InvocationHandler invHandler, Object
serviceObject, Endpoint ep, Method m, Object[] paramArray) {
Invocation inv = invHandler.createInvocation();
InvocationContext invContext = inv.getInvocationContext();
WebServiceContext wsCtx = new WebServiceContextImpl(null);
invContext.addAttachment(WebServiceContext.class, wsCtx);
- invContext.setTargetBean(targetBean);
+ invContext.setTargetBean(serviceObject);
inv.setJavaMethod(m);
inv.setArgs(paramArray);
return inv;
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpoint.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpoint.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpoint.java 2014-08-06
07:18:31 UTC (rev 18825)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.samples.session;
+
+import javax.jws.WebService;
+
+@WebService
+public interface SessionEndpoint
+{
+ String setNumber(int value);
+ String getNumber();
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpoint.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointImpl.java 2014-08-06
07:18:31 UTC (rev 18825)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.samples.session;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.annotations.FactoryType;
+
+@WebService(serviceName = "SessionService", endpointInterface =
"org.jboss.test.ws.jaxws.samples.session.SessionEndpoint",
targetNamespace="http://jboss.org/jaxws-samples-session")
+(a)FactoryType(FactoryType.Type.Session)
+public class SessionEndpointImpl implements SessionEndpoint
+{
+ String result;
+ public String setNumber(int value)
+ {
+ System.out.println("Set value " + value + "to " + this);
+ result = "Number is " + value;
+ return result;
+ }
+
+ public String getNumber() {
+ System.out.println("Get value from " + this);
+ return result;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointImpl.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointTestCase.java 2014-08-06
07:18:31 UTC (rev 18825)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.samples.session;
+
+import java.io.File;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestHelper.BaseDeployment;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Test to demonstrate enable session with cxf <code>@FactoryType</code>
+ * annotation
+ *
+ * @author ema(a)redhat.com
+ */
+public class SessionEndpointTestCase extends JBossWSTest
+{
+ private String targetNS = "http://jboss.org/jaxws-samples-session";
+
+ private SessionEndpoint proxy;
+
+ public static BaseDeployment<?>[] createDeployments()
+ {
+ List<BaseDeployment<?>> list = new
LinkedList<BaseDeployment<?>>();
+ list.add(new
JBossWSTestHelper.WarDeployment("jaxws-samples-session.war")
+ {
+ {
+ archive
+ .setManifest(new StringAsset("Manifest-Version: 1.0\n" +
"Dependencies: org.apache.cxf.impl\n"))
+
.addClass(org.jboss.test.ws.jaxws.samples.session.SessionEndpoint.class)
+
.addClass(org.jboss.test.ws.jaxws.samples.session.SessionEndpointImpl.class)
+ .setWebXML(
+ new File(JBossWSTestHelper.getTestResourcesDir() +
"/jaxws/samples/session/WEB-INF/web.xml"));
+ }
+ });
+ return list.toArray(new BaseDeployment<?>[list.size()]);
+ }
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(SessionEndpointTestCase.class,
JBossWSTestHelper.writeToFile(createDeployments()));
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ }
+
+ public void testSession() throws Exception
+ {
+ SessionEndpoint proxy = this.createPort();
+ SessionEndpoint proxy2 = this.createPort();
+ ((BindingProvider)
proxy).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
+ ((BindingProvider)
proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:8080/jaxws-samples-session/session");
+ ((BindingProvider)
proxy2).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
+ ((BindingProvider)
proxy2).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:8080/jaxws-samples-session/session");
+ proxy.setNumber(10);
+ assertEquals("Number is 10", proxy.getNumber());
+ proxy2.setNumber(20);
+ assertEquals("Number is 20", proxy2.getNumber());
+ assertEquals("Number is 10", proxy.getNumber());
+ }
+
+ public SessionEndpoint createPort() throws Exception
+ {
+ QName serviceName = new QName(targetNS, "SessionService");
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-session/session?wsdl");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ proxy = (SessionEndpoint) service.getPort(SessionEndpoint.class);
+ return proxy;
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/session/SessionEndpointTestCase.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/WEB-INF/web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/WEB-INF/web.xml 2014-08-06
07:18:31 UTC (rev 18825)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
+ version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <servlet>
+ <servlet-name>SessionService</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.samples.session.SessionEndpointImpl</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SessionService</servlet-name>
+ <url-pattern>/session</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/session/WEB-INF/web.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified: stack/cxf/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/pom.xml 2014-07-29 18:00:00 UTC (rev 18824)
+++ stack/cxf/trunk/modules/testsuite/pom.xml 2014-08-06 07:18:31 UTC (rev 18825)
@@ -700,6 +700,9 @@
<!-- Manually setup KDC before run this test-->
<exclude>org/jboss/test/ws/jaxws/samples/wsse/kerberos/*TestCase*</exclude>
+
+ <!-- Enable it after backport change to wilfly800 ASIL -->
+
<exclude>org/jboss/test/ws/jaxws/samples/session/*TestCase*</exclude>
</excludes>
</configuration>
</plugin>
@@ -788,6 +791,8 @@
<!-- Manually setup KDC before run this test-->
<exclude>org/jboss/test/ws/jaxws/samples/wsse/kerberos/*TestCase*</exclude>
+ <!-- Enable it after backport change to wilfly810 ASIL -->
+
<exclude>org/jboss/test/ws/jaxws/samples/session/*TestCase*</exclude>
</excludes>
</configuration>
</plugin>
@@ -877,6 +882,10 @@
<!-- Manually setup KDC before run this test-->
<exclude>org/jboss/test/ws/jaxws/samples/wsse/kerberos/*TestCase*</exclude>
+
+ <!-- Enable it after merge to wildfly9 -->
+
<exclude>org/jboss/test/ws/jaxws/samples/session/*TestCase*</exclude>
+
</excludes>
</configuration>
</plugin>