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/16 18:18:08 UTC

svn commit: r357187 [21/25] - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: ./ addressing/ client/ client/async/ context/ deployment/ deployment/listener/ deployment/repository/util/ deployment/scheduler/ deployment/util/ descript...

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -46,31 +47,134 @@
  * This is meant to be used on a SOAP Client to call a SOAP server.
  */
 public class JMSSender extends AbstractHandler implements TransportSender {
-
-    protected static Log log =
-            LogFactory.getLog(JMSSender.class.getName());
-
-    HashMap params = new HashMap();
+    protected static Log log = LogFactory.getLog(JMSSender.class.getName());
 
     static {
+
         // add a shutdown hook to close JMS connections
-        Runtime.getRuntime().addShutdownHook(
-                new Thread() {
-                    public void run() {
-                        JMSSender.closeAllConnectors();
-                    }
-                }
-        );
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() {
+                JMSSender.closeAllConnectors();
+            }
+        });
     }
 
+    HashMap params = new HashMap();
 
     public JMSSender() {
     }
 
-    public void init(ConfigurationContext confContext, TransportOutDescription transportOut) throws AxisFault {
+    public void cleanUp(MessageContext msgContext) throws AxisFault {
+    }
+
+    /**
+     * Closes all JMS connectors
+     */
+    public static void closeAllConnectors() {
+        if (log.isDebugEnabled()) {
+            log.debug("Enter: JMSTransport::closeAllConnectors");
+        }
+
+        JMSConnectorManager.getInstance().closeAllConnectors();
+
+        if (log.isDebugEnabled()) {
+            log.debug("Exit: JMSTransport::closeAllConnectors");
+        }
+    }
+
+    /**
+     * Closes JMS connectors that match the specified endpoint address
+     *
+     * @param endpointAddr the JMS endpoint address
+     * @param username
+     * @param password
+     */
+    public static void closeMatchingJMSConnectors(String endpointAddr, String username,
+                                                  String password) {
+        if (log.isDebugEnabled()) {
+            log.debug("Enter: JMSTransport::closeMatchingJMSConnectors");
+        }
+
+        try {
+            JMSURLHelper jmsurl = new JMSURLHelper(endpointAddr);
+            String vendorId = jmsurl.getVendor();
+            JMSVendorAdapter vendorAdapter = null;
+
+            if (vendorId == null) {
+                vendorId = JMSConstants.JNDI_VENDOR_ID;
+            }
+
+            vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
+
+            // the vendor adapter may not exist
+            if (vendorAdapter == null) {
+                return;
+            }
+
+            // determine the set of properties to be used for matching the connection
+            HashMap connectorProps = vendorAdapter.getJMSConnectorProperties(jmsurl);
+            HashMap cfProps = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
+
+            JMSConnectorManager.getInstance().closeMatchingJMSConnectors(connectorProps, cfProps,
+                    username, password, vendorAdapter);
+        } catch (Exception e) {
+            log.warn(Messages.getMessage("malformedURLException00"), e);
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Exit: JMSTransport::closeMatchingJMSConnectors");
+        }
+    }
+
+    /**
+     * Return a map of properties that makeup the application-specific
+     * for the JMS Messages.
+     */
+    protected HashMap createApplicationProperties(MessageContext context) {
+        HashMap props = new HashMap();
+
+        if (context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS) != null) {
+            props.putAll((Map) context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS));
+        }
+
+        return props;
+    }
+
+    private HashMap createSendProperties(MessageContext context) {
+
+        // I'm not sure why this helper method is private, but
+        // we need to delegate to factory method that can build the
+        // application-specific map of properties so make a change to
+        // delegate here.
+        HashMap props = createApplicationProperties(context);
+
+        if (context.getProperty(JMSConstants.PRIORITY) != null) {
+            props.put(JMSConstants.PRIORITY, context.getProperty(JMSConstants.PRIORITY));
+        }
+
+        if (context.getProperty(JMSConstants.DELIVERY_MODE) != null) {
+            props.put(JMSConstants.DELIVERY_MODE, context.getProperty(JMSConstants.DELIVERY_MODE));
+        }
+
+        if (context.getProperty(JMSConstants.TIME_TO_LIVE) != null) {
+            props.put(JMSConstants.TIME_TO_LIVE, context.getProperty(JMSConstants.TIME_TO_LIVE));
+        }
+
+        if (context.getProperty(JMSConstants.JMS_CORRELATION_ID) != null) {
+            props.put(JMSConstants.JMS_CORRELATION_ID,
+                    context.getProperty(JMSConstants.JMS_CORRELATION_ID));
+        }
+
+        return props;
+    }
+
+    public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+            throws AxisFault {
         Iterator iterator = transportOut.getParameters().iterator();
+
         while (iterator.hasNext()) {
             Parameter param = (Parameter) iterator.next();
+
             params.put(param.getName(), param.getValue());
         }
     }
@@ -85,12 +189,12 @@
     public void invoke(MessageContext msgContext) throws AxisFault {
         JMSConnector connector = null;
         HashMap properties = null;
-
         Destination dest = null;
+
         if (msgContext.isServerSide()) {
             JMSOutTransportInfo transportInfo =
-                    (JMSOutTransportInfo) msgContext.getProperty(
-                            Constants.OUT_TRANSPORT_INFO);
+                    (JMSOutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+
             if (transportInfo != null) {
                 dest = transportInfo.getDestination();
                 properties = transportInfo.getProperties();
@@ -98,21 +202,27 @@
         }
 
         String endpointAddress = msgContext.getTo().getAddress();
-
         boolean waitForResponse = false;
+
         if (dest == null) {
-            if (msgContext.getProperty(Constants.Configuration.IS_USING_SEPARATE_LISTENER) != null && msgContext.getProperty(Constants.Configuration.IS_USING_SEPARATE_LISTENER).equals(Boolean.TRUE))
-                waitForResponse =
-                        !((Boolean) msgContext.getProperty(
-                                Constants.Configuration.IS_USING_SEPARATE_LISTENER)).booleanValue();
+            if ((msgContext
+                    .getProperty(Constants.Configuration
+                            .IS_USING_SEPARATE_LISTENER) != null) && msgContext
+                    .getProperty(Constants.Configuration.IS_USING_SEPARATE_LISTENER)
+                    .equals(Boolean.TRUE)) {
+                waitForResponse = !((Boolean) msgContext.getProperty(
+                        Constants.Configuration.IS_USING_SEPARATE_LISTENER)).booleanValue();
+            }
         } else {
             if (properties != null) {
                 JMSURLHelper url = null;
+
                 try {
                     url = new JMSURLHelper("jms:/" + dest);
                 } catch (Exception e) {
                     throw AxisFault.makeFault(e);
                 }
+
                 url.getProperties().putAll(properties);
                 endpointAddress = url.getURLString();
             }
@@ -123,23 +233,27 @@
         if (connector == null) {
             connector = (JMSConnector) msgContext.getProperty(JMSConstants.CONNECTOR);
         }
+
         try {
             JMSEndpoint endpoint = null;
+
             if (dest == null) {
                 Object destination = msgContext.getProperty(JMSConstants.DESTINATION);
 
-                if (destination == null && msgContext.getTo() != null) {
+                if ((destination == null) && (msgContext.getTo() != null)) {
                     String to = msgContext.getTo().getAddress();
+
                     if (to != null) {
                         JMSURLHelper url = new JMSURLHelper(to);
+
                         destination = url.getDestination();
                     }
                 }
+
                 if (destination == null) {
                     throw new AxisFault("noDestination");
                 }
 
-
                 if (destination instanceof String) {
                     endpoint = connector.createEndpoint((String) destination);
                 } else {
@@ -148,149 +262,39 @@
             } else {
                 endpoint = connector.createEndpoint(dest);
             }
+
             ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-            // TODO: How do we fix Attachments?            
+            // TODO: How do we fix Attachments?
             writeMessage(msgContext, out);
 
             HashMap props = createSendProperties(msgContext);
 
             props.put("contentType", getContentType(msgContext));
             props.put("SOAPAction", getSOAPAction(msgContext));
+
             if (waitForResponse) {
                 long timeout = Options.DEFAULT_TIMEOUT_MILLISECONDS;
+
                 if (msgContext.getProperty(JMSConstants.TIMEOUT_TIME) != null) {
-                    timeout = ((Long) msgContext.getProperty(JMSConstants.TIMEOUT_TIME)).longValue();
+                    timeout =
+                            ((Long) msgContext.getProperty(JMSConstants.TIMEOUT_TIME)).longValue();
                 }
-                byte[] response = endpoint.call(out.toByteArray(), timeout, props);
+
+                byte[]      response = endpoint.call(out.toByteArray(), timeout, props);
                 InputStream in = new ByteArrayInputStream(response);
+
                 msgContext.setProperty(MessageContext.TRANSPORT_IN, in);
             } else {
                 endpoint.send(out.toByteArray(), props);
             }
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new AxisFault("failedSend", e);
-        }
-        finally {
-            if (connector != null)
+        } finally {
+            if (connector != null) {
                 JMSConnectorManager.getInstance().release(connector);
-        }
-    }
-
-    private HashMap createSendProperties(MessageContext context) {
-        //I'm not sure why this helper method is private, but 
-        //we need to delegate to factory method that can build the
-        //application-specific map of properties so make a change to
-        //delegate here. 
-        HashMap props = createApplicationProperties(context);
-
-        if (context.getProperty(JMSConstants.PRIORITY) != null)
-            props.put(JMSConstants.PRIORITY,
-                    context.getProperty(JMSConstants.PRIORITY));
-        if (context.getProperty(JMSConstants.DELIVERY_MODE) != null)
-            props.put(JMSConstants.DELIVERY_MODE,
-                    context.getProperty(JMSConstants.DELIVERY_MODE));
-        if (context.getProperty(JMSConstants.TIME_TO_LIVE) != null)
-            props.put(JMSConstants.TIME_TO_LIVE,
-                    context.getProperty(JMSConstants.TIME_TO_LIVE));
-        if (context.getProperty(JMSConstants.JMS_CORRELATION_ID) != null)
-            props.put(JMSConstants.JMS_CORRELATION_ID,
-                    context.getProperty(JMSConstants.JMS_CORRELATION_ID));
-        return props;
-    }
-
-    /**
-     * Return a map of properties that makeup the application-specific
-     * for the JMS Messages.
-     */
-    protected HashMap createApplicationProperties(MessageContext context) {
-        HashMap props = new HashMap();
-        if (context.getProperty(
-                JMSConstants.JMS_APPLICATION_MSG_PROPS) != null) {
-            props.putAll((Map) context.getProperty(
-                    JMSConstants.JMS_APPLICATION_MSG_PROPS));
-        }
-        return props;
-    }
-
-    public void cleanUp(MessageContext msgContext) throws AxisFault {
-    }
-
-    public void writeMessage(MessageContext msgContext, OutputStream out)
-            throws AxisFault {
-        SOAPEnvelope envelope = msgContext.getEnvelope();
-        OMElement outputMessage = envelope;
-
-        if (envelope != null && msgContext.isDoingREST()) {
-            outputMessage = envelope.getBody().getFirstElement();
-        }
-
-        if (outputMessage != null) {
-            try {
-                OMOutputFormat format = new OMOutputFormat();
-                //Pick the char set encoding from the msgContext
-                String charSetEnc = (String) msgContext
-                        .getProperty(MessageContext.CHARACTER_SET_ENCODING);
-                format.setDoOptimize(msgContext.isDoingMTOM());
-                format.setCharSetEncoding(charSetEnc);
-                outputMessage.serializeAndConsume(out, format);
-                out.flush();
-            } catch (Exception e) {
-                throw new AxisFault(e);
             }
-        } else {
-            throw new AxisFault(Messages.getMessage("outMessageNull"));
-        }
-    }
-
-    public String getContentType(MessageContext msgCtx) {
-        OMOutputFormat format = new OMOutputFormat();
-
-        String soapActionString = getSOAPAction(msgCtx);
-
-        String charSetEnc =
-                (String) msgCtx.getProperty(
-                        MessageContext.CHARACTER_SET_ENCODING);
-        if (charSetEnc != null) {
-            format.setCharSetEncoding(charSetEnc);
-        } else {
-            OperationContext opctx = msgCtx.getOperationContext();
-            if (opctx != null) {
-                charSetEnc = (String) opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
-            }
-        }
-        /**
-         * If the char set enc is still not found use the default
-         */
-        if (charSetEnc == null) {
-            charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
-        }
-        format.setSOAP11(msgCtx.isSOAP11());
-        format.setCharSetEncoding(charSetEnc);
-
-        String encoding = format.getCharSetEncoding();
-        String contentType = format.getContentType();
-        if (encoding != null) {
-            contentType += "; charset=" + encoding;
-        }
-
-        // action header is not mandated in SOAP 1.2. So putting it, if available
-        if (!msgCtx.isSOAP11() && soapActionString != null && !"".equals(soapActionString.trim())) {
-            contentType = contentType + ";action=\"" + soapActionString + "\";";
         }
-        return contentType;
-    }
-
-    private String getSOAPAction(MessageContext msgCtx) {
-        String soapActionString = msgCtx.getSoapAction();
-        if (soapActionString == null || soapActionString.length() == 0) {
-            soapActionString = msgCtx.getWSAAction();
-        }
-        if (soapActionString == null) {
-            soapActionString = "";
-        }
-        return soapActionString;
     }
 
     /**
@@ -299,8 +303,7 @@
      * @param context the context to set up
      * @throws AxisFault if service cannot be found
      */
-    public void setupTransport(MessageContext context, String endpointAddr)
-            throws AxisFault {
+    public void setupTransport(MessageContext context, String endpointAddr) throws AxisFault {
         if (log.isDebugEnabled()) {
             log.debug("Enter: JMSTransport::invoke");
         }
@@ -308,7 +311,6 @@
         JMSConnector connector = null;
         HashMap connectorProperties = null;
         HashMap connectionFactoryProperties = null;
-
         JMSVendorAdapter vendorAdapter = null;
         JMSURLHelper jmsurl = null;
 
@@ -318,36 +320,42 @@
         String password = "";
 
         // the presence of an endpoint address indicates whether the client application
-        //  is instantiating the JMSTransport directly (deprecated) or indirectly via JMS URL
-
+        // is instantiating the JMSTransport directly (deprecated) or indirectly via JMS URL
         if (endpointAddr != null) {
             try {
+
                 // performs minimal validation ('jms:/destination?...')
                 jmsurl = new JMSURLHelper(endpointAddr);
 
                 // lookup the appropriate vendor adapter
                 String vendorId = jmsurl.getVendor();
-                if (vendorId == null)
+
+                if (vendorId == null) {
                     vendorId = JMSConstants.JNDI_VENDOR_ID;
+                }
 
-                if (log.isDebugEnabled())
-                    log.debug("JMSTransport.invoke(): endpt=" + endpointAddr +
-                            ", vendor=" + vendorId);
+                if (log.isDebugEnabled()) {
+                    log.debug("JMSTransport.invoke(): endpt=" + endpointAddr + ", vendor="
+                            + vendorId);
+                }
 
                 vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
+
                 if (vendorAdapter == null) {
                     throw new AxisFault("cannotLoadAdapterClass:" + vendorId);
                 }
 
                 // populate the connector and connection factory properties tables
                 connectorProperties = vendorAdapter.getJMSConnectorProperties(jmsurl);
-                connectionFactoryProperties = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
-            }
-            catch (Exception e) {
+                connectionFactoryProperties =
+                        vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
+            } catch (Exception e) {
                 log.error(Messages.getMessage("malformedURLException00"), e);
+
                 throw new AxisFault(Messages.getMessage("malformedURLException00"), e);
             }
         } else {
+
             // the JMSTransport was instantiated directly, use the default adapter
             try {
                 vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
@@ -361,14 +369,15 @@
         }
 
         try {
-            connector = JMSConnectorManager.getInstance().getConnector(connectorProperties, connectionFactoryProperties,
-                    username, password, vendorAdapter);
-        }
-        catch (Exception e) {
+            connector = JMSConnectorManager.getInstance().getConnector(connectorProperties,
+                    connectionFactoryProperties, username, password, vendorAdapter);
+        } catch (Exception e) {
             log.error(Messages.getMessage("cannotConnectError"), e);
 
-            if (e instanceof AxisFault)
-                throw (AxisFault) e;
+            if (e instanceof AxisFault) {
+                throw(AxisFault) e;
+            }
+
             throw new AxisFault("cannotConnect", e);
         }
 
@@ -399,60 +408,87 @@
         }
     }
 
-    /**
-     * Closes all JMS connectors
-     */
-    public static void closeAllConnectors() {
-        if (log.isDebugEnabled()) {
-            log.debug("Enter: JMSTransport::closeAllConnectors");
+    public void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault {
+        SOAPEnvelope envelope = msgContext.getEnvelope();
+        OMElement outputMessage = envelope;
+
+        if ((envelope != null) && msgContext.isDoingREST()) {
+            outputMessage = envelope.getBody().getFirstElement();
         }
 
-        JMSConnectorManager.getInstance().closeAllConnectors();
+        if (outputMessage != null) {
+            try {
+                OMOutputFormat format = new OMOutputFormat();
 
-        if (log.isDebugEnabled()) {
-            log.debug("Exit: JMSTransport::closeAllConnectors");
+                // Pick the char set encoding from the msgContext
+                String charSetEnc =
+                        (String) msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+
+                format.setDoOptimize(msgContext.isDoingMTOM());
+                format.setCharSetEncoding(charSetEnc);
+                outputMessage.serializeAndConsume(out, format);
+                out.flush();
+            } catch (Exception e) {
+                throw new AxisFault(e);
+            }
+        } else {
+            throw new AxisFault(Messages.getMessage("outMessageNull"));
         }
     }
 
-    /**
-     * Closes JMS connectors that match the specified endpoint address
-     *
-     * @param endpointAddr the JMS endpoint address
-     * @param username
-     * @param password
-     */
-    public static void closeMatchingJMSConnectors(String endpointAddr, String username, String password) {
-        if (log.isDebugEnabled()) {
-            log.debug("Enter: JMSTransport::closeMatchingJMSConnectors");
+    public String getContentType(MessageContext msgCtx) {
+        OMOutputFormat format = new OMOutputFormat();
+        String soapActionString = getSOAPAction(msgCtx);
+        String charSetEnc =
+                (String) msgCtx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+
+        if (charSetEnc != null) {
+            format.setCharSetEncoding(charSetEnc);
+        } else {
+            OperationContext opctx = msgCtx.getOperationContext();
+
+            if (opctx != null) {
+                charSetEnc = (String) opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+            }
         }
 
-        try {
-            JMSURLHelper jmsurl = new JMSURLHelper(endpointAddr);
-            String vendorId = jmsurl.getVendor();
+        /**
+         * If the char set enc is still not found use the default
+         */
+        if (charSetEnc == null) {
+            charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
 
-            JMSVendorAdapter vendorAdapter = null;
-            if (vendorId == null)
-                vendorId = JMSConstants.JNDI_VENDOR_ID;
-            vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
+        format.setSOAP11(msgCtx.isSOAP11());
+        format.setCharSetEncoding(charSetEnc);
 
-            // the vendor adapter may not exist
-            if (vendorAdapter == null)
-                return;
+        String encoding = format.getCharSetEncoding();
+        String contentType = format.getContentType();
 
-            // determine the set of properties to be used for matching the connection
-            HashMap connectorProps = vendorAdapter.getJMSConnectorProperties(jmsurl);
-            HashMap cfProps = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
+        if (encoding != null) {
+            contentType += "; charset=" + encoding;
+        }
 
-            JMSConnectorManager.getInstance().closeMatchingJMSConnectors(connectorProps, cfProps,
-                    username, password,
-                    vendorAdapter);
+        // action header is not mandated in SOAP 1.2. So putting it, if available
+        if (!msgCtx.isSOAP11() && (soapActionString != null)
+                && !"".equals(soapActionString.trim())) {
+            contentType = contentType + ";action=\"" + soapActionString + "\";";
         }
-        catch (Exception e) {
-            log.warn(Messages.getMessage("malformedURLException00"), e);
+
+        return contentType;
+    }
+
+    private String getSOAPAction(MessageContext msgCtx) {
+        String soapActionString = msgCtx.getSoapAction();
+
+        if ((soapActionString == null) || (soapActionString.length() == 0)) {
+            soapActionString = msgCtx.getWSAAction();
         }
 
-        if (log.isDebugEnabled()) {
-            log.debug("Exit: JMSTransport::closeMatchingJMSConnectors");
+        if (soapActionString == null) {
+            soapActionString = "";
         }
+
+        return soapActionString;
     }
-}
\ No newline at end of file
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLConnection.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLConnection.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLConnection.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLConnection.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -28,4 +29,4 @@
 
     public void connect() {
     }
-}
\ No newline at end of file
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLHelper.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLHelper.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSURLHelper.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -29,7 +30,9 @@
  * The URL must be of the form: "jms:/<destination>?[<property>=<key>&]*"
  */
 public class JMSURLHelper {
-    private URI url;
+
+    // application-specific JMS message properties
+    private Vector appProperties;
 
     // the only property not in the query string
     private String destination;
@@ -39,9 +42,7 @@
 
     // required properties
     private Vector requiredProperties;
-
-    //application-specific JMS message properties
-    private Vector appProperties;
+    private URI url;
 
     public JMSURLHelper(String url) throws Exception {
         this(new URI(url), null);
@@ -51,7 +52,8 @@
         this(url, null);
     }
 
-    public JMSURLHelper(URI url, String[] requiredProperties) throws java.net.MalformedURLException {
+    public JMSURLHelper(URI url, String[] requiredProperties)
+            throws java.net.MalformedURLException {
         this.url = url;
         properties = new HashMap();
         appProperties = new Vector();
@@ -59,27 +61,34 @@
         // the path should be something like '/SampleQ1'
         // clip the leading '/' if there is one
         destination = url.getEscapedPath();
-        if (destination.startsWith("/"))
+
+        if (destination.startsWith("/")) {
             destination = destination.substring(1);
+        }
 
-        if ((destination == null) || (destination.trim().length() < 1))
+        if ((destination == null) || (destination.trim().length() < 1)) {
             throw new java.net.MalformedURLException("Missing destination in URL");
+        }
 
         // parse the query string and populate the properties table
         String query = url.getEscapedQuery();
+
         if (query != null) {
             StringTokenizer st = new StringTokenizer(query, "&;");
+
             while (st.hasMoreTokens()) {
                 String keyValue = st.nextToken();
                 int eqIndex = keyValue.indexOf("=");
+
                 if (eqIndex > 0) {
                     String key = keyValue.substring(0, eqIndex);
                     String value = keyValue.substring(eqIndex + 1);
+
                     if (key.startsWith(JMSConstants._MSG_PROP_PREFIX)) {
-                        key = key.substring(
-                                JMSConstants._MSG_PROP_PREFIX.length());
+                        key = key.substring(JMSConstants._MSG_PROP_PREFIX.length());
                         addApplicationProperty(key);
                     }
+
                     properties.put(key, value);
                 }
             }
@@ -90,33 +99,43 @@
         validateURL();
     }
 
-    public String getDestination() {
-        return destination;
-    }
+    /**
+     * Adds the name of a property from the url properties that should
+     * be added to the JMS message.
+     */
+    public void addApplicationProperty(String property) {
+        if (property == null) {
+            return;
+        }
 
-    public void setDestination(String destination) {
-        this.destination = destination;
-    }
+        if (appProperties == null) {
+            appProperties = new Vector();
+        }
 
-    public String getVendor() {
-        return getPropertyValue(JMSConstants._VENDOR);
+        appProperties.addElement(property);
     }
 
-    public String getDomain() {
-        return getPropertyValue(JMSConstants._DOMAIN);
-    }
+    /**
+     * Adds the name and value od the application property to the
+     * JMS URL.
+     */
+    public void addApplicationProperty(String property, String value) {
+        if (property == null) {
+            return;
+        }
 
-    public HashMap getProperties() {
-        return properties;
-    }
+        if (appProperties == null) {
+            appProperties = new Vector();
+        }
 
-    public String getPropertyValue(String property) {
-        return (String) properties.get(property);
+        properties.put(property, value);
+        appProperties.addElement(property);
     }
 
     public void addRequiredProperties(String[] properties) {
-        if (properties == null)
+        if (properties == null) {
             return;
+        }
 
         for (int i = 0; i < properties.length; i++) {
             addRequiredProperty(properties[i]);
@@ -124,46 +143,38 @@
     }
 
     public void addRequiredProperty(String property) {
-        if (property == null)
+        if (property == null) {
             return;
+        }
 
-        if (requiredProperties == null)
+        if (requiredProperties == null) {
             requiredProperties = new Vector();
+        }
 
         requiredProperties.addElement(property);
     }
 
-    public Vector getRequiredProperties() {
-        return requiredProperties;
-    }
-
     /**
-     * Adds the name of a property from the url properties that should
-     * be added to the JMS message.
+     * Returns a formatted URL String with the assigned properties
      */
-    public void addApplicationProperty(String property) {
-        if (property == null)
-            return;
-
-        if (appProperties == null)
-            appProperties = new Vector();
-
-        appProperties.addElement(property);
+    public String toString() {
+        return getURLString();
     }
 
-    /**
-     * Adds the name and value od the application property to the
-     * JMS URL.
-     */
-    public void addApplicationProperty(String property, String value) {
-        if (property == null)
+    private void validateURL() throws java.net.MalformedURLException {
+        Vector required = getRequiredProperties();
+
+        if (required == null) {
             return;
+        }
 
-        if (appProperties == null)
-            appProperties = new Vector();
+        for (int i = 0; i < required.size(); i++) {
+            String key = (String) required.elementAt(i);
 
-        properties.put(property, value);
-        appProperties.addElement(property);
+            if (properties.get(key) == null) {
+                throw new java.net.MalformedURLException();
+            }
+        }
     }
 
     /**
@@ -176,6 +187,25 @@
         return appProperties;
     }
 
+    public String getDestination() {
+        return destination;
+    }
+
+    public String getDomain() {
+        return getPropertyValue(JMSConstants._DOMAIN);
+    }
+
+    public HashMap getProperties() {
+        return properties;
+    }
+
+    public String getPropertyValue(String property) {
+        return (String) properties.get(property);
+    }
+
+    public Vector getRequiredProperties() {
+        return requiredProperties;
+    }
 
     /**
      * Returns a URL formatted String. The properties of the URL may not
@@ -184,43 +214,38 @@
      */
     public String getURLString() {
         StringBuffer text = new StringBuffer("jms:/");
+
         text.append(getDestination());
         text.append("?");
+
         Map props = (Map) properties.clone();
         boolean firstEntry = true;
+
         for (Iterator itr = properties.keySet().iterator(); itr.hasNext();) {
             String key = (String) itr.next();
+
             if (!firstEntry) {
                 text.append("&");
             }
+
             if (appProperties.contains(key)) {
                 text.append(JMSConstants._MSG_PROP_PREFIX);
             }
+
             text.append(key);
             text.append("=");
             text.append(props.get(key));
             firstEntry = false;
         }
+
         return text.toString();
     }
 
-    /**
-     * Returns a formatted URL String with the assigned properties
-     */
-    public String toString() {
-        return getURLString();
+    public String getVendor() {
+        return getPropertyValue(JMSConstants._VENDOR);
     }
 
-    private void validateURL()
-            throws java.net.MalformedURLException {
-        Vector required = getRequiredProperties();
-        if (required == null)
-            return;
-
-        for (int i = 0; i < required.size(); i++) {
-            String key = (String) required.elementAt(i);
-            if (properties.get(key) == null)
-                throw new java.net.MalformedURLException();
-        }
+    public void setDestination(String destination) {
+        this.destination = destination;
     }
-}
\ No newline at end of file
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapter.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapter.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapter.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -32,7 +33,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-
 /**
  * SPI Interface that all JMSVendorAdaptors must implement.  Allows for
  * ConnectionFactory creation and Destination lookup
@@ -44,34 +44,117 @@
     public static final int RECEIVE_ACTION = 3;
     public static final int ON_EXCEPTION_ACTION = 4;
 
-    public abstract QueueConnectionFactory getQueueConnectionFactory(HashMap cfProps)
-            throws Exception;
-
-    public abstract TopicConnectionFactory getTopicConnectionFactory(HashMap cfProps)
-            throws Exception;
-
     // let adapters add vendor-specific properties or override standard ones
     public abstract void addVendorConnectionFactoryProperties(JMSURLHelper jmsurl, HashMap cfProps);
 
-    // let adapters match connectors using vendor-specific connection factory properties
-    public abstract boolean isMatchingConnectionFactory(javax.jms.ConnectionFactory cf, JMSURLHelper jmsurl, HashMap cfProps);
+    public void setupApplicationProperties(MessageContext context, JMSURLHelper jmsurl) {
 
-    // returns <adapter> in 'org.apache.axis2.transport.jms.<adapter>VendorAdapter'
-    public String getVendorId() {
-        String name = this.getClass().getName();
+        // start with application properties from the URL
+        Map appProps = new HashMap();
 
-        // cut off the trailing 'VendorAdapter'
-        if (name.endsWith(JMSConstants.ADAPTER_POSTFIX)) {
-            int index = name.lastIndexOf(JMSConstants.ADAPTER_POSTFIX);
-            name = name.substring(0, index);
+        if ((jmsurl != null) && (jmsurl.getApplicationProperties() != null)) {
+            for (Iterator itr = jmsurl.getApplicationProperties().iterator(); itr.hasNext();) {
+                String name = (String) itr.next();
+
+                appProps.put(name, jmsurl.getPropertyValue(name));
+            }
         }
 
-        // cut off the leading 'org.apache.axis2.transport.jms.'
-        int index = name.lastIndexOf(".");
-        if (index > 0)
-            name = name.substring(index + 1);
+        // next add application properties from the message context
+        Map ctxProps = (Map) context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS);
 
-        return name;
+        if (ctxProps != null) {
+            appProps.putAll(ctxProps);
+        }
+
+        // now tore these properties within the context
+        context.setProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS, appProps);
+    }
+
+    /**
+     * Set JMS properties in the message context.
+     * <p/>
+     * TODO: just copy all properties that are not used for the JMS connector
+     * or connection factory
+     */
+    public void setupMessageContext(MessageContext context, JMSURLHelper jmsurl) {
+        Object tmp = null;
+        String jmsurlDestination = null;
+
+        if (jmsurl != null) {
+            jmsurlDestination = jmsurl.getDestination();
+        }
+
+        if (jmsurlDestination != null) {
+            context.setProperty(JMSConstants.DESTINATION, jmsurlDestination);
+        }
+
+        String delivMode = null;
+
+        if (jmsurl != null) {
+            delivMode = jmsurl.getPropertyValue(JMSConstants._DELIVERY_MODE);
+        }
+
+        if (delivMode != null) {
+            int mode = JMSConstants.DEFAULT_DELIVERY_MODE;
+
+            if (delivMode.equalsIgnoreCase(JMSConstants.DELIVERY_MODE_PERSISTENT)) {
+                mode = javax.jms.DeliveryMode.PERSISTENT;
+            } else if (delivMode.equalsIgnoreCase(JMSConstants.DELIVERY_MODE_NONPERSISTENT)) {
+                mode = javax.jms.DeliveryMode.NON_PERSISTENT;
+            }
+
+            context.setProperty(JMSConstants.DELIVERY_MODE, new Integer(mode));
+        }
+
+        String prio = null;
+
+        if (jmsurl != null) {
+            prio = jmsurl.getPropertyValue(JMSConstants._PRIORITY);
+        }
+
+        if (prio != null) {
+            context.setProperty(JMSConstants.PRIORITY, Integer.valueOf(prio));
+        }
+
+        String ttl = null;
+
+        if (jmsurl != null) {
+            ttl = jmsurl.getPropertyValue(JMSConstants._TIME_TO_LIVE);
+        }
+
+        if (ttl != null) {
+            context.setProperty(JMSConstants.TIME_TO_LIVE, Long.valueOf(ttl));
+        }
+
+        setupApplicationProperties(context, jmsurl);
+    }
+
+    /**
+     * Creates a connection factory property table using values supplied in
+     * the endpoint address
+     *
+     * @param jmsurl the endpoint address
+     * @return the set of properties to be used for instantiating the connection factory
+     */
+    public HashMap getJMSConnectionFactoryProperties(JMSURLHelper jmsurl) {
+        HashMap cfProps = new HashMap();
+
+        // hold on to the original address (this will be useful when the JNDI vendor adapter
+        // matches connectors)
+        cfProps.put(JMSConstants.JMS_URL, jmsurl);
+
+        // JMSConstants.DOMAIN
+        String domain = jmsurl.getPropertyValue(JMSConstants._DOMAIN);
+
+        if (domain != null) {
+            cfProps.put(JMSConstants.DOMAIN, domain);
+        }
+
+        // allow vendors to customize the cf properties table
+        addVendorConnectionFactoryProperties(jmsurl, cfProps);
+
+        return cfProps;
     }
 
     /**
@@ -90,91 +173,113 @@
 
         // JMSConstants.CLIENT_ID,
         String clientID = jmsurl.getPropertyValue(JMSConstants._CLIENT_ID);
-        if (clientID != null)
+
+        if (clientID != null) {
             connectorProps.put(JMSConstants.CLIENT_ID, clientID);
+        }
 
         // JMSConstants.CONNECT_RETRY_INTERVAL,
         String connectRetryInterval = jmsurl.getPropertyValue(JMSConstants._CONNECT_RETRY_INTERVAL);
-        if (connectRetryInterval != null)
+
+        if (connectRetryInterval != null) {
             connectorProps.put(JMSConstants.CONNECT_RETRY_INTERVAL, connectRetryInterval);
+        }
 
         // JMSConstants.INTERACT_RETRY_INTERVAL,
-        String interactRetryInterval = jmsurl.getPropertyValue(JMSConstants._INTERACT_RETRY_INTERVAL);
-        if (interactRetryInterval != null)
+        String interactRetryInterval =
+                jmsurl.getPropertyValue(JMSConstants._INTERACT_RETRY_INTERVAL);
+
+        if (interactRetryInterval != null) {
             connectorProps.put(JMSConstants.INTERACT_RETRY_INTERVAL, interactRetryInterval);
+        }
 
         // JMSConstants.DOMAIN
         String domain = jmsurl.getPropertyValue(JMSConstants._DOMAIN);
-        if (domain != null)
+
+        if (domain != null) {
             connectorProps.put(JMSConstants.DOMAIN, domain);
+        }
 
         // JMSConstants.NUM_RETRIES
         String numRetries = jmsurl.getPropertyValue(JMSConstants._NUM_RETRIES);
-        if (numRetries != null)
+
+        if (numRetries != null) {
             connectorProps.put(JMSConstants.NUM_RETRIES, numRetries);
+        }
 
         // JMSConstants.NUM_SESSIONS
         String numSessions = jmsurl.getPropertyValue(JMSConstants._NUM_SESSIONS);
-        if (numSessions != null)
+
+        if (numSessions != null) {
             connectorProps.put(JMSConstants.NUM_SESSIONS, numSessions);
+        }
 
         // JMSConstants.TIMEOUT_TIME,
         String timeoutTime = jmsurl.getPropertyValue(JMSConstants._TIMEOUT_TIME);
-        if (timeoutTime != null)
+
+        if (timeoutTime != null) {
             connectorProps.put(JMSConstants.TIMEOUT_TIME, timeoutTime);
+        }
 
         return connectorProps;
     }
 
-    /**
-     * Creates a connection factory property table using values supplied in
-     * the endpoint address
-     *
-     * @param jmsurl the endpoint address
-     * @return the set of properties to be used for instantiating the connection factory
-     */
-    public HashMap getJMSConnectionFactoryProperties(JMSURLHelper jmsurl) {
-        HashMap cfProps = new HashMap();
+    public Queue getQueue(QueueSession session, String name) throws Exception {
+        return session.createQueue(name);
+    }
 
-        // hold on to the original address (this will be useful when the JNDI vendor adapter
-        // matches connectors)
-        cfProps.put(JMSConstants.JMS_URL, jmsurl);
+    public abstract QueueConnectionFactory getQueueConnectionFactory(HashMap cfProps)
+            throws Exception;
 
-        // JMSConstants.DOMAIN
-        String domain = jmsurl.getPropertyValue(JMSConstants._DOMAIN);
-        if (domain != null)
-            cfProps.put(JMSConstants.DOMAIN, domain);
+    public Topic getTopic(TopicSession session, String name) throws Exception {
+        return session.createTopic(name);
+    }
 
-        // allow vendors to customize the cf properties table
-        addVendorConnectionFactoryProperties(jmsurl, cfProps);
+    public abstract TopicConnectionFactory getTopicConnectionFactory(HashMap cfProps)
+            throws Exception;
 
-        return cfProps;
-    }
+    // returns <adapter> in 'org.apache.axis2.transport.jms.<adapter>VendorAdapter'
+    public String getVendorId() {
+        String name = this.getClass().getName();
 
-    public Queue getQueue(QueueSession session, String name)
-            throws Exception {
-        return session.createQueue(name);
-    }
+        // cut off the trailing 'VendorAdapter'
+        if (name.endsWith(JMSConstants.ADAPTER_POSTFIX)) {
+            int index = name.lastIndexOf(JMSConstants.ADAPTER_POSTFIX);
 
-    public Topic getTopic(TopicSession session, String name)
-            throws Exception {
-        return session.createTopic(name);
+            name = name.substring(0, index);
+        }
+
+        // cut off the leading 'org.apache.axis2.transport.jms.'
+        int index = name.lastIndexOf(".");
+
+        if (index > 0) {
+            name = name.substring(index + 1);
+        }
+
+        return name;
     }
 
+    // let adapters match connectors using vendor-specific connection factory properties
+    public abstract boolean isMatchingConnectionFactory(javax.jms.ConnectionFactory cf,
+                                                        JMSURLHelper jmsurl, HashMap cfProps);
+
     public boolean isRecoverable(Throwable thrown, int action) {
-        if (thrown instanceof RuntimeException ||
-                thrown instanceof Error ||
-                thrown instanceof JMSSecurityException ||
-                thrown instanceof InvalidDestinationException)
+        if ((thrown instanceof RuntimeException) || (thrown instanceof Error)
+                || (thrown instanceof JMSSecurityException)
+                || (thrown instanceof InvalidDestinationException)) {
             return false;
-        if (action == ON_EXCEPTION_ACTION)
+        }
+
+        if (action == ON_EXCEPTION_ACTION) {
             return false;
+        }
+
         return true;
     }
 
-    public void setProperties(Message message, HashMap props)
-            throws JMSException {
+    public void setProperties(Message message, HashMap props) throws JMSException {
         Iterator iter = props.keySet().iterator();
+
         while (iter.hasNext()) {
             String key = (String) iter.next();
             String value = (String) props.get(key);
@@ -182,70 +287,4 @@
             message.setStringProperty(key, value);
         }
     }
-
-    /**
-     * Set JMS properties in the message context.
-     * <p/>
-     * TODO: just copy all properties that are not used for the JMS connector
-     * or connection factory
-     */
-    public void setupMessageContext(MessageContext context,
-                                    JMSURLHelper jmsurl) {
-        Object tmp = null;
-
-        String jmsurlDestination = null;
-        if (jmsurl != null)
-            jmsurlDestination = jmsurl.getDestination();
-        if (jmsurlDestination != null)
-            context.setProperty(JMSConstants.DESTINATION, jmsurlDestination);
-
-        String delivMode = null;
-        if (jmsurl != null)
-            delivMode = jmsurl.getPropertyValue(JMSConstants._DELIVERY_MODE);
-        if (delivMode != null) {
-            int mode = JMSConstants.DEFAULT_DELIVERY_MODE;
-            if (delivMode.equalsIgnoreCase(JMSConstants.DELIVERY_MODE_PERSISTENT))
-                mode = javax.jms.DeliveryMode.PERSISTENT;
-            else if (delivMode.equalsIgnoreCase(JMSConstants.DELIVERY_MODE_NONPERSISTENT))
-                mode = javax.jms.DeliveryMode.NON_PERSISTENT;
-            context.setProperty(JMSConstants.DELIVERY_MODE, new Integer(mode));
-        }
-
-        String prio = null;
-        if (jmsurl != null)
-            prio = jmsurl.getPropertyValue(JMSConstants._PRIORITY);
-        if (prio != null)
-            context.setProperty(JMSConstants.PRIORITY, Integer.valueOf(prio));
-
-        String ttl = null;
-        if (jmsurl != null)
-            ttl = jmsurl.getPropertyValue(JMSConstants._TIME_TO_LIVE);
-        if (ttl != null)
-            context.setProperty(JMSConstants.TIME_TO_LIVE, Long.valueOf(ttl));
-
-        setupApplicationProperties(context, jmsurl);
-    }
-
-    public void setupApplicationProperties(MessageContext context,
-                                           JMSURLHelper jmsurl) {
-        //start with application properties from the URL
-        Map appProps = new HashMap();
-        if (jmsurl != null && jmsurl.getApplicationProperties() != null) {
-            for (Iterator itr = jmsurl.getApplicationProperties().iterator();
-                 itr.hasNext();) {
-                String name = (String) itr.next();
-                appProps.put(name, jmsurl.getPropertyValue(name));
-            }
-        }
-
-        //next add application properties from the message context
-        Map ctxProps =
-                (Map) context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS);
-        if (ctxProps != null) {
-            appProps.putAll(ctxProps);
-        }
-
-        //now tore these properties within the context
-        context.setProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS, appProps);
-    }
-}
\ No newline at end of file
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapterFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapterFactory.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapterFactory.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSVendorAdapterFactory.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -27,34 +28,39 @@
  */
 public class JMSVendorAdapterFactory {
     private static HashMap s_adapters = new HashMap();
-    private final static String VENDOR_PKG = "org.apache.axis2.transport.jms";
     private static Loader loader = new Loader();
+    private final static String VENDOR_PKG = "org.apache.axis2.transport.jms";
 
     public static final JMSVendorAdapter getJMSVendorAdapter() throws Exception {
         return (JMSVendorAdapter) Loader.loadClass(VENDOR_PKG + ".JNDIVendorAdapter").newInstance();
     }
 
     public static final JMSVendorAdapter getJMSVendorAdapter(String vendorId) {
+
         // check to see if the adapter has already been instantiated
-        if (s_adapters.containsKey(vendorId))
+        if (s_adapters.containsKey(vendorId)) {
             return (JMSVendorAdapter) s_adapters.get(vendorId);
+        }
 
         // create a new instance
         JMSVendorAdapter adapter = null;
+
         try {
             Class vendorClass = Class.forName(getVendorAdapterClassname(vendorId));
+
             adapter = (JMSVendorAdapter) vendorClass.newInstance();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return null;
         }
 
         synchronized (s_adapters) {
-            if (s_adapters.containsKey(vendorId))
+            if (s_adapters.containsKey(vendorId)) {
                 return (JMSVendorAdapter) s_adapters.get(vendorId);
+            }
 
-            if (adapter != null)
+            if (adapter != null) {
                 s_adapters.put(vendorId, adapter);
+            }
         }
 
         return adapter;
@@ -62,9 +68,10 @@
 
     private static String getVendorAdapterClassname(String vendorId) {
         StringBuffer sb = new StringBuffer(VENDOR_PKG).append(".");
+
         sb.append(vendorId);
         sb.append("VendorAdapter");
 
         return sb.toString();
     }
-}
\ No newline at end of file
+}

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=357187&r1=357186&r2=357187&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 Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -34,84 +35,95 @@
 public class JNDIVendorAdapter extends JMSVendorAdapter {
     public final static String CONTEXT_FACTORY = "java.naming.factory.initial";
     public final static String PROVIDER_URL = "java.naming.provider.url";
-
     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;
     public final static String CONNECTION_FACTORY_JNDI_VALUE = "ConnectionFactory";
-
+    public final static String CONNECTION_FACTORY_JNDI_NAME = JMSConstants.JMS_PROPERTY_PREFIX
+            + _CONNECTION_FACTORY_JNDI_NAME;
     public final static String _DESTINATION = "Destination";
-    public final static String DESTINATION = JMSConstants.JMS_PROPERTY_PREFIX +
-            _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;
-
+    public final static String USER = JMSConstants.JMS_PROPERTY_PREFIX + _USER;
+    public final static String PASSWORD = JMSConstants.JMS_PROPERTY_PREFIX + _PASSWORD;
     private Context context;
 
-    public QueueConnectionFactory getQueueConnectionFactory(HashMap cfConfig)
-            throws Exception {
-        return (QueueConnectionFactory) getConnectionFactory(cfConfig);
-    }
+    /**
+     * Populates the connection factory config table with properties from
+     * the JMS URL query string
+     *
+     * @param jmsurl   The target endpoint address of the Axis call
+     * @param cfConfig The set of properties necessary to create/configure the connection factory
+     */
+    public void addVendorConnectionFactoryProperties(JMSURLHelper jmsurl, HashMap cfConfig) {
 
-    public TopicConnectionFactory getTopicConnectionFactory(HashMap cfConfig)
-            throws Exception {
-        return (TopicConnectionFactory) getConnectionFactory(cfConfig);
+        // add the connection factory jndi name
+        String cfJNDIName = jmsurl.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);
+
+        if (cfJNDIName != null) {
+            cfConfig.put(CONNECTION_FACTORY_JNDI_NAME, cfJNDIName);
+        }
+
+        // add the initial ctx factory
+        String ctxFactory = jmsurl.getPropertyValue(CONTEXT_FACTORY);
+
+        if (ctxFactory != null) {
+            cfConfig.put(CONTEXT_FACTORY, ctxFactory);
+        }
+
+        // add the provider url
+        String providerURL = jmsurl.getPropertyValue(PROVIDER_URL);
+
+        if (providerURL != null) {
+            cfConfig.put(PROVIDER_URL, providerURL);
+        }
     }
 
-    private ConnectionFactory getConnectionFactory(HashMap cfProps)
-            throws Exception {
-        if (cfProps == null)
+    private ConnectionFactory getConnectionFactory(HashMap cfProps) throws Exception {
+        if (cfProps == null) {
             throw new IllegalArgumentException("noCFProps");
+        }
+
         String jndiName = (String) cfProps.get(CONNECTION_FACTORY_JNDI_NAME);
-        if (jndiName == null || jndiName.trim().length() == 0)
+
+        if ((jndiName == null) || (jndiName.trim().length() == 0)) {
             jndiName = CONNECTION_FACTORY_JNDI_VALUE;
+        }
 
         Hashtable environment = new Hashtable(cfProps);
 
         // set the context factory if provided in the JMS URL
         String ctxFactory = (String) cfProps.get(CONTEXT_FACTORY);
-        if (ctxFactory != null)
+
+        if (ctxFactory != null) {
             environment.put(CONTEXT_FACTORY, ctxFactory);
+        }
 
         // set the provider url if provided in the JMS URL
         String providerURL = (String) cfProps.get(PROVIDER_URL);
-        if (providerURL != null)
+
+        if (providerURL != null) {
             environment.put(PROVIDER_URL, providerURL);
+        }
 
         context = new InitialContext(environment);
 
         return (ConnectionFactory) context.lookup(jndiName);
     }
 
-    /**
-     * Populates the connection factory config table with properties from
-     * the JMS URL query string
-     *
-     * @param jmsurl   The target endpoint address of the Axis call
-     * @param cfConfig The set of properties necessary to create/configure the connection factory
-     */
-    public void addVendorConnectionFactoryProperties(JMSURLHelper jmsurl,
-                                                     HashMap cfConfig) {
-        // add the connection factory jndi name
-        String cfJNDIName = jmsurl.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);
-        if (cfJNDIName != null)
-            cfConfig.put(CONNECTION_FACTORY_JNDI_NAME, cfJNDIName);
+    public Queue getQueue(QueueSession session, String name) throws Exception {
+        return (Queue) context.lookup(name);
+    }
 
-        // add the initial ctx factory
-        String ctxFactory = jmsurl.getPropertyValue(CONTEXT_FACTORY);
-        if (ctxFactory != null)
-            cfConfig.put(CONTEXT_FACTORY, ctxFactory);
+    public QueueConnectionFactory getQueueConnectionFactory(HashMap cfConfig) throws Exception {
+        return (QueueConnectionFactory) getConnectionFactory(cfConfig);
+    }
 
-        // add the provider url
-        String providerURL = jmsurl.getPropertyValue(PROVIDER_URL);
-        if (providerURL != null)
-            cfConfig.put(PROVIDER_URL, providerURL);
+    public Topic getTopic(TopicSession session, String name) throws Exception {
+        return (Topic) context.lookup(name);
+    }
+
+    public TopicConnectionFactory getTopicConnectionFactory(HashMap cfConfig) throws Exception {
+        return (TopicConnectionFactory) getConnectionFactory(cfConfig);
     }
 
     /**
@@ -123,8 +135,7 @@
      * @param cfProps        the set of properties that should be used to determine the match
      * @return true or false to indicate whether a match has been found
      */
-    public boolean isMatchingConnectionFactory(ConnectionFactory cf,
-                                               JMSURLHelper originalJMSURL,
+    public boolean isMatchingConnectionFactory(ConnectionFactory cf, JMSURLHelper originalJMSURL,
                                                HashMap cfProps) {
         JMSURLHelper jmsurl = (JMSURLHelper) cfProps.get(JMSConstants.JMS_URL);
 
@@ -132,19 +143,10 @@
         String cfJndiName = jmsurl.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);
         String originalCfJndiName = originalJMSURL.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);
 
-        if (cfJndiName.equalsIgnoreCase(originalCfJndiName))
+        if (cfJndiName.equalsIgnoreCase(originalCfJndiName)) {
             return true;
+        }
 
         return false;
     }
-
-    public Queue getQueue(QueueSession session, String name)
-            throws Exception {
-        return (Queue) context.lookup(name);
-    }
-
-    public Topic getTopic(TopicSession session, String name)
-            throws Exception {
-        return (Topic) context.lookup(name);
-    }
-}
\ No newline at end of file
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/MapUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/MapUtils.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/MapUtils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/MapUtils.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 
 package org.apache.axis2.transport.jms;
 
@@ -22,95 +23,106 @@
  * MapUtils provides convenience methods for accessing a java.util.Map
  */
 public class MapUtils {
+
     /**
-     * Returns an int property from a Map and removes it.
+     * Returns a boolean property from a Map and removes it.
      *
      * @param properties
      * @param key
      * @param defaultValue
      * @return old value
      */
-    public static int removeIntProperty(Map properties, String key, int defaultValue) {
-        int value = defaultValue;
-        if (properties != null && properties.containsKey(key)) {
+    public static boolean removeBooleanProperty(Map properties, String key, boolean defaultValue) {
+        boolean value = defaultValue;
+
+        if ((properties != null) && properties.containsKey(key)) {
             try {
-                value = ((Integer) properties.remove(key)).intValue();
+                value = ((Boolean) properties.remove(key)).booleanValue();
             } catch (Exception ignore) {
             }
         }
+
         return value;
     }
 
     /**
-     * Returns a long property from a Map and removes it.
+     * Returns an int property from a Map and removes it.
      *
      * @param properties
      * @param key
      * @param defaultValue
      * @return old value
      */
-    public static long removeLongProperty(Map properties, String key, long defaultValue) {
-        long value = defaultValue;
-        if (properties != null && properties.containsKey(key)) {
+    public static int removeIntProperty(Map properties, String key, int defaultValue) {
+        int value = defaultValue;
+
+        if ((properties != null) && properties.containsKey(key)) {
             try {
-                value = ((Long) properties.remove(key)).longValue();
+                value = ((Integer) properties.remove(key)).intValue();
             } catch (Exception ignore) {
             }
         }
+
         return value;
     }
 
     /**
-     * Returns a String property from a Map and removes it.
+     * Returns a long property from a Map and removes it.
      *
      * @param properties
      * @param key
      * @param defaultValue
      * @return old value
      */
-    public static String removeStringProperty(Map properties, String key, String defaultValue) {
-        String value = defaultValue;
-        if (properties != null && properties.containsKey(key)) {
+    public static long removeLongProperty(Map properties, String key, long defaultValue) {
+        long value = defaultValue;
+
+        if ((properties != null) && properties.containsKey(key)) {
             try {
-                value = (String) properties.remove(key);
+                value = ((Long) properties.remove(key)).longValue();
             } catch (Exception ignore) {
             }
         }
+
         return value;
     }
 
     /**
-     * Returns a boolean property from a Map and removes it.
+     * Returns an Object property from a Map and removes it.
      *
      * @param properties
      * @param key
      * @param defaultValue
      * @return old value
      */
-    public static boolean removeBooleanProperty(Map properties, String key, boolean defaultValue) {
-        boolean value = defaultValue;
-        if (properties != null && properties.containsKey(key)) {
-            try {
-                value = ((Boolean) properties.remove(key)).booleanValue();
-            } catch (Exception ignore) {
-            }
+    public static Object removeObjectProperty(Map properties, String key, Object defaultValue) {
+        Object value = defaultValue;
+
+        if ((properties != null) && properties.containsKey(key)) {
+            value = properties.remove(key);
         }
+
         return value;
     }
 
     /**
-     * Returns an Object property from a Map and removes it.
+     * Returns a String property from a Map and removes it.
      *
      * @param properties
      * @param key
      * @param defaultValue
      * @return old value
      */
-    public static Object removeObjectProperty(Map properties, String key, Object defaultValue) {
-        Object value = defaultValue;
-        if (properties != null && properties.containsKey(key)) {
-            value = properties.remove(key);
+    public static String removeStringProperty(Map properties, String key, String defaultValue) {
+        String value = defaultValue;
+
+        if ((properties != null) && properties.containsKey(key)) {
+            try {
+                value = (String) properties.remove(key);
+            } catch (Exception ignore) {
+            }
         }
+
         return value;
     }
 }