You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/12/07 23:21:35 UTC

svn commit: r354875 - in /webservices/axis2/trunk/java/modules: core/src/org/apache/axis2/transport/jms/JNDIVendorAdapter.java core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java integration/test/org/apache/axis2/integration/UtilsJMSServer.java

Author: dims
Date: Wed Dec  7 14:21:30 2005
New Revision: 354875

URL: http://svn.apache.org/viewcvs?rev=354875&view=rev
Log:
fleshing out the listener in preparation to add it to axis2.xml


Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JNDIVendorAdapter.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JNDIVendorAdapter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JNDIVendorAdapter.java?rev=354875&r1=354874&r2=354875&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JNDIVendorAdapter.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JNDIVendorAdapter.java Wed Dec  7 14:21:30 2005
@@ -37,7 +37,19 @@
 
     public final static String _CONNECTION_FACTORY_JNDI_NAME = "ConnectionFactoryJNDIName";
     public final static String CONNECTION_FACTORY_JNDI_NAME = JMSConstants.JMS_PROPERTY_PREFIX +
-            _CONNECTION_FACTORY_JNDI_NAME;
+                                                                _CONNECTION_FACTORY_JNDI_NAME;
+
+    public final static String _DESTINATION = "Destination";
+    public final static String DESTINATION = JMSConstants.JMS_PROPERTY_PREFIX +
+                                                    _DESTINATION;
+
+    public final static String _USER = "User";
+    public final static String USER = JMSConstants.JMS_PROPERTY_PREFIX +
+                                                    _USER;
+
+    public final static String _PASSWORD = "Password";
+    public final static String PASSWORD = JMSConstants.JMS_PROPERTY_PREFIX +
+                                            _PASSWORD;
 
     private Context context;
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java?rev=354875&r1=354874&r2=354875&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java Wed Dec  7 14:21:30 2005
@@ -16,10 +16,15 @@
 
 package org.apache.axis2.transport.jms;
 
-import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.util.OptionsParser;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.util.OptionsParser;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -29,6 +34,7 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Properties;
 
 
@@ -41,36 +47,71 @@
  * is not otherwise tuned for performance. As such, its intended use is not
  * for production code, but for demos, debugging, and performance profiling.
  */
-public class SimpleJMSListener implements MessageListener {
+public class SimpleJMSListener extends TransportListener implements MessageListener {
     protected static Log log =
             LogFactory.getLog(SimpleJMSListener.class.getName());
 
     // Do we use (multiple) threads to process incoming messages?
-    private static boolean doThreads;
+    private boolean doThreads = true;
 
     private JMSConnector connector;
     private JMSEndpoint endpoint;
-    private HashMap connectorProps;
+    private HashMap properties;
+    private String destination;
     protected ConfigurationContext configurationContext;
 
+    public SimpleJMSListener() {
+
+    }
+
+    public void init(ConfigurationContext axisConf, TransportInDescription transprtIn) throws AxisFault {
+        try {
+            this.configurationContext = axisConf;
+            HashMap params = new HashMap();
+            Iterator iterator = transprtIn.getParameters().iterator();
+            while (iterator.hasNext()) {
+                Parameter param = (Parameter) iterator.next();
+                params.put(param.getName(), param.getValue());
+            }
+            String user = null, password = null, destination = null;
+            if (transprtIn.getParameter(JNDIVendorAdapter.USER) != null) {
+                user = (String) transprtIn.getParameter(JNDIVendorAdapter.USER).getValue();
+            }
+            if (transprtIn.getParameter(JNDIVendorAdapter.PASSWORD) != null) {
+                password = (String) transprtIn.getParameter(JNDIVendorAdapter.PASSWORD).getValue();
+            }
+            if (transprtIn.getParameter(JNDIVendorAdapter.DESTINATION) != null) {
+                destination = (String) transprtIn.getParameter(JNDIVendorAdapter.DESTINATION).getValue();
+            }
+            initListener(params, params, user, password, destination);
+        } catch (Exception e1) {
+            throw new AxisFault(e1);
+        }
+    }
+
     public SimpleJMSListener(String repositoryDirectory, HashMap connectorMap, HashMap cfMap,
                              String destination, String username,
                              String password, boolean doThreads)
             throws Exception {
         ConfigurationContextFactory erfac = new ConfigurationContextFactory();
         this.configurationContext = erfac.buildConfigurationContext(repositoryDirectory);
+        this.doThreads = doThreads;
 
-        SimpleJMSListener.doThreads = doThreads;
+        initListener(connectorMap, cfMap, username, password, destination);
+    }
 
+    private void initListener(HashMap connectorMap, HashMap cfMap, String username, String password, String destination) throws Exception {
         try {
             // create a JMS connector using the default vendor adapter
             JMSVendorAdapter adapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
-            connector = JMSConnectorFactory.createServerConnector(connectorMap,
+            this.connector = JMSConnectorFactory.createServerConnector(connectorMap,
                     cfMap,
                     username,
                     password,
                     adapter);
-            connectorProps = connectorMap;
+            this.properties = new HashMap(connectorMap);
+            this.properties.putAll(cfMap);
+            this.destination = destination;
         } catch (Exception e) {
             log.error(Messages.getMessage("exception00"), e);
             throw e;
@@ -85,9 +126,9 @@
     }
 
     public ConfigurationContext getSystemContext() {
-       return this.configurationContext;
-   }
-    
+        return this.configurationContext;
+    }
+
     /**
      * This method is called asynchronously whenever a message arrives.
      *
@@ -113,17 +154,36 @@
         }
     }
 
-    public void start()
-            throws Exception {
-        endpoint.registerListener(this, connectorProps);
+    public void start() {
+        try {
+            endpoint.registerListener(this, properties);
+        } catch (Exception e) {
+            log.error(Messages.getMessage("exception00"), e);
+            e.printStackTrace();
+        }
         connector.start();
     }
 
-    public void shutdown()
-            throws Exception {
-        endpoint.unregisterListener(this);
-        connector.stop();
-        connector.shutdown();
+    public void stop() throws AxisFault {
+        try {
+            endpoint.unregisterListener(this);
+            connector.stop();
+            connector.shutdown();
+        } catch (Exception e) {
+            log.error(Messages.getMessage("exception00"), e);
+            e.printStackTrace();
+        }
+    }
+
+    public EndpointReference getReplyToEPR(String serviceName) throws AxisFault {
+        try {
+            JMSURLHelper url = new JMSURLHelper("jms:/" + destination);
+            url.getProperties().putAll(properties);
+            return new EndpointReference(url.getURLString());
+        } catch (Exception e) {
+            log.error(Messages.getMessage("exception00"), e);
+            throw AxisFault.makeFault(e);
+        }
     }
 
     public static final HashMap createConnectorMap(org.apache.axis2.util.OptionsParser optionsParser) {

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java?rev=354875&r1=354874&r2=354875&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java Wed Dec  7 14:21:30 2005
@@ -99,7 +99,7 @@
     public static synchronized void stop() {
         try {
             if (count == 1) {
-                receiver.shutdown();
+                receiver.stop();
                 count = 0;
                 System.out.print("Server stopped .....");
             } else {