axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap WSIFOperation_ApacheSOAP.java SOAPJMSConnection.java
Date Tue, 15 Oct 2002 12:10:12 GMT
antelder    2002/10/15 05:10:12

  Modified:    java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFOperation_ApacheAxis.java WSIFJmsSender.java
                        WSIFJmsTransport.java
               java/src/org/apache/wsif/providers/soap/apachesoap
                        WSIFOperation_ApacheSOAP.java
                        SOAPJMSConnection.java
  Log:
  Enhance SOAP JMS operations to allow timouts to be specified for each operation request
  
  Revision  Changes    Path
  1.26      +65 -15    xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
  
  Index: WSIFOperation_ApacheAxis.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- WSIFOperation_ApacheAxis.java	15 Oct 2002 08:13:15 -0000	1.25
  +++ WSIFOperation_ApacheAxis.java	15 Oct 2002 12:10:12 -0000	1.26
  @@ -600,16 +600,21 @@
   		if (axistransport != null) {
   			call.setTransport(axistransport);
   			if (axistransport instanceof WSIFJmsTransport) {
  -				dest = ((WSIFJmsTransport) axistransport).getDestination();
  +				WSIFJmsTransport jmst = (WSIFJmsTransport) axistransport;
  +				dest = jmst.getDestination();
   				dest.setAsyncMode(isAsyncOperation());
  +				jmst.setSyncTimeout(null); // reset timeouts to defaults
  +				jmst.setAsyncTimeout(null);
   			}
   		}
   
   		if (names == null)
   			prepare(call);
   
  -		if (inJmsPropVals != null && !inJmsPropVals.isEmpty())
  +		if (inJmsPropVals != null && !inJmsPropVals.isEmpty()) {
  +			checkForTimeoutProperties(inJmsPropVals, dest);
   			dest.setProperties(inJmsPropVals);
  +		}
   
   		setDestinationContext(dest); // TODO WSDL props override context???
   
  @@ -638,10 +643,14 @@
   				}
   			}
   
  -			if (inJmsProps.containsKey(names[i]) && dest != null)
  -				dest.setProperty((String) (inJmsProps.get(names[i])), obj);
  -			else
  +			if (inJmsProps.containsKey(names[i]) && dest != null) {
  +				String name = (String) (inJmsProps.get(names[i]));
  +				if (!timeoutProperty(dest, name, obj)) {
  +					dest.setProperty(name, obj);
  +				}
  +			} else {
   				objects.add(obj);
  +			}
   		}
   
   		setCallContext(call);
  @@ -1014,19 +1023,22 @@
   		if (context == null || dest == null) {
   			return;
   		}
  -		String partName;
   		HashMap jmsProps = new HashMap();
   		for (Iterator i = context.getPartNames(); i.hasNext();) {
  -			partName = (String) i.next();
  -			if (partName.startsWith(WSIFConstants.CONTEXT_JMS_PREFIX)) {
  -				try {
  -					jmsProps.put(
  -						partName.substring(
  -							WSIFConstants.CONTEXT_JMS_PREFIX.length()),
  -						context.getObjectPart(partName));
  -				} catch (WSIFException ex) {
  -					Trc.ignoredException(ex);
  +			String partName = (String) i.next();
  +			try {
  +				Object value = context.getObjectPart(partName);
  +				if (!timeoutProperty(dest, partName, value)) {
  +					if (partName
  +						.startsWith(WSIFConstants.CONTEXT_JMS_PREFIX)) {
  +						String propertyName =
  +							partName.substring(
  +								WSIFConstants.CONTEXT_JMS_PREFIX.length());
  +						jmsProps.put(propertyName, value);
  +					}
   				}
  +			} catch (WSIFException ex) {
  +				Trc.ignoredException(ex);
   			}
   		}
   		if (jmsProps.size() > 0) {
  @@ -1100,6 +1112,44 @@
   		} else if (name.equals(WSIFConstants.CONTEXT_HTTP_PSWD)) {
   			call.setProperty(Call.PASSWORD_PROPERTY, value);
   		}
  +	}
  +
  +	private void checkForTimeoutProperties(
  +		HashMap inJmsPropVals,
  +		WSIFJMSDestination dest) {
  +		for (Iterator i = inJmsPropVals.keySet().iterator(); i.hasNext();) {
  +			String name = (String) i.next();
  +			Object value = inJmsPropVals.get(name);
  +			if (timeoutProperty(dest, name, value)) {
  +				i.remove();
  +			}
  +		}
  +	}
  +
  +	private boolean timeoutProperty(
  +		WSIFJMSDestination dest,
  +		String propertyName,
  +		Object value) {
  +		boolean isTimeoutProperty = false;
  +		try {
  +			if (WSIFConstants.WSIF_PROP_SYNC_TIMEOUT.equals(propertyName)) {
  +				isTimeoutProperty = true;
  +				Long syncTimeout = new Long(value.toString());
  +				WSIFJmsTransport transport = (WSIFJmsTransport) getTransport();
  +				transport.setSyncTimeout(syncTimeout);
  +				Trc.event(this, "overridding syncTimeout to " + syncTimeout);
  +			} else if (
  +				WSIFConstants.WSIF_PROP_ASYNC_TIMEOUT.equals(propertyName)) {
  +				isTimeoutProperty = true;
  +				Long asyncTimeout = new Long(value.toString());
  +				WSIFJmsTransport transport = (WSIFJmsTransport) getTransport();
  +				transport.setAsyncTimeout(asyncTimeout);
  +				Trc.event(this, "overridding asyncTimeout to " + asyncTimeout);
  +			}
  +		} catch (NumberFormatException ex) {
  +			Trc.ignoredException(ex);
  +		}
  +		return isTimeoutProperty;
   	}
   
   	/**
  
  
  
  1.7       +16 -2     xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsSender.java
  
  Index: WSIFJmsSender.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsSender.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WSIFJmsSender.java	7 Aug 2002 15:10:25 -0000	1.6
  +++ WSIFJmsSender.java	15 Oct 2002 12:10:12 -0000	1.7
  @@ -76,6 +76,7 @@
    * @author Mark Whitlock <whitlock@apache.org>
    */
   public class WSIFJmsSender extends BasicHandler {
  +    private static final long SYNC_TIMEOUT = WSIFProperties.getSyncTimeout();
       private static final long ASYNC_TIMEOUT = WSIFProperties.getAsyncTimeout();
       private static final String DUMMY_RESPONSE =
           "<?xml version='1.0' encoding='UTF-8'?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n<SOAP-ENV:Body>\n<ns1:addEntryResponse
xmlns:ns1=\"http://wsifservice.addressbook/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n</ns1:addEntryResponse>\n\n</SOAP-ENV:Body>\n</SOAP-ENV:Envelope>";
  @@ -89,6 +90,13 @@
               WSIFJMSDestination dest =
                   (WSIFJMSDestination) messageContext.getProperty(WSIFJmsTransport.DESTINATION);
   
  +            Long transportSyncTimeoutValue = 
  +                (Long)messageContext.getProperty(WSIFJmsTransport.SYNC_TIMEOUT);
  +            long syncTimeout = 
  +               transportSyncTimeoutValue==null
  +                  ? SYNC_TIMEOUT
  +                  : transportSyncTimeoutValue.longValue();
  +
               Message message = messageContext.getRequestMessage();
               String contents = message.getSOAPPartAsString();
   
  @@ -96,7 +104,7 @@
                   performAsyncSend(messageContext, dest, contents);
               } else {
                   String id = dest.send(contents, null);
  -                String response = dest.receiveString(id);
  +                String response = dest.receiveString(id, syncTimeout);
                   Message responseMessage = new Message(response);
                   messageContext.setResponseMessage(responseMessage);
               }
  @@ -139,13 +147,19 @@
              msgID = dest.send( data );
              cid = new WSIFJMSCorrelationId( msgID );
           } else {
  +            Long transportAsyncTimeoutValue = 
  +               (Long)messageContext.getProperty(WSIFJmsTransport.ASYNC_TIMEOUT);
  +            long asyncTimeout = 
  +               transportAsyncTimeoutValue==null
  +               ? ASYNC_TIMEOUT
  +               : transportAsyncTimeoutValue.longValue();
              WSIFCorrelationService correlator = 
                 WSIFCorrelationServiceLocator.getCorrelationService();
              synchronized( correlator ) {   
                 msgID = dest.send( data );
                 cid = new WSIFJMSCorrelationId( msgID );
                 if ( correlator != null ) {
  -                 correlator.put( cid, (Serializable)wsifOp, ASYNC_TIMEOUT );
  +                 correlator.put( cid, (Serializable)wsifOp, asyncTimeout );
                 }
              }
           }
  
  
  
  1.3       +37 -0     xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsTransport.java
  
  Index: WSIFJmsTransport.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsTransport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFJmsTransport.java	19 Jul 2002 15:46:31 -0000	1.2
  +++ WSIFJmsTransport.java	15 Oct 2002 12:10:12 -0000	1.3
  @@ -68,15 +68,20 @@
   
   /**
    * @author Mark Whitlock <whitlock@apache.org>
  + * @author Ant Elder <ant.elder@uk.ibm.com>
    */
   public class WSIFJmsTransport extends Transport {
       private WSIFJMSDestination destination = null;
       private String asyncOperation = "false";
       private WSIFOperation wsifOperation = null;
  +    private Long syncTimeout = null;
  +    private Long asyncTimeout = null;
   
       public static final String DESTINATION = "destination";
       public static final String ASYNCOPERATION = "asyncOperation";
       public static final String WSIFOPERATION = "wsifOperation";
  +    public static final String SYNC_TIMEOUT = "syncTimeout";
  +    public static final String ASYNC_TIMEOUT = "asyncTimeout";
   
       public void setDestination(WSIFJMSDestination destination) {
           Trc.entry(this, destination);
  @@ -96,6 +101,18 @@
           Trc.exit();
       }
   
  +    public void setSyncTimeout(Long syncTimeout) {
  +        Trc.entry(this, syncTimeout);
  +        this.syncTimeout = syncTimeout;
  +        Trc.exit();
  +    }
  +
  +    public void setAsyncTimeout(Long asyncTimeout) {
  +        Trc.entry(this, asyncTimeout);
  +        this.asyncTimeout = asyncTimeout;
  +        Trc.exit();
  +    }
  +
       public WSIFJMSDestination getDestination() {
           Trc.entry(this);
           Trc.exit(this.destination);
  @@ -114,6 +131,18 @@
           return this.wsifOperation;
       }
   
  +    public Long getSyncTimeout() {
  +        Trc.entry(this);
  +        Trc.exit(this.syncTimeout);
  +        return this.syncTimeout;
  +    }
  +
  +    public Long getAsyncTimeout() {
  +        Trc.entry(this);
  +        Trc.exit(this.asyncTimeout);
  +        return this.asyncTimeout;
  +    }
  +
       public void setupMessageContextImpl(
           MessageContext context,
           Call call,
  @@ -126,6 +155,10 @@
           context.setProperty(ASYNCOPERATION, new Boolean(asyncOperation));
           if (wsifOperation != null)
               context.setProperty(WSIFOPERATION, wsifOperation);
  +        if (syncTimeout != null)
  +            context.setProperty(SYNC_TIMEOUT, syncTimeout);
  +        if (asyncTimeout != null)
  +            context.setProperty(ASYNC_TIMEOUT, asyncTimeout);
           Trc.exit();
       }
   
  @@ -135,6 +168,8 @@
           t.setDestination(destination);
           t.setAsyncOperation(asyncOperation);
           t.setWsifOperation(wsifOperation);
  +        t.setSyncTimeout(syncTimeout);
  +        t.setAsyncTimeout(asyncTimeout);
           if (Trc.ON)
               Trc.exit(t.deep());
           return t;
  @@ -148,6 +183,8 @@
               buff += "destination:" + destination;
               buff += "asyncOperation:" + asyncOperation;
               buff += "wsifOperation:" + wsifOperation;
  +            buff += "syncTimeout:" + syncTimeout;
  +            buff += "asyncTimeout:" + asyncTimeout;
           } catch (Exception e) {
               Trc.exceptionInTrace(e);
           }
  
  
  
  1.29      +83 -19    xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java
  
  Index: WSIFOperation_ApacheSOAP.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- WSIFOperation_ApacheSOAP.java	20 Sep 2002 15:29:56 -0000	1.28
  +++ WSIFOperation_ApacheSOAP.java	15 Oct 2002 12:10:12 -0000	1.29
  @@ -110,6 +110,7 @@
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Trc;
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
  +import org.apache.wsif.util.WSIFProperties;
   import org.apache.wsif.util.WSIFUtils;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  @@ -580,14 +581,22 @@
           call.setEncodingStyleURI(getInputEncodingStyle());
   
           SOAPTransport st = getTransport();
  -        if (st != null)
  +        if (st != null) {
               call.setSOAPTransport(st);
  +            if (st instanceof SOAPJMSConnection) {
  +            	SOAPJMSConnection sjt = (SOAPJMSConnection) st;
  +            	sjt.setSyncTimeout(WSIFProperties.getSyncTimeout());
  +            	sjt.setAsyncTimeout(WSIFProperties.getAsyncTimeout());
  +            }
  +        }
   
           call.setTargetObjectURI(getInputNamespace());
           call.setMethodName(getName());
   
  -        if (inJmsPropVals != null && !inJmsPropVals.isEmpty())
  -             ((SOAPJMSConnection) st).setJmsProperties(inJmsPropVals);
  +		if (inJmsPropVals != null && !inJmsPropVals.isEmpty()) {
  +			checkForTimeoutProperties(st, inJmsPropVals);
  +            ((SOAPJMSConnection) st).setJmsProperties(inJmsPropVals);
  +		}
   
           setTransportContext(st); // TODO WSDL props override context???
   
  @@ -615,11 +624,14 @@
                           + types[i]);
               }
   
  -            if (inJmsProps.containsKey(names[i]))
  -                ((SOAPJMSConnection) st).setJmsProperty(
  -                    (String) (inJmsProps.get(names[i])),
  -                    value);
  -            else {
  +			if (inJmsProps.containsKey(names[i]) && st != null) {
  +				String name = (String) (inJmsProps.get(names[i]));
  +				if (!timeoutProperty(st, name, value)) {
  +                   ((SOAPJMSConnection) st).setJmsProperty(
  +				      name,
  +				      value);
  +				}
  +			} else {
                   Parameter param =
                       new Parameter(
                           names[i],
  @@ -747,8 +759,16 @@
   
           SOAPTransport st = getTransport();
   
  -        if (inJmsPropVals != null && !inJmsPropVals.isEmpty())
  -             ((SOAPJMSConnection) st).setJmsProperties(inJmsPropVals);
  +        if (st instanceof SOAPJMSConnection) {
  +           SOAPJMSConnection sjt = (SOAPJMSConnection) st;
  +           sjt.setSyncTimeout(WSIFProperties.getSyncTimeout());
  +           sjt.setAsyncTimeout(WSIFProperties.getAsyncTimeout());
  +        }
  +
  +        if (inJmsPropVals != null && !inJmsPropVals.isEmpty()) {
  + 		   checkForTimeoutProperties(st, inJmsPropVals);
  +           ((SOAPJMSConnection) st).setJmsProperties(inJmsPropVals);
  +        }
   
           //TODO docstyle headers
           //setCallContext( call );
  @@ -1435,20 +1455,22 @@
           if (context == null || !(t instanceof SOAPJMSConnection)) {
               return;
           }
  -        String partName;
           HashMap jmsProps = new HashMap();
           for (Iterator i = context.getPartNames(); i.hasNext();) {
  -            partName = (String) i.next();
  -            if (partName.startsWith(WSIFConstants.CONTEXT_JMS_PREFIX)) {
  -                try {
  +           try {
  +              String partName = (String) i.next();
  +      		  Object value = context.getObjectPart(partName);
  +	    	  if (!timeoutProperty(t, partName, value)) {
  +                 if (partName.startsWith(WSIFConstants.CONTEXT_JMS_PREFIX)) {
                       jmsProps.put(
                           partName.substring(
                               WSIFConstants.CONTEXT_JMS_PREFIX.length()),
  -                        context.getObjectPart(partName));
  -                } catch (WSIFException ex) {
  -                    Trc.ignoredException(ex);
  -                }
  -            }
  +                        value);
  +                 }
  + 	    	  }
  +           } catch (WSIFException ex) {
  +              Trc.ignoredException(ex);
  +           }
           }
           if (jmsProps.size() > 0) {
               ((SOAPJMSConnection) t).setJmsProperties(jmsProps);
  @@ -1585,6 +1607,48 @@
              }
           }
       }
  +
  +	private void checkForTimeoutProperties(SOAPTransport st, HashMap inJmsPropVals) {
  +       if (inJmsPropVals != null) {
  +		  for (Iterator i = inJmsPropVals.keySet().iterator(); i.hasNext();) {
  +		 	 String name = (String) i.next();
  +			 Object value = inJmsPropVals.get(name);
  +			 if (timeoutProperty(st, name, value)) {
  +				i.remove();
  +			 }
  +		  }
  +       }
  +	}
  +
  +	private boolean timeoutProperty(
  +        SOAPTransport t,
  +		String propertyName,
  +		Object value) {
  +		Trc.entry(this, t, propertyName, value);
  +		boolean isTimeoutProperty = false;
  +		if (t != null 
  +		&& t instanceof SOAPJMSConnection) {
  +		   SOAPJMSConnection st = (SOAPJMSConnection) t;
  +   		   try {
  +			  if (WSIFConstants.WSIF_PROP_SYNC_TIMEOUT.equals(propertyName)) {
  +			     isTimeoutProperty = true;
  +				 long syncTimeout = Long.parseLong(value.toString());
  +				 st.setSyncTimeout(syncTimeout);
  +				 Trc.event(this, "overridding syncTimeout to " + syncTimeout);
  +			  } else if (
  +			 	 WSIFConstants.WSIF_PROP_ASYNC_TIMEOUT.equals(propertyName)) {
  +				 isTimeoutProperty = true;
  +				 long asyncTimeout = Long.parseLong(value.toString());
  +				 st.setAsyncTimeout(asyncTimeout);
  +				 Trc.event(this, "overridding asyncTimeout to " + asyncTimeout);
  +			  }
  +		   } catch (NumberFormatException ex) {
  +			  Trc.ignoredException(ex);
  +		   }
  +		}
  +		Trc.exit(isTimeoutProperty);
  +		return isTimeoutProperty;
  +	}
   
       public String deep() {
           String buff = "";
  
  
  
  1.9       +28 -3     xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/SOAPJMSConnection.java
  
  Index: SOAPJMSConnection.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/SOAPJMSConnection.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SOAPJMSConnection.java	27 Aug 2002 10:24:07 -0000	1.8
  +++ SOAPJMSConnection.java	15 Oct 2002 12:10:12 -0000	1.9
  @@ -96,7 +96,8 @@
       // folowing are for async operation
       private boolean asyncOperation = false;
       private WSIFOperation_ApacheSOAP wsifOperation = null;
  -    private static final long ASYNC_TIMEOUT = WSIFProperties.getAsyncTimeout();
  +    private long syncTimeout;
  +    private long asyncTimeout;
   
       private static final String DUMMY_RESPONSE =
           "<?xml version='1.0' encoding='UTF-8'?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n<SOAP-ENV:Body>\n<ns1:addEntryResponse
xmlns:ns1=\"http://wsifservice.addressbook/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n</ns1:addEntryResponse>\n\n</SOAP-ENV:Body>\n</SOAP-ENV:Envelope>";
  @@ -123,6 +124,18 @@
           return responseSOAPContext;
       }
   
  +    public long getSyncTimeout() {
  +        Trc.entry(this);
  +        Trc.exit(new Long(syncTimeout));
  +        return syncTimeout;
  +    }
  +
  +    public long getAsyncTimeout() {
  +        Trc.entry(this);
  +        Trc.exit(new Long(asyncTimeout));
  +        return asyncTimeout;
  +    }
  +
       public BufferedReader receive() {
           Trc.entry(this);
           Trc.exit();
  @@ -151,7 +164,7 @@
                   StringWriter payloadSW = new StringWriter();
                   env.marshall(payloadSW, smr, ctx);
                   String id = destination.send(payloadSW.toString(), null);
  -                String response = destination.receiveString(id);
  +                String response = destination.receiveString(id, syncTimeout);
                   responseSOAPContext = new SOAPContext();
                   responseSOAPContext.setRootPart(response, "text/xml");
                   responseReader = new BufferedReader(new StringReader(response));
  @@ -204,7 +217,7 @@
                    correlator.put( 
                       cid,
                       (Serializable)getWsifOperation(),
  -                    ASYNC_TIMEOUT );
  +                    asyncTimeout );
                 }
              }
           }
  @@ -265,6 +278,18 @@
       void close() throws WSIFException {
           Trc.entry(this);
           destination.close();
  +        Trc.exit();
  +    }
  +
  +    public void setSyncTimeout(long timeout) {
  +        Trc.entry(this, new Long(timeout));
  +        syncTimeout = timeout;
  +        Trc.exit();
  +    }
  +
  +    public void setAsyncTimeout(long timeout) {
  +        Trc.entry(this, new Long(timeout));
  +        asyncTimeout = timeout;
           Trc.exit();
       }
   }
  
  
  

Mime
View raw message