Author: mriou
Date: Wed Aug 16 16:24:25 2006
New Revision: 432065

URL: http://svn.apache.org/viewvc?rev=432065&view=rev
Log:
ODE-27 ODE-14 More management API tests, more bug fixes.

Modified:
    
incubator/ode/trunk/axis2-war/src/main/webapp/WEB-INF/classes/log4j.properties
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/MessageExchangeContextImpl.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/deploy/DeploymentPoller.java
    incubator/ode/trunk/axis2/src/main/wsdl/pmapi.wsdl
    
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java
    
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/ProcessManagement.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentUnitImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java

Modified: 
incubator/ode/trunk/axis2-war/src/main/webapp/WEB-INF/classes/log4j.properties
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2-war/src/main/webapp/WEB-INF/classes/log4j.properties?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2-war/src/main/webapp/WEB-INF/classes/log4j.properties 
(original)
+++ 
incubator/ode/trunk/axis2-war/src/main/webapp/WEB-INF/classes/log4j.properties 
Wed Aug 16 16:24:25 2006
@@ -1,42 +1,18 @@
-#
-# 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.
-#
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=WARN, CONSOLE
 
-# Set root category priority to INFO and its only appender to CONSOLE.
-log4j.rootCategory=D, CONSOLE
-#log4j.rootCategory=INFO, CONSOLE, LOGFILE
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=ERROR
+log4j.category.org.hibernate.type=WARN
+log4j.category.org.objectweb=ERROR
+log4j.category.org.apache.ode.axis2=DEBUG
+log4j.category.org.apache.ode.bpel.engine=DEBUG
+log4j.category.org.apache.ode.bpel.epr=INFO
 
-# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
-log4j.logger.org.apache.axis2.enterprise=FATAL, CONSOLE
-log4j.logger.de.hunsicker.jalopy.io=FATAL, CONSOLE
-
-# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+# Console appender
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=INFO
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
-
-# LOGFILE is set to be a File appender using a PatternLayout.
-log4j.appender.LOGFILE=org.apache.log4j.FileAppender
-log4j.appender.LOGFILE.File=axis2.log
-log4j.appender.LOGFILE.Append=true
-log4j.appender.LOGFILE.Threshold=INFO
-log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+log4j.appender.CONSOLE.layout=org.apache.log4j.SimpleLayout
 
-log4j.category.org.apache.axis2=DEBUG
\ No newline at end of file
+# Uncomment the following if you want fancy 
+#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+#log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
 Wed Aug 16 16:24:25 2006
@@ -19,16 +19,6 @@
 
 package org.apache.ode.axis2;
 
-import org.apache.ode.bpel.epr.MutableEndpoint;
-import org.apache.ode.bpel.epr.EndpointFactory;
-import org.apache.ode.bpel.iapi.Message;
-import org.apache.ode.bpel.iapi.MessageExchange;
-import org.apache.ode.bpel.iapi.PartnerRoleChannel;
-import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
-import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.Namespaces;
-import org.apache.ode.axis2.util.OMUtils;
-import org.apache.ode.axis2.util.SOAPUtils;
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
@@ -38,6 +28,16 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.util.OMUtils;
+import org.apache.ode.axis2.util.SOAPUtils;
+import org.apache.ode.bpel.epr.EndpointFactory;
+import org.apache.ode.bpel.epr.MutableEndpoint;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.Namespaces;
 import org.w3c.dom.Element;
 
 import javax.wsdl.Definition;
@@ -146,6 +146,9 @@
                 ODEService.genEPRfromWSDL(_definition, _serviceName, 
_portName));
         org.apache.ode.bpel.iapi.EndpointReference ref = 
EndpointFactory.convert(
                 new QName(Namespaces.WS_ADDRESSING_NS, "EndpointReference"), 
eprElmt);
+        System.out.println("INITIAL EPR CREATION 
#########################################################");
+        System.out.println(DOMUtils.domToString(ref.toXML()));
+        
System.out.println("#########################################################");
         return ref;
     }
 

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/MessageExchangeContextImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/MessageExchangeContextImpl.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/MessageExchangeContextImpl.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/MessageExchangeContextImpl.java
 Wed Aug 16 16:24:25 2006
@@ -19,18 +19,17 @@
 
 package org.apache.ode.axis2;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.epr.EndpointFactory;
+import org.apache.ode.bpel.epr.WSAEndpoint;
 import org.apache.ode.bpel.iapi.BpelEngineException;
 import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.EndpointReference;
 import org.apache.ode.bpel.iapi.MessageExchangeContext;
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
 import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
-import org.apache.ode.bpel.iapi.EndpointReference;
-import org.apache.ode.bpel.epr.WSDL11Endpoint;
-import org.apache.ode.bpel.epr.EndpointFactory;
-import org.apache.ode.bpel.epr.WSAEndpoint;
 import org.apache.ode.utils.Namespaces;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 
@@ -41,41 +40,41 @@
  */
 public class MessageExchangeContextImpl implements MessageExchangeContext {
 
-  private static final Log __log = 
LogFactory.getLog(MessageExchangeContextImpl.class);
+    private static final Log __log = 
LogFactory.getLog(MessageExchangeContextImpl.class);
 
-  private ODEServer _server;
+    private ODEServer _server;
 
-  public MessageExchangeContextImpl(ODEServer server) {
-    _server = server;
-  }
-
-  public void invokePartner(PartnerRoleMessageExchange 
partnerRoleMessageExchange) throws ContextException {
-    if (__log.isDebugEnabled())
-      __log.debug("Invoking a partner operation: " + 
partnerRoleMessageExchange.getOperationName());
-
-    EndpointReference epr = partnerRoleMessageExchange.getEndpointReference();
-    // We only invoke with WSA endpoints, that makes our life easier
-    if (!(epr instanceof WSAEndpoint))
-      epr = EndpointFactory.convert(new QName(Namespaces.WS_ADDRESSING_NS, 
"EndpointReference"),
-              epr.toXML().getDocumentElement());
-    // It's now safe to cast
-    QName serviceName = ((WSAEndpoint)epr).getServiceName();
-    String portName = ((WSAEndpoint)epr).getPortName();
-    if (__log.isDebugEnabled())
-      __log.debug("The service to invoke is the external service " + 
serviceName);
-    ExternalService service = _server.getExternalService(serviceName, 
portName);
-    service.invoke(partnerRoleMessageExchange);
-  }
-
-  public void onAsyncReply(MyRoleMessageExchange myRoleMessageExchange) throws 
BpelEngineException {
-    if (__log.isDebugEnabled())
-      __log.debug("Processing an async reply from service " + 
myRoleMessageExchange.getServiceName());
-
-    // TODO Add a port in MessageExchange (for now there's only service) to be 
able to find the
-    // TODO right service. For now we'll just lookup by service+portType but 
if we have severalt ports
-    // TODO for the same portType that will not work.
-    ODEService service = 
_server.getService(myRoleMessageExchange.getServiceName(),
-            myRoleMessageExchange.getPortType().getQName());
-    service.notifyResponse(myRoleMessageExchange);
-  }
+    public MessageExchangeContextImpl(ODEServer server) {
+        _server = server;
+    }
+
+    public void invokePartner(PartnerRoleMessageExchange 
partnerRoleMessageExchange) throws ContextException {
+        if (__log.isDebugEnabled())
+            __log.debug("Invoking a partner operation: " + 
partnerRoleMessageExchange.getOperationName());
+
+        EndpointReference epr = 
partnerRoleMessageExchange.getEndpointReference();
+        // We only invoke with WSA endpoints, that makes our life easier
+        if (!(epr instanceof WSAEndpoint))
+            epr = EndpointFactory.convert(new 
QName(Namespaces.WS_ADDRESSING_NS, "EndpointReference"),
+                    epr.toXML().getDocumentElement());
+        // It's now safe to cast
+        QName serviceName = ((WSAEndpoint)epr).getServiceName();
+        String portName = ((WSAEndpoint)epr).getPortName();
+        if (__log.isDebugEnabled())
+            __log.debug("The service to invoke is the external service " + 
serviceName);
+        ExternalService service = _server.getExternalService(serviceName, 
portName);
+        service.invoke(partnerRoleMessageExchange);
+    }
+
+    public void onAsyncReply(MyRoleMessageExchange myRoleMessageExchange) 
throws BpelEngineException {
+        if (__log.isDebugEnabled())
+            __log.debug("Processing an async reply from service " + 
myRoleMessageExchange.getServiceName());
+
+        // TODO Add a port in MessageExchange (for now there's only service) 
to be able to find the
+        // TODO right service. For now we'll just lookup by service+portType 
but if we have severalt ports
+        // TODO for the same portType that will not work.
+        ODEService service = 
_server.getService(myRoleMessageExchange.getServiceName(),
+                myRoleMessageExchange.getPortType().getQName());
+        service.notifyResponse(myRoleMessageExchange);
+    }
 }

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/deploy/DeploymentPoller.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/deploy/DeploymentPoller.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/deploy/DeploymentPoller.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/deploy/DeploymentPoller.java
 Wed Aug 16 16:24:25 2006
@@ -38,15 +38,15 @@
 
 package org.apache.ode.axis2.deploy;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.ODEServer;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.FilenameFilter;
 import java.io.IOException;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.axis2.ODEServer;
-
 /**
  * Polls a directory for the deployment of a new deployment unit.
  */
@@ -118,7 +118,6 @@
             }
 
             if (deployedMarker.exists()) {
-                __log.debug("Deployed marker for " + file + " exists, skipping 
deployment");
                 continue;
             }
 

Modified: incubator/ode/trunk/axis2/src/main/wsdl/pmapi.wsdl
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/wsdl/pmapi.wsdl?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- incubator/ode/trunk/axis2/src/main/wsdl/pmapi.wsdl (original)
+++ incubator/ode/trunk/axis2/src/main/wsdl/pmapi.wsdl Wed Aug 16 16:24:25 2006
@@ -72,6 +72,13 @@
   <message name="getProcessInfoOutput">
     <part name="process-info" type="typ:tProcessInfo"/>
   </message>
+  <message name="getProcessInfoCustomInput">
+    <part name="pid" type="xsd:QName"/>
+    <part name="customizer" type="xsd:string"/>
+  </message>
+  <message name="getProcessInfoCustomOutput">
+    <part name="process-info" type="typ:tProcessInfo"/>
+  </message>
   <message name="getExtensibilityElementsInput">
     <part name="pid" type="xsd:QName"/>
     <part name="aids" type="tns:aidsType"/>
@@ -97,8 +104,8 @@
   </message>
   <message name="setEndpointReferenceInput">
     <part name="pid" type="xsd:QName"/>
-    <part name="partnerLink" type="xsd:QName"/>
-    <part name="role" type="xsd:QName"/>
+    <part name="partnerLink" type="xsd:string"/>
+    <part name="role" type="xsd:string"/>
     <part name="endpoint" type="xsd:anyType"/>
   </message>
   <message name="setEndpointReferenceOutput">
@@ -221,6 +228,10 @@
     <operation name="getProcessInfo">
       <input message="tns:getProcessInfoInput"/>
       <output message="tns:getProcessInfoOutput"/>
+    </operation>
+    <operation name="getProcessInfoCustom">
+      <input message="tns:getProcessInfoCustomInput"/>
+      <output message="tns:getProcessInfoCustomOutput"/>
     </operation>
     <operation name="setProcessProperty">
       <input message="tns:setProcessPropertyInput"/>

Modified: 
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java
 Wed Aug 16 16:24:25 2006
@@ -94,11 +94,14 @@
         assert(result.toString().indexOf("DynPartnerResponder") >= 0);
     }
 
-    public void testGetProcessInfo() throws Exception {
-        OMElement root = buildMessage("getProcessInfo", new String[] {"pid"},
-                new QName[] { new QName("http://ode/bpel/responder";, 
"DynPartnerResponder")});
+    public void testSetProcessProperty() throws Exception {
+        OMElement root = buildMessage("setProcessProperty",
+                new String[] {"pid", "propertyName", "propertyValue"},
+                new Object[] { new QName("http://ode/bpel/unit-test";, 
"DynPartnerMain"),
+                        new QName("http://ode/custom/ns";, "someprop"), 
"somevalue" });
         OMElement result = sendToPM(root);
-        assert(result.toString().indexOf("DynPartnerResponder") >= 0);
+        assert(result.toString().indexOf("DynPartnerMain") >= 0);
+        assert(result.toString().indexOf("somevalue") >= 0);
     }
 
     protected void setUp() throws Exception {

Modified: 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/ProcessManagement.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/ProcessManagement.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/ProcessManagement.java
 (original)
+++ 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/pmapi/ProcessManagement.java
 Wed Aug 16 16:24:25 2006
@@ -18,7 +18,6 @@
  */
 package org.apache.ode.bpel.pmapi;
 
-import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import javax.xml.namespace.QName;
@@ -96,20 +95,6 @@
   ProcessInfoDocument setProcessProperty(QName pid, QName propertyName, String 
value)
           throws ManagementException;
 
-  /**
-   * Associates an endpoint reference with the provided partner link role 
(overriding
-   * default endpoint address extracted from WSDL).
-   * @param pid
-   * @param partnerLink
-   * @param role
-   * @param endpointRef
-   * @return [EMAIL PROTECTED] ProcessInfoDocument} reflecting the modification
-   * TODO: avoid using Element arguments
-   */
-  ProcessInfoDocument setEndpointReference(QName pid, String partnerLink, 
String role, Element endpointRef)
-          throws ManagementException;
-
-  
   /**
    * Activate a process.
    * @param pid identifier for the process to activate

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentUnitImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentUnitImpl.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentUnitImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DeploymentUnitImpl.java
 Wed Aug 16 16:24:25 2006
@@ -55,216 +55,216 @@
  */
 public class DeploymentUnitImpl implements DeploymentUnit {
 
-  private static Log __log = LogFactory.getLog(DeploymentUnitImpl.class);
+    private static Log __log = LogFactory.getLog(DeploymentUnitImpl.class);
 
-  private long _lastModified;
+    private long _lastModified;
 
-  private String _name;
+    private String _name;
 
-  private File _duDirectory;
+    private File _duDirectory;
 
-  private DocumentRegistry _docRegistry;
-
-  private HashMap<QName, OProcess> _processes;
-
-  private DeployDocument _dd;
-
-  private File _descriptorFile;
-
-  private HashMap<QName, TDeployment.Process> _processInfo;
-
-  private static final FileFilter _wsdlFilter = new FileFilter() {
-    public boolean accept(File path) {
-      return path.getName().endsWith(".wsdl");
-    }
-  };
-
-  private static final FileFilter _cbpFilter = new FileFilter() {
-    public boolean accept(File path) {
-      return path.getName().endsWith(".cbp");
-    }
-  };
-
-  private static final FileFilter _bpelFilter = new FileFilter() {
-    public boolean accept(File path) {
-      return path.getName().endsWith(".bpel");
-    }
-  };
-
-  public DeploymentUnitImpl(File dir) {
-    if (!dir.exists())
-      throw new IllegalArgumentException("Directory "  + dir + " does not 
exist!");
-
-    _duDirectory = dir;
-    _name = dir.getName();
-    _descriptorFile = new File(_duDirectory, "deploy.xml");
-
-    if (!_descriptorFile.exists())
-      throw new IllegalArgumentException("Directory " + dir + " does not 
contain a deploy.xml file!");
-
-    _lastModified = _descriptorFile.lastModified();
-  }
-
-  /**
-   * Checking for each BPEL file if we have a corresponding compiled process.
-   * If we don't, starts compilation. The force parameter just forces
-   * compilation, whether a cbp file exists or not.
-   */
-  private void compileProcesses() {
-    File[] bpels = _duDirectory.listFiles(_bpelFilter);
-    for (File bpel : bpels) {
-      compile(bpel);
-    }
-  }
-
-  private void compile(File bpelFile) {
-    BpelC bpelc = BpelC.newBpelCompiler();
-    bpelc.setOutputDirectory(_duDirectory);
-    bpelc.setWsdlFinder(new DUWsdlFinder(_duDirectory));
-    bpelc.setXsltFinder(new DUXsltFinder(_duDirectory));
-    try {
-      bpelc.compile(bpelFile.toURL());
-    } catch (IOException e) {
-      __log.error("Couldn't compile process file!", e);
-    }
-  }
-
-  private void loadProcessDefinitions() {
-    try {
-      compileProcesses();
-    } catch (CompilationException e) {
-      // No retry on compilation error, we just forget about it
-      _lastModified = new File(_duDirectory, "deploy.xml").lastModified();
-      throw new BpelEngineException("Compilation failure!");
-    }
-    if (_processes == null) {
-      _processes = new HashMap<QName, OProcess>();
-      File[] cbps = _duDirectory.listFiles(_cbpFilter);
-      for (File file : cbps) {
-        OProcess oprocess = loadProcess(file);
-        _processes.put(new QName(oprocess.targetNamespace, 
oprocess.getName()), oprocess);
-      }
-    }
-  }
-
-  /**
-   * Load the parsed and compiled BPEL process definition.
-   */
-  private OProcess loadProcess(File f) {
-    InputStream is = null;
-    try {
-      is = new FileInputStream(f);
-      Serializer ofh = new Serializer(is);
-      return ofh.readOProcess();
-    } catch (Exception e) {
-      throw new BpelEngineException("Couldn't read compiled BPEL process " + 
f.getAbsolutePath(), e);
-    } finally {
-      try {
-        if (is != null)
-          is.close();
-      } catch (Exception e) {
-      }
-    }
-  }
-
-  public boolean removed() {
-    return !_duDirectory.exists();
-  }
-
-  public boolean matches(File f) {
-    return f.getAbsolutePath().equals(new File(_duDirectory, 
"deploy.xml").getAbsolutePath());
-  }
-
-  public boolean checkForUpdate() {
-    File deployXml = new File(_duDirectory, "deploy.xml");
-    if (!deployXml.exists())
-      return false;
-    return deployXml.lastModified() != _lastModified;
-  }
-
-  public int hashCode() {
-    return (int) (_name.hashCode() + _lastModified);
-  }
-
-  public File getDeployDir() {
-    return _duDirectory;
-  }
-
-  public void setLastModified(long lastModified) {
-    _lastModified = lastModified;
-  }
-
-  public long getLastModified() {
-    return _lastModified;
-  }
-
-  public DeployDocument getDeploymentDescriptor() {
-    if (_dd == null) {
-      File ddLocation = new File(_duDirectory, "deploy.xml");
-      try {
-        _dd = DeployDocument.Factory.parse(ddLocation);
-      } catch (Exception e) {
-        throw new BpelEngineException("Couldnt read deployment descriptor at 
location "
-                + ddLocation.getAbsolutePath(), e);
-      }
-
-    }
-    return _dd;
-  }
-
-  public HashMap<QName, OProcess> getProcesses() {
-    loadProcessDefinitions();
-    return _processes;
-  }
-
-  public DocumentRegistry getDocRegistry() {
-    if (_docRegistry == null) {
-      _docRegistry = new DocumentRegistry(new 
DocumentEntityResolver(_duDirectory));
+    private DocumentRegistry _docRegistry;
 
-      WSDLFactory4BPEL wsdlFactory = (WSDLFactory4BPEL) 
WSDLFactoryBPEL20.newInstance();
-      WSDLReader r = wsdlFactory.newWSDLReader();
+    private HashMap<QName, OProcess> _processes;
 
-      File[] wsdls = _duDirectory.listFiles(_wsdlFilter);
-      for (File file : wsdls) {
+    private DeployDocument _dd;
+
+    private File _descriptorFile;
+
+    private HashMap<QName, TDeployment.Process> _processInfo;
+
+    private static final FileFilter _wsdlFilter = new FileFilter() {
+        public boolean accept(File path) {
+            return path.getName().endsWith(".wsdl");
+        }
+    };
+
+    private static final FileFilter _cbpFilter = new FileFilter() {
+        public boolean accept(File path) {
+            return path.getName().endsWith(".cbp");
+        }
+    };
+
+    private static final FileFilter _bpelFilter = new FileFilter() {
+        public boolean accept(File path) {
+            return path.getName().endsWith(".bpel");
+        }
+    };
+
+    public DeploymentUnitImpl(File dir) {
+        if (!dir.exists())
+            throw new IllegalArgumentException("Directory "  + dir + " does 
not exist!");
+
+        _duDirectory = dir;
+        _name = dir.getName();
+        _descriptorFile = new File(_duDirectory, "deploy.xml");
+
+        if (!_descriptorFile.exists())
+            throw new IllegalArgumentException("Directory " + dir + " does not 
contain a deploy.xml file!");
+
+        _lastModified = _descriptorFile.lastModified();
+    }
+
+    /**
+     * Checking for each BPEL file if we have a corresponding compiled process.
+     * If we don't, starts compilation. The force parameter just forces
+     * compilation, whether a cbp file exists or not.
+     */
+    private void compileProcesses() {
+        File[] bpels = _duDirectory.listFiles(_bpelFilter);
+        for (File bpel : bpels) {
+            compile(bpel);
+        }
+    }
+
+    private void compile(File bpelFile) {
+        BpelC bpelc = BpelC.newBpelCompiler();
+        bpelc.setOutputDirectory(_duDirectory);
+        bpelc.setWsdlFinder(new DUWsdlFinder(_duDirectory));
+        bpelc.setXsltFinder(new DUXsltFinder(_duDirectory));
+        try {
+            bpelc.compile(bpelFile.toURL());
+        } catch (IOException e) {
+            __log.error("Couldn't compile process file!", e);
+        }
+    }
+
+    private void loadProcessDefinitions() {
+        try {
+            compileProcesses();
+        } catch (CompilationException e) {
+            // No retry on compilation error, we just forget about it
+            _lastModified = new File(_duDirectory, 
"deploy.xml").lastModified();
+            throw new BpelEngineException("Compilation failure!");
+        }
+        if (_processes == null) {
+            _processes = new HashMap<QName, OProcess>();
+            File[] cbps = _duDirectory.listFiles(_cbpFilter);
+            for (File file : cbps) {
+                OProcess oprocess = loadProcess(file);
+                _processes.put(new QName(oprocess.targetNamespace, 
oprocess.getName()), oprocess);
+            }
+        }
+    }
+
+    /**
+     * Load the parsed and compiled BPEL process definition.
+     */
+    private OProcess loadProcess(File f) {
+        InputStream is = null;
         try {
-          _docRegistry.addDefinition((Definition4BPEL) 
r.readWSDL(file.toURI().toString()));
-        } catch (WSDLException e) {
-          throw new BpelEngineException("Couldn't read WSDL document " + 
file.getAbsolutePath(), e);
-        }
-      }
-    }
-    return _docRegistry;
-  }
-
-  public Definition4BPEL getDefinitionForNamespace(String namespaceURI) {
-    return getDocRegistry().getDefinition(namespaceURI);
-  }
-
-  public Collection<Definition4BPEL> getDefinitions() {
-    Definition4BPEL defs[] = getDocRegistry().getDefinitions();
-    ArrayList<Definition4BPEL> ret = new 
ArrayList<Definition4BPEL>(defs.length);
-    for (Definition4BPEL def: defs)
-      ret.add(def);
-    return ret;
-  }
-
-  public Set<QName> getProcessNames() {
-    return _processes.keySet();
-  }
-
-  public String toString() {
-    return "{DeploymentUnit " + _name + "}";
-  }
-
-  public TDeployment.Process getProcessDeployInfo(QName pid) {
-    if (_processInfo == null) {
-      _processInfo = new HashMap<QName, TDeployment.Process>();
-
-      for (TDeployment.Process p : 
getDeploymentDescriptor().getDeploy().getProcessList()) {
-        _processInfo.put(p.getName(), p);
-      }
+            is = new FileInputStream(f);
+            Serializer ofh = new Serializer(is);
+            return ofh.readOProcess();
+        } catch (Exception e) {
+            throw new BpelEngineException("Couldn't read compiled BPEL process 
" + f.getAbsolutePath(), e);
+        } finally {
+            try {
+                if (is != null)
+                    is.close();
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    public boolean removed() {
+        return !_duDirectory.exists();
+    }
+
+    public boolean matches(File f) {
+        return f.getAbsolutePath().equals(new File(_duDirectory, 
"deploy.xml").getAbsolutePath());
+    }
+
+    public boolean checkForUpdate() {
+        File deployXml = new File(_duDirectory, "deploy.xml");
+        if (!deployXml.exists())
+            return false;
+        return deployXml.lastModified() != _lastModified;
+    }
+
+    public int hashCode() {
+        return (int) (_name.hashCode() + _lastModified);
     }
 
-    return _processInfo.get(pid);
-  }
+    public File getDeployDir() {
+        return _duDirectory;
+    }
+
+    public void setLastModified(long lastModified) {
+        _lastModified = lastModified;
+    }
+
+    public long getLastModified() {
+        return _lastModified;
+    }
+
+    public DeployDocument getDeploymentDescriptor() {
+        if (_dd == null) {
+            File ddLocation = new File(_duDirectory, "deploy.xml");
+            try {
+                _dd = DeployDocument.Factory.parse(ddLocation);
+            } catch (Exception e) {
+                throw new BpelEngineException("Couldnt read deployment 
descriptor at location "
+                        + ddLocation.getAbsolutePath(), e);
+            }
+
+        }
+        return _dd;
+    }
+
+    public HashMap<QName, OProcess> getProcesses() {
+        loadProcessDefinitions();
+        return _processes;
+    }
+
+    public DocumentRegistry getDocRegistry() {
+        if (_docRegistry == null) {
+            _docRegistry = new DocumentRegistry(new 
DocumentEntityResolver(_duDirectory));
+
+            WSDLFactory4BPEL wsdlFactory = (WSDLFactory4BPEL) 
WSDLFactoryBPEL20.newInstance();
+            WSDLReader r = wsdlFactory.newWSDLReader();
+
+            File[] wsdls = _duDirectory.listFiles(_wsdlFilter);
+            for (File file : wsdls) {
+                try {
+                    _docRegistry.addDefinition((Definition4BPEL) 
r.readWSDL(file.toURI().toString()));
+                } catch (WSDLException e) {
+                    throw new BpelEngineException("Couldn't read WSDL document 
" + file.getAbsolutePath(), e);
+                }
+            }
+        }
+        return _docRegistry;
+    }
+
+    public Definition4BPEL getDefinitionForNamespace(String namespaceURI) {
+        return getDocRegistry().getDefinition(namespaceURI);
+    }
+
+    public Collection<Definition4BPEL> getDefinitions() {
+        Definition4BPEL defs[] = getDocRegistry().getDefinitions();
+        ArrayList<Definition4BPEL> ret = new 
ArrayList<Definition4BPEL>(defs.length);
+        for (Definition4BPEL def: defs)
+            ret.add(def);
+        return ret;
+    }
+
+    public Set<QName> getProcessNames() {
+        return _processes.keySet();
+    }
+
+    public String toString() {
+        return "{DeploymentUnit " + _name + "}";
+    }
+
+    public TDeployment.Process getProcessDeployInfo(QName pid) {
+        if (_processInfo == null) {
+            _processInfo = new HashMap<QName, TDeployment.Process>();
+
+            for (TDeployment.Process p : 
getDeploymentDescriptor().getDeploy().getProcessList()) {
+                _processInfo.put(p.getName(), p);
+            }
+        }
+
+        return _processInfo.get(pid);
+    }
 }

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
 Wed Aug 16 16:24:25 2006
@@ -424,7 +424,6 @@
                                               boolean isMyEPR) throws 
FaultException {
         PartnerLinkDAO pl = fetchPartnerLinkDAO(pLink);
         Element epr = (isMyEPR ? pl.getMyEPR() : pl.getPartnerEPR());
-        if (epr != null) System.out.println("### EPR from DB " + 
DOMUtils.domToString(epr));
 
         if (epr == null && isMyEPR)
             epr = _bpelProcess.getInitialMyRoleEPR(pLink.partnerLink);

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java
 Wed Aug 16 16:24:25 2006
@@ -19,14 +19,8 @@
 
 package org.apache.ode.bpel.engine;
 
-import javax.wsdl.Operation;
-import javax.wsdl.PortType;
-import javax.xml.namespace.QName;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Element;
-
 import org.apache.ode.bpel.dao.MessageDAO;
 import org.apache.ode.bpel.dao.MessageExchangeDAO;
 import org.apache.ode.bpel.iapi.BpelEngineException;
@@ -35,6 +29,11 @@
 import org.apache.ode.bpel.iapi.MessageExchange;
 import org.apache.ode.bpel.o.OProcess;
 import org.apache.ode.utils.msg.MessageBundle;
+import org.w3c.dom.Element;
+
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
 
 abstract class MessageExchangeImpl implements MessageExchange {
   
@@ -138,8 +137,6 @@
   public Operation getOperation() {
     return _operation;
   }
-
-  
 
   public PortType getPortType() {
     return _portType;

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?rev=432065&r1=432064&r2=432065&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
 Wed Aug 16 16:24:25 2006
@@ -19,7 +19,6 @@
 
 package org.apache.ode.bpel.engine;
 
-import org.apache.commons.collections.map.MultiKeyMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.BpelEventFilter;
@@ -201,55 +200,6 @@
         return ret;
     }
 
-    public ProcessInfoDocument setEndpointReference(final QName pid, final 
String partnerLink,
-                                                    final String roleName, 
final Element endpointRef)
-            throws ManagementException {
-        ProcessInfoDocument ret = ProcessInfoDocument.Factory.newInstance();
-        final TProcessInfo pi = ret.addNewProcessInfo();
-        try {
-            _db.exec(new BpelDatabase.Callable<Object>() {
-                public Object run(BpelDAOConnection conn) throws Exception {
-                    ProcessDAO proc = conn.getProcess(pid);
-                    if (proc == null)
-                        throw new ProcessNotFoundException("ProcessNotFound:" 
+ pid);
-
-                    OProcess oprocess = _engine.getOProcess(pid);
-                    if (oprocess == null)
-                        throw new ProcessNotFoundException("ProcessNotFound:" 
+ pid);
-
-                    OPartnerLink plink = oprocess.getPartnerLink(partnerLink);
-                    if (plink == null)
-                        throw new InvalidRequestException("Unknown 
partner-link "
-                                + partnerLink + " for process " + pid);
-
-                    throw new UnsupportedOperationException("todo: 
reimplement");
-//          PartnerLinkDAO depdao = 
proc.getDeployedEndpointReference(plink.getId());
-//          
-//          if (plink != null && ((plink.myRoleName != null) && 
(plink.myRoleName.equals(roleName)))) {
-//            depdao.setMyEPR(endpointRef);
-//          } else if (plink != null && ((plink.partnerRoleName != null) && 
(plink.partnerRoleName.equals(roleName)))) {
-//            depdao.setPartnerEPR(endpointRef);
-//          } else {
-//            throw new InvalidRequestException("Invalid 
partnerLink/partnerRole combination "
-//                + partnerLink + "/" + roleName + " for process " + pid);
-//            
-//          }
-//          
-//          fillProcessInfo(pi, proc, new 
ProcessInfoCustomizer(ProcessInfoCustomizer.Item.ENDPOINTS));
-//          return null;
-                }
-            });
-        } catch (ManagementException me) {
-            throw me;
-        } catch (Exception e) {
-            __log.error("DbError", e);
-            throw new ProcessingException("DbError",e);
-        }
-
-        return ret;
-    }
-
-
     public InstanceInfoListDocument listInstances(String filter, String order, 
int limit) {
         InstanceInfoListDocument ret = 
InstanceInfoListDocument.Factory.newInstance();
         final TInstanceInfoList infolist = ret.addNewInstanceInfoList();
@@ -685,36 +635,18 @@
             OProcess oprocess = _engine.getOProcess(proc.getProcessId());
             for (OPartnerLink oplink : oprocess.getAllPartnerLinks()) {
                 if (oplink.hasPartnerRole() && oplink.initializePartnerRole) {
-                    MultiKeyMap mm = buildEprMap(proc);
-                    Node eprNode = (Node) mm.get(oplink.name, 
oplink.partnerRoleName);
-                    if (eprNode != null) {
+                    Element eprElmt = 
_engine._activeProcesses.get(proc.getProcessId())
+                            .getInitialPartnerRoleEPR(oplink);
+                    if (eprElmt != null) {
                         TEndpointReferences.EndpointRef epr = 
eprs.addNewEndpointRef();
-                        epr.setPartnerLink(oplink.name);
-                        epr.setPartnerRole(oplink.partnerRoleName);
                         Document eprNodeDoc = 
epr.getDomNode().getOwnerDocument();
-                        
epr.getDomNode().appendChild(eprNodeDoc.importNode(eprNode, true));
-                    } else {
-                        __log.error("The process " + proc.getProcessId() + " 
has probably been deployed in a wrong way, the " +
-                                "partner link " + oplink.name + " has no 
endpoint associated with it, which probably means " +
-                                "that the deployment descriptor wasn't 
included in the process package you deployed.");
+                        
epr.getDomNode().appendChild(eprNodeDoc.importNode(eprElmt, true));
                     }
                 }
             }
         }
 
         //TODO: add documents to the above data structure.
-    }
-
-    private MultiKeyMap buildEprMap(ProcessDAO proc) {
-        MultiKeyMap mm = new MultiKeyMap();
-        // TODO: eliminate or fix?
-//    for (PartnerLinkDAO eprDao : proc.getDeployedEndpointReferences()) {
-//      if (eprDao.getMyEPR() != null)
-//        mm.put(eprDao.getPartnerLinkName(), eprDao.getMyRoleName(), 
eprDao.getMyEPR());
-//      if (eprDao.getPartnerEPR() != null)
-//        mm.put(eprDao.getPartnerLinkName(), eprDao.getPartnerEPR(), 
eprDao.getPartnerEPR());
-//    }
-        return mm;
     }
 
     /**


Reply via email to