Author: jim.ma
Date: 2009-11-06 02:37:48 -0500 (Fri, 06 Nov 2009)
New Revision: 11094
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/FromJavaJMSTransportTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJmsImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jboss-web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jbossws-cxf.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/web.xml
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jaxws.xml
Log:
[JBWS-2660]:add java first jms transport sample;[JBWS-2814]:register the java first jms
endpoint
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2009-11-05
10:14:13 UTC (rev 11093)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2009-11-06
07:37:48 UTC (rev 11094)
@@ -48,6 +48,7 @@
import org.apache.cxf.management.counters.CounterRepository;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.jms.AddressType;
+import org.apache.cxf.transport.jms.JMSDestination;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.apache.cxf.transport.servlet.ServletController;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
@@ -138,17 +139,19 @@
ServletContext context = servletConfig.getServletContext();
String contextPath = context.getContextPath();
endpoint = initServiceEndpoint(contextPath);
-
+ //Add customization check to use default CXF configurer
+ BindingCustomization customization =
endpoint.getAttachment(BindingCustomization.class);
+ if (customization != null) {
+ //Add extension to configure server beans according to JBossWS customizations
+ JBossWSCXFConfigurer jbosswsConfigurer = new
JBossWSCXFConfigurer(bus.getExtension(Configurer.class));
+
jbosswsConfigurer.setBindingCustomization(endpoint.getAttachment(BindingCustomization.class));
+ bus.setExtension(jbosswsConfigurer, Configurer.class);
+ }
context.setAttribute(ServletController.class.getName(), getController());
}
private void loadAdditionalConfigExt(ApplicationContext ctx, ServletConfig
servletConfig) throws ServletException
{
- //Add extension to configure server beans according to JBossWS customizations
- JBossWSCXFConfigurer jbosswsConfigurer = new
JBossWSCXFConfigurer(bus.getExtension(Configurer.class));
-
jbosswsConfigurer.setBindingCustomization(endpoint.getAttachment(BindingCustomization.class));
- bus.setExtension(jbosswsConfigurer, Configurer.class);
-
//Load configuration
String location =
servletConfig.getServletContext().getInitParameter(PARAM_CXF_BEANS_URL);
if (location != null)
@@ -273,10 +276,25 @@
&&
JMS_NS.equals(server.getEndpoint().getEndpointInfo().getTransportId())) {
//server.getDestination().getAddress()
AddressType address =
server.getEndpoint().getEndpointInfo().getExtensor(AddressType.class);
- String jmsURL = "jms://" +
address.getJndiDestinationName();
- if (address.getJndiReplyDestinationName() != null) {
- jmsURL = jmsURL +"?replyToName="
+address.getJndiReplyDestinationName();
- endpoint.setAddress(jmsURL);
+ if (address == null)
+ {
+ //java first : the address is from jbossws-cxf.xml
+ JMSDestination jmsDestination =
(JMSDestination)server.getDestination();
+ String url = "jms://" +
jmsDestination.getJmsConfig().getTargetDestination();
+ if (jmsDestination.getJmsConfig().getReplyDestination() != null)
{
+ url = url + "?replyToName=" +
jmsDestination.getJmsConfig().getReplyDestination();
+ endpoint.setAddress(url);
+ }
+
+ } else
+ {
+ //wsdl first: the address is from wsdl
+ String jmsURL = "jms://" +
address.getJndiDestinationName();
+ if (address.getJndiReplyDestinationName() != null)
+ {
+ jmsURL = jmsURL + "?replyToName=" +
address.getJndiReplyDestinationName();
+ endpoint.setAddress(jmsURL);
+ }
}
}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jaxws.xml 2009-11-05
10:14:13 UTC (rev 11093)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jaxws.xml 2009-11-06
07:37:48 UTC (rev 11094)
@@ -38,7 +38,29 @@
</metainf>
</jar>
+ <!-- jaxws-fromjava-jmstransport -->
+ <war
+ warfile="${tests.output.dir}/test-libs/jaxws-fromjava-jmstransport.war"
+
webxml="${tests.output.dir}/test-resources/jaxws/samples/jmstransport/fromjava/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/jmstransport/Organization.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJmsImpl.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/jmstransport/fromjava/WEB-INF">
+ <include name="jbossws-cxf.xml"/>
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
+ <jar
jarfile="${tests.output.dir}/test-libs/jaxws-fromjava-jmstransport.sar">
+ <fileset dir="${tests.output.dir}/test-libs">
+ <include name="jaxws-fromjava-jmstransport.war"/>
+ </fileset>
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/jmstransport/META-INF">
+ <include name="jboss-service.xml"/>
+ </metainf>
+ </jar>
+
<!-- jaxws-samples-wsa -->
<war
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/FromJavaJMSTransportTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/FromJavaJMSTransportTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/FromJavaJMSTransportTestCase.java 2009-11-06
07:37:48 UTC (rev 11094)
@@ -0,0 +1,130 @@
+/*
+ * 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.jmstransport;
+
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * The test for cxf java first jms transport
+ *
+ * @author <a href=mailto:ema@redhat.com> Jim Ma </a>
+ */
+public class FromJavaJMSTransportTestCase extends JBossWSTest
+{
+ private static boolean waitForResponse;
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(FromJavaJMSTransportTestCase.class,
"jaxws-fromjava-jmstransport.sar");
+ }
+
+ public void testMessagingClient() throws Exception
+ {
+ String reqMessage =
+ "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ "<env:Body>" +
+ "<ns1:getContactInfo
xmlns:ns1='http://org.jboss.ws/samples/jmstransport'>" +
+ "<arg0>mafia</arg0>" +
+ "</ns1:getContactInfo>" +
+ "</env:Body>" +
+ "</env:Envelope>";
+
+ String resMessage =
+ "<soap:Envelope
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ "<soap:Body>" +
+ "<ns1:getContactInfoResponse
xmlns:ns1='http://org.jboss.ws/samples/jmstransport'>" +
+ "<return>The 'mafia' boss is currently out of
office, please call again.</return>" +
+ "</ns1:getContactInfoResponse>" +
+ "</soap:Body>" +
+ "</soap:Envelope>";
+
+ InitialContext context = new InitialContext();
+ QueueConnectionFactory connectionFactory =
(QueueConnectionFactory)context.lookup("ConnectionFactory");
+ Queue reqQueue = (Queue)context.lookup("queue/RequestQueue");
+ Queue resQueue = (Queue)context.lookup("queue/ResponseQueue");
+
+ QueueConnection con = connectionFactory.createQueueConnection();
+ QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ QueueReceiver receiver = session.createReceiver(resQueue);
+ ResponseListener responseListener = new ResponseListener();
+ receiver.setMessageListener(responseListener);
+ con.start();
+
+ TextMessage message = session.createTextMessage(reqMessage);
+ message.setJMSReplyTo(resQueue);
+
+ waitForResponse = true;
+
+ QueueSender sender = session.createSender(reqQueue);
+ sender.send(message);
+ sender.close();
+
+ int timeout = 3000;
+ while (waitForResponse && timeout > 0)
+ {
+ Thread.sleep(100);
+ timeout -= 10;
+ }
+
+ assertNotNull("Expected response message", responseListener.resMessage);
+ assertEquals(DOMUtils.parse(resMessage),
DOMUtils.parse(responseListener.resMessage));
+
+ con.stop();
+ session.close();
+ con.close();
+ }
+
+ public static class ResponseListener implements MessageListener
+ {
+ public String resMessage;
+
+ public void onMessage(Message msg)
+ {
+ TextMessage textMessage = (TextMessage)msg;
+ try
+ {
+ resMessage = textMessage.getText();
+ waitForResponse = false;
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJmsImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJmsImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJmsImpl.java 2009-11-06
07:37:48 UTC (rev 11094)
@@ -0,0 +1,40 @@
+/*
+ * 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.jmstransport;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService (serviceName="OrganizationService", portName="JmsPort",
+ targetNamespace = "http://org.jboss.ws/samples/jmstransport",
+
endpointInterface="org.jboss.test.ws.jaxws.samples.jmstransport.Organization")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+
+public class OrganizationJmsImpl implements Organization
+{
+ @WebMethod
+ public String getContactInfo(String organization)
+ {
+ return "The '" + organization + "' boss is currently out of
office, please call again.";
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jboss-web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jboss-web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jboss-web.xml 2009-11-06
07:37:48 UTC (rev 11094)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <context-root>/jaxws-fromjava-jmstransport</context-root>
+</jboss-web>
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jbossws-cxf.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jbossws-cxf.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/jbossws-cxf.xml 2009-11-06
07:37:48 UTC (rev 11094)
@@ -0,0 +1,31 @@
+<beans
xmlns='http://www.springframework.org/schema/beans'
+
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:beans='http://www.springframework.org/schema/beans'
+
xmlns:jms="http://cxf.apache.org/transports/jms"
xmlns:jaxws='http://cxf.apache.org/jaxws'
+
xsi:schemaLocation='http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+
http://www.w3.org/2006/07/ws-policy http://www.w3.org/2006/07/ws-policy.xsd
+
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+
http://cxf.apache.org/transports/jms
http://cxf.apache.org/schemas/configuration/jms.xsd'>
+
+ <jaxws:endpoint id='JMSQueryService'
+ implementor='org.jboss.test.ws.jaxws.samples.jmstransport.OrganizationJmsImpl'
+
transportId="http://cxf.apache.org/transports/jms">
+ </jaxws:endpoint>
+
+ <jms:conduit
+ name="{http://org.jboss.ws/samples/jmstransport}JmsPort.jms-conduit">
+ <jms:address destinationStyle="queue"
+ jndiConnectionFactoryName="ConnectionFactory"
jndiDestinationName="queue/RequestQueue"
+ jndiReplyDestinationName="queue/ResponseQueue">
+ </jms:address>
+ </jms:conduit>
+ <jms:destination
name="{http://org.jboss.ws/samples/jmstransport}JmsPort.jms-destination">
+ <jms:address destinationStyle="queue"
+ jndiConnectionFactoryName="ConnectionFactory"
jndiDestinationName="queue/RequestQueue"
+ jndiReplyDestinationName="queue/ResponseQueue">
+ </jms:address>
+ </jms:destination>
+
+
+</beans>
+
+
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/jmstransport/fromjava/WEB-INF/web.xml 2009-11-06
07:37:48 UTC (rev 11094)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>OrganizationJmsService</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.samples.jmstransport.OrganizationJmsImpl</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>OrganizationJmsService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+