Author: mriou
Date: Tue Aug 15 10:58:51 2006
New Revision: 431656

URL: http://svn.apache.org/viewvc?rev=431656&view=rev
Log:
ODE-27 Made some tests and fixed a couple of problems on management API. 2 
methods are working, a small start but a start. And more coming...

Added:
    incubator/ode/trunk/axis2/src/test/resources/
Modified:
    incubator/ode/trunk/axis2/pom.xml
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
    
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/dao/ProcessDAO.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcess.java

Modified: incubator/ode/trunk/axis2/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/pom.xml?rev=431656&r1=431655&r2=431656&view=diff
==============================================================================
--- incubator/ode/trunk/axis2/pom.xml (original)
+++ incubator/ode/trunk/axis2/pom.xml Tue Aug 15 10:58:51 2006
@@ -19,78 +19,111 @@
   -->
 
 <project>
-  <groupId>ode</groupId>
-  <artifactId>ode-axis2</artifactId>
-  <name>ODE :: AXIS2 Integration Layer</name>
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
     <groupId>ode</groupId>
-    <artifactId>ode</artifactId>
+    <artifactId>ode-axis2</artifactId>
+    <name>ODE :: AXIS2 Integration Layer</name>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>ode</groupId>
+        <artifactId>ode</artifactId>
+        <version>2.0-SNAPSHOT</version>
+    </parent>
     <version>2.0-SNAPSHOT</version>
-  </parent>
-  <version>2.0-SNAPSHOT</version>
-  <dependencies>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-dao-hibernate</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-bpel-runtime</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-bpel-scheduler-quartz</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-bpel-dd</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-minerva</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-naming</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-bpel-api</artifactId>
-    </dependency>
+    <properties>
+        <!-- maven.test.skip>false</maven.test.skip -->
+    </properties>
 
-             <dependency>
-      <groupId>ode</groupId>
-      <artifactId>ode-bpel-connector</artifactId>
-    </dependency>
+    <dependencies>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-dao-hibernate</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-bpel-runtime</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-bpel-scheduler-quartz</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-bpel-dd</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-minerva</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-naming</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-bpel-api</artifactId>
+        </dependency>
 
-    <dependency>
-      <groupId>axis2</groupId>
-      <artifactId>axis2</artifactId>
-    </dependency>
-    <dependency>
-        <groupId>ws-commons</groupId>
-        <artifactId>axiom-api</artifactId>
-    </dependency>
-    <dependency>
-        <groupId>ws-commons</groupId>
-        <artifactId>axiom-impl</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-servlet_2.4_spec</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>jotm</groupId>
-      <artifactId>jotm</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>javax.activation</groupId>
-      <artifactId>activation</artifactId>
-    </dependency>
-  </dependencies>
+        <dependency>
+            <groupId>ode</groupId>
+            <artifactId>ode-bpel-connector</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom-impl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom-dom</artifactId>
+            <version>${axis2Version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.4_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>jotm</groupId>
+            <artifactId>jotm</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>activation</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>neethi</artifactId>
+            <version>1.0.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>1.0.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>woodstox</groupId>
+            <artifactId>wstx</artifactId>
+            <version>1.0.7</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>commons-httpclient</groupId>
+          <artifactId>commons-httpclient</artifactId>
+          <scope>test</scope>
+        </dependency>
+    </dependencies>
 </project>

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=431656&r1=431655&r2=431656&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 15 10:58:51 2006
@@ -123,7 +123,7 @@
       } catch (IllegalAccessException e) {
         throw new AxisFault("Couldn't invoke method named " + methodName + " 
in management interface!", e);
       } catch (InvocationTargetException e) {
-        throw new AxisFault("Couldn't invoke method named " + methodName + " 
in management interface!", e);
+        throw new AxisFault("Invocation of method " + methodName + " in 
management interface failed!", e);
       }
   }
 

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=431656&r1=431655&r2=431656&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 15 10:58:51 2006
@@ -33,6 +33,7 @@
 
 import java.io.FileInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
 
 public class DeploymentTest extends TestCase {
 
@@ -49,10 +50,9 @@
         OMElement zipElmt = factory.createOMElement("zip", depns);
 
         // Add the zip to deploy
-        // TODO figure out a way to get a process zip
-        FileInputStream fis = new 
FileInputStream("/home/dusty/tmp/DynPartner.zip");
+        InputStream is = 
this.getClass().getClassLoader().getResourceAsStream("DynPartner.zip");
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        for (int b = fis.read(); b >= 0; b = fis.read()) {
+        for (int b = is.read(); b >= 0; b = is.read()) {
             outputStream.write((byte) b);
         }
         String base64Enc = Base64.encode(outputStream.toByteArray());
@@ -65,6 +65,11 @@
         // Deploy
         sendToDeployment(root);
 
+        // Check deployment
+        OMElement listRoot = buildMessage("listProcesses", new String[] 
{"filter", "orderKeys"}, new String[] {"", ""});
+        OMElement result = sendToPM(listRoot);
+        System.out.println(result);
+
         // Prepare undeploy message
         root = factory.createOMElement("undeploy", depns);
         OMElement part = factory.createOMElement("processName", null);
@@ -72,18 +77,41 @@
         root.addChild(part);
 
         // Undeploy
-//    sendToDeployment(root);
+        sendToDeployment(root);
+    }
+
+    private OMElement sendToPM(OMElement msg) throws AxisFault {
+        return send(msg, 
"http://localhost:8080/ode/services/ProcessManagement";);
     }
 
     private OMElement sendToDeployment(OMElement msg) throws AxisFault {
+        return send(msg, 
"http://localhost:8080/ode/services/DeploymentService";);
+    }
+
+    private OMElement send(OMElement msg, String url) throws AxisFault {
         Options options = new Options();
-        EndpointReference target = new 
EndpointReference("http://localhost:8080/ode/services/DeploymentService";);
+        EndpointReference target = new EndpointReference(url);
         options.setTo(target);
 
         ServiceClient serviceClient = new ServiceClient();
         serviceClient.setOptions(options);
 
         return serviceClient.sendReceive(msg);
+    }
+
+    private OMElement buildMessage(String operation, String[] params, String[] 
values) {
+      //create a factory
+      OMFactory factory = OMAbstractFactory.getOMFactory();
+
+      //use the factory to create three elements
+      OMNamespace pmns = 
factory.createOMNamespace("http://www.apache.org/ode/pmapi","pmapi";);
+      OMElement root = factory.createOMElement(operation, pmns);
+      for (int m = 0; m < params.length; m++) {
+        OMElement omelmt = factory.createOMElement(params[m], null);
+        omelmt.setText(values[m]);
+        root.addChild(omelmt);
+      }
+      return root;
     }
 
 }

Modified: 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java?rev=431656&r1=431655&r2=431656&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
 (original)
+++ 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
 Tue Aug 15 10:58:51 2006
@@ -35,129 +35,125 @@
  * yet to be created or not yet correlated..
  */
 public interface ProcessDAO {
-  /**
-   * Get the unique process identifier.
-   * @return process identifier
-   */
-  QName getProcessId();
-
-  /**
-   * Get the BPEL process name.
-   * @return qualified BPEL process name.
-   */
-  QName getType();
-
-  
-  /**
-   * Get the name of the user that deployed the proces.s
-   * @return name of deploying user.
-   */
-  String getDeployer();
-
-  /**
-   * Get the date when the process was deployed.
-   * @return deployment date.
-   */
-  Date getDeployDate();
-
-  /**
-   * Get the process version
-   * @return version
-   */
-  int getVersion();
-
-  /**
-   * Get a message correlator instance.
-   *
-   * @param correlatorId correlator identifier
-   * @return correlator corresponding to the given identifier
-   */
-  CorrelatorDAO getCorrelator(String correlatorId);
-
-  /**
-   * Create a new process instance object.
-   *
-   * @param instantiatingCorrelator instantiating [EMAIL PROTECTED] 
CorrelatorDAO}
-   * @return newly generated instance DAO
-   */
-  ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator);
-
-  /**
-   * Get a process instance (by identifier).
-   * @param iid unique instance identifier.
-   * @return DAO corresponding to the process instance
-   */
-  ProcessInstanceDAO getInstance(Long iid);
-
-  /**
-   * Locates a process instance based on a correlation key.
-   * @param cckey correlation key
-   * @return collection of [EMAIL PROTECTED] ProcessInstanceDAO} that match 
correlation key, ordered by date
-   */
-  Collection<ProcessInstanceDAO> findInstance(CorrelationKey cckey);
-
-  /**
-   * Remove the routes with the given Id for all the correlators in the
-   * process.
-   * @todo remove this method.
-   * @param routeId
-   */
-  void removeRoutes(String routeId, ProcessInstanceDAO target);
-
-  /**
-   * Callback indicating that a process instance has completed its duties. 
-   * @param instance the completed [EMAIL PROTECTED] ProcessInstanceDAO}
-   */
-  void instanceCompleted(ProcessInstanceDAO instance);
-
-  /**
-   * Adds a named property on the process providing its value as
-   * and XML Node.
-   * @param name of the property
-   * @param ns namespace of the property
-   * @param content value of the property
-   */
-  void setProperty(String name, String ns, Node content);
-
-  /**
-   * Adds a named property on the process providing its value as
-   * a simple type (handled as a simple string).
-   * @param name of the property
-   * @param ns namespace of the property
-   * @param content value of the property
-   */
-  void setProperty(String name, String ns, String content);
-
-  /**
-   * Gets the properties for the process.
-   * @return collection of [EMAIL PROTECTED] ProcessPropertyDAO}
-   */
-  Collection<ProcessPropertyDAO> getProperties();
-
-  
-  /**
-   * Remove the process from the database (along with any instance,
-   * variable data, etc...).
-   */
-  void delete();
-  
-  
-  public boolean isRetired();
-  
-  public void setRetired(boolean retired);
-
-  void setActive(boolean active);
-
-  boolean isActive();
-  
-  void addCorrelator(String correlator);
-
-  void setDeployURI(URI dduri);
-  
-  void setCompiledProcess(byte[] cbp);
-  
-  byte[] getCompiledProcess();
-  
-  URI getDeployURI();
+    /**
+     * Get the unique process identifier.
+     * @return process identifier
+     */
+    QName getProcessId();
+
+    /**
+     * Get the BPEL process name.
+     * @return qualified BPEL process name.
+     */
+    QName getType();
+
+
+    /**
+     * Get the name of the user that deployed the proces.s
+     * @return name of deploying user.
+     */
+    String getDeployer();
+
+    /**
+     * Get the date when the process was deployed.
+     * @return deployment date.
+     */
+    Date getDeployDate();
+
+    /**
+     * Get the process version
+     * @return version
+     */
+    int getVersion();
+
+    /**
+     * Get a message correlator instance.
+     *
+     * @param correlatorId correlator identifier
+     * @return correlator corresponding to the given identifier
+     */
+    CorrelatorDAO getCorrelator(String correlatorId);
+
+    /**
+     * Create a new process instance object.
+     *
+     * @param instantiatingCorrelator instantiating [EMAIL PROTECTED] 
CorrelatorDAO}
+     * @return newly generated instance DAO
+     */
+    ProcessInstanceDAO createInstance(CorrelatorDAO instantiatingCorrelator);
+
+    /**
+     * Get a process instance (by identifier).
+     * @param iid unique instance identifier.
+     * @return DAO corresponding to the process instance
+     */
+    ProcessInstanceDAO getInstance(Long iid);
+
+    /**
+     * Locates a process instance based on a correlation key.
+     * @param cckey correlation key
+     * @return collection of [EMAIL PROTECTED] ProcessInstanceDAO} that match 
correlation key, ordered by date
+     */
+    Collection<ProcessInstanceDAO> findInstance(CorrelationKey cckey);
+
+    /**
+     * Remove the routes with the given Id for all the correlators in the
+     * process.
+     * @todo remove this method.
+     * @param routeId
+     */
+    void removeRoutes(String routeId, ProcessInstanceDAO target);
+
+    /**
+     * Callback indicating that a process instance has completed its duties.
+     * @param instance the completed [EMAIL PROTECTED] ProcessInstanceDAO}
+     */
+    void instanceCompleted(ProcessInstanceDAO instance);
+
+    /**
+     * Adds a named property on the process providing its value as
+     * and XML Node.
+     * @param name of the property
+     * @param ns namespace of the property
+     * @param content value of the property
+     */
+    void setProperty(String name, String ns, Node content);
+
+    /**
+     * Adds a named property on the process providing its value as
+     * a simple type (handled as a simple string).
+     * @param name of the property
+     * @param ns namespace of the property
+     * @param content value of the property
+     */
+    void setProperty(String name, String ns, String content);
+
+    /**
+     * Gets the properties for the process.
+     * @return collection of [EMAIL PROTECTED] ProcessPropertyDAO}
+     */
+    Collection<ProcessPropertyDAO> getProperties();
+
+
+    /**
+     * Remove the process from the database (along with any instance,
+     * variable data, etc...).
+     */
+    void delete();
+
+
+    public boolean isRetired();
+
+    public void setRetired(boolean retired);
+
+    void setActive(boolean active);
+
+    boolean isActive();
+
+    void addCorrelator(String correlator);
+
+    void setCompiledProcess(byte[] cbp);
+
+    byte[] getCompiledProcess();
 
 }

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java?rev=431656&r1=431655&r2=431656&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
 Tue Aug 15 10:58:51 2006
@@ -193,7 +193,7 @@
 
     OProcess getOProcess(QName processId) {
         // TODO Auto-generated method stub
-        throw new UnsupportedOperationException("todo");
+        return _activeProcesses.get(processId)._oprocess;
     }
 
     public void onScheduledJob(String jobId, Map<String, Object> jobDetail) {

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java?rev=431656&r1=431655&r2=431656&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelManagementFacadeImpl.java
 Tue Aug 15 10:58:51 2006
@@ -55,260 +55,260 @@
  * the methods necessary to support process debugging. It also implements all 
the methods in the
  * newer Process/Instance Management interface (pmapi).
  */
-class BpelManagementFacadeImpl extends ProcessAndInstanceManagementImpl 
-  implements BpelManagementFacade {
-  private static UUIDGen _uuidGen = new UUIDGen();
-  
-  BpelManagementFacadeImpl(BpelDatabase db, BpelEngineImpl engine) {
-    super(db,engine);
-       }
-
-       public short getState(final Long iid) throws ManagementException {
-
-    return dbexec(new BpelDatabase.Callable<Short>()  {
-      public Short run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        return Short.valueOf(instance.getState());
-      }
-    }).shortValue();
-    
-       }
-
-
-       public Long getProcessInstance(String pid, final CorrelationKey ckey) 
throws ManagementException {
-
-    return dbexec(_db.getProcessDb(QName.valueOf(pid)).new Callable<Long>()  {
-      public Long run(BpelDAOConnection session) throws Exception {
-        Iterator<ProcessInstanceDAO> i = 
getProcessDAO().findInstance(ckey).iterator();
-        return (i.hasNext()) ? i.next().getInstanceId() : null;
-      }
-    });
-  }
-
-       public List<BpelEvent> getEvents(final Long iid, final int startIdx, 
final int count)
-          throws ManagementException {
-
-    // TODO: this is a bit of hack, if there are two events with exactly the 
-    // same timestamp, we can have more events returned then requested.
-    
-    List<String> timeline;
-    
-    try {
-      timeline = getEventTimeline("iid="+iid,null);
-    } catch (Exception ex) {
-      throw new ManagementException("Unable to retrieve timeline.", ex);
-    }
-    
-    if (startIdx >= timeline.size())
-      return Collections.emptyList();
-    
-    timeline = 
timeline.subList(startIdx,Math.min(timeline.size(),startIdx+count));
-    String startdt = timeline.get(0);
-    String enddt = timeline.get(timeline.size()-1);
-    
-    return listEvents("iid="+iid,"timestamp>="+startdt +" " 
+"timestamp<="+enddt,0);
-       }
-
-       public int getEventCount(final Long iid) throws ManagementException {
-    EventInfo einfo = getInstanceInfo(iid).getInstanceInfo().getEventInfo();
-    if (einfo == null)
-      return 0;
-    return einfo.getCount();
-       }
-
-  
-
-  public String getVariable(final Long iid, final Long scopeId, final String 
varName)
-          throws ManagementException {
-    return dbexec(new BpelDatabase.Callable<String>()  {
-      public String run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        if (instance == null) {
-          throw new ManagementException("InstanceNotFound:" + iid);
+class BpelManagementFacadeImpl extends ProcessAndInstanceManagementImpl
+        implements BpelManagementFacade {
+    private static UUIDGen _uuidGen = new UUIDGen();
+
+    BpelManagementFacadeImpl(BpelDatabase db, BpelEngineImpl engine, 
BpelServerImpl server) {
+        super(db, engine, server);
+    }
+
+    public short getState(final Long iid) throws ManagementException {
+
+        return dbexec(new BpelDatabase.Callable<Short>()  {
+            public Short run(BpelDAOConnection session) throws Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                return Short.valueOf(instance.getState());
+            }
+        }).shortValue();
+
+    }
+
+
+    public Long getProcessInstance(String pid, final CorrelationKey ckey) 
throws ManagementException {
+
+        return dbexec(_db.getProcessDb(QName.valueOf(pid)).new 
Callable<Long>()  {
+            public Long run(BpelDAOConnection session) throws Exception {
+                Iterator<ProcessInstanceDAO> i = 
getProcessDAO().findInstance(ckey).iterator();
+                return (i.hasNext()) ? i.next().getInstanceId() : null;
+            }
+        });
+    }
+
+    public List<BpelEvent> getEvents(final Long iid, final int startIdx, final 
int count)
+            throws ManagementException {
+
+        // TODO: this is a bit of hack, if there are two events with exactly 
the
+        // same timestamp, we can have more events returned then requested.
+
+        List<String> timeline;
+
+        try {
+            timeline = getEventTimeline("iid="+iid,null);
+        } catch (Exception ex) {
+            throw new ManagementException("Unable to retrieve timeline.", ex);
         }
+
+        if (startIdx >= timeline.size())
+            return Collections.emptyList();
+
+        timeline = 
timeline.subList(startIdx,Math.min(timeline.size(),startIdx+count));
+        String startdt = timeline.get(0);
+        String enddt = timeline.get(timeline.size()-1);
+
+        return listEvents("iid="+iid,"timestamp>="+startdt +" " 
+"timestamp<="+enddt,0);
+    }
+
+    public int getEventCount(final Long iid) throws ManagementException {
+        EventInfo einfo = 
getInstanceInfo(iid).getInstanceInfo().getEventInfo();
+        if (einfo == null)
+            return 0;
+        return einfo.getCount();
+    }
+
+
+
+    public String getVariable(final Long iid, final Long scopeId, final String 
varName)
+            throws ManagementException {
+        return dbexec(new BpelDatabase.Callable<String>()  {
+            public String run(BpelDAOConnection session) throws Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                if (instance == null) {
+                    throw new ManagementException("InstanceNotFound:" + iid);
+                }
+                ScopeDAO scope = instance.getScope(scopeId);
+                if (scope == null) {
+                    throw new ManagementException("ScopeNotFound:" + scopeId);
+                }
+                XmlDataDAO var = scope.getVariable(varName);
+                if (var == null) {
+                    throw new ManagementException("VarNotFound:" + varName);
+                }
+                return nodeToString(var);
+            }
+        });
+    }
+
+    public Long[] getScopeInstancesForScope(final Long iid, final String 
scopeName) throws ManagementException {
+
+        return dbexec(new BpelDatabase.Callable<Long[]>()  {
+            public Long[] run(BpelDAOConnection session) throws Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                if (instance == null) {
+                    throw new ManagementException("InstanceNotFound:" + iid);
+                }
+                Collection<ScopeDAO> scopes = instance.getScopes(scopeName);
+                List<Long>instanceIds = new ArrayList<Long>(scopes.size());
+                for(ScopeDAO i : scopes) {
+                    instanceIds.add(i.getScopeInstanceId());
+                }
+                return instanceIds.toArray(new Long[scopes.size()]);
+            }
+        });
+    }
+
+    public void setVariable(Long pid, Long scopeId, String varName, String 
data) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setCorrelation(final Long iid, final Long scopeId, final 
String correlationSet,
+                               final QName[] propertyNames, final 
CorrelationKey values)
+            throws ManagementException {
+
+        dbexec(new BpelDatabase.Callable<Object>()  {
+            public Object run(BpelDAOConnection session) throws Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                if (instance == null) {
+                    throw new ManagementException("InstanceNotFound:" + iid);
+                }
+                CorrelationSetDAO correlationSetDAO = 
instance.getCorrelationSet(correlationSet);
+                correlationSetDAO.setValue(propertyNames, values);
+                return null;
+            }
+        });
+
+    }
+
+    public CorrelationKey getCorrelation(final Long iid, final Long scopeId, 
final String correlationSet) throws ManagementException {
+        return dbexec(new BpelDatabase.Callable<CorrelationKey>()  {
+            public CorrelationKey run(BpelDAOConnection session) throws 
Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                if (instance == null) {
+                    throw new ManagementException("InstanceNotFound:" + iid);
+                }
+                CorrelationSetDAO corr = findCorrelationSetDAO(instance, 
scopeId, correlationSet);
+                return corr.getValue();
+            }
+        });
+    }
+
+    /**
+     * @see BpelManagementFacade#getProcessDef(String)
+     * @param procid
+     */
+    public OProcess getProcessDef(String procid) throws ManagementException {
+        if (_engine == null)
+            throw new ProcessingException("ServiceProvider required for 
debugger operation.");
+
+        BpelProcess process = 
_engine._activeProcesses.get(QName.valueOf(procid));
+        if (process == null)
+            throw new InvalidRequestException("The process \"" + procid + "\" 
is not available. Please make sure it is deployed and encompassing System is 
activated." );
+
+        return process._oprocess;
+    }
+
+    public void step(final Long iid) throws ManagementException {
+        // We need debugger support in order to resume (since we have to force
+        // a reduction. If one is not available the getDebugger() method should
+        // throw a ProcessingException
+        DebuggerSupport debugSupport = getDebugger(iid);
+        assert debugSupport != null : "getDebugger(Long) returned NULL!";
+        debugSupport.step(iid);
+    }
+
+    public QName getCompletedFault(final Long iid) throws ManagementException {
+
+        return dbexec(new BpelDatabase.Callable<QName>()  {
+            public QName run(BpelDAOConnection session) throws Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                if (instance == null)
+                    throw new ManagementException("InstanceNotFound:" + iid);
+                return instance.getFault().getName();
+            }
+        });
+    }
+
+    public Breakpoint[] getGlobalBreakpoints(String procId) throws 
ManagementException {
+        DebuggerSupport debuggerSupport = getDebugger(QName.valueOf(procId));
+        return debuggerSupport.getGlobalBreakpoints();
+    }
+
+    public Breakpoint[] getBreakpoints(Long iid) throws ManagementException {
+        DebuggerSupport debuggerSupport = getDebugger(iid);
+        return debuggerSupport.getBreakpoints(iid);
+    }
+
+
+    public void removeGlobalBreakpoint(String procid, Breakpoint sp) throws 
ManagementException {
+        DebuggerSupport debuggerSupport = getDebugger(QName.valueOf(procid));
+        debuggerSupport.removeGlobalBreakpoint(sp);
+    }
+
+    public void removeBreakpoint(Long iid, Breakpoint sp) throws 
ManagementException {
+        DebuggerSupport debuggerSupport = getDebugger(iid);
+        debuggerSupport.removeBreakpoint(iid, sp);
+    }
+
+    public ActivityBreakpoint addGlobalActivityBreakpoint(String procid, 
String activity) throws ManagementException {
+        DebuggerSupport debuggerSupport = getDebugger(QName.valueOf(procid));
+
+        ActivityBreakpointImpl bp = new 
ActivityBreakpointImpl(_uuidGen.nextUUID(), activity);
+        debuggerSupport.addGlobalBreakpoint(bp);
+        return bp;
+    }
+
+    public ActivityBreakpoint addActivityBreakpoint(Long iid, String activity) 
throws ManagementException {
+        DebuggerSupport debuggerSupport = getDebugger(iid);
+
+        ActivityBreakpointImpl bp = new 
ActivityBreakpointImpl(_uuidGen.nextUUID(), activity);
+        debuggerSupport.addBreakpoint(iid, bp);
+        return bp;
+    }
+
+    public VariableModificationBreakpoint 
addVariableModificationBreakpoint(Long iid, String scopename, String variable) {
+        throw new UnsupportedOperationException();
+    }
+
+    public Date getStartTime(final Long iid) throws ManagementException {
+
+        return dbexec(new BpelDatabase.Callable<Date>()  {
+            public Date run(BpelDAOConnection session) throws Exception {
+                ProcessInstanceDAO instance = session.getInstance(iid);
+                if (instance == null)
+                    throw new InstanceNotFoundException("InstanceNotFound:" + 
iid);
+                return instance.getCreateTime();
+            }
+        });
+    }
+
+    private CorrelationSetDAO findCorrelationSetDAO(ProcessInstanceDAO 
instance, Long scopeId, String correlationSet)
+            throws ManagementException {
         ScopeDAO scope = instance.getScope(scopeId);
-        if (scope == null) {
-          throw new ManagementException("ScopeNotFound:" + scopeId);
-        }
-        XmlDataDAO var = scope.getVariable(varName);
-        if (var == null) {
-          throw new ManagementException("VarNotFound:" + varName);
-        }
-        return nodeToString(var);
-      }
-    });
-       }
-
-  public Long[] getScopeInstancesForScope(final Long iid, final String 
scopeName) throws ManagementException {
-
-    return dbexec(new BpelDatabase.Callable<Long[]>()  {
-      public Long[] run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        if (instance == null) {
-          throw new ManagementException("InstanceNotFound:" + iid);
-        }
-        Collection<ScopeDAO> scopes = instance.getScopes(scopeName);
-        List<Long>instanceIds = new ArrayList<Long>(scopes.size());
-        for(ScopeDAO i : scopes) {
-          instanceIds.add(i.getScopeInstanceId());
-        }
-        return instanceIds.toArray(new Long[scopes.size()]);
-      }
-    });
-  }
-  
-       public void setVariable(Long pid, Long scopeId, String varName, String 
data) {
-               throw new UnsupportedOperationException();
-       }
-
-       public void setCorrelation(final Long iid, final Long scopeId, final 
String correlationSet,
-                             final QName[] propertyNames, final CorrelationKey 
values)
-          throws ManagementException {
-
-    dbexec(new BpelDatabase.Callable<Object>()  {
-      public Object run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        if (instance == null) {
-          throw new ManagementException("InstanceNotFound:" + iid);
-        }
-        CorrelationSetDAO correlationSetDAO = 
instance.getCorrelationSet(correlationSet);
-        correlationSetDAO.setValue(propertyNames, values);
-        return null;
-      }
-    });
-
-       }
-
-       public CorrelationKey getCorrelation(final Long iid, final Long 
scopeId, final String correlationSet) throws ManagementException {
-    return dbexec(new BpelDatabase.Callable<CorrelationKey>()  {
-      public CorrelationKey run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        if (instance == null) {
-          throw new ManagementException("InstanceNotFound:" + iid);
+        CorrelationSetDAO corr = null;
+        do {
+            corr = scope.getCorrelationSet(correlationSet);
+            if(corr != null)
+                break;
+            scope = scope.getParentScope();
+        } while(scope != null);
+
+        if(corr == null)
+            throw new ManagementException("CorrelationSetNotFound:" + 
correlationSet);
+
+        return corr;
+    }
+
+
+    private static String nodeToString(XmlDataDAO xml){
+        Node data = xml.get();
+        String str;
+        if (data == null) {
+            str = null;
+        } else if (data.getNodeType() == Node.ELEMENT_NODE) {
+            str = DOMUtils.domToString(data);
+        } else {
+            str = data.getNodeValue();
         }
-        CorrelationSetDAO corr = findCorrelationSetDAO(instance, scopeId, 
correlationSet);
-        return corr.getValue();
-      }
-    });
-       }
-
-       /**
-        * @see BpelManagementFacade#getProcessDef(String)
-   * @param procid
-   */
-       public OProcess getProcessDef(String procid) throws ManagementException 
{
-    if (_engine == null)
-      throw new ProcessingException("ServiceProvider required for debugger 
operation.");
-
-    BpelProcess process = _engine._activeProcesses.get(QName.valueOf(procid));
-    if (process == null)
-      throw new InvalidRequestException("The process \"" + procid + "\" is not 
available. Please make sure it is deployed and encompassing System is 
activated." );
-
-    return process._oprocess;
-       }
-
-       public void step(final Long iid) throws ManagementException {
-    // We need debugger support in order to resume (since we have to force
-    // a reduction. If one is not available the getDebugger() method should
-    // throw a ProcessingException
-    DebuggerSupport debugSupport = getDebugger(iid);
-    assert debugSupport != null : "getDebugger(Long) returned NULL!";
-    debugSupport.step(iid);
-       }
-
-       public QName getCompletedFault(final Long iid) throws 
ManagementException {
-
-    return dbexec(new BpelDatabase.Callable<QName>()  {
-      public QName run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        if (instance == null)
-          throw new ManagementException("InstanceNotFound:" + iid);
-        return instance.getFault().getName();
-      }
-    });
-       }
-
-  public Breakpoint[] getGlobalBreakpoints(String procId) throws 
ManagementException {
-    DebuggerSupport debuggerSupport = getDebugger(QName.valueOf(procId));
-    return debuggerSupport.getGlobalBreakpoints();
-  }
-
-       public Breakpoint[] getBreakpoints(Long iid) throws ManagementException 
{
-    DebuggerSupport debuggerSupport = getDebugger(iid);
-    return debuggerSupport.getBreakpoints(iid);
-       }
-
-
-  public void removeGlobalBreakpoint(String procid, Breakpoint sp) throws 
ManagementException {
-    DebuggerSupport debuggerSupport = getDebugger(QName.valueOf(procid));
-    debuggerSupport.removeGlobalBreakpoint(sp);
-  }
-
-       public void removeBreakpoint(Long iid, Breakpoint sp) throws 
ManagementException {
-    DebuggerSupport debuggerSupport = getDebugger(iid);
-    debuggerSupport.removeBreakpoint(iid, sp);
-       }
-
-  public ActivityBreakpoint addGlobalActivityBreakpoint(String procid, String 
activity) throws ManagementException {
-    DebuggerSupport debuggerSupport = getDebugger(QName.valueOf(procid));
-
-    ActivityBreakpointImpl bp = new 
ActivityBreakpointImpl(_uuidGen.nextUUID(), activity);
-      debuggerSupport.addGlobalBreakpoint(bp);
-    return bp;
-       }
-  
-       public ActivityBreakpoint addActivityBreakpoint(Long iid, String 
activity) throws ManagementException {
-    DebuggerSupport debuggerSupport = getDebugger(iid);
-
-    ActivityBreakpointImpl bp = new 
ActivityBreakpointImpl(_uuidGen.nextUUID(), activity);
-    debuggerSupport.addBreakpoint(iid, bp);
-    return bp;
-       }
-
-       public VariableModificationBreakpoint 
addVariableModificationBreakpoint(Long iid, String scopename, String variable) {
-               throw new UnsupportedOperationException();
-       }
-
-       public Date getStartTime(final Long iid) throws ManagementException {
-
-    return dbexec(new BpelDatabase.Callable<Date>()  {
-      public Date run(BpelDAOConnection session) throws Exception {
-        ProcessInstanceDAO instance = session.getInstance(iid);
-        if (instance == null)
-               throw new InstanceNotFoundException("InstanceNotFound:" + iid);
-        return instance.getCreateTime();
-      }
-    });
-       }
-
-  private CorrelationSetDAO findCorrelationSetDAO(ProcessInstanceDAO instance, 
Long scopeId, String correlationSet)
-          throws ManagementException {
-    ScopeDAO scope = instance.getScope(scopeId);
-    CorrelationSetDAO corr = null;
-    do {
-      corr = scope.getCorrelationSet(correlationSet);
-      if(corr != null)
-        break;
-      scope = scope.getParentScope();
-    } while(scope != null);
-
-    if(corr == null)
-      throw new ManagementException("CorrelationSetNotFound:" + 
correlationSet);
-
-    return corr;
-  }
-
-
-  private static String nodeToString(XmlDataDAO xml){
-       Node data = xml.get();
-    String str;
-    if (data == null) {
-      str = null;
-    } else if (data.getNodeType() == Node.ELEMENT_NODE) {
-      str = DOMUtils.domToString(data);
-    } else {
-      str = data.getNodeValue();
+        return str;
     }
-    return str;
-  }
 }

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=431656&r1=431655&r2=431656&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 15 10:58:51 2006
@@ -338,7 +338,7 @@
     }
 
     public BpelManagementFacade getBpelManagementFacade() {
-        return new BpelManagementFacadeImpl(_db, _engine);
+        return new BpelManagementFacadeImpl(_db, _engine, this);
     }
 
     public void setMessageExchangeContext(MessageExchangeContext mexContext) 
throws BpelEngineException {
@@ -554,7 +554,7 @@
         }
     }
 
-    private DeploymentUnitImpl getDeploymentUnit(QName pid) {
+    public DeploymentUnitImpl getDeploymentUnit(QName pid) {
         return _deploymentUnits.get(pid);
     }
 


Reply via email to