Author: edwardsmj
Date: Thu May 29 15:06:54 2008
New Revision: 661501
URL: http://svn.apache.org/viewvc?rev=661501&view=rev
Log:
Fixes for
a) filename issues on Linux with the compiled BPEL file
b) database issues for non-transient BPEL processes
Added:
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
Added:
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java?rev=661501&view=auto
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java
(added)
+++
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java
Thu May 29 15:06:54 2008
@@ -0,0 +1,208 @@
+package org.apache.tuscany.sca.implementation.bpel.ode;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Reference;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+
+/**
+ * A class that handles the deploy.xml file required for each BPEL process by
the ODE runtime
+ * @author Mike Edwards
+ *
+ * An explanation of the structure of the ODE deploy file:
+ *
+ * <deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+ * xmlns:tns="http://helloworld"
+ * xmlns:tus="http://tuscany.apache.org">
+ *
+ * <process name="tns:HelloWorld">
+ * <active>true</active>
+ * <provide partnerLink="helloPartnerLink">
+ * <service name="tus:helloPartnerLink" port="HelloWorld"/>
+ * </provide>
+ * <invoke partnerLink="greetingsPartnerLink">
+ * <service name="tus:greetingsPartnerLink" port="Greetings"/>
+ * </invoke>
+ * </process>
+ * </deploy>
+ *
+ * For SCA purposes:
+ *
+ * a) Each partner link in the BPEL process is declared using either a
<provide.../>
+ * (for a service) or using a <invoke.../> (for a reference).
+ *
+ * b) Each <provide/> and <invoke/> must use the partnerLink name, as declared
in the
+ * BPEL process.
+ *
+ * c) The <provide/> and <invoke/> elements each have a single child
<service/> element.
+ * The <service/> elements have name and port attributes. The NAME attribute
MUST be set
+ * to the same name as the partnerLink and MUST be prefixed by a prefix which
references
+ * the namespace "http://tuscany.apache.org" ("tus" in the example above).
+ * The port attribute can be set to any name (it must be present but it is not
actually
+ * used for anything significant).
+ *
+ * When SCA loads a BPEL process to the ODE server, this file is read by the
ODE server to
+ * characterize the process. When SCA interacts with ODE at later points -
either when a
+ * service is being invoked or the process invokes a reference - it is the
service @name
+ * attribute that identifies the service or reference involved.
+ *
+ * @version
+ */
+public class BPELODEDeployFile {
+ private final Log __log = LogFactory.getLog(getClass());
+
+ static final String DEPLOY_ELEMENT_START = "<deploy
xmlns=\"http://www.apache.org/ode/schemas/dd/2007/03\"";
+ static final String DEPLOY_ENDELEMENT = "</deploy>";
+ static final String PROCESS_NAMESPACE_DECL = "xmlns:tns=";
+ static final String SERVICE_NAMESPACE =
"xmlns:tus=\"http://tuscany.apache.org\"";
+ static final String PROCESS_ELEMENT_START = "<process name=\"tns:";
+ static final String PROCESS_ELEMENT_END = "\">";
+ static final String PROCESS_ENDELEMENT = "</process>";
+ static final String ACTIVE_ELEMENT = "<active>true</active>";
+ static final String PROVIDE_ELEMENT_START = "<provide partnerLink=\"";
+ static final String PROVIDE_ELEMENT_END = "\">";
+ static final String PROVIDE_ENDELEMENT = "</provide>";
+ static final String SERVICE_ELEMENT_START = "<service name=\"tus:";
+ static final String SERVICE_ELEMENT_PORT = "\" port=\"";
+ static final String SERVICE_ELEMENT_END = "Port\"/>";
+ static final String INVOKE_ELEMENT_START = "<invoke partnerLink=\"";
+ static final String INVOKE_ELEMENT_END = "\">";
+ static final String INVOKE_ENDELEMENT = "</invoke>";
+
+ static final String DEPLOY_FILENAME = "deploy.xml";
+
+ private BPELImplementation implementation;
+
+ /**
+ * Constructor - requires a BPELImplementation as a parameter
+ * The ODE deploy.xml file is for this supplied BPELImplementation
+ * @param theImplementation
+ */
+ public BPELODEDeployFile( BPELImplementation theImplementation ) {
+
+ implementation = theImplementation;
+
+ } // end BPELODEDeployFile constructor
+
+ /**
+ * Writes the deploy file into the same directory as the BPEL process
file, with the name
+ * "deploy.xml"
+ */
+ public void writeDeployfile() throws IOException {
+
+ File theDirectory = getDirectory();
+
+ File deployFile = new File( theDirectory, DEPLOY_FILENAME );
+ new FileOutputStream( deployFile );
+ //if( !deployFile.canWrite() ) throw new IOException( "Unable
to write to deploy file" +
+ //
deployFile.getPath() );
+
+ // Create a stream for the data and write the data to the file
+ PrintStream theStream = new PrintStream( new FileOutputStream(
deployFile ) );
+ try {
+ constructDeployXML( theStream );
+ if( theStream.checkError() ) throw new IOException();
+ } catch (Exception e) {
+ throw new IOException( "Unable to write data to deploy
file" +
+ deployFile.getPath() );
+ } finally {
+ theStream.close();
+ } // end try
+
+ } // end writeDeployFile
+
+ /**
+ * Creates the deploy.xml data and writes it to a supplied PrintStream
+ * @param stream
+ */
+ public void constructDeployXML( PrintStream stream ) {
+
+ // <deploy + namespace...
+ stream.println( DEPLOY_ELEMENT_START );
+ // namespace of the BPEL process
+ QName process = implementation.getProcess();
+ String processNamespace = process.getNamespaceURI();
+ stream.println( PROCESS_NAMESPACE_DECL + "\"" +
processNamespace + "\"" );
+ // namespace for the service name elements
+ stream.println( SERVICE_NAMESPACE + ">" );
+
+ // <process> element
+ stream.println( PROCESS_ELEMENT_START + process.getLocalPart()
+
+ PROCESS_ELEMENT_END );
+
+ // <active/> element
+ stream.println( ACTIVE_ELEMENT );
+
+ ComponentType componentType = implementation.getComponentType();
+ List<Service> theServices = componentType.getServices();
+ // Loop over the <provide/> elements - one per service
+ for ( Service service : theServices ) {
+ String serviceName = service.getName();
+ // Provide element...
+ stream.println( PROVIDE_ELEMENT_START + serviceName +
PROVIDE_ELEMENT_END );
+ // Child service element...
+ stream.println( SERVICE_ELEMENT_START + serviceName +
+ SERVICE_ELEMENT_PORT + serviceName +
SERVICE_ELEMENT_END );
+ stream.println( PROVIDE_ENDELEMENT );
+ } // end for
+
+ // Loop over the <invoke/> elements - one per reference
+ List<Reference> theReferences = componentType.getReferences();
+ for ( Reference reference : theReferences ) {
+ String referenceName = reference.getName();
+ stream.println( INVOKE_ELEMENT_START + referenceName +
INVOKE_ELEMENT_END );
+ // Child service element...
+ stream.println( SERVICE_ELEMENT_START + referenceName +
+ SERVICE_ELEMENT_PORT + referenceName +
SERVICE_ELEMENT_END );
+ stream.println( INVOKE_ENDELEMENT );
+
+ } // end for
+
+ // </process> element
+ stream.println( PROCESS_ENDELEMENT );
+
+ // </deploy>
+ stream.println( DEPLOY_ENDELEMENT );
+
+ } // end constructDeployXML
+
+ /**
+ * Gets the directory containing the BPEL process
+ * @return
+ */
+ private File getDirectory() {
+ File theDir = getBPELFile().getParentFile();
+ return theDir;
+ } // end getDirectory
+
+ /**
+ * Gets the File containing the BPEL process definition
+ * @return - the File object containing the BPEL process
+ */
+ private File getBPELFile() {
+ URL fileURL = implementation.getProcessDefinition().getLocation();
+ try {
+ File theProcess = new File( fileURL.toURI());
+ return theProcess;
+ } catch( Exception e ) {
+ if(__log.isDebugEnabled()) {
+ __log.debug("Exception converting BPEL file URL to an URI: " +
e );
+ }
+ } // end try
+ return null;
+ } // end getBPELFile
+
+
+
+} // end class BPELODEDeployFile
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java?rev=661501&r1=661500&r2=661501&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
Thu May 29 15:06:54 2008
@@ -175,7 +175,7 @@
ProcessConf conf = (ProcessConf)
store.getProcessConfiguration(event.pid);
// Test processes always run with in-mem DAOs
// conf.setTransient(true); //FIXME: what should we use
for ProcessConfImpl
- //_bpelServer.register(conf);
+ _bpelServer.register(conf);
} // end if
} // end onProcessStoreEvent
@@ -272,12 +272,19 @@
public void deploy(ODEDeployment d, BPELImplementation implementation) {
try {
- // old code
+ // old code - using the ODE store
+ // Generate the required ODE deploy.xml file "on the fly" - it
is required by the ODE
+ // store - this code avoids the need for the programmer to
create this file manually.
+ BPELODEDeployFile deployFile = new BPELODEDeployFile(
implementation );
+ deployFile.writeDeployfile();
store.deploy(d.deployDir);
//System.out.println("Completed calling old Process deployment
code...");
- TuscanyProcessConfImpl processConf = new
TuscanyProcessConfImpl( implementation );
- _bpelServer.register(processConf);
+ // Code for doing deployment directly from Tuscany without
using the ODE store
+ // - disabled for the present due to issues with the ODE engine
when used in this
+ // mode - Mike Edwards 29/05/2008
+ //TuscanyProcessConfImpl processConf = new
TuscanyProcessConfImpl( implementation );
+ //_bpelServer.register(processConf);
//System.out.println("Completed calling new Process deployment
code...");
} catch (Exception ex) {
String errMsg = ">>> DEPLOY: Unexpected exception: " +
ex.getMessage();
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java?rev=661501&r1=661500&r2=661501&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
Thu May 29 15:06:54 2008
@@ -49,7 +49,7 @@
import org.w3c.dom.Node;
/**
- * Process Conf
+ * A Tuscany implementation of the ODE Process Conf
*
* @version $Rev$ $Date$
*/
@@ -112,7 +112,18 @@
//System.out.println("getCBPInputStream called");
// Find the CBP file - it has the same name as the BPEL process and
lives in the same
// directory as the process file
- String cbpFileName =
implementation.getProcessDefinition().getName().getLocalPart() + ".cbp";
+ String cbpFileName = null;
+ try {
+ String fileName = getRelativePath( getDirectory(), getBPELFile() );
+ cbpFileName = fileName.substring(0, fileName.lastIndexOf(".")) +
".cbp";
+ } catch (Exception e ) {
+ // IOException trying to fetch the BPEL file name
+ if(__log.isDebugEnabled()) {
+ __log.debug("Unable to calculate the file name for BPEL
process: " +
+
implementation.getProcessDefinition().getName(), e);
+ return null;
+ } // end if
+ } // end try
File cbpFile = new File( getDirectory(), cbpFileName );
if( cbpFile.exists() ) {
// Create an InputStream from the cbp file...
@@ -166,6 +177,7 @@
* at the PartnerLinkType which in turn points at an (WSDL) interface
definition.
*/
public Definition getDefinitionForService(QName serviceQName ) {
+ //System.out.println("getDefinitionForService called for Service: " +
serviceQName );
if(__log.isDebugEnabled()){
__log.debug("getDefinitionforService called for service: " +
serviceQName );
}
@@ -326,7 +338,7 @@
*/
public boolean isTransient() {
//System.out.println("isTransient called");
- return false;
+ return true;
} // end isTransient
/**
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java?rev=661501&r1=661500&r2=661501&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel-ode/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
Thu May 29 15:06:54 2008
@@ -93,15 +93,15 @@
// deploy the process
if (odeServer.isInitialized()) {
try {
- txMgr.begin();
+ //txMgr.begin();
odeServer.registerTuscanyRuntimeComponent(implementation.getProcess(),
component);
// Replaced by Mike Edwards 23/05/2008
//odeServer.deploy(new ODEDeployment(deploymentDir));
odeServer.deploy(new ODEDeployment(deploymentDir),
implementation );
- txMgr.commit();
+ //txMgr.commit();
} catch (Exception e) {
e.printStackTrace();
- txMgr.rollback();
+ //txMgr.rollback();
}
}