axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glyn Normington" <glyn_norming...@uk.ibm.com>
Subject Re: [PATCH] Make SimpleTargetedChain extend SimpleChain
Date Thu, 03 Jan 2002 15:20:34 GMT
Let me try to explain the rationale behind this, updated and improved,
patch in order to persuade Glen to commit it.

1. The most important reason for the patch is to allow more consistent use
of terminology. Without the patch TargetedChain is not strictly a Chain at
all (i.e. the TargetedChain interface doesn't extend the Chain interface),
so its name is rather misleading. Renaming TargetedChain to avoid referring
to Chain doesn't help as the concepts are so close. I believe that a
TargetedChain really is a special type of Chain with separately
identifiable requst, pivot, and response handlers. Similarly,
SimpleTargetedChain is really a special type of SimpleChain as its name
implies and the patch enshrines this in the code by making the former
extend the latter.

2. SimpleTargetedChain is initialised in stages which allows it to appear
in partially initialised states, e.g. with the request handler set but
without the response handler. This is changed to provide explicit
constructors which take the appropriate number of parameters and produce
valid SimpleTargetedChain instances. The error checking code in SOAPService
to cope with partially initialised states is then unnecessary.

3. There is quite a bit of duplicated logic between SimpleTargetedChain and
SimpleChain which can be deleted once the former is changed to extend the
latter. The result is easier to maintain. For example, if we rename undo or
modify its behaviour, we will not have to touch SimpleTargetedChain as it
will inherit its undo behaviour from SimpleChain.

4. There is also duplicated logic between SimpleTargetedChain and
SOAPService. In the patch, the additional logic has been separated out into
a Handler inside SOAPService which then allows the standard behaviour of
SimpleChain invoke (and undo) to be inherited.

I believe this is now a significant improvement and I would urge Glen to
consider committing it. Getting the architectural concepts explicitly
enshrined in the code is a great help towards understanding and will enable
a reasonably coherent architecture guide to be written (I hope to circulate
a partial draft in the next day or so).

Glyn

Index: xml-axis/java/samples/proxy/ProxyService.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/samples/proxy/ProxyService.java,v
retrieving revision 1.10
diff -u -r1.10 ProxyService.java
--- xml-axis/java/samples/proxy/ProxyService.java  3 Dec 2001 22:49:22 -0000     1.10
+++ xml-axis/java/samples/proxy/ProxyService.java  3 Jan 2002 15:07:33 -0000
@@ -94,9 +94,8 @@
             service.setEngine( msgContext.getAxisEngine().getClientEngine() );
             Call    call = (Call) service.createCall();

-            SimpleTargetedChain c = new SimpleTargetedChain();
-            c.setPivotHandler(new TCPSender());
-        service.getEngine().deployTransport("tcp", c);
+            SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
+            service.getEngine().deployTransport("tcp", c);

             // add TCP for proxy testing
             call.addTransportPackage("samples.transport");
Index: xml-axis/java/samples/transport/FileTest.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/samples/transport/FileTest.java,v
retrieving revision 1.20
diff -u -r1.20 FileTest.java
--- xml-axis/java/samples/transport/FileTest.java  26 Nov 2001 02:21:38 -0000    1.20
+++ xml-axis/java/samples/transport/FileTest.java  3 Jan 2002 15:07:33 -0000
@@ -37,8 +37,7 @@
         AxisEngine engine = service.getEngine();

         // Manually deploy file sender and file transport for this example
-        SimpleTargetedChain c = new SimpleTargetedChain();
-        c.setPivotHandler(new FileSender());
+        SimpleTargetedChain c = new SimpleTargetedChain(new FileSender());
         engine.deployTransport("FileTransport", c);

         call.setOperationName( "getQuote" );
Index: xml-axis/java/samples/transport/tcp/AdminClient.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/samples/transport/tcp/AdminClient.java,v
retrieving revision 1.11
diff -u -r1.11 AdminClient.java
--- xml-axis/java/samples/transport/tcp/AdminClient.java     15 Nov 2001 19:48:42 -0000  
 1.11
+++ xml-axis/java/samples/transport/tcp/AdminClient.java     3 Jan 2002 15:07:33 -0000
@@ -77,8 +77,7 @@
             org.apache.axis.client.AdminClient client =
                 new org.apache.axis.client.AdminClient(System.err);

-            SimpleTargetedChain c = new SimpleTargetedChain();
-            c.setPivotHandler(new TCPSender());
+            SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
             client.getCall().getService().getEngine().deployTransport("tcp", c);

             System.out.println(client.process(args));
Index: xml-axis/java/samples/transport/tcp/GetQuote.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/samples/transport/tcp/GetQuote.java,v
retrieving revision 1.13
diff -u -r1.13 GetQuote.java
--- xml-axis/java/samples/transport/tcp/GetQuote.java   15 Nov 2001 19:48:42 -0000    1.13
+++ xml-axis/java/samples/transport/tcp/GetQuote.java   3 Jan 2002 15:07:33 -0000
@@ -93,8 +93,7 @@
         Service service = new Service();
         Call call = (Call)service.createCall();

-        SimpleTargetedChain c = new SimpleTargetedChain();
-        c.setPivotHandler(new TCPSender());
+        SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
         service.getEngine().deployTransport("tcp", c);

         call.setTransport(new TCPTransport());
Index: xml-axis/java/samples/transport/tcp/TCPListener.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/samples/transport/tcp/TCPListener.java,v
retrieving revision 1.13
diff -u -r1.13 TCPListener.java
--- xml-axis/java/samples/transport/tcp/TCPListener.java     3 Dec 2001 22:49:22 -0000   
 1.13
+++ xml-axis/java/samples/transport/tcp/TCPListener.java     3 Jan 2002 15:07:34 -0000
@@ -155,8 +155,7 @@
                 engine = new AxisServer();
                 engine.init();

-                SimpleTargetedChain c = new SimpleTargetedChain();
-                c.setPivotHandler(new TCPSender());
+                SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());

                 try {
                     engine.deployTransport(transportName, c);
Index: xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java,v
retrieving revision 1.33
diff -u -r1.33 SimpleTargetedChain.java
--- xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java    7 Dec 2001 18:30:27 -0000
    1.33
+++ xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java    3 Jan 2002 15:07:34 -0000
@@ -67,8 +67,9 @@
 /**
  *
  * @author Doug Davis (dug@us.ibm.com)
+ * @author Glyn Normington (norm@uk.ibm.com)
  */
-public class SimpleTargetedChain extends BasicHandler implements TargetedChain
+public class SimpleTargetedChain extends SimpleChain implements TargetedChain
 {
    static Category category =
             Category.getInstance(SimpleTargetedChain.class.getName());
@@ -76,208 +77,81 @@
     protected Handler    requestHandler ;
     protected Handler    pivotHandler ;
     protected Handler    responseHandler ;
-
-    public void init() {
-        if ( requestHandler   != null )   requestHandler.init();
-        if ( pivotHandler != null ) pivotHandler.init();
-        if ( responseHandler  != null )  responseHandler.init();
-    }
-
-    public void cleanup() {
-        if ( requestHandler   != null )   requestHandler.cleanup();
-        if ( pivotHandler != null ) pivotHandler.cleanup();
-        if ( responseHandler  != null )  responseHandler.cleanup();
-    }
-
+
     /**
-     * Invoke the request chain, pivot handler and response chain.  If there's
-     * a fault we need to make sure that we undo any completed handler
-     * that has been successfully invoked and then rethrow the fault.
+     * Pivot indicator sets "past pivot point" before the response handler
+     * runs. This avoids having to reimplement SimpleChain.invoke and
+     * SimpleChain.generateWSDL.
      */
-    public void invoke(MessageContext msgContext) throws AxisFault {
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::invoke")
);
-        }
+    private class PivotIndicator extends BasicHandler {
+        public PivotIndicator() {}

-        if ( requestHandler != null ) requestHandler.invoke( msgContext );
-        try {
-            if ( pivotHandler != null ) pivotHandler.invoke( msgContext );
-        }
-        catch( Exception e ) {
-            category.error( "SimpleTargetedChain caught exception", e );
-            if ( requestHandler != null )
-                requestHandler.undo( msgContext );
-            throw AxisFault.makeFault(e);
-        }
-        msgContext.setPastPivot(true);
-        try {
-            if ( responseHandler != null )
-                responseHandler.invoke( msgContext );
-        }
-        catch( Exception e ) {
-            category.error( e );
-            if ( pivotHandler != null ) pivotHandler.undo( msgContext );
-            if ( requestHandler != null )
-                requestHandler.undo( msgContext );
-            throw AxisFault.makeFault(e);
-        }
-
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::invoke")
);
+        public void undo(MessageContext msgContext) {}
+
+        public void invoke(MessageContext msgContext) throws AxisFault {
+            msgContext.setPastPivot(true);
         }
     }

-    public void generateWSDL(MessageContext msgContext) throws AxisFault {
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::editWSDL")
);
-        }
+    /**
+     * Default no-arg constructor.
+     */
+    public SimpleTargetedChain() {}

-        if ( requestHandler != null ) requestHandler.generateWSDL( msgContext );
-        try {
-            if ( pivotHandler != null ) pivotHandler.generateWSDL( msgContext );
-        }
-        catch( Exception e ) {
-            category.error( e );
-            if ( requestHandler != null )
-                requestHandler.undo( msgContext );
-            throw AxisFault.makeFault(e);
-        }
-        msgContext.setPastPivot(true);
-        try {
-            if ( responseHandler != null )
-                responseHandler.generateWSDL( msgContext );
-        }
-        catch( Exception e ) {
-            category.error( e );
-            throw AxisFault.makeFault(e);
+    /**
+     * Constructor for an instance with effectively only a pivot handler.
+     */
+    public SimpleTargetedChain(Handler handler) {
+        pivotHandler = handler;
+        if (pivotHandler != null) {
+            addHandler(pivotHandler);
+            addHandler(new PivotIndicator());
         }
+   }

-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::editWSDL")
);
-        }
+    /**
+     * Constructor which takes real or null request, pivot, and response
+     * handlers.
+     */
+    public SimpleTargetedChain(Handler reqHandler, Handler pivHandler,
+                               Handler respHandler) {
+        init(reqHandler, null, pivHandler, null, respHandler);
     }

     /**
-     * Undo all of the work - in reverse order.
+     * Initialiser which takes real or null request, pivot, and response
+     * handlers and which allows for special request and response
+     * handlers to be inserted just before and after any pivot handler.
      */
-    public void undo(MessageContext msgContext) {
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::undo") );
-        }
-
-        if ( responseHandler   != null )   responseHandler.undo( msgContext );
-        if ( pivotHandler  != null )  pivotHandler.undo( msgContext );
-        if ( requestHandler    != null )    requestHandler.undo( msgContext );
+    protected void init(Handler reqHandler, Handler specialReqHandler,
+                        Handler pivHandler, Handler specialRespHandler,
+                        Handler respHandler) {
+
+        requestHandler = reqHandler;
+        if (requestHandler != null)
+            addHandler(requestHandler);

-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::undo") );
+        if (specialReqHandler != null)
+            addHandler(specialReqHandler);
+
+        pivotHandler = pivHandler;
+        if (pivotHandler != null) {
+            addHandler(pivotHandler);
+            addHandler(new PivotIndicator());
         }
-    }

-    public boolean canHandleBlock(QName qname) {
-        // TODO !!! : Need to look at this logic
-        return ((requestHandler==null) ? false :
-                  (requestHandler.canHandleBlock(qname) ||
-                   (pivotHandler==null)) ? false :
-                       (pivotHandler.canHandleBlock(qname) ||
-                        (responseHandler==null))  ? false :
-                            responseHandler.canHandleBlock(qname) );
+        if (specialRespHandler != null)
+            addHandler(specialRespHandler);
+
+        responseHandler = respHandler;
+        if (responseHandler != null)
+            addHandler(responseHandler);
     }

     public Handler getRequestHandler() { return( requestHandler ); }

-    public void setRequestHandler(Handler reqHandler)
-    {
-        requestHandler = reqHandler;
-    }
-
     public Handler getPivotHandler() { return( pivotHandler ); }

-    public void setPivotHandler(Handler handler) { pivotHandler = handler ; }
-
     public Handler getResponseHandler() { return( responseHandler ); }
-
-    public void setResponseHandler(Handler respHandler)
-    {
-        responseHandler = respHandler;
-    }
-
-    public void clear() {
-        requestHandler = null ;
-        pivotHandler = null ;
-        responseHandler = null ;
-    }
-
-    public Element getDeploymentData(Document doc) {
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::getDeploymentData")
);
-        }
-
-        Element   root = doc.createElementNS("", "chain");
-        fillInDeploymentData(root);
-
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::getDeploymentData")
);
-        }
-        return( root );
-    }
-
-    /**
-     * Used by subclasses (i.e. SOAPService) to fill in deployment
-     * data into an Element which might not be named "chain".
-     *
-     * @param root the Element to fill in with deployment data.
-     */
-    public void fillInDeploymentData(Element root)
-    {
-        Document doc = root.getOwnerDocument();
-        StringBuffer str  = new StringBuffer();
-        Handler      h ;
-
-        if ( requestHandler != null ) {
-            if (requestHandler instanceof Chain) {
-                Handler[]  handlers = ((Chain)requestHandler).getHandlers();
-                str = new StringBuffer();
-                for ( int i = 0 ; i < handlers.length ; i++ ) {
-                    h = (Handler) handlers[i];
-                    if ( i != 0 ) str.append(",");
-                    str.append( h.getName() );
-                }
-            } else {
-                str.append(requestHandler.getName());
-            }
-            root.setAttribute( "request", str.toString() );
-        }
-        if ( pivotHandler != null ) {
-            root.setAttribute( "pivot", pivotHandler.getName() );
-        }
-        if ( responseHandler != null ) {
-            if (responseHandler instanceof Chain) {
-                Handler[]  handlers = ((Chain)responseHandler).getHandlers();
-                str = new StringBuffer();
-                for ( int i = 0 ; i < handlers.length ; i++ ) {
-                    h = (Handler) handlers[i];
-                    if ( i != 0 ) str.append(",");
-                    str.append( h.getName() );
-                }
-            } else {
-                str.append(responseHandler.getName());
-            }
-            root.setAttribute( "response", str.toString() );
-        }
-
-        options = this.getOptions();
-        if ( options != null ) {
-            Enumeration e = options.keys();
-            while ( e.hasMoreElements() ) {
-                String k = (String) e.nextElement();
-                Object v = options.get(k);
-                Element e1 = doc.createElementNS("", "option");
-                e1.setAttribute( "name", k );
-                e1.setAttribute( "value", v.toString() );
-                root.appendChild( e1 );
-            }
-        }
-    }

 };
Index: xml-axis/java/src/org/apache/axis/TargetedChain.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/TargetedChain.java,v
retrieving revision 1.7
diff -u -r1.7 TargetedChain.java
--- xml-axis/java/src/org/apache/axis/TargetedChain.java     30 Oct 2001 16:46:34 -0000  
 1.7
+++ xml-axis/java/src/org/apache/axis/TargetedChain.java     3 Jan 2002 15:07:34 -0000
@@ -57,7 +57,7 @@
 /**
  * @author James Snell (jasnell@us.ibm.com)
  */
-public interface TargetedChain extends Handler {
+public interface TargetedChain extends Chain {

     /**
      * Returns the Request handler
@@ -65,33 +65,13 @@
     public Handler   getRequestHandler();

     /**
-     * Sets the Request Chain
-     */
-    public void    setRequestHandler(Handler reqHandler);
-
-    /**
      * Returns the Pivot Handler
      */
     public Handler getPivotHandler();

     /**
-     * Sets the Pivot Handler
-     */
-    public void    setPivotHandler(Handler handler);
-
-    /**
      * Returns the Response Handler
      */
     public Handler   getResponseHandler();
-
-    /**
-     * Sets the Response Handler
-     */
-    public void    setResponseHandler(Handler respHandler);
-
-    /**
-     * Clears the Handlers
-     */
-    public void    clear();
-
+
 }
Index: xml-axis/java/src/org/apache/axis/deployment/v2dd/V2DDDeployableItem.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/deployment/v2dd/V2DDDeployableItem.java,v
retrieving revision 1.15
diff -u -r1.15 V2DDDeployableItem.java
--- xml-axis/java/src/org/apache/axis/deployment/v2dd/V2DDDeployableItem.java    14 Nov 2001
17:26:18 -0000     1.15
+++ xml-axis/java/src/org/apache/axis/deployment/v2dd/V2DDDeployableItem.java    3 Jan 2002
15:07:34 -0000
@@ -55,7 +55,6 @@
 package org.apache.axis.deployment.v2dd;

 import org.apache.axis.Handler;
-import org.apache.axis.SimpleTargetedChain;
 import org.apache.axis.deployment.DeployableItem;
 import org.apache.axis.deployment.DeploymentRegistry;
 import org.apache.axis.deployment.DeploymentException;
@@ -99,8 +98,6 @@
         // definition to configure the instance

         try {
-            SimpleTargetedChain stc = new SimpleTargetedChain();
-
             V2DDProvider prov = service.getProvider();
             String[] methods = prov.getMethods();

Index: xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
retrieving revision 1.29
diff -u -r1.29 WSDDService.java
--- xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java      23 Dec 2001 12:33:31
-0000    1.29
+++ xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java      3 Jan 2002 15:07:34
-0000
@@ -205,34 +205,38 @@
             return cachedService;
         }

-        SOAPService   service  = new SOAPService();
-        if ( getQName() != null )
-            service.setName(getQName().getLocalPart());
-        service.setOptions(getParametersTable());
-
-        WSDDChain     request  = getRequestFlow();
-        WSDDChain      response = getResponseFlow();
+        Handler reqHandler = null;
+        WSDDChain request = getRequestFlow();

         if (request != null) {
-            service.setRequestHandler(request.getInstance(registry));
+            reqHandler = request.getInstance(registry);
         }

-        //service.setPivotHandler(getProvider().getInstance(registry));
+        Handler providerHandler = null;
+
         if (providerQName != null) {
-            Handler providerHandler = WSDDProvider.getInstance(providerQName,
-                                                               this,
-                                                               registry);
+            providerHandler = WSDDProvider.getInstance(providerQName,
+                                                       this,
+                                                       registry);
             if (providerHandler == null)
                 throw new WSDDException(
                         JavaUtils.getMessage("couldntConstructProvider00"));
-
-            service.setPivotHandler(providerHandler);
         }
-
+
+        Handler respHandler = null;
+        WSDDChain response = getResponseFlow();
+
         if (response != null) {
-            service.setResponseHandler(response.getInstance(registry));
+            respHandler = response.getInstance(registry);
         }

+        SOAPService service = new SOAPService(reqHandler, providerHandler,
+                                              respHandler);
+
+        if ( getQName() != null )
+            service.setName(getQName().getLocalPart());
+        service.setOptions(getParametersTable());
+
         if (tmr == null) {
             tmr = new TypeMappingRegistry();
         }
Index: xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java,v
retrieving revision 1.3
diff -u -r1.3 WSDDTargetedChain.java
--- xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java     14 Nov 2001
17:26:18 -0000     1.3
+++ xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java     3 Jan 2002
15:07:35 -0000
@@ -185,11 +185,10 @@
     public Handler makeNewInstance(DeploymentRegistry registry)
         throws Exception
     {
-        TargetedChain c = new org.apache.axis.SimpleTargetedChain();
-
+        Handler reqHandler = null;
         WSDDChain req = getRequestFlow();
         if (req != null)
-            c.setRequestHandler(req.getInstance(registry));
+            reqHandler = req.getInstance(registry);

         Handler pivot = null;
         if (pivotQName != null) {
@@ -199,14 +198,14 @@
                 pivot = registry.getHandler(pivotQName);
             }
         }
-
-        c.setPivotHandler(pivot);

+        Handler respHandler = null;
         WSDDChain resp = getResponseFlow();
         if (resp != null)
-            c.setResponseHandler(resp.getInstance(registry));
+            respHandler = resp.getInstance(registry);

-        return c;
+        return new org.apache.axis.SimpleTargetedChain(reqHandler, pivot,
+                                                       respHandler);
     }

     /**
Index: xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.38
diff -u -r1.38 SOAPService.java
--- xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java   23 Dec 2001 12:33:32
-0000    1.38
+++ xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java   3 Jan 2002 15:07:35
-0000
@@ -58,6 +58,7 @@
 import org.apache.axis.AxisFault;
 import org.apache.axis.Constants;
 import org.apache.axis.Handler;
+import org.apache.axis.handlers.BasicHandler;
 import org.apache.axis.Message;
 import org.apache.axis.MessageContext;
 import org.apache.axis.SimpleTargetedChain;
@@ -102,14 +103,93 @@
      */
     private TypeMappingRegistry typeMap;

+    /**
+     * SOAPRequestHandler is used to inject SOAP semantics just before
+     * the pivot handler.
+     */
+    private class SOAPRequestHandler extends BasicHandler {
+        public SOAPRequestHandler() {}
+
+        public void undo(MessageContext msgContext) {}
+
+        public void invoke(MessageContext msgContext) throws AxisFault {
+            // Do SOAP semantics here
+            if (category.isDebugEnabled()) {
+                category.debug( JavaUtils.getMessage("semanticCheck00"));
+            }
+
+            // 1. Check mustUnderstands
+            SOAPEnvelope env = msgContext.getRequestMessage().getSOAPEnvelope();
+            Vector headers = env.getHeaders();
+            Vector misunderstoodHeaders = null;
+            Enumeration enum = headers.elements();
+            while (enum.hasMoreElements()) {
+                SOAPHeader header = (SOAPHeader)enum.nextElement();
+                if (header.isMustUnderstand() && !header.isProcessed()) {
+                    if (misunderstoodHeaders == null)
+                        misunderstoodHeaders = new Vector();
+                    misunderstoodHeaders.addElement(header);
+                }
+            }
+
+            // !!! we should indicate SOAP1.2 compliance via the
+            // MessageContext, not a boolean here....
+            boolean doMisunderstoodHeaders = true;
+
+            if (misunderstoodHeaders != null) {
+                // !!! If SOAP 1.2, insert misunderstood fault header here
+                if (doMisunderstoodHeaders) {
+                    Message respMsg = msgContext.getResponseMessage();
+                    if (respMsg == null) {
+                        respMsg = new Message(new SOAPEnvelope());
+                        msgContext.setResponseMessage(respMsg);
+                    }
+                    env = respMsg.getSOAPEnvelope();
+                    enum = misunderstoodHeaders.elements();
+                    while (enum.hasMoreElements()) {
+                        SOAPHeader badHeader = (SOAPHeader)enum.nextElement();
+                        QName badQName = new QName(badHeader.getNamespaceURI(),
+                                                   badHeader.getName());
+                        SOAPHeader newHeader = new SOAPHeader(
+                                                              Constants.URI_SOAP12_FAULT_NS,
+                                                              Constants.ELEM_MISUNDERSTOOD);
+                        newHeader.addAttribute(null,
+                                               Constants.ATTR_QNAME,
+                                               badQName);
+
+                        env.addHeader(newHeader);
+                    }
+                }
+
+                throw new AxisFault(Constants.FAULT_MUSTUNDERSTAND,
+                                    JavaUtils.getMessage("noUnderstand00"),
+                                    null, null);
+            }
+        }
+    }
+
     /** Standard, no-arg constructor.
      */
     public SOAPService()
     {
+        initTypeMappingRegistry();
+    }
+
+    /** Constructor with real or null request, pivot, and response
+     *  handlers. A special request handler is specified to inject
+     *  SOAP semantics.
+     */
+    public SOAPService(Handler reqHandler, Handler pivHandler,
+                       Handler respHandler) {
+        init(reqHandler, new SOAPRequestHandler(), pivHandler, null, respHandler);
+        initTypeMappingRegistry();
+    }
+
+    private void initTypeMappingRegistry() {
         typeMap = new TypeMappingRegistry();
         typeMap.setParent(SOAPTypeMappingRegistry.getSingleton());
     }
-
+
     public TypeMappingRegistry getTypeMappingRegistry()
     {
         return typeMap;
@@ -125,8 +205,8 @@
      */
     public SOAPService(Handler serviceHandler)
     {
-        this();
-        setPivotHandler(serviceHandler);
+        init(null, new SOAPRequestHandler(), serviceHandler, null, null);
+        initTypeMappingRegistry();
     }

     /** Tell this service which engine it's deployed to.
@@ -165,154 +245,6 @@
         return true;
     }

-    public void invoke(MessageContext msgContext) throws AxisFault
-    {
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("enter00",
-                "SOAPService::invoke") );
-        }
-
-        if (!availableFromTransport(msgContext.getTransportName()))
-            throw new AxisFault("Server.NotAvailable",
-                JavaUtils.getMessage("noService02", msgContext.getTransportName()),
-                null, null);
-
-        msgContext.setPastPivot(false);
-
-        Handler h = getRequestHandler() ;
-        if ( h != null ) {
-            if (category.isDebugEnabled()) {
-                category.debug( JavaUtils.getMessage("invokeRequest00") );
-            }
-
-            h.invoke(msgContext);
-        } else {
-            if (category.isDebugEnabled()) {
-                category.debug( JavaUtils.getMessage("noRequest01") );
-            }
-        }
-
-        // Do SOAP semantics here
-        if (category.isDebugEnabled()) {
-            category.debug( JavaUtils.getMessage("semanticCheck00"));
-        }
-
-        // 1. Check mustUnderstands
-        SOAPEnvelope env = msgContext.getRequestMessage().getSOAPEnvelope();
-        Vector headers = env.getHeaders();
-        Vector misunderstoodHeaders = null;
-        Enumeration enum = headers.elements();
-        while (enum.hasMoreElements()) {
-            SOAPHeader header = (SOAPHeader)enum.nextElement();
-            if (header.isMustUnderstand() && !header.isProcessed()) {
-                if (misunderstoodHeaders == null)
-                    misunderstoodHeaders = new Vector();
-                misunderstoodHeaders.addElement(header);
-            }
-        }
-
-        // !!! we should indicate SOAP1.2 compliance via the
-        // MessageContext, not a boolean here....
-        boolean doMisunderstoodHeaders = true;
-
-        if (misunderstoodHeaders != null) {
-            // !!! If SOAP 1.2, insert misunderstood fault header here
-            if (doMisunderstoodHeaders) {
-                Message respMsg = msgContext.getResponseMessage();
-                if (respMsg == null) {
-                    respMsg = new Message(new SOAPEnvelope());
-                    msgContext.setResponseMessage(respMsg);
-                }
-                env = respMsg.getSOAPEnvelope();
-                enum = misunderstoodHeaders.elements();
-                while (enum.hasMoreElements()) {
-                    SOAPHeader badHeader = (SOAPHeader)enum.nextElement();
-                    QName badQName = new QName(badHeader.getNamespaceURI(),
-                                               badHeader.getName());
-                    SOAPHeader newHeader = new SOAPHeader(
-                                               Constants.URI_SOAP12_FAULT_NS,
-                                               Constants.ELEM_MISUNDERSTOOD);
-                    newHeader.addAttribute(null,
-                                           Constants.ATTR_QNAME,
-                                           badQName);
-
-                    env.addHeader(newHeader);
-                }
-            }
-
-            throw new AxisFault(Constants.FAULT_MUSTUNDERSTAND,
-                        JavaUtils.getMessage("noUnderstand00"),
-                        null, null);
-        }
-
-        h = getPivotHandler();
-        if ( h != null ) {
-            if (category.isDebugEnabled()) {
-                category.debug( JavaUtils.getMessage("invokeService00") );
-            }
-
-            h.invoke(msgContext);
-        } else {
-            if (category.isDebugEnabled()) {
-                category.debug( JavaUtils.getMessage("noService03") );
-            }
-        }
-
-        // OK, we're past the pivot, so let the MessageContext know.
-        msgContext.setPastPivot(true);
-
-        h = getResponseHandler();
-        if ( h != null ) {
-            if (category.isDebugEnabled()) {
-                category.debug( JavaUtils.getMessage("invokeResponse00") );
-            }
-
-            h.invoke(msgContext);
-        } else {
-            if (category.isDebugEnabled()) {
-                category.debug( JavaUtils.getMessage("noResponse00") );
-            }
-        }
-
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("exit00",
-                "SOAPService::invoke") );
-        }
-    }
-
-    public void undo(MessageContext msgContext)
-    {
-        if (category.isDebugEnabled()) {
-            category.debug(JavaUtils.getMessage("enter00",
-                "SOAPService::undo") );
-            category.debug(JavaUtils.getMessage("exit00",
-                "SOAPService::undo") );
-        }
-    }
-
-    public Element getDeploymentData(Document doc) {
-      if (category.isDebugEnabled()) {
-          category.debug(JavaUtils.getMessage("enter00",
-              "SOAPService::getDeploymentData") );
-      }
-
-      Element  root = doc.createElementNS("", "service");
-
-      fillInDeploymentData(root);
-
-      if (!getTypeMappingRegistry().isEmpty()) {
-        Element elem = doc.createElementNS("", "typeMappings");
-        getTypeMappingRegistry().dumpToElement(elem);
-        root.appendChild(elem);
-      }
-
-      if (category.isDebugEnabled()) {
-          category.debug(JavaUtils.getMessage("exit00",
-              "SOAPService::getDeploymentData") );
-      }
-      return( root );
-    }
-
     /*********************************************************************
      * Administration and management APIs
      *
Index: xml-axis/java/src/org/apache/axis/server/Transport.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/server/Transport.java,v
retrieving revision 1.9
diff -u -r1.9 Transport.java
--- xml-axis/java/src/org/apache/axis/server/Transport.java  8 Nov 2001 21:43:59 -0000   
 1.9
+++ xml-axis/java/src/org/apache/axis/server/Transport.java  3 Jan 2002 15:07:36 -0000
@@ -72,14 +72,4 @@
     static Category category =
             Category.getInstance(Transport.class.getName());

-    public Element getDeploymentData(Document doc) {
-        category.debug(JavaUtils.getMessage("enter00", "Transport::getDeploymentData"));
-
-        Element  root = doc.createElementNS("", "transport");
-
-        fillInDeploymentData(root);
-
-        category.debug(JavaUtils.getMessage("exit00", "Transport::getDeploymentData"));
-        return( root );
-    }
 }
Index: xml-axis/java/test/functional/TestTCPTransportSample.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/test/functional/TestTCPTransportSample.java,v
retrieving revision 1.16
diff -u -r1.16 TestTCPTransportSample.java
--- xml-axis/java/test/functional/TestTCPTransportSample.java     3 Dec 2001 23:23:03 -0000
    1.16
+++ xml-axis/java/test/functional/TestTCPTransportSample.java     3 Jan 2002 15:07:36 -0000
@@ -99,8 +99,7 @@
             Service  service = new Service();
             Call     call    = (Call) service.createCall();

-            SimpleTargetedChain c = new SimpleTargetedChain();
-            c.setPivotHandler(new TCPSender());
+            SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
             service.getEngine().deployTransport("tcp", c);

             call.setTargetEndpointAddress( new URL("tcp://localhost:8088") );
Index: xml-axis/java/test/session/TestSimpleSession.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/test/session/TestSimpleSession.java,v
retrieving revision 1.5
diff -u -r1.5 TestSimpleSession.java
--- xml-axis/java/test/session/TestSimpleSession.java   25 Nov 2001 19:11:59 -0000    1.5
+++ xml-axis/java/test/session/TestSimpleSession.java   3 Jan 2002 15:07:36 -0000
@@ -71,14 +71,15 @@
     public void testSessionService() throws Exception
     {
         // Set up the server side
-        SOAPService service = new SOAPService(new RPCProvider());
         SimpleSessionHandler sessionHandler = new SimpleSessionHandler();
         // Set a 3-second reap period, and a 3-second timeout
         sessionHandler.setReapPeriodicity(3000);
         sessionHandler.setDefaultSessionTimeout(3000);

-        service.setRequestHandler(sessionHandler);
-        service.setResponseHandler(sessionHandler);
+        SOAPService service = new SOAPService(sessionHandler,
+                                              new RPCProvider(),
+                                              sessionHandler);
+
         service.setOption("scope", "session");
         service.setOption("className", "test.session.TestSimpleSession");
         service.setOption("methodName", "counter");


Mime
View raw message