You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2008/03/26 00:23:47 UTC

svn commit: r641075 - in /ode/branches/APACHE_ODE_1.1: ./ axis2/src/main/java/org/apache/ode/axis2/ axis2/src/main/java/org/apache/ode/axis2/service/ axis2/src/main/java/org/apache/ode/axis2/util/ bpel-epr/src/main/java/org/apache/ode/il/ jbi/src/main/...

Author: boisvert
Date: Tue Mar 25 16:23:44 2008
New Revision: 641075

URL: http://svn.apache.org/viewvc?rev=641075&view=rev
Log:
ODE-248: Expose ProcessManagement API on JBI bus

Added:
    ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/DynamicService.java
    ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/OMUtils.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/BaseMessageExchangeProcessor.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/DynamicMessageExchangeProcessor.java
Removed:
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/OMUtils.java
Modified:
    ode/branches/APACHE_ODE_1.1/Rakefile
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/JbiMessageExchangeEventRouter.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeComponent.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeSUManager.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeService.java
    ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/Receiver.java

Modified: ode/branches/APACHE_ODE_1.1/Rakefile
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/Rakefile?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/Rakefile (original)
+++ ode/branches/APACHE_ODE_1.1/Rakefile Tue Mar 25 16:23:44 2008
@@ -136,7 +136,7 @@
       JAVAX.activation, JAVAX.servlet, JAVAX.stream, JAVAX.transaction, JENCKS, WSDL4J, WS_COMMONS.xml_schema,
       XMLBEANS
 
-    test.with project("tools"), XERCES, WOODSTOX, AXIOM, JAVAX.javamail
+    test.with project("tools"), AXIOM, JAVAX.javamail, COMMONS.codec, COMMONS.httpclient, XERCES, WOODSTOX
     test.exclude '*'
 
     package :jar
@@ -222,7 +222,7 @@
   desc "ODE Interface Layers Common"
   define "bpel-epr" do
     compile.with projects("utils", "bpel-dao", "bpel-api"),
-      COMMONS.logging, DERBY, JAVAX.transaction, GERONIMO.transaction, GERONIMO.connector, TRANQL, JAVAX.connector, COMMONS.lang
+      AXIOM, COMMONS.lang, COMMONS.logging, DERBY, JAVAX.connector, JAVAX.stream, JAVAX.transaction, GERONIMO.transaction, GERONIMO.connector, TRANQL, XMLBEANS
     package :jar
   end
 
@@ -407,7 +407,7 @@
   define "jbi" do
     compile.with projects("bpel-api", "bpel-connector", "bpel-dao", "bpel-epr", "bpel-obj",
       "bpel-runtime", "scheduler-simple", "bpel-schemas", "bpel-store", "utils"),
-      COMMONS.logging, COMMONS.pool, JAVAX.transaction, JBI, LOG4J, WSDL4J, XERCES
+      AXIOM, COMMONS.logging, COMMONS.pool, JAVAX.transaction, JBI, LOG4J, WSDL4J, XERCES
 
     package(:jar)
     package(:jbi).tap do |jbi|
@@ -416,7 +416,7 @@
         "bpel-epr", "jca-ra", "jca-server", "bpel-obj", "bpel-ql", "bpel-runtime",
         "scheduler-simple", "bpel-schemas", "bpel-store", "dao-hibernate", "dao-jpa",
         "jacob", "jacob-ap", "utils"),
-        ANT, BACKPORT, COMMONS.codec, COMMONS.collections, COMMONS.dbcp, COMMONS.lang, COMMONS.pool,
+        ANT, AXIOM, BACKPORT, COMMONS.codec, COMMONS.collections, COMMONS.dbcp, COMMONS.lang, COMMONS.pool,
         COMMONS.primitives, JAXEN, JAVAX.connector, JAVAX.ejb, JAVAX.jms,
         JAVAX.persistence, JAVAX.stream, JAVAX.transaction, LOG4J, OPENJPA, SAXON, TRANQL,
         XALAN, XMLBEANS, XSTREAM, WSDL4J)

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java Tue Mar 25 16:23:44 2008
@@ -19,6 +19,14 @@
 
 package org.apache.ode.axis2;
 
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Operation;
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
@@ -31,28 +39,26 @@
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.ode.axis2.util.OMUtils;
 import org.apache.ode.axis2.util.SoapMessageConverter;
 import org.apache.ode.bpel.epr.EndpointFactory;
 import org.apache.ode.bpel.epr.MutableEndpoint;
 import org.apache.ode.bpel.epr.WSAEndpoint;
-import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.bpel.iapi.BpelServer;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.ode.bpel.iapi.Scheduler;
 import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
+import org.apache.ode.il.OMUtils;
 import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.Namespaces;
 import org.apache.ode.utils.uuid.UUID;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import javax.wsdl.Definition;
-import javax.wsdl.Fault;
-import javax.wsdl.Operation;
-import javax.xml.namespace.QName;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-
 /**
- * Acts as a service not provided by ODE. Used mainly for invocation as a way to maintain the WSDL decription of used
+ * Acts as a service not provided by ODE. Used mainly for invocation as a way to maintain the WSDL description of used
  * services.
  *
  * @author Matthieu Riou <mriou at apache dot org>

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java Tue Mar 25 16:23:44 2008
@@ -20,6 +20,24 @@
 package org.apache.ode.axis2.service;
 
 
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.activation.DataHandler;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
@@ -38,29 +56,12 @@
 import org.apache.ode.axis2.OdeFault;
 import org.apache.ode.axis2.deploy.DeploymentPoller;
 import org.apache.ode.axis2.hooks.ODEAxisService;
-import org.apache.ode.axis2.util.OMUtils;
 import org.apache.ode.bpel.iapi.BpelServer;
 import org.apache.ode.bpel.iapi.ProcessConf;
 import org.apache.ode.bpel.iapi.ProcessStore;
+import org.apache.ode.il.OMUtils;
 import org.apache.ode.utils.fs.FileUtils;
 
-import javax.activation.DataHandler;
-import javax.wsdl.Definition;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
 /**
  * Axis wrapper for process deployment.
  */
@@ -274,9 +275,7 @@
             OMElement responseOp = factory.createOMElement(op, _pmapi);
             responseOp.addChild(response);
             envelope.getBody().addChild(response);
-            AxisEngine engine = new AxisEngine(
-                    messageContext.getOperationContext().getServiceContext().getConfigurationContext());
-            engine.send(outMsgContext);
+            AxisEngine.send(outMsgContext);
         }
     }
 

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java Tue Mar 25 16:23:44 2008
@@ -23,48 +23,37 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
 import javax.wsdl.Definition;
 import javax.wsdl.WSDLException;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.soap.*;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.soap.SOAPFaultReason;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.axis2.util.Utils;
-import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.ode.axis2.OdeFault;
 import org.apache.ode.axis2.hooks.ODEAxisService;
-import org.apache.ode.axis2.util.OMUtils;
 import org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl;
 import org.apache.ode.bpel.iapi.BpelServer;
 import org.apache.ode.bpel.iapi.ProcessStore;
 import org.apache.ode.bpel.pmapi.InstanceManagement;
-import org.apache.ode.bpel.pmapi.ProcessInfoCustomizer;
 import org.apache.ode.bpel.pmapi.ProcessManagement;
-import org.apache.ode.bpel.pmapi.ManagementException;
+import org.apache.ode.il.DynamicService;
 import org.apache.ode.utils.Namespaces;
-import org.apache.xmlbeans.XmlObject;
-import org.w3c.dom.Node;
 
 /**
  * Axis2 wrapper for process and instance management interfaces.
@@ -73,11 +62,19 @@
 
     private static final Log __log = LogFactory.getLog(ManagementService.class);
 
+    public static final QName PM_SERVICE_NAME = new QName("http://www.apache.org/ode/pmapi", "ProcessManagementService");
+    public static final String PM_PORT_NAME = "ProcessManagementPort";
+    public static final String PM_AXIS2_NAME = "ProcessManagement";
+
+    public static final QName IM_SERVICE_NAME = new QName("http://www.apache.org/ode/pmapi", "InstanceManagementService");
+    public static final String IM_PORT_NAME = "InstanceManagementPort";
+    public static final String IM_AXIS2_NAME = "InstanceManagement";
+
     private ProcessManagement _processMgmt;
     private InstanceManagement _instanceMgmt;
 
     public void enableService(AxisConfiguration axisConfig, BpelServer server, ProcessStore _store, String rootpath) {
-        ProcessAndInstanceManagementImpl pm = new ProcessAndInstanceManagementImpl(server,_store);
+        ProcessAndInstanceManagementImpl pm = new ProcessAndInstanceManagementImpl(server, _store);
         _processMgmt = pm;
         _instanceMgmt = pm;
 
@@ -88,12 +85,10 @@
 
             File wsdlFile = new File(rootpath + "/pmapi.wsdl");
             def = wsdlReader.readWSDL(wsdlFile.toURI().toString());
-            AxisService processService = ODEAxisService.createService(
-                    axisConfig, new QName("http://www.apache.org/ode/pmapi", "ProcessManagementService"),
-                    "ProcessManagementPort", "ProcessManagement", def, new ProcessMessageReceiver());
-            AxisService instanceService = ODEAxisService.createService(
-                    axisConfig, new QName("http://www.apache.org/ode/pmapi", "InstanceManagementService"),
-                    "InstanceManagementPort", "InstanceManagement", def, new InstanceMessageReceiver());
+            AxisService processService = ODEAxisService.createService(axisConfig, PM_SERVICE_NAME, PM_PORT_NAME,
+                    PM_AXIS2_NAME, def, new DynamicMessageReceiver<ProcessManagement>(_processMgmt));
+            AxisService instanceService = ODEAxisService.createService(axisConfig, IM_SERVICE_NAME, IM_PORT_NAME,
+                    IM_AXIS2_NAME, def, new DynamicMessageReceiver<InstanceManagement>(_instanceMgmt));
             axisConfig.addService(processService);
             axisConfig.addService(instanceService);
         } catch (WSDLException e) {
@@ -103,148 +98,52 @@
         }
     }
 
-    private static void invokeBusinessLogic(MessageContext msgContext, Class mgmtClass,
-                                Object mgmtObject, SOAPFactory soapFactory) throws AxisFault {
-        if (__log.isDebugEnabled())
-            __log.debug("Received mgmt message for " + msgContext.getAxisService().getName() +
-                    "." + msgContext.getAxisOperation().getName());
+    public ProcessManagement getProcessMgmt() {
+        return _processMgmt;
+    }
 
-        String methodName = msgContext.getAxisOperation().getName().getLocalPart();
-        try {
-            MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
-            outMsgContext.getOperationContext().addMessageContext(outMsgContext);
+    public InstanceManagement getInstanceMgmt() {
+        return _instanceMgmt;
+    }
+
+    class DynamicMessageReceiver<T> extends AbstractMessageReceiver {
+        T _service;
 
+        public DynamicMessageReceiver(T service) {
+            _service = service;
+        }
+
+        public void invokeBusinessLogic(MessageContext messageContext) throws AxisFault {
+            DynamicService<T> service = new DynamicService<T>(_service);
+            MessageContext outMsgContext = Utils.createOutMessageContext(messageContext);
+            outMsgContext.getOperationContext().addMessageContext(outMsgContext);
+            SOAPFactory soapFactory = getSOAPFactory(messageContext);
             SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
             outMsgContext.setEnvelope(envelope);
 
-            // Our services are defined in WSDL which requires operation names to be different
-            Method invokedMethod = findMethod(mgmtClass, methodName);
-            Object[] params = extractParams(invokedMethod, msgContext.getEnvelope().getBody().getFirstElement());
-            Object result = null;
+            OMElement response;
             try {
-                result = invokedMethod.invoke(mgmtObject, params);
-                if (hasResponse(msgContext.getAxisOperation())) {
-                    OMElement wrapper = soapFactory.createOMElement(new QName("http://www.apache.org/ode/pmapi", methodName+"Response"));
-                    OMElement parts = convertToOM(soapFactory, result);
-                    parts = stripNamespace(soapFactory, parts);
-                    wrapper.addChild(parts);
-                    envelope.getBody().addChild(wrapper);
-
-                    if (__log.isDebugEnabled()) {
-                        __log.debug("Reply mgmt for " + msgContext.getAxisService().getName() +
-                                "." + msgContext.getAxisOperation().getName());
-                        __log.debug("Reply mgmt message " + outMsgContext.getEnvelope());
-                    }
+                response = service.invoke(messageContext.getAxisOperation().getName().getLocalPart(),
+                                          messageContext.getEnvelope().getBody().getFirstElement());
+                if (response != null) {
+                    envelope.getBody().addChild(response);
                 }
-            } catch (ManagementException e) {
+            } catch (Exception e) {
                 // Building a nicely formatted fault
                 envelope.getBody().addFault(toSoapFault(e, soapFactory));
             }
-            AxisEngine engine = new AxisEngine(
-                    msgContext.getOperationContext().getServiceContext().getConfigurationContext());
-            engine.send(outMsgContext);
-        } catch (IllegalAccessException e) {
-            throw new OdeFault("Couldn't invoke method named " + methodName + " in management interface!", e);
-        } catch (InvocationTargetException e) {
-            throw new OdeFault("Invocation of method " + methodName + " in management interface failed!", e.getTargetException());
-        }
-    }
-
-    private static Object[] extractParams(Method method, OMElement omElmt) throws AxisFault {
-        Class[] paramTypes = method.getParameterTypes();
-        Object[] params = new Object[method.getParameterTypes().length];
-        Iterator omChildren = omElmt.getChildElements();
-        int paramIdx = 0;
-        for (Class<?> paramClass : paramTypes) {
-            OMElement omchild = (OMElement) omChildren.next();
-            __log.debug("Extracting param " + paramClass + " from " + omchild);
-            params[paramIdx++] = convertFromOM(paramClass, omchild);
-        }
-        return params;
-    }
-
-    private static Object convertFromOM(Class clazz, OMElement elmt) throws AxisFault {
-        // Here comes the nasty code...
-        if (elmt == null || elmt.getText().length() == 0 && !elmt.getChildElements().hasNext())
-            return null;
-        else if (clazz.equals(String.class)) {
-            return elmt.getText();
-        } else if (clazz.equals(Boolean.class) || clazz.equals(Boolean.TYPE)) {
-            return (elmt.getText().equals("true") || elmt.getText().equals("yes")) ? Boolean.TRUE : Boolean.FALSE;
-        } else if (clazz.equals(QName.class)) {
-            // The getTextAsQName is buggy, it sometimes return the full text without extracting namespace
-            return OMUtils.getTextAsQName(elmt);
-        } else if (clazz.equals(ProcessInfoCustomizer.class)) {
-            return new ProcessInfoCustomizer(elmt.getText());
-        } else if (Node.class.isAssignableFrom(clazz)) {
-            return OMUtils.toDOM(elmt.getFirstElement());
-        } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) {
-            return Long.parseLong(elmt.getText());
-        } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) {
-            return Integer.parseInt(elmt.getText());
-        } else if (clazz.isArray()) {
-            ArrayList<Object> alist = new ArrayList<Object>();
-            Iterator children = elmt.getChildElements();
-            Class targetClazz = clazz.getComponentType();
-            while (children.hasNext())
-                alist.add(parseType(targetClazz, ((OMElement)children.next()).getText()));
-            return alist.toArray((Object[]) Array.newInstance(targetClazz, alist.size()));
-        } else if (XmlObject.class.isAssignableFrom(clazz)) {
-            try {
-                Class beanFactory = Class.forName(clazz.getCanonicalName() + ".Factory");
-                return beanFactory.getMethod("parse", XMLStreamReader.class)
-                        .invoke(elmt.getXMLStreamReaderWithoutCaching());
-            } catch (ClassNotFoundException e) {
-                throw new OdeFault("Couldn't find class " + clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
-            } catch (IllegalAccessException e) {
-                throw new OdeFault("Couldn't access class " + clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
-            } catch (InvocationTargetException e) {
-                throw new OdeFault("Couldn't access xml bean parse method on class " + clazz.getCanonicalName() + ".Factory " +
-                        "to instantiate xml bean", e);
-            } catch (NoSuchMethodException e) {
-                throw new OdeFault("Couldn't find xml bean parse method on class " + clazz.getCanonicalName() + ".Factory " +
-                        "to instantiate xml bean", e);
-            }
-        } else throw new OdeFault("Couldn't use element " + elmt + " to obtain a management method parameter.");
-    }
-
-    private static OMElement convertToOM(SOAPFactory soapFactory, Object obj) throws AxisFault {
-        if (obj instanceof XmlObject) {
-            try {
-                return new StAXOMBuilder(((XmlObject)obj).newInputStream()).getDocumentElement();
-            } catch (XMLStreamException e) {
-                throw new OdeFault("Couldn't serialize result to an outgoing messages.", e);
-            }
-        } else if (obj instanceof List) {
-            OMElement listElmt = soapFactory.createOMElement("list", null);
-            for (Object stuff : ((List) obj)) {
-                OMElement stuffElmt = soapFactory.createOMElement("element", null);
-                stuffElmt.setText(stuff.toString());
-                listElmt.addChild(stuffElmt);
-            }
-            return listElmt;
-        } else throw new OdeFault("Couldn't convert object " + obj + " into a response element.");
-    }
-
-    private static OMElement stripNamespace(SOAPFactory soapFactory, OMElement element) {
-        OMElement parent = soapFactory.createOMElement(new QName("", element.getLocalName()));
-        Iterator<OMElement> iter = element.getChildElements();
-        while (iter.hasNext()) {
-            OMElement child = iter.next();
-            child = child.cloneOMElement();
-            parent.addChild(child);
-        }
-        return parent;
+            AxisEngine.send(outMsgContext);
     }
 
-    private static SOAPFault toSoapFault(ManagementException e, SOAPFactory soapFactory) {
+        private SOAPFault toSoapFault(Exception e, SOAPFactory soapFactory) {
         SOAPFault fault = soapFactory.createSOAPFault();
         SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
         code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server"));
         SOAPFaultReason reason = soapFactory.createSOAPFaultReason(fault);
         reason.setText(e.toString());
 
-        OMElement detail = soapFactory.createOMElement(new QName(Namespaces.ODE_PMAPI, e.getClass().getSimpleName()));
+            OMElement detail = soapFactory
+                    .createOMElement(new QName(Namespaces.ODE_PMAPI, e.getClass().getSimpleName()));
         StringWriter stack = new StringWriter();
         e.printStackTrace(new PrintWriter(stack));
         detail.setText(stack.toString());
@@ -252,52 +151,6 @@
         soapDetail.addDetailEntry(detail);
         return fault;
     }
-    
-    private static boolean hasResponse(AxisOperation op) {
-        switch(op.getAxisSpecificMEPConstant()) {
-            case WSDLConstants.MEP_CONSTANT_IN_OUT: return true;
-            case WSDLConstants.MEP_CONSTANT_OUT_ONLY: return true;
-            case WSDLConstants.MEP_CONSTANT_OUT_OPTIONAL_IN: return true;
-            case WSDLConstants.MEP_CONSTANT_ROBUST_OUT_ONLY: return true;
-            default: return false;
-        }
-    }
-
-    class ProcessMessageReceiver extends AbstractMessageReceiver {
-        public void invokeBusinessLogic(MessageContext messageContext) throws AxisFault {
-            ManagementService.invokeBusinessLogic(messageContext, ProcessManagement.class,
-                    _processMgmt, getSOAPFactory(messageContext));
-        }
-    }
-
-    class InstanceMessageReceiver extends AbstractMessageReceiver {
-        public void invokeBusinessLogic(MessageContext messageContext) throws AxisFault {
-            ManagementService.invokeBusinessLogic(messageContext, InstanceManagement.class,
-                    _instanceMgmt, getSOAPFactory(messageContext));
-        }
-    }
-
-    private static Method findMethod(Class clazz, String methodName) throws AxisFault {
-        for (Method method : clazz.getMethods()) {
-            if (method.getName().equals(methodName)) return method;
-        }
-        throw new OdeFault("Couldn't find any method named " + methodName + " in interface " + clazz.getName());
-    }
-
-    private static Object parseType(Class clazz, String str) {
-        if (clazz.equals(Integer.class)) return Integer.valueOf(str);
-        if (clazz.equals(Float.class)) return Integer.valueOf(str);
-        if (clazz.equals(String.class)) return str;
-        return null;
-    }
-    
-    public ProcessManagement getProcessMgmt()
-	{
-		return _processMgmt;
 	}
 
-	public InstanceManagement getInstanceMgmt()
-	{
-		return _instanceMgmt;
-	}
 }

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java Tue Mar 25 16:23:44 2008
@@ -19,21 +19,10 @@
 
 package org.apache.ode.axis2.util;
 
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.soap.*;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.namespace.Constants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.axis2.Messages;
-import org.apache.ode.axis2.OdeFault;
-import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.Namespaces;
-import org.apache.ode.utils.stl.CollectionsX;
-import org.w3c.dom.Element;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.wsdl.Binding;
 import javax.wsdl.BindingInput;
@@ -48,16 +37,33 @@
 import javax.wsdl.Port;
 import javax.wsdl.Service;
 import javax.wsdl.extensions.ElementExtensible;
-import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPBody;
 import javax.wsdl.extensions.soap.SOAPHeader;
 import javax.wsdl.extensions.soap.SOAPOperation;
 import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.soap.SOAPFaultReason;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.namespace.Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.Messages;
+import org.apache.ode.axis2.OdeFault;
+import org.apache.ode.il.OMUtils;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.Namespaces;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.w3c.dom.Element;
 
 /**
  * SOAP/ODE Message converter. Uses WSDL binding information to convert the protocol-neutral ODE representation into a SOAP

Added: ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/DynamicService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/DynamicService.java?rev=641075&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/DynamicService.java (added)
+++ ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/DynamicService.java Tue Mar 25 16:23:44 2008
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ode.il;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.pmapi.ProcessInfoCustomizer;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Node;
+
+/**
+ * Dynamic invocation handler for XML-based service;  uses RPC message format conventions to dispatch
+ * invocation based on top-level element name (e.g. method name) and sub-elements (e.g. parameters).
+ */
+public class DynamicService<T> {
+    private final Log __log = LogFactory.getLog(getClass());
+
+    static final OMFactory OM = OMAbstractFactory.getOMFactory();
+
+    T _service;
+    Class<T> _clazz;
+    
+    @SuppressWarnings("unchecked")
+    public DynamicService(T service) {
+        _clazz = (Class<T>) service.getClass();
+        _service = service;
+    }
+    
+    public OMElement invoke(String operation, OMElement payload) {
+        if (__log.isDebugEnabled())
+            __log.debug("Invoke: operation "+operation+" on "+_clazz + ":\n" + payload);
+
+        String methodName = operation;
+        try {
+            Method invokedMethod = findMethod(methodName);
+            Object[] params = extractParams(invokedMethod, payload);
+            Object result = invokedMethod.invoke(_service, params);
+            OMElement response = null;
+            if (result != null) {
+                response = OM.createOMElement(new QName(payload.getNamespace().getNamespaceURI(), methodName+"Response"));
+                OMElement parts = convertToOM(result);
+                parts = stripNamespace(parts);
+                response.addChild(parts);
+            }
+            if (__log.isDebugEnabled()) {
+                __log.debug("Response: operation "+operation+" on "+_clazz + ":\n" + response);
+            }
+            return response;
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException("Couldn't invoke method named " + methodName + " in management interface!", e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException("Invocation of method " + methodName + " in management interface failed!", e.getTargetException());
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private Object[] extractParams(Method method, OMElement omElmt) {
+        Class<?>[] paramTypes = method.getParameterTypes();
+        Object[] params = new Object[method.getParameterTypes().length];
+        Iterator<OMElement> omChildren = (Iterator<OMElement>) omElmt.getChildElements();
+        int paramIdx = 0;
+        for (Class<?> paramClass : paramTypes) {
+            OMElement omchild = (OMElement) omChildren.next();
+            __log.debug("Extracting param " + paramClass + " from " + omchild);
+            params[paramIdx++] = convertFromOM(paramClass, omchild);
+        }
+        return params;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static Object convertFromOM(Class<?> clazz, OMElement elmt) {
+        // Here comes the nasty code...
+        if (elmt == null || elmt.getText().length() == 0 && !elmt.getChildElements().hasNext())
+            return null;
+        else if (clazz.equals(String.class)) {
+            return elmt.getText();
+        } else if (clazz.equals(Boolean.class) || clazz.equals(Boolean.TYPE)) {
+            return (elmt.getText().equals("true") || elmt.getText().equals("yes")) ? Boolean.TRUE : Boolean.FALSE;
+        } else if (clazz.equals(QName.class)) {
+            // The getTextAsQName is buggy, it sometimes return the full text without extracting namespace
+            return OMUtils.getTextAsQName(elmt);
+        } else if (clazz.equals(ProcessInfoCustomizer.class)) {
+            return new ProcessInfoCustomizer(elmt.getText());
+        } else if (Node.class.isAssignableFrom(clazz)) {
+            return OMUtils.toDOM(elmt.getFirstElement());
+        } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) {
+            return Long.parseLong(elmt.getText());
+        } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) {
+            return Integer.parseInt(elmt.getText());
+        } else if (clazz.isArray()) {
+            ArrayList<Object> alist = new ArrayList<Object>();
+            Iterator<OMElement> children = elmt.getChildElements();
+            Class<?> targetClazz = clazz.getComponentType();
+            while (children.hasNext())
+                alist.add(parseType(targetClazz, ((OMElement)children.next()).getText()));
+            return alist.toArray((Object[]) Array.newInstance(targetClazz, alist.size()));
+        } else if (XmlObject.class.isAssignableFrom(clazz)) {
+            try {
+                Class beanFactory = Class.forName(clazz.getCanonicalName() + ".Factory");
+                return beanFactory.getMethod("parse", XMLStreamReader.class)
+                        .invoke(elmt.getXMLStreamReaderWithoutCaching());
+            } catch (ClassNotFoundException e) {
+                throw new RuntimeException("Couldn't find class " + clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
+            } catch (IllegalAccessException e) {
+                throw new RuntimeException("Couldn't access class " + clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
+            } catch (InvocationTargetException e) {
+                throw new RuntimeException("Couldn't access xml bean parse method on class " + clazz.getCanonicalName() + ".Factory " +
+                        "to instantiate xml bean", e);
+            } catch (NoSuchMethodException e) {
+                throw new RuntimeException("Couldn't find xml bean parse method on class " + clazz.getCanonicalName() + ".Factory " +
+                        "to instantiate xml bean", e);
+            }
+        } else throw new RuntimeException("Couldn't use element " + elmt + " to obtain a management method parameter.");
+    }
+
+    @SuppressWarnings("unchecked")
+    private static OMElement convertToOM(Object obj) {
+        if (obj instanceof XmlObject) {
+            try {
+                return new StAXOMBuilder(((XmlObject)obj).newInputStream()).getDocumentElement();
+            } catch (XMLStreamException e) {
+                throw new RuntimeException("Couldn't serialize result to an outgoing messages.", e);
+            }
+        } else if (obj instanceof List) {
+            OMElement listElmt = OM.createOMElement("list", null);
+            for (Object stuff : ((List) obj)) {
+                OMElement stuffElmt = OM.createOMElement("element", null);
+                stuffElmt.setText(stuff.toString());
+                listElmt.addChild(stuffElmt);
+            }
+            return listElmt;
+        } else throw new RuntimeException("Couldn't convert object " + obj + " into a response element.");
+    }
+
+    @SuppressWarnings("unchecked")
+    private static OMElement stripNamespace(OMElement element) {
+        OMElement parent = OM.createOMElement(new QName("", element.getLocalName()));
+        Iterator<OMElement> iter = (Iterator<OMElement>) element.getChildElements();
+        while (iter.hasNext()) {
+            OMElement child = iter.next();
+            child = child.cloneOMElement();
+            parent.addChild(child);
+        }
+        return parent;
+    }
+
+    private Method findMethod(String methodName) {
+        for (Method method : _clazz.getMethods()) {
+            if (method.getName().equals(methodName)) return method;
+        }
+        throw new RuntimeException("Couldn't find any method named " + methodName + " in interface " + _clazz.getName());
+    }
+
+    private static Object parseType(Class<?> clazz, String str) {
+        if (clazz.equals(Integer.class)) return Integer.valueOf(str);
+        if (clazz.equals(Float.class)) return Integer.valueOf(str);
+        if (clazz.equals(String.class)) return str;
+        return null;
+    }
+    
+}

Added: ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/OMUtils.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/OMUtils.java?rev=641075&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/OMUtils.java (added)
+++ ode/branches/APACHE_ODE_1.1/bpel-epr/src/main/java/org/apache/ode/il/OMUtils.java Tue Mar 25 16:23:44 2008
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ode.il;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.transform.Source;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.NSContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+
+/**
+ * Utility methods to convert from/to AxiOM and DOM.
+ */
+public class OMUtils {
+
+    public static Element toDOM(OMElement element) {
+        return toDOM(element, DOMUtils.newDocument());
+    }
+
+    public static Element toDOM(OMElement element, Document doc) { 
+        return toDOM(element,doc,true);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public static Element toDOM(OMElement element, Document doc, boolean deepNS) {
+        final Element domElement = doc.createElementNS(element.getQName().getNamespaceURI(), element.getQName().getLocalPart());
+
+        if (deepNS) {
+            NSContext nscontext = new NSContext();
+            buildNScontext(nscontext, element);
+            DOMUtils.injectNamespaces(domElement,nscontext);
+        } else {
+            if (element.getAllDeclaredNamespaces() != null) {
+                for (Iterator<OMNamespace> i = element.getAllDeclaredNamespaces(); i.hasNext(); ) {
+                    OMNamespace omns = i.next();
+                    if (omns.getPrefix().equals(""))
+                        domElement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns", omns.getNamespaceURI() == null ? "" : omns.getNamespaceURI());
+                    else
+                        domElement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:"+ omns.getPrefix(), omns.getNamespaceURI());
+                }
+    
+            }
+        }
+            
+        for (Iterator i = element.getAllAttributes(); i.hasNext();) {
+            final OMAttribute attr = (OMAttribute) i.next();
+            if (attr.getNamespace() != null)
+                domElement.setAttributeNS(attr.getNamespace().getNamespaceURI(), attr.getLocalName(), attr.getAttributeValue());
+            else
+                domElement.setAttributeNS(null,attr.getLocalName(), attr.getAttributeValue());
+                
+        }
+
+        for (Iterator<OMNode> i = element.getChildren(); i.hasNext();) {
+            OMNode omn = i.next();
+
+            switch (omn.getType()) {
+            case OMNode.CDATA_SECTION_NODE:
+                domElement.appendChild(doc.createCDATASection(((OMText)omn).getText()));
+                break;
+            case OMNode.TEXT_NODE:
+                domElement.appendChild(doc.createTextNode(((OMText)omn).getText()));
+                break;
+            case OMNode.ELEMENT_NODE:
+                domElement.appendChild(toDOM((OMElement)omn,doc, false));
+                break;
+            }
+            
+        }
+        
+        return domElement;
+        
+    }
+
+    @SuppressWarnings("unchecked")
+    private static void buildNScontext(NSContext nscontext, OMElement element) {
+        if (element == null)
+            return;
+        
+        if (element.getParent() instanceof OMElement)
+            buildNScontext(nscontext, (OMElement) element.getParent());
+        
+        if (element.getAllDeclaredNamespaces() != null)
+            for (Iterator<OMNamespace> i=element.getAllDeclaredNamespaces(); i.hasNext(); ){
+                OMNamespace omn = i.next();
+                nscontext.register(omn.getPrefix(), omn.getNamespaceURI());
+            }
+        
+        if (element.getDefaultNamespace() != null)
+            nscontext.register("", element.getDefaultNamespace().getNamespaceURI());
+    }
+
+    public static OMElement toOM(Element src, OMFactory omf) {
+        return toOM(src,omf,null);
+    }
+
+    public static OMElement toOM(Element src, OMFactory omf, OMContainer parent) {
+        OMNamespace elns = null;
+        if (src.getNamespaceURI() != null) {
+            elns = omf.createOMNamespace(src.getNamespaceURI(), src.getPrefix());
+        }
+        OMElement omElement = parent == null ? omf.createOMElement(src.getLocalName(),elns) :
+        omf.createOMElement(src.getLocalName(),elns,parent);
+        
+        if (parent == null) {
+            NSContext nscontext = DOMUtils.getMyNSContext(src);
+            injectNamespaces(omElement,nscontext.toMap());
+        } else {
+            Map<String,String> nss = DOMUtils.getMyNamespaces(src);
+            injectNamespaces(omElement, nss);
+        }
+        
+        NamedNodeMap attrs = src.getAttributes();
+        for (int i = 0; i <attrs.getLength(); ++i) {
+            Attr attr = (Attr)attrs.item(i);
+            if (attr.getLocalName().equals("xmlns") 
+                    || (attr.getNamespaceURI() != null && attr.getNamespaceURI().equals(DOMUtils.NS_URI_XMLNS)))
+                continue;
+            OMNamespace attrOmNs = null;
+            String attrNs = attr.getNamespaceURI();
+            String attrPrefix = attr.getPrefix();
+            if (attrNs != null)
+                attrOmNs = omElement.findNamespace(attrNs,null);
+            if (attrOmNs == null && attrPrefix != null)
+                attrOmNs = omElement.findNamespace(null, attrPrefix);
+            omElement.addAttribute(attr.getLocalName(), attr.getValue(), attrOmNs);
+        }
+
+        NodeList children = src.getChildNodes();
+        for (int i = 0 ; i < children.getLength(); ++i) {
+            Node n = children.item(i);
+
+            switch (n.getNodeType()) {
+            case Node.CDATA_SECTION_NODE:
+                omElement.addChild(omf.createOMText(((CDATASection)n).getTextContent(),XMLStreamConstants.CDATA));
+                break;
+            case Node.TEXT_NODE:
+                omElement.addChild(omf.createOMText(((Text)n).getTextContent(),XMLStreamConstants.CHARACTERS));
+                break;
+            case Node.ELEMENT_NODE:
+                toOM((Element)n,omf,omElement);
+                break;
+            }
+            
+        }
+        
+        return omElement;
+    }
+
+
+    private static void injectNamespaces(OMElement omElement, Map<String,String> nscontext) {
+        for (String prefix : nscontext.keySet()) {
+            String uri = nscontext.get(prefix);
+            if (prefix.equals(""))
+                omElement.declareDefaultNamespace(uri);
+            else
+                omElement.declareNamespace(uri, prefix);
+        }
+    }
+
+    /**
+     * Axiom is supposed to handle this properly however this method is buggy and doesn't work (whereas setting a QName as text
+     * works).
+     * 
+     * @param elmt
+     * @return text qname
+     */
+    public static QName getTextAsQName(OMElement elmt) {
+        QName qname = elmt.getTextAsQName();
+        // The getTextAsQName is buggy, it sometimes return the full text without extracting namespace
+        if (qname.getNamespaceURI().length() == 0) {
+            int colonIdx = elmt.getText().indexOf(":");
+            String localpart = elmt.getText().substring(colonIdx + 1, elmt.getText().length());
+            String prefix = elmt.getText().substring(0, colonIdx);
+            String ns = elmt.findNamespaceURI(prefix).getNamespaceURI();
+            qname = new QName(ns, localpart, prefix);
+        }
+        return qname;
+    }
+
+    /**
+     * Parse an XML document located using an {@link InputSource} using the
+     * pooled document builder.
+     */
+    public static OMElement toOM(Source inputSource) throws IOException {
+        Document doc = DOMUtils.sourceToDOM(inputSource);
+        return toOM(doc.getDocumentElement(), OMAbstractFactory.getOMFactory());
+    }
+
+}

Added: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/BaseMessageExchangeProcessor.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/BaseMessageExchangeProcessor.java?rev=641075&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/BaseMessageExchangeProcessor.java (added)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/BaseMessageExchangeProcessor.java Tue Mar 25 16:23:44 2008
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ode.jbi;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base message exchange processor; handles common JBI message exchange conditions and delegates
+ * actual invocation to subclass.
+ */
+public abstract class BaseMessageExchangeProcessor implements JbiMessageExchangeProcessor {
+    final Log LOG = LogFactory.getLog(getClass());
+
+    DeliveryChannel _channel;
+    
+    public BaseMessageExchangeProcessor(DeliveryChannel channel) {
+        _channel = channel;
+    }
+
+    /**
+     * Handle the JBI message exchange
+     */
+    public void onJbiMessageExchange(MessageExchange jbiMex) throws MessagingException {
+        if (jbiMex.getStatus() == ExchangeStatus.DONE) {
+            // everything went right, nothing to do
+            return;
+        }
+        if (jbiMex.getStatus() == ExchangeStatus.ERROR) {
+            LOG.error("Error reported for JBI mex "+jbiMex, jbiMex.getError());
+            return;
+        }
+
+        if (jbiMex.getPattern().equals(MessageExchangePattern.IN_ONLY)) {
+            boolean success = false;
+            Exception err = null;
+            try {
+                invoke((InOnly) jbiMex);
+                success = true;
+            } catch (Exception ex) {
+                LOG.error("Error invoking "+getClass(), ex);
+                err = ex;
+            } finally {
+                if (!success) {
+                    jbiMex.setStatus(ExchangeStatus.ERROR);
+                    if (err != null && jbiMex.getError() == null)
+                        jbiMex.setError(err);
+                } else {
+                    if (jbiMex.getStatus() == ExchangeStatus.ACTIVE)
+                        jbiMex.setStatus(ExchangeStatus.DONE);
+                }
+                _channel.send(jbiMex);
+            }
+        } else if (jbiMex.getPattern().equals(MessageExchangePattern.IN_OUT)) {
+            InOut mex = (InOut) jbiMex;
+            boolean success = false;
+            Exception err = null;
+            try {
+                NormalizedMessage response = invoke(mex);
+                mex.setOutMessage(response);
+                _channel.send(jbiMex);
+                success = true;
+            } catch (Exception ex) {
+                LOG.error("Error invoking "+getClass(), ex);
+                err = ex;
+            } catch (Throwable t) {
+                LOG.error("Unexpected error invoking ODE.", t);
+                err = new RuntimeException(t);
+            } finally {
+                // If we got an error that wasn't sent.  
+                if (jbiMex.getStatus() == ExchangeStatus.ACTIVE && !success) {
+                    if (err != null && jbiMex.getError() == null)  {
+                        jbiMex.setError(err);
+                    }
+                    jbiMex.setStatus(ExchangeStatus.ERROR);     
+                    _channel.send(jbiMex);
+                }       
+            }
+        } else {
+            LOG.error("JBI MessageExchange " + jbiMex.getExchangeId() + " is of an unsupported pattern "
+                    + jbiMex.getPattern());
+            jbiMex.setStatus(ExchangeStatus.ERROR);
+            jbiMex.setError(new Exception("Unknown message exchange pattern: " + jbiMex.getPattern()));
+        }
+
+    }
+
+    /**
+     * Invoke with an In-Out message exchange pattern. 
+     */
+    public abstract NormalizedMessage invoke(InOut mex) throws MessagingException;
+
+    /**
+     * Invoke with an In-Only message exchange pattern.
+     */
+    public abstract void invoke(InOnly mex) throws MessagingException;
+    
+}

Added: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/DynamicMessageExchangeProcessor.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/DynamicMessageExchangeProcessor.java?rev=641075&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/DynamicMessageExchangeProcessor.java (added)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/DynamicMessageExchangeProcessor.java Tue Mar 25 16:23:44 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ode.jbi;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.ode.il.DynamicService;
+import org.apache.ode.il.OMUtils;
+
+/**
+ * JBI message exchange processor that uses {@link DynamicService} for reflection-based method
+ * dispatch.
+ */
+public class DynamicMessageExchangeProcessor<T> extends BaseMessageExchangeProcessor {
+
+    T _service;
+    
+    public DynamicMessageExchangeProcessor(T service, DeliveryChannel channel) {
+        super(channel);
+        _service = service;
+    }
+
+    @Override
+    public void invoke(InOnly mex) throws MessagingException {
+        try {
+            DynamicService<T> service = new DynamicService<T>(_service);
+            OMElement payload = OMUtils.toOM(mex.getInMessage().getContent());
+            service.invoke(mex.getOperation().getLocalPart(), payload);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public NormalizedMessage invoke(InOut mex) throws MessagingException {
+        try {
+            DynamicService<T> service = new DynamicService<T>(_service);
+            OMElement payload = OMUtils.toOM(mex.getInMessage().getContent());
+            OMElement response = service.invoke(mex.getOperation().getLocalPart(), payload);
+            NormalizedMessage nresponse = null;
+            if (response != null) {
+                nresponse = mex.createMessage();
+                nresponse.setContent(new DOMSource(OMUtils.toDOM(response)));
+            }
+            return nresponse;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/JbiMessageExchangeEventRouter.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/JbiMessageExchangeEventRouter.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/JbiMessageExchangeEventRouter.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/JbiMessageExchangeEventRouter.java Tue Mar 25 16:23:44 2008
@@ -21,34 +21,55 @@
 
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
+import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.iapi.Endpoint;
 
+/**
+ * Route incoming JBI messages to Ode services
+ */
 class JbiMessageExchangeEventRouter implements JbiMessageExchangeProcessor {
-  private static final Log __log = LogFactory.getLog(JbiMessageExchangeEventRouter.class);
-  
-  private OdeContext _ode;
-  
-  JbiMessageExchangeEventRouter(OdeContext ode) {
-    _ode = ode;
-  }
-  
-  public void onJbiMessageExchange(MessageExchange mex) throws MessagingException {
-    if (mex.getRole().equals(javax.jbi.messaging.MessageExchange.Role.CONSUMER)) {
-      _ode._consumer.onJbiMessageExchange(mex);
-    } else if (mex.getRole().equals(javax.jbi.messaging.MessageExchange.Role.PROVIDER)) {
-      OdeService svc = _ode.getService(new Endpoint(mex.getEndpoint().getServiceName(), mex.getEndpoint().getEndpointName()));
-      if (svc == null)  {
-        __log.error("Received message exchange for unknown service: " + mex.getEndpoint().getServiceName());
-        return;
-      }
-      svc.onJbiMessageExchange(mex);
-    } else {
-      __log.debug("unexpected role: " + mex.getRole());
+    private static final Log __log = LogFactory.getLog(JbiMessageExchangeEventRouter.class);
+
+    private OdeContext _ode;
+
+    JbiMessageExchangeEventRouter(OdeContext ode) {
+        _ode = ode;
+    }
+
+    public void onJbiMessageExchange(MessageExchange mex) throws MessagingException {
+        if (mex.getRole().equals(javax.jbi.messaging.MessageExchange.Role.CONSUMER)) {
+            _ode._consumer.onJbiMessageExchange(mex);
+        } else if (mex.getRole().equals(javax.jbi.messaging.MessageExchange.Role.PROVIDER)) {
+
+            if (OdeContext.PM_SERVICE_NAME.equals(mex.getEndpoint().getServiceName())) {
+                if (_ode._processManagementProcessor == null)
+                    throw new IllegalStateException("Process Management API not initialized");
+                _ode._processManagementProcessor.onJbiMessageExchange(mex);
+                return;
+            }
+
+            if (OdeContext.IM_SERVICE_NAME.equals(mex.getEndpoint().getServiceName())) {
+                if (_ode._instanceManagementProcessor == null)
+                    throw new IllegalStateException("Instance Management API not initialized");
+                _ode._instanceManagementProcessor.onJbiMessageExchange(mex);
+                return;
+            }
+            
+            Endpoint endpoint = new Endpoint(mex.getEndpoint().getServiceName(), mex.getEndpoint().getEndpointName());
+            OdeService svc = _ode.getService(endpoint);
+            if (svc == null) {
+                __log.error("Received message exchange for unknown service: " + mex.getEndpoint().getServiceName());
+                return;
+            }
+            svc.onJbiMessageExchange(mex);
+        } else {
+            __log.debug("unexpected role: " + mex.getRole());
+        }
+
     }
-   
-  }
 
 }
+

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeComponent.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeComponent.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeComponent.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeComponent.java Tue Mar 25 16:23:44 2008
@@ -28,7 +28,7 @@
 import org.w3c.dom.DocumentFragment;
 
 /**
- * This class implements javax.jbi.component.Component interface.
+ * This class implements {@link javax.jbi.component.Component} interface.
  */
 public class OdeComponent implements Component {
 	private OdeLifeCycle _lifeCycle;
@@ -47,11 +47,10 @@
 
 	/**
 	 * 
-	 * @param ref
-	 *          ServiceEndpoint object                       
+     * @param ref ServiceEndpoint object
 	 * 
-	 * @return Descriptor Object implementing javax.jbi.servicedesc.Descriptor
-	 *         interface.
+     * @return Descriptor Object implementing
+     *         {@link javax.jbi.servicedesc.Descriptor} interface.
 	 */
 	public Document getServiceDescription(ServiceEndpoint ref) {
 		return  _lifeCycle.getOdeContext().getServiceDescription(ref.getServiceName());
@@ -96,7 +95,7 @@
 	 * 
 	 * @param exchange
 	 *          the proposed message exchange to be performed
-	 * @return true if this consurer component can interact with the described
+     * @return true if this consumer component can interact with the described
 	 *         provider to perform the given exchange
 	 */
 	public boolean isExchangeWithProviderOkay(ServiceEndpoint endpoint, MessageExchange exchange) {

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java Tue Mar 25 16:23:44 2008
@@ -24,9 +24,11 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 
+import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.messaging.DeliveryChannel;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
 import javax.sql.DataSource;
 import javax.transaction.TransactionManager;
 import javax.wsdl.Definition;
@@ -38,11 +40,14 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
 import org.apache.ode.bpel.engine.BpelServerImpl;
+import org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl;
 import org.apache.ode.bpel.iapi.Endpoint;
 import org.apache.ode.bpel.iapi.ProcessConf;
 import org.apache.ode.bpel.o.OPartnerLink;
 import org.apache.ode.bpel.o.OProcess;
 import org.apache.ode.bpel.o.Serializer;
+import org.apache.ode.bpel.pmapi.InstanceManagement;
+import org.apache.ode.bpel.pmapi.ProcessManagement;
 import org.apache.ode.jbi.msgmap.Mapper;
 import org.apache.ode.jbi.util.WSDLFlattener;
 import org.apache.ode.scheduler.simple.SimpleScheduler;
@@ -55,9 +60,14 @@
  * @author mszefler
  */
 final class OdeContext {
-
     private static final Log __log = LogFactory.getLog(OdeContext.class);
 
+    public static final QName PM_SERVICE_NAME = new QName("http://www.apache.org/ode/pmapi", "ProcessManagementService");
+    public static final String PM_PORT_NAME = "ProcessManagementPort";
+
+    public static final QName IM_SERVICE_NAME = new QName("http://www.apache.org/ode/pmapi", "InstanceManagementService");
+    public static final String IM_PORT_NAME = "InstanceManagementPort";
+    
     /** static singleton */
     private static OdeContext __self;
 
@@ -65,7 +75,7 @@
 
     private Map<QName, Document> _descriptorCache = new ConcurrentHashMap<QName, Document>();
 
-    /** Ordered list of messsage mappers. */
+    /** Ordered list of message mappers */
     private ArrayList<Mapper> _mappers = new ArrayList<Mapper>();
 
     /** Mapper by class name. */
@@ -93,6 +103,15 @@
 
     ProcessStoreImpl _store;
 
+    ServiceEndpoint _processManagementEndpoint;    
+    ServiceEndpoint _instanceManagementEndpoint;
+
+    JbiMessageExchangeProcessor _processManagementProcessor;    
+    JbiMessageExchangeProcessor _instanceManagementProcessor;
+
+    ProcessManagement _processManagement;
+    InstanceManagement _instanceManagement;
+
     /** Mapping of Endpoint to OdeService */
     private Map<Endpoint, OdeService> _activeOdeServices = new ConcurrentHashMap<Endpoint, OdeService>();
 
@@ -249,5 +268,32 @@
 
     public Mapper getDefaultMapper() {
         return _mappers.get(0);
+    }
+    
+    void activatePMAPIs() throws JBIException {
+        ProcessAndInstanceManagementImpl pm = new ProcessAndInstanceManagementImpl(_server, _store);
+        _processManagement = pm;
+        _instanceManagement = pm;
+        _processManagementEndpoint = getContext().activateEndpoint(PM_SERVICE_NAME, PM_PORT_NAME);
+        _instanceManagementEndpoint = getContext().activateEndpoint(IM_SERVICE_NAME, IM_PORT_NAME);
+        _processManagementProcessor = new DynamicMessageExchangeProcessor<ProcessManagement>(pm, getChannel());
+        _instanceManagementProcessor = new DynamicMessageExchangeProcessor<InstanceManagement>(pm, getChannel());
+    }
+
+    void deactivatePMAPIs() throws JBIException {
+        if (_processManagementEndpoint != null) {
+            try {
+                getContext().deactivateEndpoint(_processManagementEndpoint);
+            } catch (Exception e) {
+                __log.error("Error deactivating ProcessManagement service", e);
+            }
+        }
+        if (_instanceManagementEndpoint != null) {
+            try {
+                getContext().deactivateEndpoint(_instanceManagementEndpoint);
+            } catch (Exception e) {
+                __log.error("Error deactivating InstanceManagement service", e);
+            }
+        }
     }
 }

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java Tue Mar 25 16:23:44 2008
@@ -29,7 +29,6 @@
 import javax.jbi.component.ComponentLifeCycle;
 import javax.jbi.component.ServiceUnitManager;
 import javax.management.ObjectName;
-import javax.naming.InitialContext;
 import javax.transaction.TransactionManager;
 
 import org.apache.commons.logging.Log;
@@ -122,6 +121,9 @@
             __log.debug("Starting JCA connector.");
             initConnector();
 
+            __log.debug("Register ProcessManagement APIs");
+            _ode.activatePMAPIs();
+
             _suManager = new OdeSUManager(_ode);
             _initSuccess = true;
             __log.info(__msgs.msgOdeInitialized());
@@ -132,10 +134,11 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     private void initMappers() throws JBIException {
-        Class mapperClass;
+        Class<Mapper> mapperClass;
         try {
-            mapperClass = Class.forName(_ode._config.getMessageMapper());
+            mapperClass = (Class<Mapper>) Class.forName(_ode._config.getMessageMapper());
         } catch (ClassNotFoundException e) {
             String errmsg = __msgs.msgOdeInitMapperClassNotFound(_ode._config.getMessageMapper());
             __log.error(errmsg);
@@ -222,7 +225,6 @@
 	_ode._server.setConfigProperties(_ode._config.getProperties());
 
         _ode._server.init();
-
     }
 
     /**
@@ -377,6 +379,8 @@
         ClassLoader old = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
 
+        _ode.deactivatePMAPIs();
+        
         if (_connector != null) {
             try {
                 _connector.shutdown();
@@ -413,30 +417,6 @@
         } finally {
             Thread.currentThread().setContextClassLoader(old);
         }
-    }
-
-    @SuppressWarnings("unchecked")
-    private <T> T lookupInJndi(String objName) throws Exception {
-        ClassLoader old = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-        try {
-            InitialContext ctx = null;
-            try {
-                ctx = new InitialContext();
-                return (T) ctx.lookup(objName);
-            } finally {
-                if (ctx != null)
-                    try {
-                        ctx.close();
-                    } catch (Exception ex1) {
-                        ; // swallow
-                        __log.error("Error closing JNDI connection.", ex1);
-                    }
-            }
-        } finally {
-            Thread.currentThread().setContextClassLoader(old);
-        }
-
     }
 
 }

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeSUManager.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeSUManager.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeSUManager.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeSUManager.java Tue Mar 25 16:23:44 2008
@@ -49,13 +49,10 @@
     _ode = odeContext;
   }
 
-  public synchronized String deploy(String serviceUnitID,
-      String serviceUnitRootPath) throws DeploymentException {
-    __log
-        .trace("deploy: id=" + serviceUnitID + ", path=" + serviceUnitRootPath);
+    public synchronized String deploy(String serviceUnitID, String serviceUnitRootPath) throws DeploymentException {
+        __log.trace("deploy: id=" + serviceUnitID + ", path=" + serviceUnitRootPath);
 
-    OdeServiceUnit su = new OdeServiceUnit(_ode, serviceUnitID,
-        serviceUnitRootPath);
+        OdeServiceUnit su = new OdeServiceUnit(_ode, serviceUnitID, serviceUnitRootPath);
     try {
       su.deploy();
     } catch (Exception ex) {
@@ -67,19 +64,16 @@
 
   }
 
-  public synchronized void init(String serviceUnitID, String serviceUnitRootPath)
-      throws DeploymentException {
+    public synchronized void init(String serviceUnitID, String serviceUnitRootPath) throws DeploymentException {
     __log.trace("init called for " + serviceUnitID);
 
     if (_serviceUnits.containsKey(serviceUnitID)) {
-      __log.debug("odd, init() called for su " + serviceUnitID
-          + ", but it is already init()ed");
+            __log.debug("odd, init() called for su " + serviceUnitID + ", but it is already init()ed");
       return;
     }
 
     try {
-      OdeServiceUnit su = new OdeServiceUnit(_ode, serviceUnitID,
-          serviceUnitRootPath);
+            OdeServiceUnit su = new OdeServiceUnit(_ode, serviceUnitID, serviceUnitRootPath);
       su.init();
       _serviceUnits.put(serviceUnitID, su);
     } catch (Exception ex) {
@@ -89,8 +83,7 @@
     }
   }
 
-  public synchronized void shutDown(String serviceUnitID)
-      throws DeploymentException {
+    public synchronized void shutDown(String serviceUnitID) throws DeploymentException {
     __log.trace("shutDown called for " + serviceUnitID);
 
     OdeServiceUnit su = _serviceUnits.remove(serviceUnitID);
@@ -106,8 +99,7 @@
     }
   }
 
-  public synchronized void start(String serviceUnitID)
-      throws DeploymentException {
+    public synchronized void start(String serviceUnitID) throws DeploymentException {
     __log.trace("start called for " + serviceUnitID);
 
     OdeServiceUnit su = _serviceUnits.get(serviceUnitID);
@@ -140,8 +132,7 @@
    * @throws DeploymentException
    *           deployment exception
    */
-  public synchronized void stop(String serviceUnitID)
-      throws DeploymentException {
+    public synchronized void stop(String serviceUnitID) throws DeploymentException {
     __log.trace("stop called for " + serviceUnitID);
 
     OdeServiceUnit su = _serviceUnits.get(serviceUnitID);
@@ -177,13 +168,10 @@
    * @throws DeploymentException
    *           deployment exception
    */
-  public synchronized String undeploy(String serviceUnitID,
-      String serviceUnitRootPath) throws DeploymentException {
-    __log
-        .trace("undeploy: id=" + serviceUnitID + ", path=" + serviceUnitRootPath);
+    public synchronized String undeploy(String serviceUnitID, String serviceUnitRootPath) throws DeploymentException {
+        __log.trace("undeploy: id=" + serviceUnitID + ", path=" + serviceUnitRootPath);
 
-    OdeServiceUnit su = new OdeServiceUnit(_ode, serviceUnitID,
-        serviceUnitRootPath);
+        OdeServiceUnit su = new OdeServiceUnit(_ode, serviceUnitID, serviceUnitRootPath);
 
     try {
       su.undeploy();
@@ -237,8 +225,7 @@
     doc.appendChild(elem);
     Element compNameElem = doc.createElement("component-name");
     elem.appendChild(compNameElem);
-    Element compTaskRsltDtlsElem = doc
-        .createElement("component-task-result-details");
+        Element compTaskRsltDtlsElem = doc.createElement("component-task-result-details");
     elem.appendChild(compTaskRsltDtlsElem);
     Element taskRsltDtlsElem = doc.createElement("task-result-details");
     compTaskRsltDtlsElem.appendChild(taskRsltDtlsElem);
@@ -251,8 +238,7 @@
 
     // Why do I have to tell this thing the component name? It /knows/ the
     // component name....
-    compNameElem.appendChild(doc.createTextNode(_ode.getContext()
-        .getComponentName()));
+        compNameElem.appendChild(doc.createTextNode(_ode.getContext().getComponentName()));
 
     // And why on earth do I have to tell my caller the method he just
     // called?

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeService.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeService.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/OdeService.java Tue Mar 25 16:23:44 2008
@@ -177,7 +177,7 @@
      * {@link MessageExchangeContextImpl#onAsyncReply(MyRoleMessageExchange)}
      * 
      * @param mex
-     *            message exchenge
+     *            message exchange
      */
     public void onResponse(MyRoleMessageExchange mex) {
         __log.debug("Consuming MEX tracker " + mex.getClientId());

Modified: ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/Receiver.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/Receiver.java?rev=641075&r1=641074&r2=641075&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/Receiver.java (original)
+++ ode/branches/APACHE_ODE_1.1/jbi/src/main/java/org/apache/ode/jbi/Receiver.java Tue Mar 25 16:23:44 2008
@@ -85,7 +85,7 @@
 
     /**
      * This is called to gracefully stop the Receiver thread. After shutting down the thread pool we wait for a maximum
-     * of 10 seconds before forcefully cancelling in-flight threads.
+     * of 10 seconds before forcefully canceling in-flight threads.
      */
     public void cease() {
 
@@ -120,7 +120,7 @@
                 // make sure no outstanding threads are hanging around
                 if (!_executorService.awaitTermination(THREADPOOL_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
                     __log.warn("Problem shutting down ExecutorService - trying harder.");
-                    List outstanding = _executorService.shutdownNow();
+                    List<Runnable> outstanding = _executorService.shutdownNow();
                     if (outstanding != null && !outstanding.isEmpty()) {
                         __log.warn("Cancelled " + outstanding.size() + " in-flight threads.");
                     }