antelder    2003/03/27 04:21:35

  Modified:    java/src/org/apache/wsif/wsdl/extensions/jms
                        JMSConstants.java
               java/src/org/apache/wsif/util/jms WSIFJMSDestination.java
                        WSIFJMSProperties.java WSIFJMSConstants.java
               java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFPort_ApacheAxis.java
  Log:
  Initial version of support the SOAP over JMS using the soap:address location 
attribute to define the JMS properties
  
  Revision  Changes    Path
  1.5       +11 -0     
xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSConstants.java
  
  Index: JMSConstants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSConstants.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JMSConstants.java 7 Dec 2002 12:33:48 -0000       1.4
  +++ JMSConstants.java 27 Mar 2003 12:21:34 -0000      1.5
  @@ -102,6 +102,17 @@
       public static final String ELEM_JMS_QUEUE = "queue";
       public static final String ELEM_JMS_TOPIC = "topic";
   
  +    // soap:address JMS URL property names
  +    public static final String JMS_URL_DESTINATION = "destination";
  +    public static final String JMS_URL_CONNECTION_FACTORY = "connectionFactory";
  +    public static final String JMS_URL_INITIAL_CONTEXT_FACTORY = 
"initialContextFactory";
  +    public static final String JMS_URL_PROVIDER_URL = "jndiProviderURL";
  +    public static final String JMS_URL_DELIVERY_MODE = "deliveryMode";
  +    public static final String JMS_URL_TIME_TO_LIVE = "timeToLive";
  +    public static final String JMS_URL_PRIORITY = "priority";
  +    public static final String JMS_URL_USERID = "userid";
  +    public static final String JMS_URL_PASSWORD = "password";
  +    
       // Jms Header, HeaderValue, Property, PropertyValue extension    
       public static final String ATTR_PART = "part";
       public static final String ATTR_NAME = "name";
  
  
  
  1.15      +177 -0    
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java
  
  Index: WSIFJMSDestination.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- WSIFJMSDestination.java   7 Dec 2002 12:33:58 -0000       1.14
  +++ WSIFJMSDestination.java   27 Mar 2003 12:21:34 -0000      1.15
  @@ -59,6 +59,7 @@
   
   import java.io.Serializable;
   import java.util.HashMap;
  +import java.util.StringTokenizer;
   
   import javax.jms.Destination;
   import javax.jms.JMSException;
  @@ -71,8 +72,14 @@
   import javax.jms.QueueSession;
   import javax.jms.Session;
   import javax.jms.TextMessage;
  +import javax.xml.namespace.QName;
  +
  +import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.logging.Trc;
  +import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
  +import org.apache.wsif.wsdl.extensions.jms.JMSConstants;
  +import org.apache.wsif.wsdl.extensions.jms.JMSPropertyValue;
   
   /**
    * A WSIFJMSDestination is a pair of queues, one that read from and
  @@ -640,4 +647,174 @@
           }
           return buff;
       }
  +    
  +    /**
  +     * Create a JMSAddress extensability element from a URL string
  +     * The URL string would normally be from the WSDL soap:address
  +     * location attribute.
  +     * 
  +     * The format of the URL is:
  +     * jms:/[queue|topic]?<property>=<value>|<property>=<value>|...
  +     * 
  +     * Valid properties are:
  +     * 
  +     *    destination
  +     *               The JNDI name of the destination queue or topic.
  +     *    connectionFactory  
  +     *      The JNDI name of the connection factory.
  +     *    targetService
  +     *               The name of the deployed service to which the request will be 
dispatched.
  +     * 
  +     * JNDI-related Properties (optional)
  +     * 
  +     *    initialContextFactory
  +     *       The name of the initial context factory to use 
  +     *      (this is mapped to the java.naming.factory.initial property)
  +     *    jndiProviderURL
  +     *       The JNDI provider URL 
  +     *      (this is mapped to the java.naming.provider.url property)
  +     * 
  +     * JMS-related Properties (optional)
  +     * 
  +     *    deliveryMode
  +     *               An indication as to whether the request message should be 
persistent or not. 
  +     *      The valid values are DeliveryMode.NON_PERSISTENT (default) and 
  +     *      DeliveryMode.PERSISTENT.
  +     *    timeToLive
  +     *               The lifetime (in milliseconds) of the request message. 
  +     *      A value of 0 indicates an infinite lifetime.
  +     *    priority
  +     *               The JMS priority associated with the request message 
  +     *      Valid values are 0 to 9. The default value is 4
  +     *    userid
  +     *               The userid to be used to gain access to the connection factory.
  +     *    password
  +     *               The password to be used to gain access to the connection 
factory.
  +     * 
  +     * @param url   the URL string
  +     * @return JMSAddress   the new JMSAddress created from the URL 
  +     */
  +    public static JMSAddress getJMSAddressFromURL(String url)
  +        throws WSIFException {
  +
  +        JMSAddress jmsAddress = new JMSAddress();
  +
  +        // validate protocol
  +        if (!url.startsWith(WSIFJMSConstants.jmsURLProtcol)) {
  +            throw new WSIFException(
  +                "protocol must be '"
  +                    + WSIFJMSConstants.jmsURLProtcol
  +                    + "', url: "
  +                    + url);
  +        }
  +
  +        // validate its a query
  +        int queryStart = url.indexOf(WSIFJMSConstants.jmsURLQueryChar);
  +        if (queryStart < 1) {
  +            throw new WSIFException("URL must be a query, url: " + url);
  +        }
  +
  +        // validate destination type
  +        String destinationStyle =
  +            url.substring(
  +                WSIFJMSConstants.jmsURLProtcol.length(),
  +                queryStart);
  +        if (!JMSConstants.ELEM_JMS_QUEUE.equals(destinationStyle)
  +            && !JMSConstants.ELEM_JMS_TOPIC.equals(destinationStyle)) {
  +            throw new WSIFException(
  +                "style must be queue or topic. found: " + destinationStyle);
  +        }
  +        jmsAddress.setDestStyle(destinationStyle);
  +
  +        // validate query string
  +        if (queryStart >= url.length()) {
  +            throw new WSIFException("empty query string: " + url);
  +        }
  +        String queryString = url.substring(queryStart + 1);
  +
  +        // parse and validate the query
  +        StringTokenizer st =
  +            new StringTokenizer(
  +                queryString,
  +                WSIFJMSConstants.jmsURLQuerySeperator);
  +        while (st.hasMoreTokens()) {
  +            String property = st.nextToken();
  +            int delim = property.indexOf('=');
  +            if (delim < 1 || delim >= property.length()) {
  +                throw new WSIFException(
  +                    "property must be '=' seperated name value pair: "
  +                        + property);
  +            }
  +
  +            String propertyName = property.substring(0, delim);
  +            String propertyValue = property.substring(delim + 1);
  +
  +            if (propertyName.equals(JMSConstants.JMS_URL_DESTINATION)) {
  +                jmsAddress.setJndiDestName(propertyValue);
  +
  +            } else if 
(propertyName.equals(JMSConstants.JMS_URL_CONNECTION_FACTORY)) {
  +                jmsAddress.setJndiConnFactName(propertyValue);
  +
  +            } else if 
(propertyName.equals(JMSConstants.JMS_URL_INITIAL_CONTEXT_FACTORY)) {
  +                jmsAddress.setInitCxtFact(propertyValue);
  +
  +            } else if (propertyName.equals(JMSConstants.JMS_URL_PROVIDER_URL)) {
  +                jmsAddress.setJndiProvURL(propertyValue);
  +
  +            } else if (propertyName.equals(JMSConstants.JMS_URL_DELIVERY_MODE)) {
  +                JMSPropertyValue jpv = new JMSPropertyValue();
  +                jpv.setName(WSIFJMSProperties.DELIVERYMODE);
  +                jpv.setValue(propertyValue);
  +                jpv.setType(
  +                    new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "int"));
  +                jmsAddress.addJMSPropertyValue(jpv);
  +
  +            } else if (propertyName.equals(JMSConstants.JMS_URL_TIME_TO_LIVE)) {
  +                JMSPropertyValue jpv = new JMSPropertyValue();
  +                jpv.setName(WSIFJMSProperties.TIMETOLIVE);
  +                jpv.setValue(propertyValue);
  +                jpv.setType(
  +                    new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "long"));
  +                jmsAddress.addJMSPropertyValue(jpv);
  +
  +            } else if (propertyName.equals(JMSConstants.JMS_URL_PRIORITY)) {
  +                JMSPropertyValue jpv = new JMSPropertyValue();
  +                jpv.setName(WSIFJMSProperties.PRIORITY);
  +                jpv.setValue(propertyValue);
  +                jpv.setType(
  +                    new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "int"));
  +                jmsAddress.addJMSPropertyValue(jpv);
  +
  +            } else if (propertyName.equals(JMSConstants.JMS_URL_USERID)) {
  +                JMSPropertyValue jpv = new JMSPropertyValue();
  +                jpv.setName(WSIFJMSProperties.QCF_USERID);
  +                jpv.setValue(propertyValue);
  +                jpv.setType(
  +                    new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "string"));
  +                jmsAddress.addJMSPropertyValue(jpv);
  +
  +            } else if (propertyName.equals(JMSConstants.JMS_URL_PASSWORD)) {
  +                JMSPropertyValue jpv = new JMSPropertyValue();
  +                jpv.setName(WSIFJMSProperties.QCF_PASSWORD);
  +                jpv.setValue(propertyValue);
  +                jpv.setType(
  +                    new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "string"));
  +                jmsAddress.addJMSPropertyValue(jpv);
  +
  +            } else {
  +//TODO: should this be allowed?              
  +//                throw new WSIFException(
  +//                    "invalid property in JMS URL: " + property);
  +                JMSPropertyValue jpv = new JMSPropertyValue();
  +                jpv.setName(propertyName);
  +                jpv.setValue(propertyValue);
  +                jpv.setType(
  +                    new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "string"));
  +                jmsAddress.addJMSPropertyValue(jpv);
  +            }
  +        }
  +
  +        return jmsAddress;
  +    }
  +    
   }
  
  
  
  1.11      +13 -11    
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSProperties.java
  
  Index: WSIFJMSProperties.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSProperties.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WSIFJMSProperties.java    18 Mar 2003 17:53:01 -0000      1.10
  +++ WSIFJMSProperties.java    27 Mar 2003 12:21:34 -0000      1.11
  @@ -88,17 +88,19 @@
       private static final ArrayList allDirections =
           new ArrayList(Arrays.asList(new Object[] { IN, OUT }));
   
  -    private static final String CORRELATIONID = "JMSCorrelationID";
  -    private static final String DELIVERYMODE  = "JMSDeliveryMode";
  -    private static final String DESTINATION   = "JMSDestination";
  -    private static final String EXPIRATION    = "JMSExpiration";
  -    private static final String MESSAGEID     = "JMSMessageID";
  -    private static final String PRIORITY      = "JMSPriority";
  -    private static final String REDELIVERED   = "JMSRedelivered";
  -    private static final String REPLYTO       = "JMSReplyTo";
  -    private static final String TIMESTAMP     = "JMSTimestamp";
  -    private static final String TIMETOLIVE    = "JMSTimeToLive";
  -    private static final String TYPE          = "JMSType";
  +    public static final String CORRELATIONID = "JMSCorrelationID";
  +    public static final String DELIVERYMODE  = "JMSDeliveryMode";
  +    public static final String DESTINATION   = "JMSDestination";
  +    public static final String EXPIRATION    = "JMSExpiration";
  +    public static final String MESSAGEID     = "JMSMessageID";
  +    public static final String PRIORITY      = "JMSPriority";
  +    public static final String REDELIVERED   = "JMSRedelivered";
  +    public static final String REPLYTO       = "JMSReplyTo";
  +    public static final String TIMESTAMP     = "JMSTimestamp";
  +    public static final String TIMETOLIVE    = "JMSTimeToLive";
  +    public static final String TYPE          = "JMSType";
  +    public static final String QCF_USERID    = "JMSUserid";
  +    public static final String QCF_PASSWORD  = "JMSPassword";
     
       private static final ArrayList predefinedProps = 
           new ArrayList(Arrays.asList(new Object[]{
  
  
  
  1.3       +10 -0     
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSConstants.java
  
  Index: WSIFJMSConstants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSConstants.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFJMSConstants.java     7 Dec 2002 12:33:58 -0000       1.2
  +++ WSIFJMSConstants.java     27 Mar 2003 12:21:34 -0000      1.3
  @@ -83,4 +83,14 @@
                       ? ("' linked exception '" + ((JMSException) 
t).getLinkedException() + "'")
                       : "'"));
       }
  +
  +    // protocol for the soap:address location with JMS
  +    public static final String jmsURLProtcol = "jms:/";
  +
  +    // query start character in the soap:address location with JMS
  +    public static final char jmsURLQueryChar = '?';
  +
  +    // query property seperator in the soap:address location with JMS
  +    public static final String jmsURLQuerySeperator = "|";
  +
   }
  
  
  
  1.26      +28 -18    
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java
  
  Index: WSIFPort_ApacheAxis.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- WSIFPort_ApacheAxis.java  6 Mar 2003 11:28:11 -0000       1.25
  +++ WSIFPort_ApacheAxis.java  27 Mar 2003 12:21:35 -0000      1.26
  @@ -83,6 +83,7 @@
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
   import org.apache.wsif.util.WSIFProperties;
   import org.apache.wsif.util.WSIFUtils;
  +import org.apache.wsif.util.jms.WSIFJMSConstants;
   import org.apache.wsif.util.jms.WSIFJMSDestination;
   import org.apache.wsif.util.jms.WSIFJMSFinder;
   import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
  @@ -220,6 +221,31 @@
                                        + port);
                }
   
  +             if (soapAddress != null) {
  +                     String s = soapAddress.getLocationURI();
  +                     if (s == null || s.length() < 1) {
  +                             throw new WSIFException(
  +                                     "soap:address with location URI is required 
for " + port);
  +                     }
  +                     
  +                     if (s.startsWith(WSIFJMSConstants.jmsURLProtcol)) {
  +                             this.jmsAddress = 
WSIFJMSDestination.getJMSAddressFromURL(s);
  +                             this.soapAddress = null;
  +                     } else {
  +                         try {
  +                                 this.endPointURL = new URL(s);
  +                         } catch (MalformedURLException e) {
  +                                 Trc.exception(e);
  +                                 throw new WSIFException(
  +                                         "exception setting SOAP address to "
  +                                                 + s
  +                                                 + ": "
  +                                                 + e.getLocalizedMessage(),
  +                                         e);
  +                         }
  +                     }
  +             } 
  +             
                if (isTransportJMS() && jmsAddress == null) {
                        throw new WSIFException(
                                "binding transport "
  @@ -228,26 +254,10 @@
                                        + port);
                }
   
  -             if (soapAddress != null) {
  -                     String s = soapAddress.getLocationURI();
  -                     if (s == null || s.length() < 1) {
  -                             throw new WSIFException(
  -                                     "soap:address with location URI is required 
for " + port);
  -                     }
  -                     try {
  -                             this.endPointURL = new URL(s);
  -                     } catch (MalformedURLException e) {
  -                             Trc.exception(e);
  -                             throw new WSIFException(
  -                                     "exception setting SOAP address to "
  -                                             + s
  -                                             + ": "
  -                                             + e.getLocalizedMessage(),
  -                                     e);
  -                     }
  -             } else {
  +             if (jmsAddress != null) {
                        this.jmsAddressPropVals = jmsAddress.getJMSPropertyValues();
                }
  +
        }
   
        /**
  
  
  

Reply via email to