Commit c9fd8c74 authored by Philippe Merle's avatar Philippe Merle

Added the management of namespaces starting with "classpath:" to allow to...

Added the management of namespaces starting with "classpath:" to allow to search BPEL processes in the classpath.
parent 75be8405
......@@ -42,6 +42,7 @@ import org.ow2.frascati.implementation.bpel.api.BPELPartnerLinkInput;
import org.ow2.frascati.implementation.bpel.api.BPELPartnerLinkOutput;
import org.ow2.frascati.implementation.bpel.api.BPELProcess;
import org.ow2.frascati.wsdl.WsdlCompiler;
import org.ow2.frascati.util.FrascatiException;
/**
* OW2 FraSCAti SCA Implementation BPEL processor class.
......@@ -56,6 +57,11 @@ public class FrascatiImplementationBpelProcessor
// Internal state.
// --------------------------------------------------------------------------
/**
* Classpath namespace.
*/
public static final String CLASSPATH_NS = "classpath:";
/**
* The EasyBPEL engine.
*/
......@@ -94,18 +100,44 @@ public class FrascatiImplementationBpelProcessor
if(bpelImplementationProcess == null) {
processingContext.error(toString(bpelImplementation) + " the attribute 'process' must be set");
} else {
BPELProcess bpelProcess = null;
String processNamespace = bpelImplementationProcess.getNamespaceURI();
String processUri = null;
// When the process namespace starts by "classpath:"
if(processNamespace.startsWith(CLASSPATH_NS)) {
StringBuffer sb = new StringBuffer();
sb.append(processNamespace.substring(CLASSPATH_NS.length()));
if(sb.length() > 0) {
sb.append('/');
}
sb.append(bpelImplementationProcess.getLocalPart());
// Search the process file into the processing context's class loader.
URL resource = processingContext.getResource(sb.toString());
if(resource != null) {
processUri = resource.toString();
// TODO: Currently EasyBPEL 1.2 could not read URI starting by "jar:file:..."
// So we search the BPEL file into target/classes.
if(processUri.startsWith("jar:")) {
processUri = "target/classes/" + bpelImplementationProcess.getLocalPart();
}
}
}
if(processUri == null) {
processUri = processNamespace + '/' + bpelImplementationProcess.getLocalPart();
}
try {
String processUrl = bpelImplementationProcess.getNamespaceURI() + '/' + bpelImplementationProcess.getLocalPart();
bpelProcess = bpelEngine.newBPELProcess(processUrl);
} catch(Exception e) {
// e.printStackTrace();
processingContext.error(toString(bpelImplementation) + " can't read BPEL process " + bpelImplementationProcess);
BPELProcess bpelProcess = bpelEngine.newBPELProcess(processUri);
// Store the created BPELProcess into the processing context.
processingContext.putData(bpelImplementation, BPELProcess.class, bpelProcess);
} catch(FrascatiException exc) {
// exc.printStackTrace();
processingContext.error(toString(bpelImplementation) + " can not read BPEL process " + bpelImplementationProcess);
} catch(Exception exc) {
severe(new ProcessorException(bpelImplementation, "Can not read BPEL process " + bpelImplementationProcess, exc));
return;
}
// Store the created BPELProcess into the processing context.
processingContext.putData(bpelImplementation, BPELProcess.class, bpelProcess);
}
// check attributes 'policySets' and 'requires'.
......@@ -133,7 +165,7 @@ public class FrascatiImplementationBpelProcessor
try {
this.wsdlCompiler.compileWSDL(wsdlUri, processingContext);
} catch(Exception exc) {
processingContext.error(toString(bpelImplementation) + "Can not compile WSDL '" + wsdlUri + "'");
processingContext.error(toString(bpelImplementation) + " Can not compile WSDL '" + wsdlUri + "'");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment