Author: mriou
Date: Tue Aug 22 15:35:38 2006
New Revision: 433782

URL: http://svn.apache.org/viewvc?rev=433782&view=rev
Log:
ODE-36 Provides a way to list deployed packages and check which processes are 
in there. With tests (yoohoo!). Also refactored a bit the deployment service to 
be more in line with existing management service and the IAPI. Added a 
DeploymentService interface in IAPI.

Added:
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
      - copied, changed from r433395, 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentService.java
    
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/DeploymentService.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentServiceImpl.java
Removed:
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentService.java
Modified:
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/OMUtils.java
    incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl
    
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
    
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelServer.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java 
(original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java 
Tue Aug 22 15:35:38 2006
@@ -30,7 +30,7 @@
 import org.apache.ode.axis2.deploy.DeploymentPoller;
 import org.apache.ode.axis2.hooks.ODEAxisService;
 import org.apache.ode.axis2.hooks.ODEMessageReceiver;
-import org.apache.ode.axis2.service.DeploymentService;
+import org.apache.ode.axis2.service.DeploymentWebService;
 import org.apache.ode.axis2.service.ManagementService;
 import org.apache.ode.bpel.connector.BpelServerConnector;
 import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
@@ -137,7 +137,7 @@
     __log.info(__msgs.msgPollingStarted(deploymentDir.getAbsolutePath()));
 
     new ManagementService().enableService(_axisConfig, _server, 
_appRoot.getAbsolutePath());
-    new DeploymentService().enableService(_axisConfig, _server, _poller, 
_appRoot.getAbsolutePath());
+    new DeploymentWebService().enableService(_axisConfig, _server, _poller, 
_appRoot.getAbsolutePath());
 
     __log.info(__msgs.msgOdeStarted());
   }

Copied: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
 (from r433395, 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentService.java)
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java?p2=incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java&p1=incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentService.java&r1=433395&r2=433782&rev=433782&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
 Tue Aug 22 15:35:38 2006
@@ -19,57 +19,56 @@
 
 package org.apache.ode.axis2.service;
 
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.receivers.AbstractMessageReceiver;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.util.Utils;
-import org.apache.ode.bpel.iapi.BpelServer;
-import org.apache.ode.bpel.iapi.DeploymentUnit;
-import org.apache.ode.axis2.hooks.ODEAxisService;
-import org.apache.ode.axis2.deploy.DeploymentPoller;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMText;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+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.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+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.DeploymentService;
 
+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 javax.activation.DataHandler;
-import java.io.IOException;
-import java.io.File;
 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.zip.ZipInputStream;
 import java.util.zip.ZipEntry;
-import java.util.Iterator;
+import java.util.zip.ZipInputStream;
 
 /**
  * Axis wrapper for process deployment.
  */
-public class DeploymentService {
+public class DeploymentWebService {
 
-    private static final Log __log = 
LogFactory.getLog(DeploymentService.class);
+    private static final Log __log = 
LogFactory.getLog(DeploymentWebService.class);
 
-    private BpelServer _server;
+    private DeploymentService _service;
     private File _deployPath;
     private DeploymentPoller _poller;
 
     public void enableService(AxisConfiguration axisConfig, BpelServer server,
                               DeploymentPoller poller, String rootpath) {
-        _server = server;
         _deployPath = new File(rootpath, "processes");
+        _service = server.getDeploymentService();
 
         Definition def;
         try {
@@ -88,55 +87,96 @@
     }
 
     class DeploymentMessageReceiver extends AbstractMessageReceiver {
+
         public void receive(MessageContext messageContext) throws AxisFault {
-            if 
(messageContext.getAxisOperation().getName().getLocalPart().equals("deploy")) {
-                OMElement namePart = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
-                OMElement zipPart = (OMElement) namePart.getNextOMSibling();
-                OMElement zip = zipPart.getFirstElement();
-                if (!zipPart.getQName().getLocalPart().equals("package") ||
-                        !zip.getQName().getLocalPart().equals("zip"))
-                    throw new AxisFault("Your message should contain a part 
named 'package' with a zip element");
-
-                OMText binaryNode = (OMText) zip.getFirstOMChild();
-                binaryNode.setOptimize(true);
-                try {
-                    // We're going to create a directory under the deployment 
root and put
-                    // files in there. The poller shouldn't pick them up so 
we're asking
-                    // it to hold on for a while.
-                    _poller.hold();
-                    File dest = new File(_deployPath, namePart.getText());
-                    dest.mkdir();
-                    unzip(dest, (DataHandler) binaryNode.getDataHandler());
-
-                    _server.deploy(dest);
-                    // Telling the poller what we deployed so that it doesn't 
try to deploy it again
-                    _poller.markAsDeployed(dest);
-                    __log.info("Deployment of artifact " + dest.getName() + " 
successful.");
-                    sendResponse(messageContext, "deployResponse", true);
-                } finally {
-                    _poller.release();
-                }
-            } else if 
(messageContext.getAxisOperation().getName().getLocalPart().equals("undeploy")) 
{
-                OMElement part = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
+            String operation = 
messageContext.getAxisOperation().getName().getLocalPart();
+            SOAPFactory factory = getSOAPFactory(messageContext);
+            OMNamespace depns = 
factory.createOMNamespace("http://www.apache.org/ode/pmapi","deployapi";);
+            boolean unknown = false;
 
-                String elmtStr = part.getText();
-                File deploymentDir = new File(_deployPath, elmtStr);
-                if (!deploymentDir.exists())
-                    throw new AxisFault("Couldn't find deployment package " + 
elmtStr + " in directory " + _deployPath);
-
-                try {
-                    // We're going to create a directory under the deployment 
root and put
-                    // files in there. The poller shouldn't pick them up so 
we're asking
-                    // it to hold on for a while.
-                    _poller.hold();
-                    boolean result = _server.undeploy(deploymentDir);
-                    sendResponse(messageContext, "undeployResponse", result);
-                    _poller.markAsUndeployed(deploymentDir);
-                } finally {
-                    _poller.release();
-                }
-            } else
-                throw new AxisFault("Unknown operation: '" + 
messageContext.getAxisOperation().getName() + "'");
+            try {
+                if (operation.equals("deploy")) {
+                    OMElement namePart = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
+                    OMElement zipPart = (OMElement) 
namePart.getNextOMSibling();
+                    OMElement zip = zipPart.getFirstElement();
+                    if (!zipPart.getQName().getLocalPart().equals("package") ||
+                            !zip.getQName().getLocalPart().equals("zip"))
+                        throw new AxisFault("Your message should contain a 
part named 'package' with a zip element");
+
+                    OMText binaryNode = (OMText) zip.getFirstOMChild();
+                    binaryNode.setOptimize(true);
+                    try {
+                        // We're going to create a directory under the 
deployment root and put
+                        // files in there. The poller shouldn't pick them up 
so we're asking
+                        // it to hold on for a while.
+                        _poller.hold();
+                        File dest = new File(_deployPath, namePart.getText());
+                        dest.mkdir();
+                        unzip(dest, (DataHandler) binaryNode.getDataHandler());
+
+                        _service.deploy(dest);
+                        // Telling the poller what we deployed so that it 
doesn't try to deploy it again
+                        _poller.markAsDeployed(dest);
+                        __log.info("Deployment of artifact " + dest.getName() 
+ " successful.");
+
+                        OMElement response = 
factory.createOMElement("response", depns);
+                        response.setText("true");
+                        sendResponse(factory, messageContext, 
"deployResponse", response);
+                    } finally {
+                        _poller.release();
+                    }
+                } else if (operation.equals("undeploy")) {
+                    OMElement part = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
+
+                    String elmtStr = part.getText();
+                    File deploymentDir = new File(_deployPath, elmtStr);
+                    if (!deploymentDir.exists())
+                        throw new AxisFault("Couldn't find deployment package 
" + elmtStr + " in directory " + _deployPath);
+
+                    try {
+                        // We're going to create a directory under the 
deployment root and put
+                        // files in there. The poller shouldn't pick them up 
so we're asking
+                        // it to hold on for a while.
+                        _poller.hold();
+                        boolean result = _service.undeploy(deploymentDir);
+                        OMElement response = 
factory.createOMElement("response", depns);
+                        response.setText("" + result);
+                        sendResponse(factory, messageContext, 
"undeployResponse", response);
+                        _poller.markAsUndeployed(deploymentDir);
+                    } finally {
+                        _poller.release();
+                    }
+                } else if (operation.equals("listDeployedPackages")) {
+                    String[] packageNames = _service.listDeployedPackages();
+                    OMElement response = 
factory.createOMElement("deployedPackages", depns);
+                    for (String name : packageNames) {
+                        OMElement nameElmt = factory.createOMElement("name", 
depns);
+                        nameElmt.setText(name);
+                        response.addChild(nameElmt);
+                    }
+                    sendResponse(factory, messageContext, 
"listDeployedPackagesResponse", response);
+                } else if (operation.equals("listProcesses")) {
+                    OMElement namePart = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
+                    QName[] processIds = 
_service.listProcesses(namePart.getText());
+                    OMElement response = factory.createOMElement("processIds", 
depns);
+                    for (QName qname : processIds) {
+                        OMElement nameElmt = factory.createOMElement("id", 
depns);
+                        nameElmt.setText(qname);
+                        response.addChild(nameElmt);
+                    }
+                    sendResponse(factory, messageContext, 
"listProcessResponse", response);
+                } else if (operation.equals("getProcessPackage")) {
+                    OMElement qnamePart = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
+                    String packageName = 
_service.getProcessPackage(OMUtils.getTextAsQName(qnamePart));
+                    OMElement response = 
factory.createOMElement("packageName", depns);
+                    response.setText(packageName);
+                    sendResponse(factory, messageContext, 
"getProcessPackageResponse", response);
+                } else unknown = true;
+            } catch (Throwable t) {
+                throw new AxisFault("Invokcation of operation " + operation + 
" failed!", t);
+            }
+            if (unknown) throw new AxisFault("Unknown operation: '"
+                    + messageContext.getAxisOperation().getName() + "'");
         }
 
         private void unzip(File dest, DataHandler dataHandler) throws 
AxisFault {
@@ -161,19 +201,17 @@
             }
         }
 
-        private void sendResponse(MessageContext messageContext, String op, 
boolean result) throws AxisFault {
+        private void sendResponse(SOAPFactory factory, MessageContext 
messageContext, String op,
+                                  OMElement response) throws AxisFault {
             MessageContext outMsgContext = 
Utils.createOutMessageContext(messageContext);
             
outMsgContext.getOperationContext().addMessageContext(outMsgContext);
 
-            SOAPFactory factory = getSOAPFactory(messageContext);
             SOAPEnvelope envelope = factory.getDefaultEnvelope();
             outMsgContext.setEnvelope(envelope);
 
             OMNamespace depns = 
factory.createOMNamespace("http://www.apache.org/ode/pmapi","deployapi";);
-            OMElement response = factory.createOMElement("deployResponse", 
depns);
-            OMElement respPart = factory.createOMElement("response", null);
-            respPart.setText("true");
-            response.addChild(respPart);
+            OMElement responseOp = factory.createOMElement(op, depns);
+            responseOp.addChild(response);
             envelope.getBody().addChild(response);
             AxisEngine engine = new AxisEngine(
                     
messageContext.getOperationContext().getServiceContext().getConfigurationContext());

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
 Tue Aug 22 15:35:38 2006
@@ -150,16 +150,8 @@
         } 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)) {
-            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).getName();
-                qname = new QName(ns, localpart, prefix);
-            }
-            return qname;
+            return OMUtils.getTextAsQName(elmt);
         } else if (clazz.equals(ProcessInfoCustomizer.class)) {
             return new ProcessInfoCustomizer(elmt.getText());
         } else if (Node.class.isAssignableFrom(clazz)) {

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/OMUtils.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/OMUtils.java?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/OMUtils.java 
(original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/OMUtils.java 
Tue Aug 22 15:35:38 2006
@@ -19,12 +19,13 @@
 
 package org.apache.ode.axis2.util;
 
-import org.apache.ode.utils.DOMUtils;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axis2.AxisFault;
+import org.apache.ode.utils.DOMUtils;
 import org.w3c.dom.Element;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
 import java.io.ByteArrayInputStream;
@@ -35,28 +36,47 @@
  */
 public class OMUtils {
 
-  public static Element toDOM(OMElement element) throws AxisFault {
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    try {
-      element.serialize(baos);
-      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-      return DOMUtils.parse(bais).getDocumentElement();
-    } catch (Exception e) {
-      throw new AxisFault("Unable to read Axis input messag.e", e);
+    public static Element toDOM(OMElement element) throws AxisFault {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            element.serialize(baos);
+            ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
+            return DOMUtils.parse(bais).getDocumentElement();
+        } catch (Exception e) {
+            throw new AxisFault("Unable to read Axis input messag.e", e);
+        }
+    }
+
+    public static OMElement toOM(Element element) throws AxisFault {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            DOMUtils.serialize(element, baos);
+            ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
+            XMLStreamReader parser = 
XMLInputFactory.newInstance().createXMLStreamReader(bais);
+            StAXOMBuilder builder = new StAXOMBuilder(parser);
+            return builder.getDocumentElement();
+        } catch (Exception e) {
+            throw new AxisFault("Unable to read Axis input messag.e", e);
+        }
     }
-  }
 
-  public static OMElement toOM(Element element) throws AxisFault {
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    try {
-      DOMUtils.serialize(element, baos);
-      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-      XMLStreamReader parser = 
XMLInputFactory.newInstance().createXMLStreamReader(bais);
-      StAXOMBuilder builder = new StAXOMBuilder(parser);
-      return builder.getDocumentElement();
-    } catch (Exception e) {
-      throw new AxisFault("Unable to read Axis input messag.e", e);
+    /**
+     * 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).getName();
+            qname = new QName(ns, localpart, prefix);
+        }
+        return qname;
     }
-  }
 
 }

Modified: incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl (original)
+++ incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl Tue Aug 22 15:35:38 2006
@@ -26,66 +26,131 @@
         xmlns:xmime="http://schemas.xmlsoap.org/2003/04/xmime";
         xmlns="http://schemas.xmlsoap.org/wsdl/";>
 
-  <types>
-    <xsd:complexType name="package">
-      <xsd:all>
-        <xsd:element name="zip" type="xmime:base64Binary"
-            xmime:expectedContentType="application/zip" />
-      </xsd:all>
-    </xsd:complexType>
-  </types>
+    <types>
+        <xsd:complexType name="package">
+            <xsd:all>
+                <xsd:element name="zip" type="xmime:base64Binary"
+                             xmime:expectedContentType="application/zip" />
+            </xsd:all>
+        </xsd:complexType>
+        <xsd:complexType name="packageNames">
+            <xsd:all>
+                <xsd:element name="name" type="xsd:string"/>
+            </xsd:all>
+        </xsd:complexType>
+        <xsd:complexType name="processIds">
+            <xsd:all>
+                <xsd:element name="id" type="xsd:QName"/>
+            </xsd:all>
+        </xsd:complexType>
+    </types>
 
-  <message name="deployInput">
-    <part name="name" type="xsd:string"/>
-    <part name="package" type="tns:package"/>
-  </message>
-  <message name="deployOutput">
-    <part name="response" type="xsd:boolean"/>
-  </message>
-  <message name="undeployInput">
-    <part name="processName" type="xsd:QName"/>
-  </message>
-  <message name="undeployOutput">
-    <part name="response" type="xsd:boolean"/>
-  </message>
+    <message name="deployInput">
+        <part name="name" type="xsd:string"/>
+        <part name="package" type="tns:package"/>
+    </message>
+    <message name="deployOutput">
+        <part name="response" type="xsd:boolean"/>
+    </message>
+    <message name="undeployInput">
+        <part name="processName" type="xsd:QName"/>
+    </message>
+    <message name="undeployOutput">
+        <part name="response" type="xsd:boolean"/>
+    </message>
+    <message name="listDeployedPackagesInput"/>
+    <message name="listDeployedPackagesOutput">
+        <part name="deployedPackages" type="tns:packageNames"/>
+    </message>
+    <message name="listProcessesInput">
+        <part name="packageName" type="xsd:string"/>
+    </message>
+    <message name="listProcessesOutput">
+        <part name="processIds" type="tns:processIds"/>
+    </message>
+    <message name="getProcessPackageInput">
+        <part name="processName" type="xsd:QName"/>
+    </message>
+    <message name="getProcessPackageOutput">
+        <part name="packageName" type="xsd:string"/>
+    </message>
 
-  <portType name="DeploymentPortType">
-    <operation name="deploy">
-      <input message="tns:deployInput"/>
-      <output message="tns:deployOutput"/>
-    </operation>
-    <operation name="undeploy">
-      <input message="tns:undeployInput"/>
-      <output message="tns:undeployOutput"/>
-    </operation>
-  </portType>
+    <portType name="DeploymentPortType">
+        <operation name="deploy">
+            <input message="tns:deployInput"/>
+            <output message="tns:deployOutput"/>
+        </operation>
+        <operation name="undeploy">
+            <input message="tns:undeployInput"/>
+            <output message="tns:undeployOutput"/>
+        </operation>
+        <operation name="listDeployedPackages">
+            <input message="tns:listDeployedPackagesInput"/>
+            <output message="tns:listDeployedPackagesOutput"/>
+        </operation>
+        <operation name="listProcesses">
+            <input message="tns:listProcessesInput"/>
+            <output message="tns:listProcessesOutput"/>
+        </operation>
+        <operation name="getProcessPackage">
+            <input message="tns:getProcessPackageInput"/>
+            <output message="tns:getProcessPackageOutput"/>
+        </operation>
+    </portType>
 
-  <binding name="DeploymentBinding" type="tns:DeploymentPortType">
-    <soap:binding style="rpc" 
transport="http://schemas.xmlsoap.org/soap/http"/>
-    <operation name="deploy">
-      <soap:operation soapAction="" style="rpc"/>
-      <input>
-        <soap:body namespace="http://www.apache.org/ode/pmapi"; use="encoded"/>
-      </input>
-      <output>
-        <soap:body namespace="http://www.apache.org/ode/pmapi"; use="encoded"/>
-      </output>
-    </operation>
-    <operation name="undeploy">
-      <soap:operation soapAction="" style="rpc"/>
-      <input>
-        <soap:body namespace="http://www.apache.org/ode/pmapi"; use="encoded"/>
-      </input>
-      <output>
-        <soap:body namespace="http://www.apache.org/ode/pmapi"; use="encoded"/>
-      </output>
-    </operation>
-  </binding>
+    <binding name="DeploymentBinding" type="tns:DeploymentPortType">
+        <soap:binding style="rpc" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="deploy">
+            <soap:operation soapAction="" style="rpc"/>
+            <input>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </input>
+            <output>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </output>
+        </operation>
+        <operation name="undeploy">
+            <soap:operation soapAction="" style="rpc"/>
+            <input>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </input>
+            <output>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </output>
+        </operation>
+        <operation name="listDeployedPackages">
+            <soap:operation soapAction="" style="rpc"/>
+            <input>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </input>
+            <output>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </output>
+        </operation>
+        <operation name="listProcesses">
+            <soap:operation soapAction="" style="rpc"/>
+            <input>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </input>
+            <output>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </output>
+        </operation>
+        <operation name="getProcessPackage">
+            <soap:operation soapAction="" style="rpc"/>
+            <input>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </input>
+            <output>
+                <soap:body namespace="http://www.apache.org/ode/pmapi"; 
use="encoded"/>
+            </output>
+        </operation>
+    </binding>
 
-  <service name="DeploymentService">
-    <port name="DeploymentPort" binding="tns:DeploymentBinding">
-      <soap:address location="http://localhost:8080/ode/services/deploy"/>
-    </port>
-  </service>
+    <service name="DeploymentService">
+        <port name="DeploymentPort" binding="tns:DeploymentBinding">
+            <soap:address 
location="http://localhost:8080/ode/services/deploy"/>
+        </port>
+    </service>
 
 </definitions>

Modified: 
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
 Tue Aug 22 15:35:38 2006
@@ -30,24 +30,67 @@
 import org.apache.ode.axis2.service.ServiceClientUtil;
 import org.apache.ode.utils.Namespaces;
 
+import javax.xml.namespace.QName;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
 public class DeploymentTest extends TestCase {
 
+    private OMFactory _factory;
     private ServiceClientUtil _client;
 
     public void testDeployUndeploy() throws Exception {
+        // Setup and tear down are doing ost of the job here, just checking in 
the middle
+
+        // Check deployment
+        OMElement listRoot = _client.buildMessage("listProcesses", new 
String[] {"filter", "orderKeys"},
+                new String[] {"name=DynPartnerMain", ""});
+        OMElement result = sendToPM(listRoot);
+        // Ensures that there's only 2 process-info string (ending and closing 
tags) and hence only one process
+        assert(result.toString().split("process-info").length == 3);
+        listRoot = _client.buildMessage("listProcesses", new String[] 
{"filter", "orderKeys"},
+                new String[] {"name=DynPartnerResponder", ""});
+        result = sendToPM(listRoot);
+        assert(result.toString().split("process-info").length == 3);
+    }
+
+    public void testListDeployedPackages() throws Exception {
+        OMElement root = _client.buildMessage("listDeployedPackages", new 
String[] {}, new String[] {});
+        OMElement result = sendToDeployment(root);
+        
assert(result.getFirstElement().getFirstElement().getText().equals("DynPartner"));
+    }
+
+    public void testListProcesses() throws Exception {
+        OMElement root = _client.buildMessage("listProcesses", new String[] 
{"packagesNames"},
+                new String[] {"DynPartner"});
+        OMElement result = sendToDeployment(root);
+        assert(result.toString().indexOf("http://ode/bpel/unit-test";)>=0);
+        assert(result.toString().indexOf("DynPartnerMain")>=0);
+        assert(result.toString().indexOf("http://ode/bpel/responder";)>=0);
+        assert(result.toString().indexOf("DynPartnerResponder")>=0);
+        System.out.println(result);
+    }
+
+    public void testGetProcessPackage() throws Exception {
+        OMElement root = _client.buildMessage("getProcessPackage", new 
String[] {"processId"},
+                new Object[] { new QName("http://ode/bpel/unit-test";, 
"DynPartnerMain") });
+        OMElement result = sendToDeployment(root);
+        assert(result.getText().equals("DynPartner"));
+        System.out.println(result);
+    }
+
+    protected void setUp() throws Exception {
         // Create a factory
-        OMFactory factory = OMAbstractFactory.getOMFactory();
+        _factory = OMAbstractFactory.getOMFactory();
+        _client = new ServiceClientUtil();
 
         // Use the factory to create three elements
-        OMNamespace depns = 
factory.createOMNamespace(Namespaces.ODE_PMAPI,"deployapi");
-        OMElement root = factory.createOMElement("deploy", null);
-        OMElement namePart = factory.createOMElement("name", depns);
+        OMNamespace depns = _factory.createOMNamespace(Namespaces.ODE_PMAPI, 
"deployapi");
+        OMElement root = _factory.createOMElement("deploy", null);
+        OMElement namePart = _factory.createOMElement("name", depns);
         namePart.setText("DynPartner");
-        OMElement zipPart = factory.createOMElement("package", depns);
-        OMElement zipElmt = factory.createOMElement("zip", depns);
+        OMElement zipPart = _factory.createOMElement("package", depns);
+        OMElement zipElmt = _factory.createOMElement("zip", depns);
 
         // Add the zip to deploy
         InputStream is = 
this.getClass().getClassLoader().getResourceAsStream("DynPartner.zip");
@@ -56,7 +99,7 @@
             outputStream.write((byte) b);
         }
         String base64Enc = Base64.encode(outputStream.toByteArray());
-        OMText zipContent = factory.createOMText(base64Enc, "application/zip", 
true);
+        OMText zipContent = _factory.createOMText(base64Enc, 
"application/zip", true);
         root.addChild(namePart);
         root.addChild(zipPart);
         zipPart.addChild(zipElmt);
@@ -64,36 +107,25 @@
 
         // Deploy
         sendToDeployment(root);
+    }
 
-        // Check deployment
-        OMElement listRoot = _client.buildMessage("listProcesses", new 
String[] {"filter", "orderKeys"},
-                new String[] {"name=DynPartnerMain", ""});
-        OMElement result = sendToPM(listRoot);
-        // Ensures that there's only 2 process-info string (ending and closing 
tags) and hence only one process
-        assert(result.toString().split("process-info").length == 3);
-        listRoot = _client.buildMessage("listProcesses", new String[] 
{"filter", "orderKeys"},
-                new String[] {"name=DynPartnerResponder", ""});
-        result = sendToPM(listRoot);
-        assert(result.toString().split("process-info").length == 3);
-
+    protected void tearDown() throws Exception {
         // Prepare undeploy message
-        root = factory.createOMElement("undeploy", depns);
-        OMElement part = factory.createOMElement("processName", null);
+        OMNamespace depns = _factory.createOMNamespace(Namespaces.ODE_PMAPI, 
"deployapi");
+        OMElement root = _factory.createOMElement("undeploy", depns);
+        OMElement part = _factory.createOMElement("processName", null);
         part.setText("DynPartner");
         root.addChild(part);
 
         // Undeploy
         sendToDeployment(root);
 
-        listRoot = _client.buildMessage("listProcesses", new String[] 
{"filter", "orderKeys"},
+        OMElement listRoot = _client.buildMessage("listProcesses", new 
String[] {"filter", "orderKeys"},
                 new String[] {"name=DynPartnerMain", ""});
-        result = sendToPM(listRoot);
+        OMElement result = sendToPM(listRoot);
         assert(result.toString().indexOf("process-info") < 0);
     }
 
-    protected void setUp() throws Exception {
-        _client = new ServiceClientUtil();
-    }
 
     private OMElement sendToPM(OMElement msg) throws AxisFault {
         return _client.send(msg, 
"http://localhost:8080/ode/services/ProcessManagement";);

Modified: 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelServer.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelServer.java?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelServer.java
 (original)
+++ 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelServer.java
 Tue Aug 22 15:35:38 2006
@@ -23,8 +23,6 @@
 
 import javax.xml.namespace.QName;
 import java.io.File;
-import java.io.IOException;
-import java.net.URI;
 import java.util.Collection;
 
 
@@ -36,132 +34,131 @@
  */
 public interface BpelServer {
 
-  /**
-   * Configure the [EMAIL PROTECTED] with a message-exchange context. BPEL
-   * engine uses this context to initiate communication with external
-   * services.
-   * @see MessageExchangeContext
-   * @param mexContext [EMAIL PROTECTED] MessageExchangeContext} implementation
-   */
-  void setMessageExchangeContext(MessageExchangeContext mexContext) 
-    throws BpelEngineException; 
-  
-  /**
-   * Configure the [EMAIL PROTECTED] with a scheduler.  
-   */
-  void setScheduler(Scheduler scheduler)
-    throws BpelEngineException; 
-  
-
-  /**
-   * Configure the [EMAIL PROTECTED] with an endpoint-reference (EPR) context.
-   * BPEL engine uses this context to EPRs.
-   * @see EndpointReferenceContext
-   * @param eprContext [EMAIL PROTECTED] EndpointReferenceContext} 
implementation
-   */  
-  void setEndpointReferenceContext(EndpointReferenceContext eprContext)
-    throws BpelEngineException; 
-
-  /**
-   * Configure the [EMAIL PROTECTED] with a binding context. The BPEL engine 
uses 
-   * this context to register the services that it exposes and obtain 
communication
-   * links to partner services. 
-   * @see BindingContext
-   * @param bindingContext [EMAIL PROTECTED] BindingContext} implementation
-   */  
-  void setBindingContext(BindingContext bindingContext) 
-    throws BpelEngineException;
-  
-  /**
-   * Set the DAO connection factory. The DAO is used by the BPEL engine
-   * to persist information about active processes.
-   * @param daoCF [EMAIL PROTECTED] BpelDAOConnectionFactory} implementation.
-   */
-  void setDaoConnectionFactory(BpelDAOConnectionFactory daoCF)
-    throws BpelEngineException; 
-
-  
-  /**
-   * Initialize the BPEL engine. The various contexts needed by the
-   * engine must be configured before this method is called. 
-   */
-  void init()
-    throws BpelEngineException; 
-
-  /**
-   * Start the BPEL engine. The BPEL engine will not execute process
-   * instances until it is started.
-   */
-  void start()
-    throws BpelEngineException; 
-
-
-  /**
-   * Stop the BPEL engine: results in the cessation of process
-   * execution.
-   */
-  void stop()
-    throws BpelEngineException; 
-
-            
-
-  /**
-   * Called to shutdown the BPEL egnine. 
-   */
-  void shutdown()
-    throws BpelEngineException; 
-
-  
-  /**
-   * Get the [EMAIL PROTECTED] BpelEngine} interface for handling transaction 
operations.
-   * @return transactional [EMAIL PROTECTED] BpelEngine} interfacce
-   */
-  BpelEngine getEngine();
-  
-  /**
-   * Deploy a process from the filesystem.
-   * @param deploymentUnitDirectory directory containing all deployment files
-   * @return A collection of the process ids of the deployed processes
-   */
-  Collection<QName> deploy(File deploymentUnitDirectory);
-  
-  /**
-   * Undeploy a process.
-   * @param pid
-   * @return successful or not
-   */
-  boolean undeploy(QName pid);
-
-  /**
-   * Undeploy a package.
-   * @param file package file
-   * @return successful or not
-   */
-  boolean undeploy(File file);
-
-  /**
-   * Activate a process.
-   * @param pid process to activate
-   * @param sticky is this change sticky, i.e. will the process be activated
-   *        on restart.
-   * @throws BpelEngineException
-   */
-  void activate(QName pid, boolean sticky) throws BpelEngineException;
-  
-  /**
-   * Deactivate a process.
-   * @param pid process to deactivate
-   * @param sticky whether the change is sticky, i.e. will the process be 
-   *        deactivated on restart
-   * @throws BpelEngineException
-   */
-  void deactivate(QName pid, boolean sticky) throws BpelEngineException;
-  
-  /**
-   * Get the BPEL management interface.
-   * @return BPEL management interface
-   */
-  BpelManagementFacade getBpelManagementFacade();
-  
-  
+    /**
+     * Configure the [EMAIL PROTECTED] with a message-exchange context. BPEL
+     * engine uses this context to initiate communication with external
+     * services.
+     * @see MessageExchangeContext
+     * @param mexContext [EMAIL PROTECTED] MessageExchangeContext} 
implementation
+     */
+    void setMessageExchangeContext(MessageExchangeContext mexContext)
+            throws BpelEngineException;
+
+    /**
+     * Configure the [EMAIL PROTECTED] with a scheduler.
+     */
+    void setScheduler(Scheduler scheduler)
+            throws BpelEngineException;
+
+
+    /**
+     * Configure the [EMAIL PROTECTED] with an endpoint-reference (EPR) 
context.
+     * BPEL engine uses this context to EPRs.
+     * @see EndpointReferenceContext
+     * @param eprContext [EMAIL PROTECTED] EndpointReferenceContext} 
implementation
+     */
+    void setEndpointReferenceContext(EndpointReferenceContext eprContext)
+            throws BpelEngineException;
+
+    /**
+     * Configure the [EMAIL PROTECTED] with a binding context. The BPEL engine 
uses
+     * this context to register the services that it exposes and obtain 
communication
+     * links to partner services.
+     * @see BindingContext
+     * @param bindingContext [EMAIL PROTECTED] BindingContext} implementation
+     */
+    void setBindingContext(BindingContext bindingContext)
+            throws BpelEngineException;
+
+    /**
+     * Set the DAO connection factory. The DAO is used by the BPEL engine
+     * to persist information about active processes.
+     * @param daoCF [EMAIL PROTECTED] BpelDAOConnectionFactory} implementation.
+     */
+    void setDaoConnectionFactory(BpelDAOConnectionFactory daoCF)
+            throws BpelEngineException;
+
+
+    /**
+     * Initialize the BPEL engine. The various contexts needed by the
+     * engine must be configured before this method is called.
+     */
+    void init()
+            throws BpelEngineException;
+
+    /**
+     * Start the BPEL engine. The BPEL engine will not execute process
+     * instances until it is started.
+     */
+    void start()
+            throws BpelEngineException;
+
+
+    /**
+     * Stop the BPEL engine: results in the cessation of process
+     * execution.
+     */
+    void stop()
+            throws BpelEngineException;
+
+
+
+    /**
+     * Called to shutdown the BPEL egnine.
+     */
+    void shutdown()
+            throws BpelEngineException;
+
+
+    /**
+     * Get the [EMAIL PROTECTED] BpelEngine} interface for handling 
transaction operations.
+     * @return transactional [EMAIL PROTECTED] BpelEngine} interfacce
+     */
+    BpelEngine getEngine();
+
+    /**
+     * Deploy a process from the filesystem.
+     * @param deploymentUnitDirectory directory containing all deployment files
+     * @return A collection of the process ids of the deployed processes
+     */
+    Collection<QName> deploy(File deploymentUnitDirectory);
+
+    /**
+     * Undeploy a package.
+     * @param file package file
+     * @return successful or not
+     */
+    boolean undeploy(File file);
+
+    /**
+     * Activate a process.
+     * @param pid process to activate
+     * @param sticky is this change sticky, i.e. will the process be activated
+     *        on restart.
+     * @throws BpelEngineException
+     */
+    void activate(QName pid, boolean sticky) throws BpelEngineException;
+
+    /**
+     * Deactivate a process.
+     * @param pid process to deactivate
+     * @param sticky whether the change is sticky, i.e. will the process be
+     *        deactivated on restart
+     * @throws BpelEngineException
+     */
+    void deactivate(QName pid, boolean sticky) throws BpelEngineException;
+
+    /**
+     * Get the BPEL management interface.
+     * @return BPEL management interface
+     */
+    BpelManagementFacade getBpelManagementFacade();
+
+    /**
+     * Get the deployment service.
+     * @return deployment service
+     */
+    DeploymentService getDeploymentService();
+
+
 }

Added: 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/DeploymentService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/DeploymentService.java?rev=433782&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/DeploymentService.java
 (added)
+++ 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/DeploymentService.java
 Tue Aug 22 15:35:38 2006
@@ -0,0 +1,66 @@
+/*
+ * 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.bpel.iapi;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * Provides service deployment and undeployment as well as simple query
+ * methods to check which packages have been deployed and the related
+ * process names.
+ */
+public interface DeploymentService {
+
+    /**
+     * Deploys a process from the filesystem.
+     * @param deploymentUnitDirectory directory containing all deployment files
+     * @return a collection of process ids (deployed processes)
+     */
+    Collection<QName> deploy(File deploymentUnitDirectory);
+
+    /**
+     * Undeploys a package.
+     * @param file package
+     * @return successful or not
+     */
+    boolean undeploy(File file);
+
+    /**
+     * Lists the names of all the packages that have been deployed (corresponds
+     * to a directory name on the file system).
+     * @return an array of package names
+     */
+    String[] listDeployedPackages();
+
+    /**
+     * Lists all processe ids in a given package.
+     * @return an array of process id QNames
+     */
+    QName[] listProcesses(String packageName);
+
+    /**
+     * Gets the name of the package into which a process is deployed.
+     * @param processId
+     * @return package name
+     */
+    String getProcessPackage(QName processId);
+}

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentServiceImpl.java?rev=433782&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentServiceImpl.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentServiceImpl.java
 Tue Aug 22 15:35:38 2006
@@ -0,0 +1,75 @@
+/*
+ * 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.bpel.deploy;
+
+import org.apache.ode.bpel.engine.BpelServerImpl;
+import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.bpel.iapi.DeploymentService;
+import org.apache.ode.bpel.iapi.DeploymentUnit;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * Implementation of [EMAIL PROTECTED] DeploymentService}
+ */
+public class DeploymentServiceImpl implements DeploymentService {
+
+    private BpelServerImpl _server;
+
+    public DeploymentServiceImpl(BpelServerImpl server) {
+        _server = server;
+    }
+
+    public Collection<QName> deploy(File deploymentUnitDirectory) {
+        return _server.deploy(deploymentUnitDirectory);
+    }
+
+    public boolean undeploy(File file) {
+        return _server.undeploy(file);
+    }
+
+    public String[] listDeployedPackages() {
+        String[] names = new String[_server.getDeploymentUnits().size()];
+        int m = 0;
+        HashSet<DeploymentUnit> packageSet = new 
HashSet<DeploymentUnit>(_server.getDeploymentUnits());
+        for (DeploymentUnit deploymentUnit : packageSet) {
+            names[m++] = deploymentUnit.getDeployDir().getName();
+        }
+        return names;
+    }
+
+    public QName[] listProcesses(String packageName) {
+        DeploymentUnit du = null;
+        for (DeploymentUnit deploymentUnit : _server.getDeploymentUnits()) {
+            if (deploymentUnit.getDeployDir().getName().equals(packageName))
+                du = deploymentUnit;
+        }
+        if (du == null)
+            throw new BpelEngineException("Couldn't find a deployed package 
named " + packageName);
+        return du.getProcessNames().toArray(new QName[] {});
+    }
+
+    public String getProcessPackage(QName processId) {
+        return _server.getDeploymentUnit(processId).getDeployDir().getName();
+    }
+}

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?rev=433782&r1=433781&r2=433782&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
 Tue Aug 22 15:35:38 2006
@@ -46,6 +46,7 @@
 import org.apache.ode.bpel.dd.TInvoke;
 import org.apache.ode.bpel.dd.TProvide;
 import org.apache.ode.bpel.dd.TService;
+import org.apache.ode.bpel.deploy.DeploymentServiceImpl;
 import org.apache.ode.bpel.deploy.DeploymentUnitImpl;
 import org.apache.ode.bpel.evt.BpelEvent;
 import org.apache.ode.bpel.explang.ConfigurationException;
@@ -54,6 +55,7 @@
 import org.apache.ode.bpel.iapi.BpelEngineException;
 import org.apache.ode.bpel.iapi.BpelEventListener;
 import org.apache.ode.bpel.iapi.BpelServer;
+import org.apache.ode.bpel.iapi.DeploymentService;
 import org.apache.ode.bpel.iapi.DeploymentUnit;
 import org.apache.ode.bpel.iapi.Endpoint;
 import org.apache.ode.bpel.iapi.EndpointReferenceContext;
@@ -335,6 +337,10 @@
         return new BpelManagementFacadeImpl(_db, _engine, this);
     }
 
+    public DeploymentService getDeploymentService() {
+        return new DeploymentServiceImpl(this);
+    }
+
     public void setMessageExchangeContext(MessageExchangeContext mexContext) 
throws BpelEngineException {
         _contexts.mexContext = mexContext;
     }
@@ -445,7 +451,7 @@
 
             // Figure out where on the local file system we can find the
             // deployment directory for this process
-            DeploymentUnitImpl du  = getDeploymentUnit(pid);
+            DeploymentUnitImpl du  = _deploymentUnits.get(pid);
             if (du == null) {
                 // Indicates process not deployed.
                 String errmsg = "Process " + pid + " is not deployed, it 
cannot be activated";
@@ -548,8 +554,16 @@
         }
     }
 
-    public DeploymentUnitImpl getDeploymentUnit(QName pid) {
+    public DeploymentUnit getDeploymentUnit(QName pid) {
         return _deploymentUnits.get(pid);
+    }
+
+    public Collection<DeploymentUnit> getDeploymentUnits() {
+        ArrayList<DeploymentUnit> dus = new 
ArrayList<DeploymentUnit>(_deploymentUnits.size());
+        for (DeploymentUnitImpl du : _deploymentUnits.values()) {
+            dus.add(du);
+        }
+        return dus;
     }
 
     private void dbSetProcessActive(final QName pid, final boolean val) {


Reply via email to