axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/client Stub.java
Date Thu, 08 Jan 2004 13:57:24 GMT
dims        2004/01/08 05:57:24

  Modified:    java/src/org/apache/axis/transport/jms JMSConstants.java
                        JMSSender.java JMSURLHelper.java
               java/src/org/apache/axis/components/jms
                        JMSVendorAdapter.java
               java/src/org/apache/axis/client Stub.java
  Log:
  Patch from "Jim Stafford" <jim.stafford@raba.com>. see details below:
  
  * org.apache.axis.client.Stub.extractAttachements() - defended against
  NullPointerException when no response message present
  
  * org.apache.axis.components.JMSVendorAdapter - populate MessageContext
  with application-specific properties from the jmsurl, the
  MessageContext, and Call.
  
  * org.apache.axis.transport.jms.JMSConstants - added a few properties to
  identify application-specific property prefix in URL and Map of
  properties within the MessageContext properties.
  
  * org.apache.axis.transport.jms.JMSServer - expanded the role of
  createSendProperties() such that it grabs the application-specific
  properties as well as the JMS-defined.
  
  * org.apache.axis.transport.jms.JMSURLHelper.java - added ability to
  separately track/process application-specific properties as well as
  re-generate itself into a String again.
  
  Revision  Changes    Path
  1.5       +10 -0     ws-axis/java/src/org/apache/axis/transport/jms/JMSConstants.java
  
  Index: JMSConstants.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/jms/JMSConstants.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JMSConstants.java	30 Sep 2003 19:08:09 -0000	1.4
  +++ JMSConstants.java	8 Jan 2004 13:57:24 -0000	1.5
  @@ -102,6 +102,10 @@
       final static String _INTERACT_RETRY_INTERVAL      = "interactRetryInterval";
       final static String _TIMEOUT_TIME                 = "timeoutTime";
       final static String _MIN_TIMEOUT_TIME             = "minTimeoutTime";
  +    /** Defines a prefix added to each application-specific property in the 
  +     * JMS URL that should be added to the JMS Message when issued.
  +     */
  +    final static String _MSG_PROP_PREFIX              = "msgProp.";
   
       public static String JMS_PROPERTY_PREFIX = "transport.jms.";
   
  @@ -291,6 +295,12 @@
   
       // key used to store the JMS URL string in the message context
       final static String JMS_URL         = JMS_PROPERTY_PREFIX + "EndpointAddress";
  +    
  +    /** A property that carries a Map of application-specific properties to be
  +     * added to the JMS messages when issued. 
  +     */
  +    final static String JMS_APPLICATION_MSG_PROPS = 
  +        JMS_PROPERTY_PREFIX + "msgProps";
   
       final static String ADAPTER_POSTFIX = "VendorAdapter";
   }
  
  
  
  1.5       +19 -9     ws-axis/java/src/org/apache/axis/transport/jms/JMSSender.java
  
  Index: JMSSender.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/jms/JMSSender.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JMSSender.java	1 Oct 2003 10:46:08 -0000	1.4
  +++ JMSSender.java	8 Jan 2004 13:57:24 -0000	1.5
  @@ -63,6 +63,7 @@
   import javax.jms.Destination;
   import java.io.ByteArrayOutputStream;
   import java.util.HashMap;
  +import java.util.Map;
   
   /**
    * This is meant to be used on a SOAP Client to call a SOAP server.
  @@ -137,15 +138,12 @@
   
       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.containsProperty(JMSConstants.PRIORITY) &&
  -           !context.containsProperty(JMSConstants.DELIVERY_MODE) &&
  -           !context.containsProperty(JMSConstants.TIME_TO_LIVE))
  -        {
  -            return null;
  -        }
  -
  -        HashMap props = new HashMap();
           if(context.containsProperty(JMSConstants.PRIORITY))
               props.put(JMSConstants.PRIORITY,
               context.getProperty(JMSConstants.PRIORITY));
  @@ -158,5 +156,17 @@
           return props;
       }
   
  -
  +    /** Return a map of properties that makeup the application-specific
  +        for the JMS Messages.
  +     */
  +    protected HashMap createApplicationProperties(MessageContext context) {
  +        HashMap props = null;
  +        if (context.containsProperty(
  +            JMSConstants.JMS_APPLICATION_MSG_PROPS)) {
  +            props = new HashMap();
  +            props.putAll((Map)context.getProperty(
  +                JMSConstants.JMS_APPLICATION_MSG_PROPS));
  +        }
  +        return props;
  +    }
   }
  
  
  
  1.2       +71 -1     ws-axis/java/src/org/apache/axis/transport/jms/JMSURLHelper.java
  
  Index: JMSURLHelper.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/jms/JMSURLHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMSURLHelper.java	30 Sep 2003 19:14:56 -0000	1.1
  +++ JMSURLHelper.java	8 Jan 2004 13:57:24 -0000	1.2
  @@ -55,8 +55,11 @@
   
   package org.apache.axis.transport.jms;
   
  +import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.Map;
   import java.util.StringTokenizer;
   import java.util.Vector;
   
  @@ -75,10 +78,13 @@
   
       // vendor-specific properties
       private HashMap properties;
  -
  +    
       // required properties
       private Vector requiredProperties;
   
  +    //application-specific JMS message properties
  +    private Vector appProperties;
  +
       public JMSURLHelper(java.net.URL url) throws java.net.MalformedURLException {
           this(url, null);
       }
  @@ -86,6 +92,7 @@
       public JMSURLHelper(java.net.URL url, String[] requiredProperties) throws java.net.MalformedURLException
{
           this.url = url;
           properties = new HashMap();
  +        appProperties = new Vector();
   
           // the path should be something like '/SampleQ1'
           // clip the leading '/' if there is one
  @@ -106,6 +113,11 @@
               {
                   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());
  +                    addAppplicationProperty(key);
  +                }
                   properties.put(key, value);
               }
           }
  @@ -118,6 +130,10 @@
       public String getDestination() {
           return destination;
       }
  +    
  +    public void setDestination(String destination) {
  +        this.destination = destination;
  +    }
   
       public String getVendor() {
           return getPropertyValue(JMSConstants._VENDOR);
  @@ -158,6 +174,60 @@
   
       public Vector getRequiredProperties() {
           return requiredProperties;
  +    }
  +
  +    /** Adds the name of a property from the url properties that should
  +     * be added to the JMS message.
  +     */
  +    public void addAppplicationProperty(String property) {
  +        if (property == null)
  +            return;
  +
  +        if (appProperties == null)
  +            appProperties = new Vector();
  +
  +        appProperties.addElement(property);
  +    }
  +
  +    /** Returns a collection of properties that are defined within the
  +     * JMS URL to be added directly to the JMS messages.
  +        @return collection or null depending on presence of elements
  +     */
  +    public Vector getApplicationProperties() {
  +        return appProperties;
  +    }
  +    
  +    
  +    /**
  +        Returns a URL formatted String. The properties of the URL may not 
  +        end up in the same order as the JMS URL that was originally used to
  +        create this object.
  +    */
  +    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();
       }
   
       private void validateURL()
  
  
  
  1.6       +34 -0     ws-axis/java/src/org/apache/axis/components/jms/JMSVendorAdapter.java
  
  Index: JMSVendorAdapter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/jms/JMSVendorAdapter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JMSVendorAdapter.java	20 Nov 2003 06:44:29 -0000	1.5
  +++ JMSVendorAdapter.java	8 Jan 2004 13:57:24 -0000	1.6
  @@ -57,6 +57,7 @@
   
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.Map;
   
   import javax.jms.InvalidDestinationException;
   import javax.jms.JMSException;
  @@ -325,5 +326,38 @@
               else
                   context.removeProperty(JMSConstants.WAIT_FOR_RESPONSE);
           }
  +        setupApplicationProperties(context, call, jmsurl);
  +    }
  +    
  +    public void setupApplicationProperties(MessageContext context,
  +                                    Call call,
  +                                    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);
  +        }
  +        
  +        //finally add the properties from the call
  +        Map callProps = 
  +            (Map)call.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS);
  +        if (callProps != null) {
  +            appProps.putAll(callProps);
  +        }
  +        
  +        //now tore these properties within the context
  +        context.setProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS,appProps);
       }
   }
  
  
  
  1.32      +2 -1      ws-axis/java/src/org/apache/axis/client/Stub.java
  
  Index: Stub.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/client/Stub.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Stub.java	7 Aug 2003 21:38:22 -0000	1.31
  +++ Stub.java	8 Jan 2004 13:57:24 -0000	1.32
  @@ -328,7 +328,8 @@
        */ 
       public void extractAttachments(Call call) {
           attachments.clear();
  -        if(call.getResponseMessage().countAttachments()>0) {
  +        if(call.getResponseMessage() != null &&
  +           call.getResponseMessage().countAttachments()>0) {
               Iterator iterator = call.getResponseMessage().getAttachments();
               while(iterator.hasNext()){
                   attachments.add(iterator.next());
  
  
  

Mime
View raw message