antelder 2003/01/13 12:40:21 Modified: java/src/org/apache/wsif WSIFPort.java WSIFOperation.java WSIFService.java java/src/org/apache/wsif/providers/java WSIFOperation_Java.java java/src/org/apache/wsif/base WSIFDefaultOperation.java WSIFDefaultPort.java WSIFServiceImpl.java java/src/org/apache/wsif/providers/ejb WSIFOperation_EJB.java java/src/org/apache/wsif/providers/soap/apachesoap WSIFOperation_ApacheSOAP.java java/src/org/apache/wsif/providers/jms WSIFOperation_Jms.java java/src/org/apache/wsif/providers/soap/soaprmi WSIFOperation_SoapRMI.java Log: Fix bugzilla bug 15780 - part 1 - enable context on WSIFService and WSIFPort Revision Changes Path 1.5 +13 -0 xml-axis-wsif/java/src/org/apache/wsif/WSIFPort.java Index: WSIFPort.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFPort.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WSIFPort.java 7 Dec 2002 12:33:43 -0000 1.4 +++ WSIFPort.java 13 Jan 2003 20:40:21 -0000 1.5 @@ -127,4 +127,17 @@ * <br><code>false</code> this port does not support asynchronous calls */ public boolean supportsAsync(); + + /** + * Gets the context information for this WSIFPort. + * @return context + */ + public WSIFMessage getContext() throws WSIFException ; + + /** + * Sets the context information for this WSIFPort. + * @param WSIFMessage the new context information + */ + public void setContext(WSIFMessage context); + } 1.5 +1 -1 xml-axis-wsif/java/src/org/apache/wsif/WSIFOperation.java Index: WSIFOperation.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFOperation.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WSIFOperation.java 7 Dec 2002 12:33:43 -0000 1.4 +++ WSIFOperation.java 13 Jan 2003 20:40:21 -0000 1.5 @@ -187,7 +187,7 @@ * Gets the context information for this binding. * @return context */ - public WSIFMessage getContext(); + public WSIFMessage getContext() throws WSIFException; /** * Create an input message that will be sent via this port. 1.5 +13 -0 xml-axis-wsif/java/src/org/apache/wsif/WSIFService.java Index: WSIFService.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WSIFService.java 7 Dec 2002 12:33:43 -0000 1.4 +++ WSIFService.java 13 Jan 2003 20:40:21 -0000 1.5 @@ -164,4 +164,17 @@ * @return The Definition object */ public Definition getDefinition(); + + /** + * Gets the context information for this WSIFService. + * @return context + */ + public WSIFMessage getContext() throws WSIFException ; + + /** + * Sets the context information for this WSIFService. + * @param WSIFMessage the new context information + */ + public void setContext(WSIFMessage context); + } 1.29 +7 -5 xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java Index: WSIFOperation_Java.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- WSIFOperation_Java.java 9 Dec 2002 16:51:19 -0000 1.28 +++ WSIFOperation_Java.java 13 Jan 2003 20:40:21 -0000 1.29 @@ -69,24 +69,20 @@ import java.util.Vector; import javax.wsdl.BindingFault; -import javax.wsdl.BindingInput; import javax.wsdl.BindingOperation; import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; import javax.wsdl.Fault; -import javax.wsdl.Message; import javax.wsdl.Operation; import javax.wsdl.OperationType; import javax.wsdl.Part; import javax.wsdl.Port; import javax.xml.namespace.QName; -import org.apache.wsif.WSIFConstants; 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.WSIFDefaultOperation; -import org.apache.wsif.base.WSIFServiceImpl; import org.apache.wsif.logging.MessageLogger; import org.apache.wsif.logging.Trc; import org.apache.wsif.providers.ProviderUtils; @@ -909,6 +905,12 @@ return fieldOutputMessageName; } + public WSIFPort getWSIFPort() { + Trc.entry(this); + Trc.exit(fieldPort); + return fieldPort; + } + public boolean executeRequestResponseOperation( WSIFMessage input, WSIFMessage output, 1.20 +21 -7 xml-axis-wsif/java/src/org/apache/wsif/base/WSIFDefaultOperation.java Index: WSIFDefaultOperation.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFDefaultOperation.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- WSIFDefaultOperation.java 7 Dec 2002 12:34:00 -0000 1.19 +++ WSIFDefaultOperation.java 13 Jan 2003 20:40:21 -0000 1.20 @@ -62,13 +62,14 @@ import java.util.List; import java.util.Map; -import javax.xml.namespace.QName; import javax.wsdl.Operation; +import javax.xml.namespace.QName; import org.apache.wsif.WSIFCorrelationId; import org.apache.wsif.WSIFException; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; +import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFResponseHandler; import org.apache.wsif.compiler.util.TypeMapping; import org.apache.wsif.logging.Trc; @@ -298,6 +299,8 @@ return outJmsProps; } + public abstract WSIFPort getWSIFPort(); + /** * This method adds new property values to existing HashMap. * Where a property value exists in the existing HashMap and the new list, @@ -428,6 +431,9 @@ */ public void setContext(WSIFMessage context) { Trc.entry(this, context); + if (context == null) { + throw new IllegalArgumentException("context must not be null"); + } this.context = context; Trc.exit(); } @@ -435,13 +441,21 @@ /** * Gets the context information for this binding. */ - public WSIFMessage getContext() { + public WSIFMessage getContext() throws WSIFException { Trc.entry(this); - if ( context == null ) { - context = new WSIFDefaultMessage(); - } - Trc.exit(context); - return context; + WSIFMessage contextCopy; + try { + if (this.context == null) { + contextCopy = (WSIFMessage) getWSIFPort().getContext().clone(); + } else { + contextCopy = (WSIFMessage) this.context.clone(); + } + } catch (CloneNotSupportedException e) { + throw new WSIFException( + "CloneNotSupportedException cloning context", e); + } + Trc.exit(contextCopy); + return contextCopy; } abstract protected Operation getOperation() throws Exception; 1.8 +40 -0 xml-axis-wsif/java/src/org/apache/wsif/base/WSIFDefaultPort.java Index: WSIFDefaultPort.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFDefaultPort.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WSIFDefaultPort.java 7 Dec 2002 12:34:00 -0000 1.7 +++ WSIFDefaultPort.java 13 Jan 2003 20:40:21 -0000 1.8 @@ -79,6 +79,8 @@ */ public abstract class WSIFDefaultPort implements WSIFPort { private static final long serialVersionUID = 1L; + + private WSIFMessage context; public void close() throws WSIFException { Trc.entry(this); @@ -178,4 +180,42 @@ Trc.exit(false); return false; } + + /** + * Gets the context information for this WSIFPort. + * @return context + */ + public WSIFMessage getContext() throws WSIFException { + Trc.entry(this); + WSIFMessage contextCopy; + if (this.context == null) { + // really this should call getContext on the WSIFService but + // theres no reference to that so WSIFService must call setContext + // on any WSIFPorts it creates. + contextCopy = new WSIFDefaultMessage(); + } else { + try { + contextCopy = (WSIFMessage) this.context.clone(); + } catch (CloneNotSupportedException e) { + throw new WSIFException( + "CloneNotSupportedException cloning context", e); + } + } + Trc.exit(contextCopy); + return contextCopy; + } + + /** + * Sets the context information for this WSIFPort. + * @param WSIFMessage the new context information + */ + public void setContext(WSIFMessage context) { + Trc.entry(this, context); + if (context == null) { + throw new IllegalArgumentException("context must not be null"); + } + this.context = context; + Trc.exit(null); + } + } 1.31 +42 -3 xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java Index: WSIFServiceImpl.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- WSIFServiceImpl.java 9 Dec 2002 16:51:19 -0000 1.30 +++ WSIFServiceImpl.java 13 Jan 2003 20:40:21 -0000 1.31 @@ -82,6 +82,7 @@ import org.apache.wsif.WSIFConstants; import org.apache.wsif.WSIFException; +import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFService; import org.apache.wsif.compiler.schema.tools.Schema2Java; @@ -121,6 +122,7 @@ private String preferredPort = null; private Map typeReg = null; private Port chosenPort = null; + private WSIFMessage context; /** * Create a WSIF service instance from WSDL document URL. @@ -396,12 +398,14 @@ (ExtensibilityElement) bindingExList.get(0); String bindingNS = bindingFirstEx.getElementType().getNamespaceURI(); WSIFProvider provider = WSIFPluggableProviders.getProvider(bindingNS); - if (provider != null) { - return provider.createDynamicWSIFPort(def, service, port, typeMap); - } else { + if (provider == null) { throw new WSIFException( "could not find suitable provider for binding namespace '" + bindingNS + "'"); } + WSIFPort wsifPort = + provider.createDynamicWSIFPort(def, service, port, typeMap); + wsifPort.setContext(getContext()); + return wsifPort; } public WSIFPort getPort() throws WSIFException { @@ -987,6 +991,40 @@ return def; } + /** + * Gets the context information for this WSIFService. + * @return context + */ + public WSIFMessage getContext() throws WSIFException { + Trc.entry(this); + WSIFMessage contextCopy; + if (this.context == null) { + contextCopy = new WSIFDefaultMessage(); + } else { + try { + contextCopy = (WSIFMessage) this.context.clone(); + } catch (CloneNotSupportedException e) { + throw new WSIFException( + "CloneNotSupportedException cloning context", e); + } + } + Trc.exit(contextCopy); + return contextCopy; + } + + /** + * Sets the context information for this WSIFService. + * @param WSIFMessage the new context information + */ + public void setContext(WSIFMessage context) { + Trc.entry(this, context); + if (context == null) { + throw new IllegalArgumentException("context must not be null"); + } + this.context = context; + Trc.exit(); + } + public String deep() { String buff = ""; try { @@ -1002,6 +1040,7 @@ buff += "\ntypeMapInitialised:" + typeMapInitialised; buff += "\npreferredPort:" + (preferredPort == null ? "null" : preferredPort); buff += "\nchosenPort:" + Trc.brief(chosenPort); + buff += "\ncontext:" + context; } catch (Exception e) { Trc.exceptionInTrace(e); } 1.27 +7 -1 xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java Index: WSIFOperation_EJB.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- WSIFOperation_EJB.java 10 Jan 2003 10:33:07 -0000 1.26 +++ WSIFOperation_EJB.java 13 Jan 2003 20:40:21 -0000 1.27 @@ -81,10 +81,10 @@ import javax.wsdl.Part; import javax.xml.namespace.QName; -import org.apache.wsif.WSIFConstants; 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.WSIFDefaultOperation; import org.apache.wsif.logging.MessageLogger; import org.apache.wsif.logging.Trc; @@ -939,6 +939,12 @@ return fieldOutputMessageName; } + public WSIFPort getWSIFPort() { + Trc.entry(this); + Trc.exit(fieldPort); + return fieldPort; + } + public boolean executeRequestResponseOperation( WSIFMessage input, WSIFMessage output, 1.36 +7 -0 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.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- WSIFOperation_ApacheSOAP.java 18 Dec 2002 10:49:09 -0000 1.35 +++ WSIFOperation_ApacheSOAP.java 13 Jan 2003 20:40:21 -0000 1.36 @@ -104,6 +104,7 @@ import org.apache.wsif.WSIFException; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; +import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFResponseHandler; import org.apache.wsif.base.WSIFDefaultMessage; import org.apache.wsif.base.WSIFDefaultOperation; @@ -1431,6 +1432,12 @@ wsdlOutParams = al; } + public WSIFPort getWSIFPort() { + Trc.entry(this); + Trc.exit(portInstance); + return portInstance; + } + /** * Tests if the currently executing request is an asynchronous request. * 1.39 +7 -0 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.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- WSIFOperation_Jms.java 18 Dec 2002 13:53:25 -0000 1.38 +++ WSIFOperation_Jms.java 13 Jan 2003 20:40:21 -0000 1.39 @@ -83,6 +83,7 @@ import org.apache.wsif.WSIFException; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFOperation; +import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFRequest; import org.apache.wsif.WSIFResponse; import org.apache.wsif.WSIFResponseHandler; @@ -1005,6 +1006,12 @@ return wsdlOutputParts; } + public WSIFPort getWSIFPort() { + Trc.entry(this); + Trc.exit(fieldJmsPort); + return fieldJmsPort; + } + public String deep() { String buff = ""; try { 1.7 +8 -0 xml-axis-wsif/java/src/org/apache/wsif/providers/soap/soaprmi/WSIFOperation_SoapRMI.java Index: WSIFOperation_SoapRMI.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/soaprmi/WSIFOperation_SoapRMI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WSIFOperation_SoapRMI.java 7 Dec 2002 12:33:50 -0000 1.6 +++ WSIFOperation_SoapRMI.java 13 Jan 2003 20:40:21 -0000 1.7 @@ -79,6 +79,7 @@ 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.WSIFDefaultOperation; import org.apache.wsif.logging.Trc; import org.apache.wsif.providers.WSIFDynamicTypeMap; @@ -508,4 +509,11 @@ public void setDynamicWSIFPort(WSIFPort_SoapRMI value) { portInstance = value; } + + public WSIFPort getWSIFPort() { + Trc.entry(this); + Trc.exit(portInstance); + return portInstance; + } + }