Author: alessio.soldano(a)jboss.com
Date: 2008-02-01 10:11:30 -0500 (Fri, 01 Feb 2008)
New Revision: 5557
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/DarJMSEndpoint.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClient.java
stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/
stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/jboss-web.xml
stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/web.xml
Modified:
stack/native/trunk/ant-import-tests/build-samples-jaxws.xml
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientHelper.java
Log:
[JBWS-1895] Adding JMS endpoint
Modified: stack/native/trunk/ant-import-tests/build-samples-jaxws.xml
===================================================================
--- stack/native/trunk/ant-import-tests/build-samples-jaxws.xml 2008-02-01 08:11:14 UTC
(rev 5556)
+++ stack/native/trunk/ant-import-tests/build-samples-jaxws.xml 2008-02-01 15:11:30 UTC
(rev 5557)
@@ -72,6 +72,29 @@
<include name="wsdl/reply.wsdl"/>
</webinf>
</war>
+ <jar jarfile="${tests.output.dir}/libs/jaxws-samples-dar-jms.jar">
+ <fileset dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/samples/dar/Bus.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/DarJMSEndpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/DarProcessor.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/DarRequest.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/DarResponse.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/Route.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/ServiceRequest.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/dar/Stop.class"/>
+ </fileset>
+ </jar>
+ <war jarfile="${tests.output.dir}/libs/jaxws-samples-dar-jms-client.war"
webxml="${tests.output.dir}/resources/jaxws/samples/dar/WEB-INF-jms/web.xml">
+ <fileset dir="${tests.output.dir}/classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/generated/*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/ClientHelper.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/dar/JMSClient.class"/>
+ </fileset>
+ <webinf
dir="${tests.output.dir}/resources/jaxws/samples/dar/WEB-INF-jms">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
+
<!-- jaxws-samples-jmstransport -->
<jar
jarfile="${tests.output.dir}/libs/jaxws-samples-jmstransport.jar">
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientHelper.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientHelper.java 2008-02-01
08:11:14 UTC (rev 5556)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientHelper.java 2008-02-01
15:11:30 UTC (rev 5557)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.ws.jaxws.samples.dar;
+import java.io.PrintStream;
import java.util.GregorianCalendar;
import java.util.List;
@@ -74,15 +75,20 @@
public static void printResponse(DarResponse response)
{
+ printResponse(response, System.out);
+ }
+
+ public static void printResponse(DarResponse response, PrintStream output)
+ {
List<Route> routes = response.getRoutes();
for (Route route : routes)
{
- System.out.print(route.getBusId() + ": ");
+ output.print(route.getBusId() + ": ");
for (Stop stop : route.getStops())
{
- System.out.print(stop.getNode() + " ");
+ output.print(stop.getNode() + " ");
}
- System.out.print("\n");
+ output.print("\n");
}
}
}
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/DarJMSEndpoint.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/DarJMSEndpoint.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/DarJMSEndpoint.java 2008-02-01
15:11:30 UTC (rev 5557)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.dar;
+
+//$Id$
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.transport.jms.JMSTransportSupportEJB3;
+import org.jboss.wsf.spi.annotation.WebContext;
+
+
+/**
+ * Performs DAR route optimization
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 01-Feb-2008
+ */
+@WebService (name = "DarEndpoint",
+ targetNamespace = "http://org.jboss.ws/samples/dar",
+ serviceName = "DarService")
+@WebContext(contextRoot="/dar")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+@MessageDriven(activationConfig = {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue
= "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue =
"queue/DarRequestQueue")
+ },
+ messageListenerInterface = javax.jms.MessageListener.class
+)
+public class DarJMSEndpoint extends JMSTransportSupportEJB3
+{
+
+ private static final Logger log = Logger.getLogger(DarJMSEndpoint.class);
+
+ @WebMethod(operationName = "process", action =
"http://org.jboss.test.ws.jaxws.samples.dar/action/processIn")
+ public DarResponse process(DarRequest request)
+ {
+ DarProcessor processor = new DarProcessor();
+ return processor.process(request);
+ }
+
+ @Override
+ public void onMessage(Message message)
+ {
+ log.debug("onMessage: " + message);
+ super.onMessage(message);
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/DarJMSEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClient.java
===================================================================
--- stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClient.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClient.java 2008-02-01
15:11:30 UTC (rev 5557)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.dar;
+
+//$Id$
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+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 javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.logging.Logger;
+
+/**
+ * DAR client; invokes the DAR JMS endpoint
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 31-Jan-2008
+ */
+public class JMSClient extends HttpServlet
+{
+ private Logger log = Logger.getLogger(JMSClient.class);
+
+ protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException {
+ runMessageClient(new PrintStream(httpServletResponse.getOutputStream()));
+ }
+
+ private void runMessageClient(PrintStream ps)
+ {
+ String reqMessage = "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ "<env:Header></env:Header>" +
+ "<env:Body>" +
+ "<ns1:process
xmlns:ns1='http://org.jboss.ws/samples/dar'>" +
+ "<arg0>" +
+ "<buses>" +
+ "<capacity>10</capacity>" +
+ "<id>Bus0</id>" +
+ "</buses>" +
+ "<buses>" +
+ "<capacity>10</capacity>" +
+ "<id>Bus1</id>" +
+ "</buses>" +
+ "<mapId>map1234</mapId>" +
+ "<requests>" +
+
"<from><node>667</node><time>2008-02-01T14:25:12.114+01:00</time></from>"
+
+ "<id>Req0</id>" +
+ "<people>2</people>" +
+
"<to><node>17</node><time>2008-02-01T14:25:12.114+01:00</time></to>"
+
+ "</requests>" +
+ "<requests>" +
+
"<from><node>18</node><time>2008-02-01T14:25:12.114+01:00</time></from>"
+
+ "<id>Req1</id>" +
+ "<people>1</people>" +
+
"<to><node>575</node><time>2008-02-01T14:25:12.114+01:00</time></to>"
+
+ "</requests>" +
+ "<requests>" +
+
"<from><node>713</node><time>2008-02-01T14:25:12.114+01:00</time></from>"
+
+ "<id>Req2</id>" +
+ "<people>2</people>" +
+
"<to><node>845</node><time>2008-02-01T14:25:12.114+01:00</time></to>"
+
+ "</requests>" +
+ "<requests>" +
+
"<from><node>117</node><time>2008-02-01z...zT14:25:12.114+01:00</time></from>"
+
+ "<id>Req3</id>" +
+ "<people>2</people>" +
+
"<to><node>140</node><time>2008-02-01T14:25:12.114+01:00</time></to>"
+
+ "</requests>" +
+ "<requests>" +
+
"<from><node>318</node><time>2008-02-01T14:25:12.114+01:00</time></from>"
+
+ "<id>Req4</id>" +
+ "<people>1</people>" +
+
"<to><node>57</node><time>2008-02-01T14:25:12.114+01:00</time></to>"
+
+ "</requests>" +
+ "</arg0>" +
+ "</ns1:process>" +
+ "</env:Body>" +
+ "</env:Envelope>";
+
+ QueueConnection con = null;
+ QueueSession session = null;
+ try
+ {
+ InitialContext context = new InitialContext();
+ QueueConnectionFactory connectionFactory =
(QueueConnectionFactory)context.lookup("ConnectionFactory");
+ Queue reqQueue = (Queue)context.lookup("queue/DarRequestQueue");
+ con = connectionFactory.createQueueConnection();
+ session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue resQueue = session.createTemporaryQueue();
+ QueueReceiver receiver = session.createReceiver(resQueue);
+ con.start();
+ TextMessage message = session.createTextMessage(reqMessage);
+ message.setJMSReplyTo(resQueue);
+ QueueSender sender = session.createSender(reqQueue);
+ sender.send(message);
+ sender.close();
+
+ log.info("Request message sent, doing something interesting in the mean
time... ;-) ");
+
+ TextMessage textMessage = (TextMessage)receiver.receive();
+ String result = textMessage.getText();
+ log.info("DAR response received: " + result);
+ con.stop();
+ session.close();
+ con.close();
+ ps.println(result);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(ps);
+ }
+ finally
+ {
+ try
+ {
+ session.close();
+ }
+ catch(Exception e1) {}
+ try
+ {
+ con.close();
+ }
+ catch(Exception e1) {}
+ }
+ }
+
+ protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException {
+ doGet(httpServletRequest,httpServletResponse);
+ }
+}
Property changes on:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClient.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/jboss-web.xml
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/jboss-web.xml
(rev 0)
+++
stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/jboss-web.xml 2008-02-01
15:11:30 UTC (rev 5557)
@@ -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>/dar-jms-client</context-root>
+</jboss-web>
\ No newline at end of file
Property changes on:
stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/jboss-web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/web.xml
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/web.xml
(rev 0)
+++ stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/web.xml 2008-02-01
15:11:30 UTC (rev 5557)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4"
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">
+
+ <display-name>Dar JMS client app</display-name>
+ <servlet>
+ <servlet-name>JMSClient</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.samples.dar.JMSClient</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>JMSClient</servlet-name>
+ <url-pattern>/JMSClient</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on:
stack/native/trunk/src/test/resources/jaxws/samples/dar/WEB-INF-jms/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF