You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wh...@apache.org on 2002/08/27 17:40:36 UTC
cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/jms WSIFPort_Jms.java WSIFOperation_Jms.java
whitlock 2002/08/27 08:40:36
Modified: java/src/org/apache/wsif/providers/jms WSIFPort_Jms.java
WSIFOperation_Jms.java
Log:
Improve performance by caching WSIFJmsDestination in WSIFPort_Jms
Revision Changes Path
1.9 +23 -4 xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFPort_Jms.java
Index: WSIFPort_Jms.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFPort_Jms.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WSIFPort_Jms.java 7 Aug 2002 15:10:25 -0000 1.8
+++ WSIFPort_Jms.java 27 Aug 2002 15:40:36 -0000 1.9
@@ -66,14 +66,16 @@
import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.extensions.ExtensibilityElement;
+
import org.apache.wsif.WSIFException;
-import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
-import org.apache.wsif.WSIFPort;
import org.apache.wsif.base.WSIFDefaultPort;
import org.apache.wsif.format.WSIFFormatter;
import org.apache.wsif.logging.Trc;
import org.apache.wsif.providers.WSIFDynamicTypeMap;
+import org.apache.wsif.util.WSIFProperties;
+import org.apache.wsif.util.jms.WSIFJMSDestination;
+import org.apache.wsif.util.jms.WSIFJMSFinder;
import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
/**
@@ -90,16 +92,28 @@
private JMSAddress fieldObjectReference = null; // 'physical connection'
protected Map operationInstances = new HashMap();
+ private WSIFJMSDestination jmsDest;
/**
* ctor
*/
- public WSIFPort_Jms(Definition def, Port port, WSIFDynamicTypeMap typeMap) {
+ public WSIFPort_Jms(
+ Definition def,
+ Port port,
+ WSIFDynamicTypeMap typeMap) throws WSIFException {
Trc.entry(this, def, port, typeMap);
fieldDefinition = def;
fieldPortModel = port;
+ jmsDest =
+ new WSIFJMSDestination(
+ WSIFJMSFinder.newFinder(
+ getObjectReference(),
+ fieldPortModel.getName()),
+ getObjectReference().getJmsProvDestName(),
+ WSIFProperties.getSyncTimeout());
+
if (Trc.ON)
Trc.exit(deep());
}
@@ -164,7 +178,12 @@
fieldPortModel.getBinding().getBindingOperation(name, inputName, outputName);
if (bindingOperationModel != null) {
- operation = new WSIFOperation_Jms(fieldPortModel, bindingOperationModel, this);
+ operation =
+ new WSIFOperation_Jms(
+ fieldPortModel,
+ bindingOperationModel,
+ this,
+ jmsDest);
setDynamicWSIFOperation(name, inputName, outputName, operation);
}
}
1.20 +48 -69 xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
Index: WSIFOperation_Jms.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WSIFOperation_Jms.java 27 Aug 2002 10:24:07 -0000 1.19
+++ WSIFOperation_Jms.java 27 Aug 2002 15:40:36 -0000 1.20
@@ -62,11 +62,14 @@
import java.util.Iterator;
import java.util.List;
+import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.Output;
+import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
@@ -87,7 +90,6 @@
import org.apache.wsif.util.WSIFProperties;
import org.apache.wsif.util.jms.WSIFJMSCorrelationId;
import org.apache.wsif.util.jms.WSIFJMSDestination;
-import org.apache.wsif.util.jms.WSIFJMSFinder;
import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
import org.apache.wsif.wsdl.extensions.jms.JMSBinding;
import org.apache.wsif.wsdl.extensions.jms.JMSConstants;
@@ -107,8 +109,8 @@
extends WSIFDefaultOperation
implements WSIFOperation {
- protected javax.wsdl.Port fieldBasePort;
- protected javax.wsdl.BindingOperation fieldBindingOperation;
+ protected Port fieldBasePort;
+ protected BindingOperation fieldBindingOperation;
protected WSIFPort_Jms fieldJmsPort;
protected Operation fieldOperation;
@@ -130,14 +132,16 @@
private boolean asyncOperation;
private JMSFormatter formatter;
private static final long ASYNC_TIMEOUT = WSIFProperties.getAsyncTimeout();
+ private WSIFJMSDestination jmsDest;
/**
* ctor
*/
public WSIFOperation_Jms(
- javax.wsdl.Port basePort,
+ Port basePort,
BindingOperation bindingOperation,
- WSIFPort_Jms jmsPort)
+ WSIFPort_Jms jmsPort,
+ WSIFJMSDestination jmsDest)
throws WSIFException {
Trc.entry(this, basePort, bindingOperation, jmsPort);
@@ -145,6 +149,7 @@
fieldBasePort = basePort;
fieldBindingOperation = bindingOperation;
fieldJmsPort = jmsPort;
+ this.jmsDest = jmsDest;
if (Trc.ON)
Trc.exit(deep());
@@ -157,7 +162,11 @@
public WSIFOperation_Jms copy() throws WSIFException {
Trc.entry(this);
WSIFOperation_Jms woj =
- new WSIFOperation_Jms(fieldBasePort, fieldBindingOperation, fieldJmsPort);
+ new WSIFOperation_Jms(
+ fieldBasePort,
+ fieldBindingOperation,
+ fieldJmsPort,
+ jmsDest);
if (Trc.ON)
Trc.exit(woj.deep());
return woj;
@@ -185,19 +194,12 @@
try {
getOperation();
- WSIFJMSDestination jmsDest =
- new WSIFJMSDestination(
- WSIFJMSFinder.newFinder(
- fieldJmsPort.getObjectReference(),
- fieldJmsPort.getPortModel().getName()),
- fieldJmsPort.getObjectReference().getJmsProvDestName(),
- WSIFProperties.getSyncTimeout());
// send the jms message
- String correlId = sendJmsMessage(input, jmsDest);
+ String correlId = sendJmsMessage(input);
javax.jms.Message response = jmsDest.receive(correlId);
- receiveJmsMessage(response, output, fault, jmsDest);
+ receiveJmsMessage(response, output, fault);
} catch (Exception ex) {
Trc.exception(ex);
@@ -280,27 +282,21 @@
getOperation();
this.handler = handler;
- WSIFJMSDestination jmsDest =
- new WSIFJMSDestination(
- WSIFJMSFinder.newFinder(
- fieldJmsPort.getObjectReference(),
- fieldJmsPort.getPortModel().getName()),
- fieldJmsPort.getObjectReference().getJmsProvDestName(),
- WSIFProperties.getSyncTimeout());
-
- if ( inputOnlyOp ) {
- sendJmsMessage(input, jmsDest);
+ if (inputOnlyOp) {
+ sendJmsMessage(input);
} else {
- if ( handler == null ) {
- correlId = new WSIFJMSCorrelationId( sendJmsMessage(input, jmsDest) );
- } else {
- WSIFCorrelationService cs = WSIFCorrelationServiceLocator.getCorrelationService();
- synchronized( cs ) {
- correlId = new WSIFJMSCorrelationId( sendJmsMessage(input, jmsDest) );
- //register it to the correlation service
- cs.put( correlId, this, ASYNC_TIMEOUT );
- }
- }
+ if (handler == null) {
+ correlId = new WSIFJMSCorrelationId(sendJmsMessage(input));
+ } else {
+ WSIFCorrelationService cs =
+ WSIFCorrelationServiceLocator.getCorrelationService();
+ synchronized (cs) {
+ correlId =
+ new WSIFJMSCorrelationId(sendJmsMessage(input));
+ //register it to the correlation service
+ cs.put(correlId, this, ASYNC_TIMEOUT);
+ }
+ }
}
} catch (Exception ex) {
Trc.exception(ex);
@@ -340,14 +336,7 @@
// set output message name
output.setName(fieldBindingOperation.getBindingOutput().getName());
- WSIFJMSDestination jmsDest =
- new WSIFJMSDestination(
- WSIFJMSFinder.newFinder(
- fieldJmsPort.getObjectReference(),
- fieldJmsPort.getPortModel().getName()),
- fieldJmsPort.getObjectReference().getJmsProvDestName(),
- WSIFProperties.getSyncTimeout());
- receiveJmsMessage(responseObject, output, fault, jmsDest);
+ receiveJmsMessage(responseObject, output, fault);
} catch (Exception ex) {
Trc.exception(ex);
@@ -381,17 +370,10 @@
// workflow does not need this yet! use processAsyncResponse
// **NS
- WSIFJMSDestination jmsDest =
- new WSIFJMSDestination(
- WSIFJMSFinder.newFinder(
- fieldJmsPort.getObjectReference(),
- fieldJmsPort.getPortModel().getName()),
- fieldJmsPort.getObjectReference().getJmsProvDestName(),
- WSIFProperties.getSyncTimeout());
WSIFMessage output = createOutputMessage();
WSIFMessage fault = createFaultMessage();
- receiveJmsMessage(response, output, fault, jmsDest);
+ receiveJmsMessage(response, output, fault);
handler.executeAsyncResponse(output, fault);
Trc.exit();
@@ -404,12 +386,12 @@
/**
* send jms message
*/
- private String sendJmsMessage(WSIFMessage input, WSIFJMSDestination jmsDest)
+ private String sendJmsMessage(WSIFMessage input)
throws WSIFException {
String correlId = null;
- setPropertyValues( jmsDest );
+ setPropertyValues();
/**
* set the parts onto the message
@@ -485,8 +467,7 @@
private void receiveJmsMessage(
Object responseObject,
WSIFMessage output,
- WSIFMessage fault,
- WSIFJMSDestination jmsDest)
+ WSIFMessage fault)
throws WSIFException {
if (!(responseObject instanceof javax.jms.Message))
@@ -543,7 +524,7 @@
return propertyParts;
}
- private void setPropertyValues(WSIFJMSDestination jmsDest) {
+ private void setPropertyValues() {
String value;
// First set the default properties identifying the JMS message
try {
@@ -557,7 +538,7 @@
}
try {
- javax.wsdl.BindingInput bi = fieldBindingOperation.getBindingInput();
+ BindingInput bi = fieldBindingOperation.getBindingInput();
value = (bi == null)? null : bi.getName();
if ( value != null && value.length() > 0 ) {
jmsDest.setProperty(
@@ -568,7 +549,7 @@
}
try {
- javax.wsdl.BindingOutput bo = fieldBindingOperation.getBindingOutput();
+ BindingOutput bo = fieldBindingOperation.getBindingOutput();
value = (bo == null)? null : bo.getName();
if ( value != null && value.length() > 0 ) {
jmsDest.setProperty(
@@ -582,19 +563,19 @@
try {
JMSAddress ja = fieldJmsPort.getObjectReference();
if (ja != null) {
- setJMSPropertyValues(ja.getJMSPropertyValues(), jmsDest);
+ setJMSPropertyValues(ja.getJMSPropertyValues());
}
} catch (WSIFException ex) {
Trc.exception(ex);
}
// properties from the context
- setDestinationContext( jmsDest );
+ setDestinationContext();
// propertyValues from the input message
if (fieldInputJmsPropertyValues != null) {
try {
- setJmsPropertyValues(fieldInputJmsPropertyValues, jmsDest);
+ setJmsPropertyValues(fieldInputJmsPropertyValues);
} catch (WSIFException ex) {
Trc.exception(ex);
}
@@ -604,9 +585,7 @@
/**
* sets the output message properties from the received JMS message.
*/
- private void setOutProperties(
- WSIFJMSDestination jmsDest,
- WSIFMessage output) {
+ private void setOutProperties(WSIFMessage output) {
String partName;
String propertyName;
@@ -630,7 +609,7 @@
/**
* set the specified jms property values
*/
- private void setJMSPropertyValues(List propertyValues, WSIFJMSDestination jmsDest) throws WSIFException {
+ private void setJMSPropertyValues(List propertyValues) throws WSIFException {
if ( propertyValues != null ) {
for (Iterator i = propertyValues.iterator(); i.hasNext(); ) {
JMSPropertyValue pv = (JMSPropertyValue)i.next();
@@ -642,7 +621,7 @@
/**
* set the specified jms header values
*/
- private void setJmsPropertyValues(HashMap attr, WSIFJMSDestination jmsDest)
+ private void setJmsPropertyValues(HashMap attr)
throws WSIFException {
//FIXME
// Need to separate out between header values and property values
@@ -829,8 +808,8 @@
/**
* This sets up any context JMS property values in the Destination
*/
- private void setDestinationContext(WSIFJMSDestination dest) {
- if (context == null || dest == null) {
+ private void setDestinationContext() {
+ if (context == null || jmsDest == null) {
return;
}
String partName;
@@ -849,7 +828,7 @@
}
}
if (jmsProps.size() > 0) {
- dest.setProperties(jmsProps);
+ jmsDest.setProperties(jmsProps);
}
}