axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r501978 [12/24] - in /webservices/axis2/branches/java/maven2: ./ etc/ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/ modules/adb-codegen/src/org/apache/axis2/schema/template/ modules/adb-codegen/src/org/apache/axis2/s...
Date Wed, 31 Jan 2007 20:35:35 GMT
Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/client/ServiceClient.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/client/ServiceClient.java Wed Jan 31 12:35:21 2007
@@ -20,17 +20,13 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.*;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.async.AsyncResult;
 import org.apache.axis2.client.async.Callback;
 import org.apache.axis2.context.*;
 import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.ListenerManager;
-import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.util.CallbackReceiver;
 import org.apache.axis2.wsdl.WSDLConstants;
 
 import javax.wsdl.Definition;
@@ -292,12 +288,14 @@
      * @throws AxisFault if something goes wrong
      */
     public void engageModule(QName moduleName) throws AxisFault {
-        AxisModule module = axisConfig.getModule(moduleName);
-        if (module != null) {
-            axisService.engageModule(module, axisConfig);
-        } else {
-            throw new AxisFault("Unable to engage module : " +
-                    moduleName.getLocalPart());
+        synchronized (this) {
+            AxisModule module = axisConfig.getModule(moduleName);
+            if (module != null) {
+                axisService.engageModule(module, axisConfig);
+            } else {
+                throw new AxisFault("Unable to engage module : " +
+                        moduleName.getLocalPart());
+            }
         }
     }
 
@@ -394,65 +392,11 @@
      * @see #createClient(QName)
      */
     public void sendRobust(QName operation, OMElement elem) throws AxisFault {
-        if (options.isUseSeparateListener()) {
-
-            // This mean doing a Fault may come through a different channel .
-            // If the
-            // transport is two way transport (e.g. http) Only one channel is
-            // used (e.g. in http cases
-            // 202 OK is sent to say no response available). Axis2 get blocked
-            // return when the response is available.
-            SyncCallBack callback = new SyncCallBack();
-
-            // this method call two channel non blocking method to do the work
-            // and wait on the callback
-            sendReceiveNonBlocking(operation, elem, callback);
-
-            long timeout = options.getTimeOutInMilliSeconds();
-            long waitTime = timeout;
-            long startTime = System.currentTimeMillis();
-
-            synchronized (callback) {
-                while (! callback.isComplete() && waitTime >= 0) {
-                    try {
-                        callback.wait(timeout);
-                    } catch (InterruptedException e) {
-                        // We were interrupted for some reason, keep waiting
-                        // or throw new AxisFault( "Callback was interrupted by someone?" );
-                    }
-                    // The wait finished, compute remaining time
-                    // - wait can end prematurely, see Object.wait( int timeout )
-                    waitTime = timeout - (System.currentTimeMillis() - startTime);
-                }
-
-            }
-            SOAPEnvelope envelope = callback.envelope;
-            // process the result of the invocation
-            if (envelope != null) {
-                // building soap envelope
-                envelope.build();
-                // closing transport
-                if (envelope.getBody().hasFault()) {
-                    SOAPFault soapFault = envelope.getBody().getFault();
-                    throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
-                            soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
-                }
-            } else {
-                if (callback.error instanceof AxisFault) {
-                    throw (AxisFault) callback.error;
-                } else if (callback.error != null) {
-                    throw new AxisFault(callback.error);
-                } else if (! callback.isComplete()) {
-                    //no exception has occurred
-                }
-            }
-        } else {
-            MessageContext mc = new MessageContext();
-            fillSOAPEnvelope(mc, elem);
-            OperationClient mepClient = createClient(operation);
-            mepClient.addMessageContext(mc);
-            mepClient.execute(true);
-        }
+        MessageContext mc = new MessageContext();
+        fillSOAPEnvelope(mc, elem);
+        OperationClient mepClient = createClient(operation);
+        mepClient.addMessageContext(mc);
+        mepClient.execute(true);
     }
 
     /**
@@ -522,76 +466,14 @@
      */
     public OMElement sendReceive(QName operationQName, OMElement xmlPayload)
             throws AxisFault {
-        /**
-         * If a module has set the USE_ASYNC_OPERATIONS option then we override the behaviour
-         * for sync calls. However we leave real async calls alone.
-         */
-        boolean useAsync = false;
-        if(!options.isUseSeparateListener()) {
-        	Boolean useAsyncOption = (Boolean) configContext.getProperty(Constants.Configuration.USE_ASYNC_OPERATIONS);
-        	if(useAsyncOption != null) useAsync = useAsyncOption.booleanValue();
-        }
-
-        if (useAsync || options.isUseSeparateListener()) {
-
-            // Here we are trying to do a request-response invocation using two different channels for the request
-            // and the response.
-            // For example, if the IN and OUT transports are HTTP, then two different HTTP channels will be used. The first
-            // channel will be used to send the request, which the server respond sending HTTP 200, if accepted and uses
-            // a completely different channel to send the response. This flag, informs the Axis2 client engine to
-            // keep listeners ready to receive the response.
-
-            // even if the client is blocking we use a Callback, internally, to relate the response back to the client.
-            SyncCallBack callback = new SyncCallBack();
-
-            // this method call two channel non blocking method to do the work
-            // and wait on the callback
-            sendReceiveNonBlocking(operationQName, xmlPayload, callback);
-
-            long timeout = options.getTimeOutInMilliSeconds();
-            long waitTime = timeout;
-            long startTime = System.currentTimeMillis();
-
-            synchronized (callback) {
-                while (! callback.isComplete() && waitTime >= 0) {
-                    try {
-                        callback.wait(timeout);
-                    } catch (InterruptedException e) {
-                        // We were interrupted for some reason, keep waiting
-                        // or throw new AxisFault( "Callback was interrupted by someone?" );
-                    }
-                    // The wait finished, compute remaining time
-                    // - wait can end prematurely, see Object.wait( int timeout )
-                    waitTime = timeout - (System.currentTimeMillis() - startTime);
-                }
-
-            }
-            // process the result of the invocation
-            if (callback.envelope != null) {
-                // transport was already returned by the call back receiver
-                //Building of the Envelope should happen at the setComplete()
-                // or onComplete() methods of the Callback class
-                return callback.envelope.getBody().getFirstElement();
-            } else {
-                if (callback.error instanceof AxisFault) {
-                    throw (AxisFault) callback.error;
-                } else if (callback.error != null) {
-                    throw new AxisFault(callback.error);
-                } else if (! callback.isComplete()) {
-                    throw new AxisFault(Messages.getMessage("responseTimeOut"));
-                } else
-                    throw new AxisFault(Messages.getMessage("callBackCompletedWithError"));
-            }
-        } else {
-            MessageContext messageContext = new MessageContext();
-            fillSOAPEnvelope(messageContext, xmlPayload);
-            OperationClient operationClient = createClient(operationQName);
-            operationClient.addMessageContext(messageContext);
-            operationClient.execute(true);
-            MessageContext response = operationClient
-                    .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-            return response.getEnvelope().getBody().getFirstElement();
-        }
+        MessageContext messageContext = new MessageContext();
+        fillSOAPEnvelope(messageContext, xmlPayload);
+        OperationClient operationClient = createClient(operationQName);
+        operationClient.addMessageContext(messageContext);
+        operationClient.execute(true);
+        MessageContext response = operationClient
+                .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+        return response.getEnvelope().getBody().getFirstElement();
     }
 
     /**
@@ -633,24 +515,6 @@
         // progamming model is non blocking
         mepClient.setCallback(callback);
         mepClient.addMessageContext(mc);
-
-        /**
-         * If a module has set the USE_ASYNC_OPERATIONS option then we override the behaviour
-         * for sync calls. However we leave real async calls alone.
-         */
-        boolean useAsync = false;
-        if(!options.isUseSeparateListener()) {
-        	Boolean useAsyncOption = (Boolean) configContext.getProperty(Constants.Configuration.USE_ASYNC_OPERATIONS);
-        	if(useAsyncOption != null) useAsync = useAsyncOption.booleanValue();
-        }
-
-        if (useAsync || options.isUseSeparateListener()) {
-            MessageReceiver messageReceiver = axisService.getOperation(operation).getMessageReceiver();
-            if (messageReceiver == null || !(messageReceiver instanceof CallbackReceiver)) {
-                CallbackReceiver callbackReceiver = new CallbackReceiver();
-                axisService.getOperation(operation).setMessageReceiver(callbackReceiver);
-            }
-        }
         mepClient.execute(false);
     }
 
@@ -783,42 +647,6 @@
         serviceContext.setCachingOperationContext(cachingOpContext);
     }
 
-
-    /**
-     * This class acts as a callback that allows users to wait on the result.
-     */
-    private class SyncCallBack extends Callback {
-        private SOAPEnvelope envelope;
-
-        private MessageContext msgctx;
-
-        private Exception error;
-
-        public void onComplete(AsyncResult result) {
-            this.envelope = result.getResponseEnvelope();
-            // Transport input stream gets closed after calling setComplete
-            // method. Have to build the whole envelope including the
-            // attachments at this stage. Data might get lost if the input
-            // stream gets closed before building the whole envelope.
-            this.envelope.buildWithAttachments();
-            this.msgctx = result.getResponseMessageContext();
-        }
-
-        public void setComplete(boolean complete) {
-            super.setComplete(complete);
-            synchronized (this) {
-                notify();
-            }
-        }
-
-        public void onError(Exception e) {
-            error = e;
-        }
-
-        public MessageContext getMsgctx() {
-            return msgctx;
-        }
-    }
 
     /**
      * Get the service context.

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java Wed Jan 31 12:35:21 2007
@@ -17,27 +17,18 @@
 
 package org.apache.axis2.context;
 
+import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.engine.ListenerManager;
-import org.apache.axis2.engine.ServiceLifeCycle;
 import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.modules.Module;
-import org.apache.axis2.transport.TransportSender;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.util.SessionUtils;
-import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.util.threadpool.ThreadFactory;
 import org.apache.axis2.util.threadpool.ThreadPool;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import java.io.File;
 import java.net.URL;
@@ -48,7 +39,6 @@
  */
 public class ConfigurationContext extends AbstractContext {
 
-    private static final Log log = LogFactory.getLog(ConfigurationContext.class);
     /**
      * Map containing <code>MessageID</code> to
      * <code>OperationContext</code> mapping.
@@ -65,20 +55,16 @@
     private long serviceGroupContextTimoutInterval = 30 * 1000;
 
     //To specify url mapping for services
-    private String contextRoot = "axis2";
-    private String servicePath = "services";
-    private String restPath = Constants.DEFAULT_REST_PATH;
+    private String contextRoot;
+    private String servicePath;
+    private String restPath;
 
     private String cachedServicePath = null;
 
-    private Thread cleanupThread;
-
     public ConfigurationContext(AxisConfiguration axisConfiguration) {
         super(null);
         this.axisConfiguration = axisConfiguration;
         initConfigContextTimeout(axisConfiguration);
-        cleanupThread = new CleanupThread(this);
-        Runtime.getRuntime().addShutdownHook(cleanupThread);
     }
 
     private void initConfigContextTimeout(AxisConfiguration axisConfiguration) {
@@ -126,11 +112,9 @@
                 String serviceGroupName = ((AxisServiceGroup) axisService.getParent()).getServiceGroupName();
                 serviceGroupContext = null;
 
-                synchronized (applicationSessionServiceGroupContextTable) {
-                    if (applicationSessionServiceGroupContextTable != null) {
-                        serviceGroupContext = (ServiceGroupContext) applicationSessionServiceGroupContextTable.get(
-                                serviceGroupName);
-                    }
+                if (applicationSessionServiceGroupContextTable != null) {
+                    serviceGroupContext = (ServiceGroupContext) applicationSessionServiceGroupContextTable.get(
+                            serviceGroupName);
                 }
 
                 if (serviceGroupContext == null) {
@@ -139,14 +123,12 @@
                         axisServiceGroup = (AxisServiceGroup) axisService.getParent();
                     }
                     serviceGroupContext = new ServiceGroupContext(messageContext.getConfigurationContext(),
-                                                                  axisServiceGroup);
+                            axisServiceGroup);
 
-                    synchronized (applicationSessionServiceGroupContextTable) {
-                        if (applicationSessionServiceGroupContextTable == null) {
-                            applicationSessionServiceGroupContextTable = new Hashtable();
-                        }
-                        applicationSessionServiceGroupContextTable.put(serviceGroupName, serviceGroupContext);
+                    if (applicationSessionServiceGroupContextTable == null) {
+                        applicationSessionServiceGroupContextTable = new Hashtable();
                     }
+                    applicationSessionServiceGroupContextTable.put(serviceGroupName, serviceGroupContext);
 
                 }
                 serviceContext = serviceGroupContext.getServiceContext(axisService);
@@ -194,7 +176,8 @@
                     registerServiceGroupContext(serviceGroupContext);
                 } else if (Constants.SCOPE_TRANSPORT_SESSION.equals(maxScope)) {
                     if (sessionContext != null) {
-                        sessionContext.addServiceGroupContext(serviceGroupContext, serviceGroupContextId);
+                        String serviceGroupName = serviceGroupContext.getDescription().getServiceGroupName();
+                        sessionContext.addServiceGroupContext(serviceGroupContext, serviceGroupName);
                         sessionContext.addServiceContext(serviceContext);
                     }
                 }
@@ -218,46 +201,57 @@
 
     /**
      * Registers a OperationContext with a given message ID.
+     * If the given message id already has a registered operation context,
+     * no change is made and the methid resturns false.
      *
      * @param messageID
      * @param mepContext
      */
-    public void registerOperationContext(String messageID,
+    public boolean registerOperationContext(String messageID,
                                          OperationContext mepContext) {
+        boolean alreadyInMap = false;
         mepContext.setKey(messageID);
         synchronized (operationContextMap) {
-            this.operationContextMap.put(messageID, mepContext);
+            alreadyInMap = operationContextMap.containsKey(messageID);
+            if(!alreadyInMap){
+                this.operationContextMap.put(messageID, mepContext);
+            }
+        }
+        return (!alreadyInMap);
+    }
+    
+    /**
+     * Unregisters the operation context associated with the given messageID
+     * @param key
+     */
+    public void unregisterOperationContext(String key) {
+        synchronized (operationContextMap) {
+            operationContextMap.remove(key);
         }
     }
 
     public void registerServiceGroupContext(ServiceGroupContext serviceGroupContext) {
         String id = serviceGroupContext.getId();
 
-        synchronized (serviceGroupContextMap) {
-            if (serviceGroupContextMap == null) {
-                serviceGroupContextMap = new Hashtable();
-            }
-
-            if ((serviceGroupContextMap.isEmpty()) || (serviceGroupContextMap.get(id) == null)) {
-                serviceGroupContextMap.put(id, serviceGroupContext);
-                serviceGroupContext.touch();
-                serviceGroupContext.setParent(this);
-            }
+        if (serviceGroupContextMap == null) {
+            serviceGroupContextMap = new Hashtable();
         }
 
+        if ((serviceGroupContextMap.isEmpty()) || (serviceGroupContextMap.get(id) == null)) {
+            serviceGroupContextMap.put(id, serviceGroupContext);
+            serviceGroupContext.touch();
+            serviceGroupContext.setParent(this);
+        }
         // this is the best time to clean up the SGCtxts since are not being used anymore
         cleanupServiceGroupContexts();
     }
 
-    public void addServiceGroupContextintoApplicatoionScopeTable(ServiceGroupContext serviceGroupContext) { 
-
-        synchronized (applicationSessionServiceGroupContextTable) {
-            if (applicationSessionServiceGroupContextTable == null) {
-                applicationSessionServiceGroupContextTable = new Hashtable();
-            }
-            applicationSessionServiceGroupContextTable.put(
-                    serviceGroupContext.getDescription().getServiceGroupName(), serviceGroupContext);
+    public void addServiceGroupContextintoApplicatoionScopeTable(ServiceGroupContext serviceGroupContext) {
+        if (applicationSessionServiceGroupContextTable == null) {
+            applicationSessionServiceGroupContextTable = new Hashtable();
         }
+        applicationSessionServiceGroupContextTable.put(
+                serviceGroupContext.getDescription().getServiceGroupName(), serviceGroupContext);
     }
 
     public AxisConfiguration getAxisConfiguration() {
@@ -270,70 +264,55 @@
      * @return Returns OperationContext <code>OperationContext<code>
      */
     public OperationContext getOperationContext(String id) {
-        OperationContext opCtx = null;
-        
+        OperationContext opCtx;
         synchronized (operationContextMap) {
             if (operationContextMap == null) {
                 return null;
             }
-            opCtx = (OperationContext) this.operationContextMap.get(id); 
+            opCtx = (OperationContext) this.operationContextMap.get(id);
         }
 
         return opCtx;
     }
 
-    public Map getOperationContextMap() {
-        return this.operationContextMap;
-    }
-
-    public OperationContext findOperationContext(String operationName, String serviceName, String serviceGroupName)
-    {
-        if (operationName == null)
-        {
+    public OperationContext findOperationContext(String operationName, String serviceName, String serviceGroupName) {
+        if (operationName == null) {
             return null;
         }
-        
-        if (serviceName == null)
-        {
+
+        if (serviceName == null) {
             return null;
         }
 
         // group name is not necessarily a prereq
         // but if the group name is non-null, then it has to match
 
-        synchronized (operationContextMap)
-        {
+        synchronized (operationContextMap) {
             Iterator it = operationContextMap.keySet().iterator();
 
-            while (it.hasNext())
-            {
+            while (it.hasNext()) {
                 Object key = it.next();
                 OperationContext value = (OperationContext) operationContextMap.get(key);
 
-                String valueOperationName = null;
-                String valueServiceName = null;
-                String valueServiceGroupName = null;
+                String valueOperationName;
+                String valueServiceName;
+                String valueServiceGroupName;
 
-                if (value != null)
-                {
+                if (value != null) {
                     valueOperationName = value.getOperationName();
                     valueServiceName = value.getServiceName();
                     valueServiceGroupName = value.getServiceGroupName();
 
-                    if ((valueOperationName != null) && (valueOperationName.equals(operationName)))
-                    {
-                        if ((valueServiceName != null) && (valueServiceName.equals(serviceName)))
-                        {
+                    if ((valueOperationName != null) && (valueOperationName.equals(operationName))) {
+                        if ((valueServiceName != null) && (valueServiceName.equals(serviceName))) {
                             if ((valueServiceGroupName != null) && (serviceGroupName != null)
-                                && (valueServiceGroupName.equals(serviceGroupName)))
-                            {
+                                    && (valueServiceGroupName.equals(serviceGroupName))) {
                                 // match
                                 return value;
                             }
 
                             // or, both need to be null
-                            if ((valueServiceGroupName == null) && (serviceGroupName == null))
-                            {
+                            if ((valueServiceGroupName == null) && (serviceGroupName == null)) {
                                 // match
                                 return value;
                             }
@@ -366,22 +345,21 @@
                                                       MessageContext msgContext) {
 
         ServiceGroupContext serviceGroupContext = null;
-        
-        synchronized (serviceGroupContextMap) {
-            if (serviceGroupContextMap != null) {
-                serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
 
-                if (serviceGroupContext != null) {
-                    serviceGroupContext.touch();
-                }
+        if (serviceGroupContextMap != null) {
+            serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
+
+            if (serviceGroupContext != null) {
+                serviceGroupContext.touch();
             }
         }
 
         if (serviceGroupContext == null
-            && msgContext != null
-            && msgContext.getSessionContext() != null) {
+                && msgContext != null
+                && msgContext.getSessionContext() != null) {
+            String serviceGroupName = msgContext.getAxisServiceGroup().getServiceGroupName();
             serviceGroupContext = msgContext.getSessionContext().getServiceGroupContext(
-                    serviceGroupContextId);
+                    serviceGroupName);
         }
 
         if (serviceGroupContext == null && msgContext != null) {
@@ -390,11 +368,9 @@
                 AxisServiceGroup asg = (AxisServiceGroup) axisService.getParent();
                 if (asg != null) {
 
-                    synchronized (applicationSessionServiceGroupContextTable) {
-                        if (applicationSessionServiceGroupContextTable != null) {
-                            serviceGroupContext = (ServiceGroupContext)
-                                    applicationSessionServiceGroupContextTable.get(asg.getServiceGroupName());
-                        }
+                    if (applicationSessionServiceGroupContextTable != null) {
+                        serviceGroupContext = (ServiceGroupContext)
+                                applicationSessionServiceGroupContextTable.get(asg.getServiceGroupName());
                     }
                 }
             }
@@ -406,28 +382,24 @@
 
     /**
      * Returns a ServiceGroupContext object associated
-     * with the specified ID from the internal table. 
-     * 
-     * @param Id     The ID string associated with the ServiceGroupContext object
+     * with the specified ID from the internal table.
+     *
+     * @param Id The ID string associated with the ServiceGroupContext object
      * @return The ServiceGroupContext object, or null if not found
      */
     public ServiceGroupContext getServiceGroupContext(String Id) {
 
-        if (Id == null)
-        {
+        if (Id == null) {
             // Hashtables require non-null key-value pairs
             return null;
         }
 
         ServiceGroupContext serviceGroupContext = null;
 
-        synchronized (serviceGroupContextMap)
-        {
-            if (serviceGroupContextMap != null) {
-                serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(Id);
-                if (serviceGroupContext != null) {
-                    serviceGroupContext.touch();
-                }
+        if (serviceGroupContextMap != null) {
+            serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(Id);
+            if (serviceGroupContext != null) {
+                serviceGroupContext.touch();
             }
         }
 
@@ -481,21 +453,19 @@
     }
 
     private void cleanupServiceGroupContexts() {
-        synchronized (serviceGroupContextMap) {
-            if (serviceGroupContextMap == null) {
-                return;
-            }
-            long currentTime = new Date().getTime();
-            Iterator sgCtxtMapKeyIter = serviceGroupContextMap.keySet().iterator();
-            while (sgCtxtMapKeyIter.hasNext()) {
-                String sgCtxtId = (String) sgCtxtMapKeyIter.next();
-                ServiceGroupContext serviceGroupContext =
-                        (ServiceGroupContext) serviceGroupContextMap.get(sgCtxtId);
-                if ((currentTime - serviceGroupContext.getLastTouchedTime()) >
-                        getServiceGroupContextTimoutInterval()) {
-                    sgCtxtMapKeyIter.remove();
-                    cleanupServiceContexts(serviceGroupContext);
-                }
+        if (serviceGroupContextMap == null) {
+            return;
+        }
+        long currentTime = new Date().getTime();
+        Iterator sgCtxtMapKeyIter = serviceGroupContextMap.keySet().iterator();
+        while (sgCtxtMapKeyIter.hasNext()) {
+            String sgCtxtId = (String) sgCtxtMapKeyIter.next();
+            ServiceGroupContext serviceGroupContext =
+                    (ServiceGroupContext) serviceGroupContextMap.get(sgCtxtId);
+            if ((currentTime - serviceGroupContext.getLastTouchedTime()) >
+                    getServiceGroupContextTimoutInterval()) {
+                sgCtxtMapKeyIter.remove();
+                cleanupServiceContexts(serviceGroupContext);
             }
         }
     }
@@ -518,23 +488,20 @@
         }
         while (serviceContecxtes.hasNext()) {
             ServiceContext serviceContext = (ServiceContext) serviceContecxtes.next();
-            try {
-                DependencyManager.destroyServiceObject(serviceContext);
-            } catch (AxisFault axisFault) {
-                log.info(axisFault.getMessage());
-            }
+            DependencyManager.destroyServiceObject(serviceContext);
         }
     }
 
-    private void cleanupContexts() {
+    public void cleanupContexts() {
         if ((applicationSessionServiceGroupContextTable != null) &&
-            (applicationSessionServiceGroupContextTable.size() > 0)) {
+                (applicationSessionServiceGroupContextTable.size() > 0)) {
             Iterator applicationScopeSgs = applicationSessionServiceGroupContextTable.values().iterator();
             while (applicationScopeSgs.hasNext()) {
                 ServiceGroupContext serviceGroupContext =
                         (ServiceGroupContext) applicationScopeSgs.next();
                 cleanupServiceContexts(serviceGroupContext);
             }
+            applicationSessionServiceGroupContextTable.clear();
         }
         if ((serviceGroupContextMap != null) && (serviceGroupContextMap.size() > 0)) {
             Iterator sopaSessionSgs = serviceGroupContextMap.values().iterator();
@@ -542,70 +509,25 @@
                 ServiceGroupContext serviceGroupContext = (ServiceGroupContext) sopaSessionSgs.next();
                 cleanupServiceContexts(serviceGroupContext);
             }
+            serviceGroupContextMap.clear();
         }
     }
 
     public void terminate()
-      throws AxisFault
-    {
-      Runtime.getRuntime().removeShutdownHook(cleanupThread);
-      performCleanup();
-    }
-        
-    private void performCleanup()
-      throws AxisFault
-    {
-      if (listenerManager != null)
-      {
-        listenerManager.stop();
-      }
-      
-      /*Stop the transport senders*/
-      HashMap transportOut = getAxisConfiguration().getTransportsOut();
-      if (transportOut.size() > 0) {
-          Iterator trsItr = transportOut.values().iterator();
-          while (trsItr.hasNext()) {
-              TransportOutDescription outDescription = (TransportOutDescription) trsItr.next();
-              TransportSender trsSededer = outDescription.getSender();
-              if (trsSededer != null) {
-                  trsSededer.stop();
-              }
-          }
-      }
-
-      /*Shut down the modules*/
-      HashMap modules = getAxisConfiguration().getModules();
-      if (modules != null) {
-          Iterator moduleitr = modules.values().iterator();
-          while (moduleitr.hasNext()) {
-              AxisModule axisModule = (AxisModule) moduleitr.next();
-              Module module = axisModule.getModule();
-              if (module != null) {
-                  module.shutdown(this);
-              }
-          }
-      }
-
-      cleanupContexts();
-      
-      /*Shut down the services*/
-      Iterator services = getAxisConfiguration().getServices().values().iterator();
-      while (services.hasNext()) {
-        AxisService axisService = (AxisService) services.next();
-        ServiceLifeCycle serviceLifeCycle = axisService.getServiceLifeCycle();
-        if (serviceLifeCycle != null) {
-          serviceLifeCycle.shutDown(this, axisService);
+            throws AxisFault {
+        if (listenerManager != null) {
+            listenerManager.stop();
         }
-      }
     }
-    
+
+
     public String getServiceContextPath() {
-        if(cachedServicePath == null){
+        if (cachedServicePath == null) {
             cachedServicePath = internalGetServiceContextPath();
         }
         return cachedServicePath;
     }
-    
+
     private String internalGetServiceContextPath() {
         String ctxRoot = getContextRoot().trim();
         String path = "/";
@@ -652,7 +574,7 @@
         if (contextRoot == null || contextRoot.trim().length() == 0) {
             throw new IllegalArgumentException("context root cannot be null or empty");
         }
-        return this.contextRoot.trim();
+        return contextRoot.trim();
     }
 
     public void setServicePath(String servicePath) {
@@ -665,6 +587,7 @@
 
     public void setContextRoot(String contextRoot) {
         this.contextRoot = contextRoot;
+        cachedServicePath = internalGetServiceContextPath();
     }
 
     /**
@@ -677,27 +600,5 @@
             serviceGroupContextTimoutInterval = serviceGroupContextTimoutIntervalParam.intValue();
         }
         return serviceGroupContextTimoutInterval;
-    }
-    
-    class CleanupThread extends Thread
-    {
-      ConfigurationContext configContext;
-      
-      public CleanupThread(ConfigurationContext configContext)
-      {
-        this.configContext = configContext;
-      }
-      
-      public void run()
-      {
-        try
-        {
-          configContext.performCleanup();
-        }
-        catch (AxisFault e)
-        {
-          e.printStackTrace();
-        }
-      }
     }
 }

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java Wed Jan 31 12:35:21 2007
@@ -34,14 +34,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.io.InputStream;
 import java.net.URL;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 
 public class ConfigurationContextFactory {
 
@@ -90,7 +87,7 @@
         }
     }
 
-    public static void addModuleService(ConfigurationContext configCtx) throws AxisFault {
+    private static void addModuleService(ConfigurationContext configCtx) throws AxisFault {
         AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
         HashMap modules = axisConfig.getModules();
         if (modules != null && modules.size() > 0) {
@@ -113,19 +110,14 @@
     private static void setContextPaths(AxisConfiguration axisConfig,
                                         ConfigurationContext configContext) {
         // Checking for context path
-        Parameter contextPath = axisConfig.getParameter(Constants.PARAM_CONTEXT_ROOT);
-        if (contextPath != null) {
-            String cpath = ((String) contextPath.getValue()).trim();
-            if (cpath.length() > 0) {
-                configContext.setContextRoot(cpath);
-            }
-        }
         Parameter servicePath = axisConfig.getParameter(Constants.PARAM_SERVICE_PATH);
         if (servicePath != null) {
             String spath = ((String) servicePath.getValue()).trim();
             if (spath.length() > 0) {
                 configContext.setServicePath(spath);
             }
+        } else {
+            configContext.setServicePath(Constants.DEFAULT_SERVICES_PATH);
         }
 
         Parameter restPathParam = axisConfig.getParameter(Constants.PARAM_REST_PATH);
@@ -134,6 +126,17 @@
             if (restPath.length() > 0) {
                 configContext.setRESTPath(restPath);
             }
+        } else {
+            configContext.setRESTPath(Constants.DEFAULT_REST_PATH);
+        }
+        Parameter contextPath = axisConfig.getParameter(Constants.PARAM_CONTEXT_ROOT);
+        if (contextPath != null) {
+            String cpath = ((String) contextPath.getValue()).trim();
+            if (cpath.length() > 0) {
+                configContext.setContextRoot(cpath);
+            }
+        } else {
+            configContext.setContextRoot("axis2");
         }
     }
 
@@ -190,13 +193,9 @@
      * Initializes modules and creates Transports.
      */
 
-    private static void init(ConfigurationContext configContext) throws AxisFault {
-        try {
-            initModules(configContext);
-            initTransportSenders(configContext);
-        } catch (DeploymentException e) {
-            throw new AxisFault(e);
-        }
+    private static void init(ConfigurationContext configContext) {
+        initModules(configContext);
+        initTransportSenders(configContext);
     }
 
     /**
@@ -204,9 +203,8 @@
      * it can do so in init and this is different from module.engage().
      *
      * @param context
-     * @throws DeploymentException
      */
-    private static void initModules(ConfigurationContext context) throws DeploymentException {
+    private static void initModules(ConfigurationContext context) {
         try {
             HashMap modules = context.getAxisConfiguration().getModules();
             Collection col = modules.values();
@@ -229,7 +227,7 @@
      *
      * @param configContext
      */
-    public static void initTransportSenders(ConfigurationContext configContext) {
+    private static void initTransportSenders(ConfigurationContext configContext) {
         AxisConfiguration axisConf = configContext.getAxisConfiguration();
 
         // Initialize Transport Outs
@@ -257,7 +255,10 @@
      * @return Returns ConfigurationContext.
      */
     public static ConfigurationContext createEmptyConfigurationContext() {
-        return new ConfigurationContext(new AxisConfiguration());
+        AxisConfiguration axisConfiguration = new AxisConfiguration();
+        ConfigurationContext configContext = new ConfigurationContext(axisConfiguration);
+        setContextPaths(axisConfiguration, configContext);
+        return configContext;
     }
 
     /**
@@ -272,6 +273,9 @@
         AxisConfiguration axisConfig = new AxisConfiguration();
         AxisConfigBuilder builder = new AxisConfigBuilder(in, axisConfig);
         builder.populateConfig();
-        return new ConfigurationContext(axisConfig);
+        axisConfig.validateSystemPredefinedPhases();
+        ConfigurationContext configContext = new ConfigurationContext(axisConfig);
+        setContextPaths(axisConfig, configContext);
+        return configContext;
     }
 }

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/MessageContext.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/MessageContext.java Wed Jan 31 12:35:21 2007
@@ -89,6 +89,19 @@
      */
     private static final Log log = LogFactory.getLog(MessageContext.class);
 
+    /**
+     * @serial An ID which can be used to correlate operations on a single
+     * message in the log files, irrespective of thread switches, persistence,
+     * etc. 
+     */
+    private String logCorrelationID = UUIDGenerator.getUUID();
+    
+    /**
+     * This string will be used to hold a form of the logCorrelationID that
+     * is more suitable for output than its generic form.
+     */
+    private transient String logCorrelationIDString = "[MessageContext: logID="+logCorrelationID+"]";
+    
     private static final String myClassName = "MessageContext";
 
     /**
@@ -517,6 +530,37 @@
         options = new Options();
     }
 
+    public String toString()
+    {
+      return logCorrelationIDString;
+    }
+    
+    /**
+     * Get a "raw" version of the logCorrelationID.  The logCorrelationID
+     * is guaranteed to be unique and may be persisted along with the rest
+     * of the message context.
+     * 
+     * @return A string that can be output to a log file as an identifier
+     * for this MessageContext.  It is suitable for matching related log
+     * entries. 
+     */
+    public String getLogCorrelationID()
+    {
+      return logCorrelationID;
+    }
+    
+    /**
+     * Get a formatted version of the logCorrelationID.
+     * 
+     * @return A string that can be output to a log file as an identifier
+     * for this MessageContext.  It is suitable for matching related log
+     * entries. 
+     */
+    public String getLogIDString()
+    {
+      return logCorrelationIDString;
+    }
+
     /**
      * Pause the execution of the current handler chain
      */
@@ -2223,6 +2267,8 @@
 
         out.writeLong(getLastTouchedTime());
 
+        ObjectStateUtils.writeString(out, logCorrelationID, "logCorrelationID");
+
         boolean persistWithOptimizedMTOM = (getProperty(MTOMConstants.ATTACHMENTS) != null);
         out.writeBoolean(persistWithOptimizedMTOM);
         
@@ -3176,6 +3222,9 @@
         long time = in.readLong();
         setLastTouchedTime(time);
 
+        logCorrelationID = ObjectStateUtils.readString(in, "logCorrelationID");
+        logCorrelationIDString = "[MessageContext: logID="+logCorrelationID+"]";
+        
         boolean persistedWithOptimizedMTOM = in.readBoolean();
         
         String contentType = null;
@@ -4954,4 +5003,5 @@
     {
         this.options = op;
     }
+    
 }

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/OperationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/OperationContext.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/OperationContext.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/OperationContext.java Wed Jan 31 12:35:21 2007
@@ -17,28 +17,26 @@
 
 package org.apache.axis2.context;
 
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.util.ObjectStateUtils;
-import org.apache.axis2.util.MetaDataEntry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
-import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.util.MetaDataEntry;
+import org.apache.axis2.util.ObjectStateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 /**
  * An OperationContext represents a running "instance" of an operation, which is
  * represented by an AxisOperation object. This concept is needed to allow
@@ -106,11 +104,6 @@
      */
     private transient HashMap messageContexts;
 
-    // this is the global MessageID -> OperationContext map which is stored in
-    // the EngineContext. We're caching it here for faster access.
-    private transient Map operationContextMap;
-
-
     //----------------------------------------------------------------
     // MetaData for data to be restored in activate after readExternal
     //----------------------------------------------------------------
@@ -203,15 +196,6 @@
         super(serviceContext);
         this.messageContexts = new HashMap();
         this.axisOperation = axisOperation;
-
-        ServiceContext serv = getServiceContext();
-
-        if (serv != null)
-        {
-            this.operationContextMap =
-                    serv.getConfigurationContext()
-                            .getOperationContextMap();
-        }
     }
 
     /**
@@ -241,17 +225,10 @@
      * being complete due to the optional nature of the MEP.
      */
     public void cleanup() {
-        if (key != null) {
-            if (operationContextMap == null) {
-                ServiceContext serv = getServiceContext();
-
-                if (serv != null) {
-                    this.operationContextMap =
-                            serv.getConfigurationContext()
-                                    .getOperationContextMap();
-                }
-            }
-            operationContextMap.remove(key);
+        ServiceContext serv = getServiceContext();
+
+        if (serv != null) {
+            serv.getConfigurationContext().unregisterOperationContext(key);
         }
     }
 
@@ -327,18 +304,6 @@
         isComplete = complete;
     }
 
-    public void setParent(AbstractContext context) {
-        super.setParent(context);
-
-        ServiceContext serv = getServiceContext();
-
-        if (serv != null) {
-            this.operationContextMap =
-                    serv.getConfigurationContext()
-                            .getOperationContextMap();
-        }
-    }
-
     public void setKey(String key) {
         this.key = key;
     }
@@ -695,14 +660,6 @@
 
         metaMessageContextMap = ObjectStateUtils.readHashMap(in, "OperationContext.metaMessageContextMap metadata table");
 
-
-        //---------------------------------------------------------
-        // other
-        //---------------------------------------------------------
-
-        operationContextMap = null;  //need to reseed from config context
-
-
         //---------------------------------------------------------
         // done
         //---------------------------------------------------------
@@ -850,30 +807,19 @@
             activeCC = cc;
         }
 
-        this.operationContextMap = activeCC.getOperationContextMap(); 
-
-        if ((this.operationContextMap != null) && (key != null))
-        {
-            // is the current key already in the list?
-            if (this.operationContextMap.containsKey(key) == false)
-            {
-                // make sure this OperationContext object is registered in the 
-                // list maintained by the ConfigurationContext object
-                activeCC.registerOperationContext(key, this);
-            }
-            else
-            {
+        if(key!=null){
+            // make sure this OperationContext object is registered in the 
+            // list maintained by the ConfigurationContext object
+            boolean registrationSuceeded = activeCC.registerOperationContext(key, this);
+            if(!registrationSuceeded){
                 // trace point
                 if (log.isTraceEnabled())
                 {
                     log.trace(myClassName+":activate():  OperationContext key ["+key+"] already exists in ConfigurationContext map.  This OperationContext ["+this.toString()+"] was not added to the table.");
                 }
-                //System.out.println(myClassName+":activate():  OperationContext key ["+key+"] already exists in ConfigurationContext map.");
             }
-
         }
-
-
+        
         //-------------------------------------------------------
         // update the modified entries in the messageContexts table
         //-------------------------------------------------------

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/SessionContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/SessionContext.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/SessionContext.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/context/SessionContext.java Wed Jan 31 12:35:21 2007
@@ -28,9 +28,7 @@
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
-import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -54,10 +52,10 @@
     private static final long serialVersionUID = -1100610673067568556L;
 
     /**
-     * @serial Tracks the revision level of a class to identify changes to the 
+     * @serial Tracks the revision level of a class to identify changes to the
      * class definition that are compatible to serialization/externalization.
      * If a class definition changes, then the serialization/externalization
-     * of the class is affected. 
+     * of the class is affected.
      * Refer to the writeExternal() and readExternal() methods.
      */
     // supported revision levels, add a new level to manage compatible changes
@@ -171,27 +169,23 @@
         Iterator serviceContecxtes = serviceGroupContext.getServiceContexts();
         while (serviceContecxtes.hasNext()) {
             ServiceContext serviceContext = (ServiceContext) serviceContecxtes.next();
-            try {
                 DependencyManager.destroyServiceObject(serviceContext);
-            } catch (AxisFault axisFault) {
-                log.info(axisFault.getMessage());
-            }
         }
     }
 
 
     /* ===============================================================
-     * Externalizable support 
+     * Externalizable support
      * ===============================================================
      */
-    
+
     /**
      * Save the contents of this object.
      * <p>
      * NOTE: Transient fields and static fields are not saved.
      *
      * @param out    The stream to write the object contents to
-     * 
+     *
      * @exception IOException
      */
     public void writeExternal(ObjectOutput out) throws IOException
@@ -254,15 +248,15 @@
 
 
     /**
-     * Restore the contents of the MessageContext that was 
-     * previously saved. 
-     * <p> 
+     * Restore the contents of the MessageContext that was
+     * previously saved.
+     * <p>
      * NOTE: The field data must read back in the same order and type
-     * as it was written.  Some data will need to be validated when 
+     * as it was written.  Some data will need to be validated when
      * resurrected.
      *
-     * @param in    The stream to read the object contents from 
-     * 
+     * @param in    The stream to read the object contents from
+     *
      * @exception IOException
      * @exception ClassNotFoundException
      */
@@ -324,7 +318,7 @@
         //---------------------------------------------------------
 
         // parent
-        Object tmpParent = ObjectStateUtils.readObject(in, "SessionContext.parent"); 
+        Object tmpParent = ObjectStateUtils.readObject(in, "SessionContext.parent");
 
         if (tmpParent != null)
         {

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java Wed Jan 31 12:35:21 2007
@@ -95,12 +95,12 @@
 
             processTransportReceivers(trs_Reivers);
 
-            // Process Observers
-            Iterator obs_ittr = config_element.getChildrenWithName(new QName(TAG_LISTENER));
-
             // Process TargetResolvers
             OMElement targetResolvers = config_element.getFirstChildWithName(new QName(TAG_TARGET_RESOLVERS));
             processTargetResolvers(axisConfig, targetResolvers);
+
+            // Process Observers
+            Iterator obs_ittr = config_element.getChildrenWithName(new QName(TAG_LISTENER));
 
             processObservers(obs_ittr);
 

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Wed Jan 31 12:35:21 2007
@@ -27,7 +27,6 @@
 import org.apache.axis2.deployment.scheduler.DeploymentIterator;
 import org.apache.axis2.deployment.scheduler.Scheduler;
 import org.apache.axis2.deployment.scheduler.SchedulerTask;
-import org.apache.axis2.deployment.util.PhasesInfo;
 import org.apache.axis2.deployment.util.Utils;
 import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
@@ -52,21 +51,21 @@
 public class DeploymentEngine implements DeploymentConstants {
 
     private static final Log log = LogFactory.getLog(DeploymentEngine.class);
-    private boolean hotUpdate = true;    // to do hot update or not
-    private boolean hotDeployment = true;    // to do hot deployment or not
-    private boolean antiJARLocking = false;    // to do hot deployment or not
+    protected boolean hotUpdate = true;    // to do hot update or not
+    protected boolean hotDeployment = true;    // to do hot deployment or not
+    protected boolean antiJARLocking = false;    // to do hot deployment or not
     /**
      * Stores all the web Services to deploy.
      */
-    private List wsToDeploy = new ArrayList();
+    protected List wsToDeploy = new ArrayList();
 
     /**
      * Stores all the web Services to undeploy.
      */
-    private List wsToUnDeploy = new ArrayList();
+    protected List wsToUnDeploy = new ArrayList();
 
     //to keep the web resource location if any
-    private String webLocationString = null;
+    protected String webLocationString = null;
 
     /**
      * to keep a ref to engine register
@@ -77,12 +76,12 @@
 
     protected ConfigurationContext configContext;
 
-    private RepositoryListener repoListener;
+    protected RepositoryListener repoListener;
 
-    private String servicesPath = null;
-    private File servicesDir = null;
-    private String modulesPath = null;
-    private File modulesDir = null;
+    protected String servicesPath = null;
+    protected File servicesDir = null;
+    protected String modulesPath = null;
+    protected File modulesDir = null;
 
     public void loadServices() {
         repoListener.checkServices();
@@ -109,7 +108,7 @@
             } catch (MalformedURLException e) {
                 log.info(e.getMessage());
             }
-            validateSystemPredefinedPhases();
+            axisConfig.validateSystemPredefinedPhases();
         } catch (AxisFault axisFault) {
             throw new DeploymentException(axisFault);
         }
@@ -120,7 +119,7 @@
         new RepositoryListener(this, true);
         org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
                 axisConfig.getModules(), axisConfig);
-        validateSystemPredefinedPhases();
+        axisConfig.validateSystemPredefinedPhases();
         try {
             engageModules();
         } catch (AxisFault axisFault) {
@@ -189,7 +188,7 @@
             }
             org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
                     axisConfig.getModules(), axisConfig);
-            validateSystemPredefinedPhases();
+            axisConfig.validateSystemPredefinedPhases();
         } catch (MalformedURLException e) {
             throw new DeploymentException(e);
         } catch (IOException e) {
@@ -216,7 +215,7 @@
         }
     }
 
-    private ArrayList populateService(AxisServiceGroup serviceGroup,
+    protected ArrayList populateService(AxisServiceGroup serviceGroup,
                                       URL servicesURL,
                                       String serviceName) throws DeploymentException {
         try {
@@ -317,7 +316,7 @@
         return axisConfig.getMessageReceiver(mepURL);
     }
 
-    private void addNewModule(AxisModule modulemetadata) throws AxisFault {
+    protected void addNewModule(AxisModule modulemetadata) throws AxisFault {
 
         Flow inflow = modulemetadata.getInFlow();
         ClassLoader moduleClassLoader = modulemetadata.getModuleClassLoader();
@@ -348,7 +347,7 @@
         log.debug(Messages.getMessage(DeploymentErrorMsgs.ADDING_NEW_MODULE));
     }
 
-    private void addServiceGroup(AxisServiceGroup serviceGroup,
+    protected void addServiceGroup(AxisServiceGroup serviceGroup,
                                  ArrayList serviceList,
                                  URL serviceLocation,
                                  ArchiveFileData currentArchiveFile)
@@ -361,7 +360,7 @@
         }
     }
 
-    private static void fillServiceGroup(AxisServiceGroup serviceGroup,
+    protected static void fillServiceGroup(AxisServiceGroup serviceGroup,
                                          ArrayList serviceList,
                                          URL serviceLocation,
                                          AxisConfiguration axisConfig) throws AxisFault {
@@ -437,7 +436,7 @@
         }
     }
 
-    private void addAsWebResources(File in, String serviceFileName, AxisServiceGroup serviceGroup) {
+    protected void addAsWebResources(File in, String serviceFileName, AxisServiceGroup serviceGroup) {
         try {
             if (webLocationString == null) {
                 return;
@@ -701,7 +700,7 @@
     /**
      * Starts the Deployment engine to perform Hot deployment and so on.
      */
-    private void startSearch(RepositoryListener listener) {
+    protected void startSearch(RepositoryListener listener) {
         Scheduler scheduler = new Scheduler();
 
         scheduler.schedule(new SchedulerTask(listener), new DeploymentIterator());
@@ -737,20 +736,6 @@
     }
 
     /**
-     * Checks whether some one has changed the system pre-defined phases
-     * for all the flows. If they have been changed,throws a DeploymentException.
-     *
-     * @throws DeploymentException
-     */
-    private void validateSystemPredefinedPhases() throws DeploymentException {
-        PhasesInfo phasesInfo = axisConfig.getPhasesInfo();
-        axisConfig.setInPhasesUptoAndIncludingPostDispatch(phasesInfo.getGlobalInflow());
-        axisConfig.setInFaultPhases(phasesInfo.getGlobalInFaultPhases());
-        axisConfig.setGlobalOutPhase(phasesInfo.getGlobalOutPhaseList());
-        axisConfig.setOutFaultPhases(phasesInfo.getOUT_FaultPhases());
-    }
-
-    /**
      * Gets AxisConfiguration.
      *
      * @return AxisConfiguration <code>AxisConfiguration</code>
@@ -766,7 +751,7 @@
      * @param fileName
      * @return Returns String.
      */
-    private String getAxisServiceName(String fileName) {
+    protected String getAxisServiceName(String fileName) {
         char seperator = '.';
         String value;
         int index = fileName.indexOf(seperator);
@@ -812,7 +797,7 @@
      * @param axis2repoURI : The repository folder of Axis2
      * @throws DeploymentException
      */
-    private void setClassLoaders(String axis2repoURI) throws DeploymentException {
+    protected void setClassLoaders(String axis2repoURI) throws DeploymentException {
         ClassLoader sysClassLoader =
                 Utils.getClassLoader(Thread.currentThread().getContextClassLoader(), axis2repoURI);
 
@@ -835,7 +820,7 @@
     /**
      * Sets hotDeployment and hot update.
      */
-    private void setDeploymentFeatures() {
+    protected void setDeploymentFeatures() {
         String value;
         Parameter parahotdeployment = axisConfig.getParameter(TAG_HOT_DEPLOYMENT);
         Parameter parahotupdate = axisConfig.getParameter(TAG_HOT_UPDATE);
@@ -883,7 +868,7 @@
      * @param repositoryName
      */
 
-    private void prepareRepository(String repositoryName) {
+    protected void prepareRepository(String repositoryName) {
         File repository = new File(repositoryName);
         if (servicesPath != null) {
             servicesDir = new File(servicesPath);
@@ -909,7 +894,7 @@
         }
     }
 
-    private String getRepositoryPath(File repository) {
+    protected String getRepositoryPath(File repository) {
         try {
             return repository.getCanonicalPath();
         } catch (IOException e) {
@@ -917,7 +902,7 @@
         }
     }
 
-    private ArrayList getFileList(URL fileListUrl) {
+    protected ArrayList getFileList(URL fileListUrl) {
         ArrayList fileList = new ArrayList();
         InputStream in;
         try {

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/RepositoryListener.java Wed Jan 31 12:35:21 2007
@@ -27,7 +27,7 @@
 import java.net.URLDecoder;
 
 public class RepositoryListener implements DeploymentConstants {
-    private DeploymentEngine deploymentEngine;
+    protected DeploymentEngine deploymentEngine;
 
     /**
      * The parent directory of the modules and services directories
@@ -36,7 +36,7 @@
     /**
      * Reference to a WSInfoList
      */
-    private WSInfoList wsInfoList;
+    protected WSInfoList wsInfoList;
 
     /**
      * This constructor takes two arguments, a folder name and a reference to Deployment Engine
@@ -83,7 +83,7 @@
     }
 
 
-    private boolean isSourceControlDir(File file) {
+    protected boolean isSourceControlDir(File file) {
         if (file.isDirectory()) {
             String name = file.getName();
             if (name.equalsIgnoreCase("CVS") || name.equalsIgnoreCase(".svn")) {
@@ -93,7 +93,7 @@
         return false;
     }
 
-    private void loadClassPathModules() {
+    protected void loadClassPathModules() {
         String classPath = getLocation();
         int lstindex = classPath.lastIndexOf(File.separatorChar);
         if (lstindex > 0) {
@@ -145,7 +145,7 @@
      *
      * @return String (location of the axis2 jar)
      */
-    private String getLocation() {
+    protected String getLocation() {
         try {
             Class clazz = Loader.loadClass("org.apache.axis2.engine.AxisEngine");
             java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
@@ -188,7 +188,7 @@
      * Searches a given folder for jar files and adds them to a list in the
      * WSInfolist class.
      */
-    private void findServicesInDirectory() {
+    protected void findServicesInDirectory() {
         File root = deploymentEngine.getServicesDir();
         File[] files = root.listFiles();
 

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java Wed Jan 31 12:35:21 2007
@@ -66,8 +66,8 @@
         try {
             // Processing service level parameters
             Iterator itr = service_element.getChildrenWithName(new QName(TAG_PARAMETER));
-            processParameters(itr, service, service.getParent());            
-            
+            processParameters(itr, service, service.getParent());
+
             // process service description
             OMElement descriptionElement =
                     service_element.getFirstChildWithName(new QName(TAG_DESCRIPTION));
@@ -92,7 +92,7 @@
                 }
             }
             OMAttribute serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME));
-            
+
             // If the service name is explicitly specified in the services.xml
             // then use that as the service name
             if (serviceNameatt != null) {
@@ -104,11 +104,11 @@
                     }
                 }
             }
-            
-            if (service.getParameter("ServiceClass") == null){
+
+            if (service.getParameter("ServiceClass") == null) {
                 log.info("The Service " + service.getName() + " does not specify a Service Class");
             }
-            
+
             // Process WS-Addressing flag attribute
             OMAttribute addressingRequiredatt = service_element.getAttribute(new QName(ATTRIBUTE_WSADDRESSING));
             if (addressingRequiredatt != null) {
@@ -259,7 +259,12 @@
                 ArrayList trs = new ArrayList();
                 while (transport_itr.hasNext()) {
                     OMElement trsEle = (OMElement) transport_itr.next();
-                    trs.add(trsEle.getText());
+                    String tarnsportName = trsEle.getText().trim();
+                    trs.add(tarnsportName);
+                    if (axisConfig.getTransportIn(new QName(tarnsportName)) == null) {
+                        throw new AxisFault("Service is trying to expose in a tarnsport : "
+                                + transports + " and which is not available in Axis2");
+                    }
                 }
                 service.setExposedTransports(trs);
             }

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml Wed Jan 31 12:35:21 2007
@@ -36,20 +36,8 @@
     <!--Set the flag to true if you want to enable transport level session management-->
     <parameter name="manageTransportSession" locked="false">false</parameter>
 
-    <!--Following two parameters will be used to handle REST in Axis2. The default settings will make Axis2 to have two-->
-    <!--different endpoints, one for REST (AxisRESTServlet) one for SOAP message handling (AxisServlet). But following-->
-    <!--parameters help to tweak the message handling of two main servlets. -->
-
-    <!-- If the enableRESTInAxis2MainServlet is true, then Axis2MainServlet will handle both SOAP and REST messages -->
-    <parameter name="enableRESTInAxis2MainServlet" locked="true">true</parameter>
-
-    <!-- Following parameter will completely disable REST handling in both the servlets-->
+    <!-- Following parameter will completely disable REST handling in Axis2-->
     <parameter name="disableREST" locked="true">false</parameter>
-
-    <!-- This will disable the separate servlet we have for REST handling. -->
-    <parameter name="disableSeparateEndpointForREST" locked="true">false</parameter>
-
-
 
     <!-- ================================================= -->
     <!-- Message Receivers -->

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisOperation.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisOperation.java Wed Jan 31 12:35:21 2007
@@ -324,7 +324,7 @@
                     configContext.getOperationContext(msgContext.getRelatesTo().getValue());
 
             if (null == operationContext && log.isDebugEnabled()) {
-                log.debug("Cannot correlate inbound message RelatesTo value [" + msgContext.getRelatesTo() + "] to in-progree MEP");
+                log.debug(msgContext.getLogIDString()+" Cannot correlate inbound message RelatesTo value [" + msgContext.getRelatesTo() + "] to in-progree MEP");
             }
         }
 
@@ -567,22 +567,12 @@
         faultMessages.add(faultMessage);
     }
 
-    public String getSoapAction() {
-        return soapAction;
-    }
-
     public void setSoapAction(String soapAction) {
         this.soapAction = soapAction;
     }
 
     public String getInputAction() {
-        String result = this.soapAction;
-        if (result == null || "".equals(result)) {
-            if (wsamappingList != null && !wsamappingList.isEmpty()) {
-                result = wsamappingList.get(0).toString();
-            }
-        }
-        return result;
+        return  soapAction;
     }
 
     public String getOutputAction() {

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisService.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/AxisService.java Wed Jan 31 12:35:21 2007
@@ -388,7 +388,7 @@
             axisOperation.setMessageReceiver(
                     loadDefaultMessageReceiver(axisOperation.getMessageExchangePattern(), this));
         }
-        if (axisOperation.getSoapAction() == null) {
+        if (axisOperation.getInputAction() == null) {
             axisOperation.setSoapAction("urn:" + axisOperation.getName().getLocalPart());
         }
         addChild(axisOperation);
@@ -413,7 +413,7 @@
 
         mapActionToOperation(operationName, axisOperation);
 
-        String action = axisOperation.getSoapAction();
+        String action = axisOperation.getInputAction();
         if (action.length() > 0) {
             mapActionToOperation(action, axisOperation);
         }
@@ -529,10 +529,6 @@
 
         while (operations.hasNext()) {
             AxisOperation axisOperation = (AxisOperation) operations.next();
-            if (moduleImpl != null) {
-                // notyfying module for service engagement
-                moduleImpl.engageNotify(axisOperation);
-            }
             axisOperation.engageModule(axisModule, axisConfig);
         }
         engagedModules.add(axisModule);
@@ -547,6 +543,11 @@
      * @param axisOperation the operation to map to
      */
     public void mapActionToOperation(String action, AxisOperation axisOperation) {
+        if(action == null || "".equals(action)){
+            if(log.isDebugEnabled()){
+                log.debug("mapActionToOperation: A null or empty action cannot be used to map to an operation.");
+            }
+        }
         operationsAliasesMap.put(action, axisOperation);
     }
 

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/ClientUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/ClientUtils.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/ClientUtils.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/ClientUtils.java Wed Jan 31 12:35:21 2007
@@ -42,7 +42,10 @@
             int index = transportURI.indexOf(':');
             String transport = (index > 0) ? transportURI.substring(0, index) : null;
             if (transport != null) {
-                return ac.getTransportOut(new QName(transport));
+                TransportOutDescription transportOut = ac.getTransportOut(new QName(transport));
+                if (transportOut == null) {
+                    throw new AxisFault("No Tranport Sender found for : " + transport);
+                } else return ac.getTransportOut(new QName(transport));
             } else {
                 throw new AxisFault(Messages.getMessage("cannotInferTransport", transportURI));
             }

Modified: webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java (original)
+++ webservices/axis2/branches/java/maven2/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java Wed Jan 31 12:35:21 2007
@@ -33,8 +33,11 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.TransportUtils;
 import org.apache.axis2.util.CallbackReceiver;
+import org.apache.axis2.util.Utils;
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 import java.util.HashMap;
@@ -95,6 +98,8 @@
  */
 class OutInAxisOperationClient extends OperationClient {
 
+    private static Log log = LogFactory.getLog(OutInAxisOperationClient.class);
+	
     OutInAxisOperationClient(OutInAxisOperation axisOp, ServiceContext sc,
                              Options options) {
         super(axisOp, sc, options);
@@ -149,6 +154,7 @@
      * @throws AxisFault if something goes wrong during the execution of the MEP.
      */
     public void execute(boolean block) throws AxisFault {
+    	if(log.isDebugEnabled()) log.debug("Entry: OutInAxisOperationClient::execute, " + block);
         if (completed) {
             throw new AxisFault(Messages.getMessage("mepiscomplted"));
         }
@@ -181,9 +187,29 @@
         }
         
         if (useAsync || options.isUseSeparateListener()) {
-            CallbackReceiver callbackReceiver = (CallbackReceiver) axisOp
-                    .getMessageReceiver();
-            callbackReceiver.addCallback(mc.getMessageID(), callback);
+        	if(log.isDebugEnabled())
+        		log.debug("useAsync=" + useAsync + ", seperateListener=" + options.isUseSeparateListener());
+        	/**
+        	 * We are following the async path. If the user hasn't set a callback object then we must
+        	 * block until the whole MEP is complete, as they have no other way to get their reply message.
+        	 */
+        	CallbackReceiver callbackReceiver = null;
+        	if(axisOp.getMessageReceiver() != null && axisOp.getMessageReceiver() instanceof CallbackReceiver) {
+        		callbackReceiver = (CallbackReceiver) axisOp.getMessageReceiver();
+        	} else {
+            	if(log.isDebugEnabled()) log.debug("Creating new callback receiver");
+        		callbackReceiver = new CallbackReceiver();
+        		axisOp.setMessageReceiver(callbackReceiver);
+        	}
+        	
+        	SyncCallBack internalCallback = null;
+        	if(callback != null) {
+                callbackReceiver.addCallback(mc.getMessageID(), callback);
+        	} else {
+            	if(log.isDebugEnabled()) log.debug("Creating internal callback");
+        		internalCallback = new SyncCallBack();
+        		callbackReceiver.addCallback(mc.getMessageID(), internalCallback);
+        	}
             
             /**
              * If USE_CUSTOM_LISTENER is set to 'true' the replyTo value will not be replaced and Axis2 will not
@@ -205,35 +231,50 @@
                     mc.getReplyTo().setAddress(replyToFromTransport.getAddress());
                 }
             }
-
-
             
             //if we don't do this , this guy will wait till it gets HTTP 202 in the HTTP case
             mc.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.TRUE);
             AxisEngine engine = new AxisEngine(cc);
             mc.getConfigurationContext().registerOperationContext(mc.getMessageID(), oc);
             engine.send(mc);
+            
+            if(internalCallback != null) {
+	            long timeout = options.getTimeOutInMilliSeconds();
+	            long waitTime = timeout;
+	            long startTime = System.currentTimeMillis();
+	
+	            synchronized (internalCallback) {
+	                while (! internalCallback.isComplete() && waitTime >= 0) {
+	                    try {
+	                    	internalCallback.wait(timeout);
+	                    } catch (InterruptedException e) {
+	                        // We were interrupted for some reason, keep waiting
+	                        // or throw new AxisFault( "Callback was interrupted by someone?" );
+	                    }
+	                    // The wait finished, compute remaining time
+	                    // - wait can end prematurely, see Object.wait( int timeout )
+	                    waitTime = timeout - (System.currentTimeMillis() - startTime);
+	                }
+	            }
+				// process the result of the invocation
+				if (internalCallback.envelope != null) {
+					// The call ended normally, so there is nothing to do
+				} else {
+					if (internalCallback.error instanceof AxisFault) {
+						throw (AxisFault) internalCallback.error;
+					} else if (internalCallback.error != null) {
+						throw new AxisFault(internalCallback.error);
+					} else if (! internalCallback.isComplete()) {
+						throw new AxisFault(Messages.getMessage("responseTimeOut"));
+					} else
+						throw new AxisFault(Messages.getMessage("callBackCompletedWithError"));
+				}
+            }
         } else {
             if (block) {
                 // Send the SOAP Message and receive a response
-                MessageContext response = send(mc);
-                // check for a fault and return the result
-                if (response != null) {
-                    SOAPEnvelope resEnvelope = response.getEnvelope();
-                    if (resEnvelope.getBody().hasFault()) {
-                        SOAPFault soapFault = resEnvelope.getBody().getFault();
-
-                        //we need to call engine.receiveFault
-                        AxisEngine engine = new AxisEngine(mc.getConfigurationContext());
-                        engine.receiveFault(response);
-                        if (options.isExceptionToBeThrownOnSOAPFault()) {
-                            // does the SOAPFault has a detail element for Excpetion
-                            throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
-                                    soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
-                        }
-                    }
-                }
-                completed = true;
+              send(mc);
+              completed = true;
             } else {
                 sc.getConfigurationContext().getThreadPool().execute(
                         new NonBlockingInvocationWorker(callback, mc));
@@ -249,7 +290,7 @@
      */
     protected MessageContext send(MessageContext msgctx) throws AxisFault {
 
-        AxisEngine engine = new AxisEngine(msgctx.getConfigurationContext());
+       AxisEngine engine = new AxisEngine(msgctx.getConfigurationContext());
 
         // create the responseMessageContext
         MessageContext responseMessageContext = new MessageContext();
@@ -260,8 +301,6 @@
 
         responseMessageContext.setServerSide(false);
         responseMessageContext.setMessageID(msgctx.getMessageID());
-        // FIXME Is the internal logic correct (thilina)
-        // Internally this registers the opContext not the msgContext
         addMessageContext(responseMessageContext);
         responseMessageContext.setServiceContext(msgctx.getServiceContext());
         responseMessageContext.setAxisMessage(
@@ -270,30 +309,47 @@
         //sending the message
         engine.send(msgctx);
         responseMessageContext.setDoingREST(msgctx.isDoingREST());
+
         responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgctx
                 .getProperty(MessageContext.TRANSPORT_IN));
         responseMessageContext.setTransportIn(msgctx.getTransportIn());
         responseMessageContext.setTransportOut(msgctx.getTransportOut());
-		responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
-				msgctx.getProperty(MessageContext.TRANSPORT_HEADERS));
-
-		if (responseMessageContext.getEnvelope() == null) {
-			// If request is REST we assume the responseMessageContext is REST,
-			// so set the variable
 
+        // Options object reused above so soapAction needs to be removed so
+        // that soapAction+wsa:Action on response don't conflict
+        responseMessageContext.setSoapAction("");
+
+        if (responseMessageContext.getEnvelope() == null) {
+            // If request is REST we assume the responseMessageContext is REST, so
+            // set the variable
             SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
                     responseMessageContext, msgctx.getEnvelope().getNamespace()
                     .getNamespaceURI());
-            if (resenvelope != null) {
+             if (resenvelope != null) {
                 responseMessageContext.setEnvelope(resenvelope);
+            } else {
+                throw new AxisFault(Messages
+                        .getMessage("blockingInvocationExpectsResponse"));
+            }
+        }
+        SOAPEnvelope resenvelope = responseMessageContext.getEnvelope();
+        if (resenvelope != null) {
+            if (resenvelope.getBody().hasFault()) {
+                SOAPFault soapFault = resenvelope.getBody().getFault();
+                //we need to call engine.receiveFault
+                engine = new AxisEngine(msgctx.getConfigurationContext());
+                engine.receiveFault(responseMessageContext);
+                if (options.isExceptionToBeThrownOnSOAPFault()) {
+                    // does the SOAPFault has a detail element for Excpetion
+                    AxisFault af = Utils.getInboundFaultFromMessageContext(responseMessageContext);
+                    throw af;
+                }
+            } else {
                 engine = new AxisEngine(msgctx.getConfigurationContext());
                 engine.receive(responseMessageContext);
                 if (responseMessageContext.getReplyTo() != null) {
                     sc.setTargetEPR(responseMessageContext.getReplyTo());
                 }
-            } else {
-                throw new AxisFault(Messages
-                        .getMessage("blockingInvocationExpectsResponse"));
             }
         }
         return responseMessageContext;
@@ -345,4 +401,41 @@
 			}
         }
     }
+    
+    /**
+     * This class acts as a callback that allows users to wait on the result.
+     */
+    private class SyncCallBack extends Callback {
+
+		private SOAPEnvelope envelope;
+
+		private Exception error;
+
+		public void onComplete(AsyncResult result) {
+        	if(log.isDebugEnabled()) log.debug("Entry: OutInAxisOperationClient$SyncCallBack::onComplete");
+            // Transport input stream gets closed after calling setComplete
+            // method. Have to build the whole envelope including the
+            // attachments at this stage. Data might get lost if the input
+            // stream gets closed before building the whole envelope.
+            this.envelope = result.getResponseEnvelope();
+            this.envelope.buildWithAttachments();
+        	if(log.isDebugEnabled()) log.debug("Exit: OutInAxisOperationClient$SyncCallBack::onComplete");
+        }
+
+        public void setComplete(boolean complete) {
+        	if(log.isDebugEnabled()) log.debug("Entry: OutInAxisOperationClient$SyncCallBack::setComplete, " + complete);
+            super.setComplete(complete);
+            synchronized (this) {
+                notify();
+            }
+        	if(log.isDebugEnabled()) log.debug("Exit: OutInAxisOperationClient$SyncCallBack::setComplete, " + complete);
+        }
+
+        public void onError(Exception e) {
+        	if(log.isDebugEnabled()) log.debug("Entry: OutInAxisOperationClient$SyncCallBack::onError, " + e);
+            error = e;
+        	if(log.isDebugEnabled()) log.debug("Exit: OutInAxisOperationClient$SyncCallBack::onError");
+        }
+    }
+
 }



---------------------------------------------------------------------
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