cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r998732 - in /cxf/trunk: distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ rt/transports/jms/src/main/java/org/apache/cxf/transpor...
Date Sun, 19 Sep 2010 21:04:57 GMT
Author: bimargulies
Date: Sun Sep 19 21:04:56 2010
New Revision: 998732

URL: http://svn.apache.org/viewvc?rev=998732&view=rev
Log:
Fix spelling of JMS URI constant. Add JAX-WS API code to sample; client don't work yet.

Modified:
    cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
    cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java

Modified: cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java?rev=998732&r1=998731&r2=998732&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
(original)
+++ cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
Sun Sep 19 21:04:56 2010
@@ -19,27 +19,63 @@
 
 package demo.client;
 
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
 
 import demo.service.HelloWorld;
 
 public final class ClientJMS {
+    private static final String JMS_ENDPOINT_URI = "jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"
+                               + "&jndiConnectionFactoryName=ConnectionFactory" + "&jndiInitialContextFactory"
+                               + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory";
+
+    private final static QName SERVICE_QNAME =
+        new QName("http://impl.service.demo/", "HelloWorldImplService");
+    private final static QName PORT_QNAME =
+        new QName("http://impl.service.demo/", "HelloWorldImplPort");
+
     private ClientJMS() {
         //
     }
 
     public static void main(String[] args) throws Exception {
-        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
-        factory.setServiceClass(HelloWorld.class);
-        factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
-        factory.setAddress("jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"
-            + "&jndiConnectionFactoryName=ConnectionFactory"
-            + "&jndiInitialContextFactory"
-            + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory");
-        HelloWorld client = (HelloWorld)factory.create();
+        boolean jaxws = false;
+        for (String arg : args) {
+            if ("-jaxws".equals(arg)) {
+                jaxws = true;
+            } else {
+                System.err.println("Invalid argument " + arg);
+                return;
+            }
+        }
+        HelloWorld client = null;
+        if (jaxws) {
+            client = createClientJaxWs();
+        } else {
+            client = createClientCxf();
+        }
         String reply = client.sayHi("HI");
         System.out.println(reply);
         System.exit(0);
     }
+
+    private static HelloWorld createClientJaxWs() {
+        Service service = Service.create(SERVICE_QNAME);
+        // Add a port to the Service
+        service.addPort(PORT_QNAME, JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID,
JMS_ENDPOINT_URI);
+        return service.getPort(HelloWorld.class);
+    }
+
+    private static HelloWorld createClientCxf() {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(HelloWorld.class);
+        factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
+        factory.setAddress(JMS_ENDPOINT_URI);
+        HelloWorld client = (HelloWorld)factory.create();
+        return client;
+    }
 }

Modified: cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java?rev=998732&r1=998731&r2=998732&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
(original)
+++ cxf/trunk/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
Sun Sep 19 21:04:56 2010
@@ -21,6 +21,8 @@ package demo.server;
 
 import java.lang.reflect.Method;
 
+import javax.xml.ws.Endpoint;
+
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
 
@@ -29,14 +31,32 @@ import demo.service.impl.HelloWorldImpl;
 
 
 public final class ServerJMS {
+    private static final String JMS_ENDPOINT_URI = "jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"
+                                  + "&jndiConnectionFactoryName=ConnectionFactory"
+                                  + "&jndiInitialContextFactory"
+                                  + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory";
+
     private ServerJMS() {
         //
     }
 
     public static void main(String args[]) throws Exception {
 
-        boolean amqBroker = args.length > 0 && "-activemqbroker".equals(args[0]);
-        if (amqBroker) {
+        boolean launchAmqBroker = false;
+        boolean jaxws = false;
+
+        for (String arg : args) {
+            if ("-activemqbroker".equals(arg)) {
+                launchAmqBroker = true;
+            } else if ("-jaxws".equals(arg)) {
+                jaxws = true;
+            } else {
+                System.err.println("Invalid argument " + arg);
+                return;
+            }
+        }
+
+        if (launchAmqBroker) {
             /*
              * The following make it easier to run this against something other than ActiveMQ.
You will have
              * to get a JMS broker onto the right port of localhost.
@@ -54,20 +74,29 @@ public final class ServerJMS {
             startMethod.invoke(broker);
         }
 
+        if (jaxws) {
+            launchJaxwsApi();
+        } else {
+            launchCxfApi();
+        }
+
+        System.out.println("Server ready... Press any key to exit");
+        System.in.read();
+        System.out.println("Server exiting");
+        System.exit(0);
+    }
+
+    private static void launchCxfApi() {
         Object implementor = new HelloWorldImpl();
         JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
         svrFactory.setServiceClass(HelloWorld.class);
-        svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
-        svrFactory.setAddress("jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"
-                              + "&jndiConnectionFactoryName=ConnectionFactory"
-                              + "&jndiInitialContextFactory"
-                              + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+        svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
+        svrFactory.setAddress(JMS_ENDPOINT_URI);
         svrFactory.setServiceBean(implementor);
         svrFactory.create();
+    }
 
-        System.out.println("Server ready... Press any key to exit");
-        System.in.read();
-        System.out.println("Server exiting");
-        System.exit(0);
+    private static void launchJaxwsApi() {
+        Endpoint.publish(JMS_ENDPOINT_URI, new HelloWorldImpl());
     }
 }

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java?rev=998732&r1=998731&r2=998732&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
Sun Sep 19 21:04:56 2010
@@ -25,9 +25,9 @@ package org.apache.cxf.transport.jms.spe
  */
 public final class JMSSpecConstants {
 
-    public static final String SOAP_JMS_SPECIFICIATION_TRANSPORTID 
+    public static final String SOAP_JMS_SPECIFICATION_TRANSPORTID 
         = "http://www.w3.org/2010/soapjms/";
-    public static final String SOAP_JMS_NAMESPACE = SOAP_JMS_SPECIFICIATION_TRANSPORTID;
+    public static final String SOAP_JMS_NAMESPACE = SOAP_JMS_SPECIFICATION_TRANSPORTID;
 
     public static final String SOAP_JMS_PREFIX = "SOAPJMS_";
 

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=998732&r1=998731&r2=998732&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Sun Sep 19 21:04:56 2010
@@ -1193,7 +1193,7 @@ public class JMSClientServerTest extends
             + JMS_PORT;
 
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
-        factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
+        factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
         factory.setServiceClass(Hello.class);
         factory.setAddress(address);
         Hello client = (Hello)factory.create();

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=998732&r1=998731&r2=998732&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java Sun
Sep 19 21:04:56 2010
@@ -112,7 +112,7 @@ public class Server extends AbstractBusT
         JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
         svrFactory.setServiceClass(Hello.class);
         svrFactory.setAddress(address);
-        svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
+        svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
         svrFactory.setServiceBean(implementor);
         svrFactory.create();
     }



Mime
View raw message