axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r169991 - in /webservices/axis/trunk/java/modules/core: src/org/apache/axis/engine/AxisEngine.java src/org/apache/axis/engine/Phase.java src/org/apache/axis/transport/AbstractTransportSender.java test/org/apache/axis/engine/EnginePausingTest.java
Date Fri, 13 May 2005 08:35:16 GMT
Author: hemapani
Date: Fri May 13 01:35:16 2005
New Revision: 169991

URL: http://svn.apache.org/viewcvs?rev=169991&view=rev
Log:
fix engine pausing test

Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/Phase.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/EnginePausingTest.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java?rev=169991&r1=169990&r2=169991&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java Fri
May 13 01:35:16 2005
@@ -95,7 +95,7 @@
             invokePhases(phases, context);
             
             OperationContext operationContext = context.getOperationContext();
-            phases = operationContext.getAxisOperation().getPhasesOutFlow();
+            phases = operationContext.getAxisOperation().getRemainingPhasesInFlow();
             invokePhases(phases, context);
             if (context.isServerSide()) {
                 // add invoke Phase
@@ -131,6 +131,21 @@
                     context.getTransportIn(),
                     context.getTransportOut(),
                     engineContext);
+            
+            if(context.getFaultTo() != null){
+                faultContext.setFaultTo(context.getFaultTo());
+            } else{
+                Object writer = context.getProperty(MessageContext.TRANSPORT_WRITER);
+                if(writer != null){
+                    faultContext.setProperty(MessageContext.TRANSPORT_WRITER,writer);
+                }else{
+                    //TODO Opps there are no place to send this, we will log and should we
throw the exception? 
+                    log.error("Error in fault flow", e);
+                    e.printStackTrace();
+                }
+            }       
+                    
+                    
             faultContext.setOperationContext(context.getOperationContext());
             faultContext.setProcessingFault(true);
             faultContext.setServerSide(true);

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/Phase.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/Phase.java?rev=169991&r1=169990&r2=169991&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/Phase.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/Phase.java Fri May
13 01:35:16 2005
@@ -15,40 +15,19 @@
 */
 package org.apache.axis.engine;
 
+import java.util.ArrayList;
+
 import org.apache.axis.context.MessageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-
 /**
  * <p>This is Phase, a orderd collection of Handlers.
  * seems this is Handler Chain with order.</p>
  * Should this exttends Hanlders?
  */
 public class Phase {
-    /**
-     * Field DISPATCH_PHASE
-     */
-    public static final String DISPATCH_PHASE = "DispatchPhase";
-
-    /**
-     * Field SERVICE_INVOCATION
-     */
-    public static final String SERVICE_INVOCATION = "ServiceInvocationPhase";
-
-    /**
-     * Field SENDING_PHASE
-     */
-    public static final String SENDING_PHASE = "SendPhase";
-
-    /**
-     * Field NAME
-     */
-    public static final QName NAME = new QName("http://axis.ws.apache.org",
-            "Phase");
-
+ 
     /**
      * Field phaseName
      */
@@ -107,7 +86,6 @@
      * @throws AxisFault
      */
     public void invoke(MessageContext msgctx) throws AxisFault {
-        // Stack executionStack = new Stack();
         try {
             while (indexOfHandlerToExecute < handlers.size() ) {
                 if(msgctx.isPaused()){
@@ -128,32 +106,9 @@
         } catch (Exception e) {
             log.info("Phase " + phaseName + " failed with the "
                     + e.getMessage());
-//            while (!executionStack.isEmpty()) {
-//                Handler handler = (Handler) executionStack.pop();
-//                log.info("revoke the Handler " + handler.getName()
-//                                + " with in the Phase " + phaseName);
-//                handler.revoke(msgctx);
-//            }
-            throw AxisFault.makeFault(e);
         }
     }
 
-//    /**
-//     * Method revoke
-//     *
-//     * @param msgctx
-//     */
-//    public void revoke(MessageContext msgctx) {
-//        for (int i = handlers.size() - 1; i > -1; i--) {
-//            Handler handler = (Handler) handlers.get(i);
-//            log.info("revoke the Handler " + handler.getName()
-//                            + " with in the Phase " + phaseName);
-//            if (handler != null) {
-//                handler.revoke(msgctx);
-//            }
-//        }
-//    }
-
     /**
      * @return Returns the name.
      */
@@ -161,24 +116,7 @@
         return phaseName;
     }
 
-    /**
-     * @param phaseName The name to set.
-     */
-    public void setName(String phaseName) {
-        this.phaseName = phaseName;
-    }
-//    public void postCondition(MessageContext msgCtx) throws AxisFault {
-//        
-//
-//    }
-//
-//    /* (non-Javadoc)
-//     * @see org.apache.axis.engine.Phase#preCondition(org.apache.axis.context.MessageContext)
-//     */
-//    public void preCondition(MessageContext msgCtx) throws AxisFault {
-//        // TODO Auto-generated method stub
-//
-//    }
+ 
     
 
     public int getHandlerCount(){

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java?rev=169991&r1=169990&r2=169991&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java
Fri May 13 01:35:16 2005
@@ -31,6 +31,9 @@
 import java.io.Writer;
 
 /**
+ * By the time this Class is invoked either the To EPR on the MessageContext should be set
or
+ * TRANSPORT_WRITER property set in the message Context with a Writer. This Class would write
the 
+ * SOAPMessage using either of the methods in the order To then Writer.
  */
 public abstract class AbstractTransportSender extends AbstractHandler implements TransportSender
{
     /**
@@ -58,58 +61,58 @@
      */
     public void invoke(MessageContext msgContext) throws AxisFault {
         Writer out = null;
-        
+
         EndpointReference epr = null;
-        
-        if (msgContext.isProcessingFault()) {
-            // Means we are processing fault
-            if (msgContext.getFaultTo() != null &&
-                !AddressingConstants.EPR_ANONYMOUS_URL.equals(msgContext.getFaultTo().getAddress()))
{
-                    epr = msgContext.getFaultTo();
-            } 
-        } else {
-            if (msgContext.getTo() != null && 
-                    !AddressingConstants.EPR_ANONYMOUS_URL.equals(msgContext.getTo().getAddress()))
{
-                        epr = msgContext.getTo();
-                } 
+
+        if (msgContext.getTo() != null
+            && !AddressingConstants.EPR_ANONYMOUS_URL.equals(msgContext.getTo().getAddress()))
{
+            epr = msgContext.getTo();
         }
-        
-        if(epr!= null){
-            out =  openTheConnection(epr);
-            startSendWithToAddress(msgContext,out);
-            writeMessage(msgContext,out);
-            finalizeSendWithToAddress(msgContext,out);
-        }else{
-            out = (Writer)msgContext.getProperty(MessageContext.TRANSPORT_WRITER);
-            if(out != null){
-                startSendWithOutputStreamFromIncomingConnection(msgContext,out);
-                writeMessage(msgContext,out);
-                finalizeSendWithOutputStreamFromIncomingConnection(msgContext,out);
-            } else{
+
+        if (epr != null) {
+            out = openTheConnection(epr);
+            startSendWithToAddress(msgContext, out);
+            writeMessage(msgContext, out);
+            finalizeSendWithToAddress(msgContext, out);
+        } else {
+            out = (Writer) msgContext.getProperty(MessageContext.TRANSPORT_WRITER);
+            if (out != null) {
+                startSendWithOutputStreamFromIncomingConnection(msgContext, out);
+                writeMessage(msgContext, out);
+                finalizeSendWithOutputStreamFromIncomingConnection(msgContext, out);
+            } else {
                 throw new AxisFault("Both the TO and Property MessageContext.TRANSPORT_WRITER
is Null, No where to send");
-            }       
+            }
         }
     }
 
-    public void writeMessage(MessageContext msgContext,Writer out) throws AxisFault{
+    public void writeMessage(MessageContext msgContext, Writer out) throws AxisFault {
         SOAPEnvelope envelope = msgContext.getEnvelope();
-         if (envelope != null) {
-             XMLStreamWriter outputWriter = null;
-             try {
-                 outputWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
-                 envelope.serialize(outputWriter);
-                 outputWriter.flush();
-             } catch (Exception e) {
-                 throw new AxisFault("Stream error", e);
-             }
-         }
+        if (envelope != null) {
+            XMLStreamWriter outputWriter = null;
+            try {
+                outputWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+                envelope.serialize(outputWriter);
+                outputWriter.flush();
+            } catch (Exception e) {
+                throw new AxisFault("Stream error", e);
+            }
+        }
     }
 
-    public abstract void startSendWithToAddress(MessageContext msgContext,Writer writer)throws
AxisFault;
-    public abstract void finalizeSendWithToAddress(MessageContext msgContext, Writer writer)throws
AxisFault;
-
-    public abstract void startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,Writer
writer)throws AxisFault;
-    public abstract void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext
msgContext,Writer writer)throws AxisFault;
+    public abstract void startSendWithToAddress(MessageContext msgContext, Writer writer)
+        throws AxisFault;
+    public abstract void finalizeSendWithToAddress(MessageContext msgContext, Writer writer)
+        throws AxisFault;
+
+    public abstract void startSendWithOutputStreamFromIncomingConnection(
+        MessageContext msgContext,
+        Writer writer)
+        throws AxisFault;
+    public abstract void finalizeSendWithOutputStreamFromIncomingConnection(
+        MessageContext msgContext,
+        Writer writer)
+        throws AxisFault;
 
-    protected abstract Writer openTheConnection(EndpointReference epr)throws AxisFault;
+    protected abstract Writer openTheConnection(EndpointReference epr) throws AxisFault;
 }

Modified: webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/EnginePausingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/EnginePausingTest.java?rev=169991&r1=169990&r2=169991&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/EnginePausingTest.java
(original)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/EnginePausingTest.java
Fri May 13 01:35:16 2005
@@ -16,21 +16,30 @@
 
 package org.apache.axis.engine;
 
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
 import junit.framework.TestCase;
+
 import org.apache.axis.addressing.AddressingConstants;
 import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.context.ConfigurationContext;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.context.ServiceContext;
-import org.apache.axis.description.*;
+import org.apache.axis.description.GlobalDescription;
+import org.apache.axis.description.OperationDescription;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.description.TransportInDescription;
+import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.handlers.AbstractHandler;
 import org.apache.axis.om.OMAbstractFactory;
 import org.apache.axis.soap.SOAPFactory;
 import org.apache.axis.transport.http.HTTPTransportSender;
 import org.apache.wsdl.WSDLService;
 
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
+
 
 public class EnginePausingTest extends TestCase {
 
@@ -45,7 +54,7 @@
 
     public EnginePausingTest(String arg0) throws AxisFault {
         super(arg0);
-
+        executedHandlers = new ArrayList();
         AxisConfiguration engineRegistry = new AxisSystemImpl(new GlobalDescription());
         engineContext = new ConfigurationContext(engineRegistry);
         transportOut = new TransportOutDescription(new QName("null"));
@@ -71,7 +80,7 @@
 
         mc.setTransportOut(transportOut);
         mc.setServerSide(true);
-        mc.setProperty(MessageContext.TRANSPORT_WRITER, System.out);
+        mc.setProperty(MessageContext.TRANSPORT_WRITER, new OutputStreamWriter(System.out));
         SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
         mc.setEnvelope(omFac.getDefaultEnvelope());
 
@@ -118,14 +127,15 @@
 
         //TODO
         axisOp.getRemainingPhasesInFlow().addAll(phases);
-        mc.setTo(
-            new EndpointReference(AddressingConstants.WSA_TO, "axis/services/NullService/DummyOp"));
+
         mc.setWSAAction(operationName.getLocalPart());
         System.out.flush();
 
     }
 
     public void testReceive() throws Exception {
+              mc.setTo(
+                    new EndpointReference(AddressingConstants.WSA_TO, "axis/services/NullService/DummyOp"));
         AxisEngine engine = new AxisEngine(engineContext);
         engine.receive(mc);
         assertEquals(executedHandlers.size(), 15);



Mime
View raw message