axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject svn commit: r547076 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/rpc/receivers/ adb/src/org/apache/axis2/rpc/receivers/ejb/ jaxws/test/org/apache/axis2/jaxws/provider/ kernel/src/org/apache/axis2/receivers/
Date Thu, 14 Jun 2007 01:42:30 GMT
Author: gdaniels
Date: Wed Jun 13 18:42:29 2007
New Revision: 547076

URL: http://svn.apache.org/viewvc?view=rev&rev=547076
Log:
Simplify, simplify. :)

Per hackathon discussions, refactor "asyncness" on the server side into AbstractMessageReceiver.
 Based on the value of the AbstractMessageReceiver.DO_ASYNC ("messageReceiver.invokeOnSeparateThread")
property, we'll either perform the MR logic (i.e. invokeBusinessLogic()) on the current thread
or spin up a worker thread.

Deprecate all async message receivers, but leave them there for now.  We should phase usage
of these things out during the 1.3 release cycle.

Also clean up some logic/code in a few places.

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutMessageReceiver.java
Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/ejb/EJBInOutAsyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractRobustInMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOnlyMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutAsyncMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutMessageReceiver.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -39,8 +39,6 @@
 import java.lang.reflect.Method;
 
 public class RPCMessageReceiver extends AbstractInOutSyncMessageReceiver {
-
-
     private static Log log = LogFactory.getLog(RPCMessageReceiver.class);
 
     /**

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/ejb/EJBInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/ejb/EJBInOutAsyncMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/ejb/EJBInOutAsyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/ejb/EJBInOutAsyncMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -3,6 +3,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.rpc.receivers.RPCInOutAsyncMessageReceiver;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -19,7 +20,16 @@
 * limitations under the License.
 */
 
-public class EJBInOutAsyncMessageReceiver extends RPCInOutAsyncMessageReceiver {
+/**
+ * An EJBInOutAsyncMessageReceiver
+ *
+ * @deprecated you can just use EJBMessageReceiver
+ */
+public class EJBInOutAsyncMessageReceiver extends RPCMessageReceiver {
+    public void receive(final MessageContext messageCtx) throws AxisFault {
+        messageCtx.setProperty(DO_ASYNC, Boolean.TRUE);
+        super.receive(messageCtx);
+    }
 
     protected Object makeNewServiceObject(MessageContext msgContext) throws AxisFault {
         return EJBUtil.makeNewServiceObject(msgContext);

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java
Wed Jun 13 18:42:29 2007
@@ -22,14 +22,13 @@
 import javax.xml.soap.SOAPFault;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
-import javax.xml.ws.ProtocolException;
 import javax.xml.ws.Service;
 import javax.xml.ws.soap.SOAPFaultException;
 
 public class StringProviderTests extends ProviderTestCase {
 
     String endpointUrl = "http://localhost:8080/axis2/services/StringProviderService";
-    String xmlString = "<invoke>test input</invoke>";
+    String xmlString = "<invoke>test input</invokeBusinessLogic>";
     private QName serviceName = new QName("http://ws.apache.org/axis2", "StringProviderService");
 
     protected void setUp() throws Exception {
@@ -64,7 +63,7 @@
         
         Dispatch<String> dispatch = getDispatch();
         
-        String request = "<invoke>hello world</invoke>";
+        String request = "<invoke>hello world</invokeBusinessLogic>";
         String response = dispatch.invoke(request);
         assertTrue(request.equals(response));
     }
@@ -159,7 +158,7 @@
         
         Dispatch<String> dispatch = getDispatch();
         
-        String request = "<invoke>throwWebServiceException</invoke>";
+        String request = "<invoke>throwWebServiceException</invokeBusinessLogic>";
         try {
             String response = dispatch.invoke(request);
             fail("Expected Exception");

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -21,19 +21,9 @@
 import org.apache.axis2.context.MessageContext;
 
 /**
- * This is takes care of the IN-OUT sync MEP in the server side
+ * This is takes care of the IN-ONLY MEP on the server side
+ *
+ * TODO: Deprecate this and use AMR directly?
  */
 public abstract class AbstractInMessageReceiver extends AbstractMessageReceiver {
-
-    public abstract void invokeBusinessLogic(MessageContext inMessage) throws AxisFault;
-
-    public final void receive(final MessageContext messageCtx) throws AxisFault {
-        ThreadContextDescriptor tc = setThreadContext(messageCtx);
-        try {
-            invokeBusinessLogic(messageCtx);
-            replicateState(messageCtx);
-        } finally {
-            restoreThreadContext(tc);
-        }
-    }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -20,6 +20,7 @@
 import org.apache.axis2.AxisFault;
 
 import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.util.MessageContextBuilder;
@@ -28,83 +29,12 @@
 
 /**
  * This is takes care of the IN-OUT sync MEP in the server side
+ *
+ * @deprecated no longer needed, going away after 1.3
  */
-public abstract class AbstractInOutAsyncMessageReceiver extends AbstractMessageReceiver {
-    private static final Log log = LogFactory.getLog(AbstractInOutAsyncMessageReceiver.class);
-
-    public abstract void invokeBusinessLogic(MessageContext inMessage,
-                                             MessageContext outMessage) throws AxisFault;
-
-    public final void receive(final MessageContext messageCtx) throws AxisFault {
-        final ServerCallback callback = new ServerCallback() {
-            public void handleResult(MessageContext result) throws AxisFault {
-                AxisEngine.send(result);
-                result.getTransportOut().getSender().cleanup(result);
-            }
-
-            public void handleFault(AxisFault fault) throws AxisFault {
-                MessageContext faultContext =
-                        MessageContextBuilder.createFaultMessageContext(messageCtx, fault);
-
-                AxisEngine.sendFault(faultContext);
-            }
-        };
-        
-			
-        AsyncMessageReceiverWorker theadedTask = new AsyncMessageReceiverWorker(messageCtx,callback);
-		messageCtx.getEnvelope().build();
-		
-		
-		/**
-		 * If this type of Message Reciecer is used without addressing, the condtions given in
Jira 
-		 * https://issues.apache.org/jira/browse/AXIS2-1363 would occuer(Both 202 accepted and
200 OK is written to the 
-		 * output stream). To avoid it if addressing is not present we do not spawn a new thread.
This will disapper when
-		 * async message recivers are removed later
-		 */
-		
-		if (messageCtx.getReplyTo() != null
-                && !AddressingConstants.Submission.WSA_ANONYMOUS_URL
-                        .equals(messageCtx.getReplyTo().getAddress())
-                && !AddressingConstants.Final.WSA_ANONYMOUS_URL
-                        .equals(messageCtx.getReplyTo().getAddress())) {
-            messageCtx.getConfigurationContext().getThreadPool().execute(
-                    theadedTask);
-        } else {
-            theadedTask.run();
-        }
+public abstract class AbstractInOutAsyncMessageReceiver extends AbstractInOutMessageReceiver
{
+    public void receive(final MessageContext messageCtx) throws AxisFault {
+        messageCtx.setProperty(DO_ASYNC, Boolean.TRUE);
+        super.receive(messageCtx);
     }
-    public class AsyncMessageReceiverWorker implements Runnable {
-        private MessageContext messageCtx;
-
-        private ServerCallback callback;
-
-        public AsyncMessageReceiverWorker(MessageContext messageCtx,
-                ServerCallback callback) {
-            this.messageCtx = messageCtx;
-            this.callback = callback;
-        }
-
-        public void run() {
-            try {
-                MessageContext newmsgCtx = MessageContextBuilder
-                        .createOutMessageContext(messageCtx);
-                newmsgCtx.getOperationContext().addMessageContext(newmsgCtx);
-                ThreadContextDescriptor tc = setThreadContext(messageCtx);
-                try {
-                    invokeBusinessLogic(messageCtx, newmsgCtx);
-                } finally {
-                    restoreThreadContext(tc);
-                }
-                callback.handleResult(newmsgCtx);
-            } catch (AxisFault e) {
-                try {
-                    callback.handleFault(e);
-                } catch (AxisFault axisFault) {
-                    log.error(e);
-                }
-                log.error(e);
-            }
-        }
-    };
-    
 }

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutMessageReceiver.java?view=auto&rev=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutMessageReceiver.java
(added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -0,0 +1,42 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package org.apache.axis2.receivers;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.MessageContextBuilder;
+
+/**
+ * This is the Absract IN-OUT MEP MessageReceiver. The
+ * protected abstract methods are only for the sake of breaking down the logic
+ */
+public abstract class AbstractInOutMessageReceiver extends AbstractMessageReceiver {
+    public abstract void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage)
+            throws AxisFault;
+
+    public final void invokeBusinessLogic(MessageContext msgContext) throws AxisFault {
+        MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(msgContext);
+        outMsgContext.getOperationContext().addMessageContext(outMsgContext);
+
+        invokeBusinessLogic(msgContext, outMsgContext);
+        replicateState(msgContext);
+
+        AxisEngine.send(outMsgContext);
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -25,22 +25,20 @@
 /**
  * This is the Absract IN-OUT MEP MessageReceiver. The
  * protected abstract methods are only for the sake of breaking down the logic
+ *
+ * @deprecated use AbstractInOutMessageReceiver
  */
 public abstract class AbstractInOutSyncMessageReceiver extends AbstractMessageReceiver {
     public abstract void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage)
             throws AxisFault;
 
-    public final void receive(MessageContext msgContext) throws AxisFault {
+    public final void invokeBusinessLogic(MessageContext msgContext) throws AxisFault {
         MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(msgContext);
         outMsgContext.getOperationContext().addMessageContext(outMsgContext);
 
-        ThreadContextDescriptor tc = setThreadContext(msgContext);
-        try {
-            invokeBusinessLogic(msgContext, outMsgContext);
-            replicateState(msgContext);
-        } finally {
-            restoreThreadContext(tc);
-        }
+        invokeBusinessLogic(msgContext, outMsgContext);
+        replicateState(msgContext);
+
         AxisEngine.send(outMsgContext);
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -23,27 +23,35 @@
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.clustering.context.Replicator;
 import org.apache.axis2.clustering.ClusteringFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.InOnlyAxisOperation;
 import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.util.Loader;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.axis2.classloader.MultiParentClassLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.lang.reflect.Method;
 import java.net.URL;
 
 public abstract class AbstractMessageReceiver implements MessageReceiver {
+    protected static final Log log = LogFactory.getLog(AbstractMessageReceiver.class);
+
     public static final String SCOPE = "scope";
     protected String serviceTCCL = null;
     public static final String SAVED_TCCL = "_SAVED_TCCL_";
     public static final String SAVED_MC = "_SAVED_MC_";
-
+    public static final String DO_ASYNC = "messageReceiver.invokeOnSeparateThread";
 
     // Place to store previous values
     public class ThreadContextDescriptor {
@@ -56,32 +64,68 @@
     }
 
     /**
+     * Do the actual work of the MessageReceiver.  Must be overridden by concrete subclasses.
+     *
+     * @param messageCtx active MessageContext
+     * @throws AxisFault if a problem occurred
+     */
+    protected abstract void invokeBusinessLogic(MessageContext messageCtx) throws AxisFault;
+
+    /**
+     *
+     * @param messageCtx active MessageContext
+     * @throws AxisFault if a problem occurred
+     */
+    public void receive(final MessageContext messageCtx) throws AxisFault {
+        if (messageCtx.isPropertyTrue(DO_ASYNC)) {
+            EndpointReference replyTo = messageCtx.getReplyTo();
+            if (replyTo != null && !replyTo.hasAnonymousAddress()) {
+                AsyncMessageReceiverWorker worker = new AsyncMessageReceiverWorker(messageCtx);
+                messageCtx.getEnvelope().build();
+                messageCtx.getConfigurationContext().getThreadPool().execute(worker);
+                return;
+            }
+        }
+
+        ThreadContextDescriptor tc = setThreadContext(messageCtx);
+        try {
+            invokeBusinessLogic(messageCtx);
+        } catch (AxisFault fault) {
+            // If we're in-only, eat this.  Otherwise, toss it upwards!
+            if (messageCtx.getAxisOperation() instanceof InOnlyAxisOperation) {
+                log.debug(fault);
+            } else {
+                throw fault;
+            }
+        } finally {
+            restoreThreadContext(tc);
+        }
+    }
+
+    /**
      * Several pieces of information need to be available to the service
      * implementation class.  For one, the ThreadContextClassLoader needs
      * to be correct, and for another we need to give the service code
      * access to the MessageContext (getCurrentContext()).  So we toss these
      * things in TLS.
      *
-     * @param msgContext
+     * @param msgContext the current MessageContext
+     * @return a ThreadContextDescriptor containing the old values
      */
-    protected ThreadContextDescriptor
-            setThreadContext(MessageContext msgContext) {
+    protected ThreadContextDescriptor setThreadContext(MessageContext msgContext) {
         ThreadContextDescriptor tc = new ThreadContextDescriptor();
         tc.oldMessageContext = (MessageContext) MessageContext.currentMessageContext.get();
         ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
         tc.oldClassLoader = contextClassLoader;
 
-        AxisService service =
-                msgContext.getAxisService();
-        String serviceTCCL = (String) service.getParameterValue(
-                Constants.SERVICE_TCCL);
+        AxisService service = msgContext.getAxisService();
+        String serviceTCCL = (String) service.getParameterValue(Constants.SERVICE_TCCL);
         if (serviceTCCL != null) {
             serviceTCCL = serviceTCCL.trim().toLowerCase();
 
-
             if (serviceTCCL.equals(Constants.TCCL_COMPOSITE)) {
                 Thread.currentThread().setContextClassLoader(
-                        new MultiParentClassLoader(new URL[]{}, new ClassLoader[]{
+                        new MultiParentClassLoader(new URL[] {}, new ClassLoader[] {
                                 msgContext.getAxisService().getClassLoader(),
                                 contextClassLoader,
                         }));
@@ -101,7 +145,8 @@
     }
 
     /**
-     * Method makeNewServiceObject.
+     * Create a new service object.  Override if you want to customize how
+     * this happens in your own MessageReceiver.
      *
      * @param msgContext
      * @return Returns Object.
@@ -109,8 +154,7 @@
      */
     protected Object makeNewServiceObject(MessageContext msgContext) throws AxisFault {
         try {
-            AxisService service =
-                    msgContext.getAxisService();
+            AxisService service = msgContext.getAxisService();
             ClassLoader classLoader = service.getClassLoader();
 
             // allow alternative definition of makeNewServiceObject
@@ -120,10 +164,9 @@
                 Class serviceObjectMaker = Loader.loadClass(classLoader, ((String)
                         serviceObjectParam.getValue()).trim());
 
-                // Find static getServiceObject() method, call it if there   
-                Method method = serviceObjectMaker.
-                        getMethod("getServiceObject",
-                                  new Class[]{AxisService.class});
+                // Find static getServiceObject() method, call it if there
+                Method method = serviceObjectMaker.getMethod("getServiceObject",
+                                                             new Class[]{AxisService.class});
                 if (method != null) {
                     return method.invoke(serviceObjectMaker.newInstance(), new Object[]{service});
                 }
@@ -157,11 +200,13 @@
     }
 
     /**
-     * Method getTheImplementationObject.
+     * Retrieve the implementation object.  This will either return a cached
+     * object if present in the ServiceContext, or create a new one via
+     * makeNewServiceObject() (and then cache that).
      *
-     * @param msgContext
-     * @return Returns Object.
-     * @throws AxisFault
+     * @param msgContext the active MessageContext
+     * @return the appropriate back-end service object.
+     * @throws AxisFault if there's a problem
      */
     protected Object getTheImplementationObject(MessageContext msgContext) throws AxisFault
{
         ServiceContext serviceContext = msgContext.getServiceContext();
@@ -177,6 +222,40 @@
                                                msgContext.getServiceContext());
             serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, serviceimpl);
             return serviceimpl;
+        }
+    }
+
+    public class AsyncMessageReceiverWorker implements Runnable {
+    	private MessageContext messageCtx;
+
+    	public AsyncMessageReceiverWorker(MessageContext messageCtx){
+    		this.messageCtx = messageCtx;
+    	}
+
+        public void run() {
+            try {
+                ThreadContextDescriptor tc = setThreadContext(messageCtx);
+                try {
+                    invokeBusinessLogic(messageCtx);
+                } finally {
+                    restoreThreadContext(tc);
+                }
+            } catch (AxisFault e) {
+                // If we're IN-ONLY, swallow this.  Otherwise, send it.
+                if (messageCtx.getAxisOperation() instanceof InOnlyAxisOperation) {
+                    log.debug(e);
+                } else {
+                    try {
+                        MessageContext faultContext =
+                                MessageContextBuilder.createFaultMessageContext(messageCtx,
e);
+
+                        AxisEngine.sendFault(faultContext);
+                    } catch (AxisFault axisFault) {
+                        log.error(e);
+                    }
+                    log.error(e);
+                }
+            }
         }
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractRobustInMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractRobustInMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractRobustInMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractRobustInMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -22,18 +22,8 @@
 
 /**
  * This is takes care of the IN-OUT sync MEP in the server side
+ *
+ * @deprecated not needed, since in-only MessageReceivers can throw faults
  */
 public abstract class AbstractRobustInMessageReceiver extends AbstractMessageReceiver {
-
-    public abstract void invokeBusinessLogic(MessageContext inMessage) throws AxisFault;
-
-    public final void receive(final MessageContext messageCtx) throws AxisFault {
-        ThreadContextDescriptor tc = setThreadContext(messageCtx);
-        try {
-            invokeBusinessLogic(messageCtx);
-            replicateState(messageCtx);
-        } finally {
-            restoreThreadContext(tc);
-        }
-    }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOnlyMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOnlyMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOnlyMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOnlyMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -41,31 +41,36 @@
         implements MessageReceiver {
 
     private Method findOperation(AxisOperation op, Class implClass) {
-        String methodName = op.getName().getLocalPart();
-        Method[] methods = implClass.getMethods();
+        Method method = (Method)(op.getParameterValue("myMethod"));
+        if (method != null) return method;
 
-        for (int i = 0; i < methods.length; i++) {
-            if (methods[i].getName().equals(methodName) &&
-                    methods[i].getParameterTypes().length == 1 &&
-                    OMElement.class.getName().equals(
-                            methods[i].getParameterTypes()[0].getName()) &&
-                    "void".equals(methods[i].getReturnType().getName())) {
-                return methods[i];
+        String methodName = op.getName().getLocalPart();
+        try {
+            // Looking for a method of the form "void method(OMElement)"
+            method = implClass.getMethod(methodName, new Class [] { OMElement.class });
+            if (method.getReturnType().equals(void.class)) {
+                try {
+                    op.addParameter("myMethod", method);
+                } catch (AxisFault axisFault) {
+                    // Do nothing here
+                }
+                return method;
             }
+        } catch (NoSuchMethodException e) {
+            // Fall through
         }
 
         return null;
     }
 
     /**
-     * Invokes the bussiness logic invocation on the service implementation class
+     * Invokes the business logic invocation on the service implementation class
      *
      * @param msgContext the incoming message context
      * @throws AxisFault on invalid method (wrong signature)
      */
     public void invokeBusinessLogic(MessageContext msgContext) throws AxisFault {
         try {
-
             // get the implementation class for the Web Service
             Object obj = getTheImplementationObject(msgContext);
 
@@ -75,12 +80,12 @@
             AxisOperation op = msgContext.getAxisOperation();
             Method method = findOperation(op, implClass);
 
-            if (method != null) {
-                method.invoke(
-                        obj, new Object[]{msgContext.getEnvelope().getBody().getFirstElement()});
-            } else {
+            if (method == null) {
                 throw new AxisFault(Messages.getMessage("methodDoesNotExistInOnly"));
             }
+
+            method.invoke(obj,
+                          new Object [] { msgContext.getEnvelope().getBody().getFirstElement()
});
 
         } catch (Exception e) {
             throw AxisFault.makeFault(e);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutAsyncMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutAsyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutAsyncMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -37,63 +37,11 @@
  *
  * @see RawXMLINOnlyMessageReceiver
  * @see RawXMLINOutMessageReceiver
+ * @deprecated use RawXMLINOutMessageReceiver and the DO_ASYNC property instead....
  */
-public class RawXMLINOutAsyncMessageReceiver extends AbstractInOutAsyncMessageReceiver {
-
-    private Method findOperation(AxisOperation op, Class implClass) {
-        String methodName = op.getName().getLocalPart();
-        Method[] methods = implClass.getMethods();
-
-        for (int i = 0; i < methods.length; i++) {
-            if (methods[i].getName().equals(methodName) &&
-                    methods[i].getParameterTypes().length == 1 &&
-                    OMElement.class.getName().equals(
-                            methods[i].getParameterTypes()[0].getName()) &&
-                    OMElement.class.getName().equals(methods[i].getReturnType().getName()))
{
-                return methods[i];
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Invokes the bussiness logic invocation on the service implementation class
-     *
-     * @param msgContext    the incoming message context
-     * @param newmsgContext the response message context
-     * @throws AxisFault on invalid method (wrong signature) or behaviour (return null)
-     */
-    public void invokeBusinessLogic(MessageContext msgContext, MessageContext newmsgContext)
-            throws AxisFault {
-        try {
-
-            // get the implementation class for the Web Service
-            Object obj = getTheImplementationObject(msgContext);
-
-            // find the WebService method
-            Class implClass = obj.getClass();
-
-            AxisOperation opDesc = msgContext.getAxisOperation();
-            Method method = findOperation(opDesc, implClass);
-
-            if (method != null) {
-                OMElement result = (OMElement) method.invoke(
-                        obj, new Object[]{msgContext.getEnvelope().getBody().getFirstElement()});
-                SOAPFactory fac = getSOAPFactory(msgContext);
-                SOAPEnvelope envelope = fac.getDefaultEnvelope();
-
-                if (result != null) {
-                    envelope.getBody().addChild(result);
-                }
-
-                newmsgContext.setEnvelope(envelope);
-
-            } else {
-                throw new AxisFault(Messages.getMessage("methodDoesNotExistInOut"));
-            }
-        } catch (Exception e) {
-            throw AxisFault.makeFault(e);
-        }
+public class RawXMLINOutAsyncMessageReceiver extends RawXMLINOutMessageReceiver {
+    public void receive(final MessageContext messageCtx) throws AxisFault {
+        messageCtx.setProperty(DO_ASYNC, Boolean.TRUE);
+        super.receive(messageCtx);
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutMessageReceiver.java?view=diff&rev=547076&r1=547075&r2=547076
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/RawXMLINOutMessageReceiver.java
Wed Jun 13 18:42:29 2007
@@ -47,23 +47,20 @@
         if (method != null) return method;
 
         String methodName = op.getName().getLocalPart();
-        Method[] methods = implClass.getMethods();
 
-        for (int i = 0; i < methods.length; i++) {
-            if (methods[i].getName().equals(methodName)) {
-                Class [] params = methods[i].getParameterTypes();
-                if (params.length == 1 &&
-                        OMElement.class.equals(params[0]) &&
-                        OMElement.class.equals(methods[i].getReturnType())) {
-                    method = methods[i];
-                    try {
-                        op.addParameter("myMethod", method);
-                    } catch (AxisFault axisFault) {
-                        // Do nothing here
-                    }
-                    return method;
+        try {
+            // Looking for a method of the form "OMElement method(OMElement)"
+            method = implClass.getMethod(methodName, new Class [] { OMElement.class });
+            if (method.getReturnType().equals(OMElement.class)) {
+                try {
+                    op.addParameter("myMethod", method);
+                } catch (AxisFault axisFault) {
+                    // Do nothing here
                 }
+                return method;
             }
+        } catch (NoSuchMethodException e) {
+            // Fault through
         }
 
         return null;
@@ -89,21 +86,21 @@
             AxisOperation opDesc = msgContext.getAxisOperation();
             Method method = findOperation(opDesc, implClass);
 
-            if (method != null) {
-                OMElement result = (OMElement) method.invoke(
-                        obj, new Object[]{msgContext.getEnvelope().getBody().getFirstElement()});
-                SOAPFactory fac = getSOAPFactory(msgContext);
-                SOAPEnvelope envelope = fac.getDefaultEnvelope();
-
-                if (result != null) {
-                    envelope.getBody().addChild(result);
-                }
+            if (method == null) {
+                throw new AxisFault(Messages.getMessage("methodDoesNotExistInOut",
+                                                        opDesc.getName().toString()));
+            }
 
-                newmsgContext.setEnvelope(envelope);
+            OMElement result = (OMElement) method.invoke(
+                    obj, new Object[]{msgContext.getEnvelope().getBody().getFirstElement()});
+            SOAPFactory fac = getSOAPFactory(msgContext);
+            SOAPEnvelope envelope = fac.getDefaultEnvelope();
 
-            } else {
-                throw new AxisFault(Messages.getMessage("methodDoesNotExistInOut"));
+            if (result != null) {
+                envelope.getBody().addChild(result);
             }
+
+            newmsgContext.setEnvelope(envelope);
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message