You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2006/10/17 20:38:39 UTC
svn commit: r464992 [1/4] - in /incubator/ode/trunk:
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/
bpel-obj/src/main/java/org/apache/ode/bpel/o/
bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/
Author: assaf
Date: Tue Oct 17 11:38:35 2006
New Revision: 464992
URL: http://svn.apache.org/viewvc?view=rev&rev=464992
Log:
Added getParent() to OActivity
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGeneratorMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CommonCompilationMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CompensateGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/EmptyGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/FlowGeneratorMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ForEachGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ForEachGeneratorMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/InvokeGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/InvokeGeneratorMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickReceiveGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ReceiveGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ReplyGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ReplyGeneratorMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/RethrowGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SequenceGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/TerminateGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ThrowGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WaitGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WaitGeneratorMessages.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WhileGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinder.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/XsltFinder.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/DebugInfo.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OActivity.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OAssign.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OBase.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OCatch.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OCompensate.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OCompensationHandler.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstantExpression.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstants.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OElementVarType.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEmpty.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEventHandler.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OExpression.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OExpressionLanguage.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OFaultHandler.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OFlow.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OForEach.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OInvoke.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OLValueExpression.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OLink.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OMessageVarType.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPartnerLink.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPickReceive.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OReply.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/ORethrow.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OScope.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OSequence.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OSwitch.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OTerminate.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OTerminationHandler.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OThrow.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OVarType.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OWait.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OWhile.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OXslSheet.java
incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/Serializer.java
incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java Tue Oct 17 11:38:35 2006
@@ -50,188 +50,186 @@
* implentation suffices.
*/
class AssignGenerator extends DefaultActivityGenerator {
- private static final Log __log = LogFactory.getLog(AssignGenerator.class);
+ private static final Log __log = LogFactory.getLog(AssignGenerator.class);
- private static final AssignGeneratorMessages __cmsgs =
- MessageBundle.getMessages(AssignGeneratorMessages.class);
+ private static final AssignGeneratorMessages __cmsgs =
+ MessageBundle.getMessages(AssignGeneratorMessages.class);
- public OActivity newInstance(Activity src) {
- return new OAssign(_context.getOProcess());
- }
-
- public void compile(OActivity dest, Activity source) {
- OAssign oassign = (OAssign)dest;
- AssignActivity ad = (AssignActivity)source;
- for (Copy scopy : ad.getCopies()) {
- OAssign.Copy ocopy = new OAssign.Copy(_context.getOProcess());
- ocopy.keepSrcElementName = scopy.isKeepSrcElement();
- ocopy.debugInfo = new DebugInfo(_context.getSourceLocation(), scopy.getLineNo(),
- source.getExtensibilityElements());
- try {
- if (scopy.getFrom() == null)
- throw new CompilationException(__cmsgs.errMissingFromSpec().setSource(scopy));
- ocopy.from = compileFrom(scopy.getFrom());
- if (scopy.getTo() == null)
- throw new CompilationException(__cmsgs.errMissingToSpec().setSource(scopy));
- ocopy.to = compileTo(scopy.getTo());
-
- verifyCopy(ocopy);
- oassign.copy.add(ocopy);
-
- } catch (CompilationException ce) {
- _context.recoveredFromError(scopy, ce);
- }
- }
- }
-
- /**
- * Verify that a copy follows the correct form.
- * @param ocopy
- */
- private void verifyCopy(OAssign.Copy ocopy) {
- if (__log.isDebugEnabled())
- __log.debug("verifying copy: " + ocopy);
-
- // If direct Message->Message copy
- if (ocopy.to instanceof OAssign.VariableRef
- && ((OAssign.VariableRef)ocopy.to).isMessageRef()
- && ocopy.from instanceof OAssign.VariableRef
- && ((OAssign.VariableRef)ocopy.from).isMessageRef()) {
- // Check that the LValue/RValue message types
- // match up.
- String lvar = ((OAssign.VariableRef)ocopy.to).variable.name;
- String rvar = ((OAssign.VariableRef)ocopy.from).variable.name;
- QName tlvalue = ((OMessageVarType)((OAssign.VariableRef)ocopy.to).variable.type).messageType;
- QName trvalue = ((OMessageVarType)((OAssign.VariableRef)ocopy.from).variable.type).messageType;
-
- if (!tlvalue.equals(trvalue))
- throw new CompilationException(__cmsgs.errMismatchedMessageAssignment(lvar, tlvalue,rvar,trvalue));
-
- }
-
- // If Message->Non-Message copy
- else if (ocopy.from instanceof OAssign.VariableRef
- && ((OAssign.VariableRef)ocopy.from).isMessageRef()
- && ( !(ocopy.to instanceof OAssign.VariableRef) ||
- !((OAssign.VariableRef)ocopy.to).isMessageRef())) {
- String rval = ((OAssign.VariableRef)ocopy.from).variable.name;
- throw new CompilationException(__cmsgs.errCopyFromMessageToNonMessage(rval));
-
- }
-
- // If Non-Message->Message copy
- else if (ocopy.to instanceof OAssign.VariableRef
- && ((OAssign.VariableRef)ocopy.to).isMessageRef()
- && ( !(ocopy.from instanceof OAssign.VariableRef) ||
- !((OAssign.VariableRef)ocopy.from).isMessageRef())) {
-
- String lval = ((OAssign.VariableRef)ocopy.to).variable.name;
- throw new CompilationException(__cmsgs.errCopyToMessageFromNonMessage(lval));
- }
-
- // If *->Partner Link copy
- else if (ocopy.to instanceof OAssign.PartnerLinkRef
- && !((OAssign.PartnerLinkRef)ocopy.to).partnerLink.hasPartnerRole()) {
- String lval = ((OAssign.PartnerLinkRef)ocopy.to).partnerLink.getName();
- throw new CompilationException(__cmsgs.errCopyToUndeclaredPartnerRole(lval));
- }
-
- // If Partner Link->* copy
- else if (ocopy.from instanceof OAssign.PartnerLinkRef) {
- if (((OAssign.PartnerLinkRef)ocopy.from).isMyEndpointReference
- && !((OAssign.PartnerLinkRef)ocopy.from).partnerLink.hasMyRole()) {
- String lval = ((OAssign.PartnerLinkRef)ocopy.from).partnerLink.getName();
- throw new CompilationException(__cmsgs.errCopyFromUndeclaredPartnerRole(lval, "myRole"));
- }
- if (!((OAssign.PartnerLinkRef)ocopy.from).isMyEndpointReference
- && !((OAssign.PartnerLinkRef)ocopy.from).partnerLink.hasPartnerRole()) {
- String lval = ((OAssign.PartnerLinkRef)ocopy.from).partnerLink.getName();
- throw new CompilationException(__cmsgs.errCopyFromUndeclaredPartnerRole(lval, "partnerRole"));
- }
- }
-
- __log.debug("Copy verified OK: " + ocopy);
- }
-
- private OAssign.RValue compileFrom(From from) {
- assert from != null;
- try {
- if (from instanceof LiteralVal) {
- return compileLiteral((LiteralVal) from);
- } else if (from instanceof ExpressionVal) {
- return new OAssign.Expression(_context.getOProcess(), _context.compileExpr(((ExpressionValImpl)from).getExpression()));
- } else if (from instanceof PropertyVal) {
- OAssign.PropertyRef pref = new OAssign.PropertyRef(_context.getOProcess());
- pref.variable = _context.resolveVariable(((PropertyVal)from).getVariable());
- pref.propertyAlias = _context.resolvePropertyAlias(pref.variable,((PropertyVal)from).getProperty());
- return pref;
- } else if (from instanceof VariableVal) {
- OAssign.VariableRef vref = new OAssign.VariableRef(_context.getOProcess());
- vref.variable = _context.resolveVariable(((VariableVal)from).getVariable());
- if (((VariableVal)from).getPart() != null) {
- vref.part = _context.resolvePart(vref.variable, ((VariableVal)from).getPart());
- if (((VariableVal)from).getLocation() != null)
- vref.location = _context.compileExpr(((VariableVal)from).getLocation());
- }
- // TODO: check for irrelevant properties.
- return vref;
- } else if (from instanceof PartnerLinkVal) {
- OAssign.PartnerLinkRef plref = new OAssign.PartnerLinkRef(_context.getOProcess());
- plref.partnerLink = _context.resolvePartnerLink(((PartnerLinkVal)from).getPartnerLink());
- plref.isMyEndpointReference = "myRole".equals(((PartnerLinkVal)from).getEndpointReference());
- return plref;
- }
-
- throw new CompilationException(__cmsgs.errUnkownFromSpec().setSource(from));
-
- } catch (CompilationException ce) {
- if (ce.getCompilationMessage().source == null)
- ce.getCompilationMessage().source = from;
- throw ce;
- }
- }
-
- private OAssign.RValue compileLiteral(LiteralVal from) {
- Element literal = from.getLiteral();
- Document newDoc = DOMUtils.newDocument();
- Element clone = (Element) newDoc.importNode(literal, true);
- newDoc.appendChild(clone);
- return new OAssign.Literal(_context.getOProcess(), newDoc);
- }
-
- private OAssign.LValue compileTo(To to) {
- assert to != null;
-
- try {
- if (to instanceof PropertyVal) {
- OAssign.PropertyRef pref = new OAssign.PropertyRef(_context.getOProcess());
- pref.variable = _context.resolveVariable(((PropertyVal)to).getVariable());
- pref.propertyAlias = _context.resolvePropertyAlias(pref.variable,((PropertyVal)to).getProperty());
- return pref;
- } else if (to instanceof VariableVal) {
- OAssign.VariableRef vref = new OAssign.VariableRef(_context.getOProcess());
- vref.variable = _context.resolveVariable(((VariableVal)to).getVariable());
- if (((VariableVal)to).getPart() != null) {
- vref.part = _context.resolvePart(vref.variable, ((VariableVal)to).getPart());
- if (((VariableVal)to).getLocation() != null)
- vref.location = _context.compileExpr(((VariableVal)to).getLocation());
- }
-// TODO: check for irrelevant properties.
- return vref;
- } else if (to instanceof ExpressionVal) {
- return new OAssign.LValueExpression(_context.getOProcess(), _context.compileLValueExpr(((ExpressionValImpl)to).getExpression()));
- } else if (to instanceof PartnerLinkVal) {
- OAssign.PartnerLinkRef plref = new OAssign.PartnerLinkRef(_context.getOProcess());
- plref.partnerLink = _context.resolvePartnerLink(((PartnerLinkVal)to).getPartnerLink());
- return plref;
- }
-
- throw new CompilationException(__cmsgs.errUnknownToSpec().setSource(to));
- } catch (CompilationException ce) {
- if (ce.getCompilationMessage().source == null)
- ce.getCompilationMessage().source = to;
- throw ce;
+ public OActivity newInstance(Activity src) {
+ return new OAssign(_context.getOProcess(), _context.getCurrent());
+ }
+
+ public void compile(OActivity dest, Activity source) {
+ OAssign oassign = (OAssign)dest;
+ AssignActivity ad = (AssignActivity)source;
+ for (Copy scopy : ad.getCopies()) {
+ OAssign.Copy ocopy = new OAssign.Copy(_context.getOProcess());
+ ocopy.keepSrcElementName = scopy.isKeepSrcElement();
+ ocopy.debugInfo = new DebugInfo(_context.getSourceLocation(), scopy.getLineNo(),
+ source.getExtensibilityElements());
+ try {
+ if (scopy.getFrom() == null)
+ throw new CompilationException(__cmsgs.errMissingFromSpec().setSource(scopy));
+ ocopy.from = compileFrom(scopy.getFrom());
+ if (scopy.getTo() == null)
+ throw new CompilationException(__cmsgs.errMissingToSpec().setSource(scopy));
+ ocopy.to = compileTo(scopy.getTo());
+
+ verifyCopy(ocopy);
+ oassign.copy.add(ocopy);
+
+ } catch (CompilationException ce) {
+ _context.recoveredFromError(scopy, ce);
+ }
+ }
+ }
+
+ /**
+ * Verify that a copy follows the correct form.
+ * @param ocopy
+ */
+ private void verifyCopy(OAssign.Copy ocopy) {
+ if (__log.isDebugEnabled())
+ __log.debug("verifying copy: " + ocopy);
+
+ // If direct Message->Message copy
+ if (ocopy.to instanceof OAssign.VariableRef
+ && ((OAssign.VariableRef)ocopy.to).isMessageRef()
+ && ocopy.from instanceof OAssign.VariableRef
+ && ((OAssign.VariableRef)ocopy.from).isMessageRef()) {
+ // Check that the LValue/RValue message types
+ // match up.
+ String lvar = ((OAssign.VariableRef)ocopy.to).variable.name;
+ String rvar = ((OAssign.VariableRef)ocopy.from).variable.name;
+ QName tlvalue = ((OMessageVarType)((OAssign.VariableRef)ocopy.to).variable.type).messageType;
+ QName trvalue = ((OMessageVarType)((OAssign.VariableRef)ocopy.from).variable.type).messageType;
+
+ if (!tlvalue.equals(trvalue))
+ throw new CompilationException(__cmsgs.errMismatchedMessageAssignment(lvar, tlvalue,rvar,trvalue));
+ }
+
+ // If Message->Non-Message copy
+ else if (ocopy.from instanceof OAssign.VariableRef
+ && ((OAssign.VariableRef)ocopy.from).isMessageRef()
+ && ( !(ocopy.to instanceof OAssign.VariableRef) ||
+ !((OAssign.VariableRef)ocopy.to).isMessageRef())) {
+ String rval = ((OAssign.VariableRef)ocopy.from).variable.name;
+ throw new CompilationException(__cmsgs.errCopyFromMessageToNonMessage(rval));
+ }
+
+ // If Non-Message->Message copy
+ else if (ocopy.to instanceof OAssign.VariableRef
+ && ((OAssign.VariableRef)ocopy.to).isMessageRef()
+ && ( !(ocopy.from instanceof OAssign.VariableRef) ||
+ !((OAssign.VariableRef)ocopy.from).isMessageRef())) {
+
+ String lval = ((OAssign.VariableRef)ocopy.to).variable.name;
+ throw new CompilationException(__cmsgs.errCopyToMessageFromNonMessage(lval));
+ }
+
+ // If *->Partner Link copy
+ else if (ocopy.to instanceof OAssign.PartnerLinkRef
+ && !((OAssign.PartnerLinkRef)ocopy.to).partnerLink.hasPartnerRole()) {
+ String lval = ((OAssign.PartnerLinkRef)ocopy.to).partnerLink.getName();
+ throw new CompilationException(__cmsgs.errCopyToUndeclaredPartnerRole(lval));
+ }
+
+ // If Partner Link->* copy
+ else if (ocopy.from instanceof OAssign.PartnerLinkRef) {
+ if (((OAssign.PartnerLinkRef)ocopy.from).isMyEndpointReference
+ && !((OAssign.PartnerLinkRef)ocopy.from).partnerLink.hasMyRole()) {
+ String lval = ((OAssign.PartnerLinkRef)ocopy.from).partnerLink.getName();
+ throw new CompilationException(__cmsgs.errCopyFromUndeclaredPartnerRole(lval, "myRole"));
+ }
+ if (!((OAssign.PartnerLinkRef)ocopy.from).isMyEndpointReference
+ && !((OAssign.PartnerLinkRef)ocopy.from).partnerLink.hasPartnerRole()) {
+ String lval = ((OAssign.PartnerLinkRef)ocopy.from).partnerLink.getName();
+ throw new CompilationException(__cmsgs.errCopyFromUndeclaredPartnerRole(lval, "partnerRole"));
+ }
+ }
+
+ __log.debug("Copy verified OK: " + ocopy);
+ }
+
+ private OAssign.RValue compileFrom(From from) {
+ assert from != null;
+ try {
+ if (from instanceof LiteralVal) {
+ return compileLiteral((LiteralVal) from);
+ } else if (from instanceof ExpressionVal) {
+ return new OAssign.Expression(_context.getOProcess(), _context.compileExpr(((ExpressionValImpl)from).getExpression()));
+ } else if (from instanceof PropertyVal) {
+ OAssign.PropertyRef pref = new OAssign.PropertyRef(_context.getOProcess());
+ pref.variable = _context.resolveVariable(((PropertyVal)from).getVariable());
+ pref.propertyAlias = _context.resolvePropertyAlias(pref.variable,((PropertyVal)from).getProperty());
+ return pref;
+ } else if (from instanceof VariableVal) {
+ OAssign.VariableRef vref = new OAssign.VariableRef(_context.getOProcess());
+ vref.variable = _context.resolveVariable(((VariableVal)from).getVariable());
+ if (((VariableVal)from).getPart() != null) {
+ vref.part = _context.resolvePart(vref.variable, ((VariableVal)from).getPart());
+ if (((VariableVal)from).getLocation() != null)
+ vref.location = _context.compileExpr(((VariableVal)from).getLocation());
+ }
+ // TODO: check for irrelevant properties.
+ return vref;
+ } else if (from instanceof PartnerLinkVal) {
+ OAssign.PartnerLinkRef plref = new OAssign.PartnerLinkRef(_context.getOProcess());
+ plref.partnerLink = _context.resolvePartnerLink(((PartnerLinkVal)from).getPartnerLink());
+ plref.isMyEndpointReference = "myRole".equals(((PartnerLinkVal)from).getEndpointReference());
+ return plref;
+ }
+
+ throw new CompilationException(__cmsgs.errUnkownFromSpec().setSource(from));
+
+ } catch (CompilationException ce) {
+ if (ce.getCompilationMessage().source == null)
+ ce.getCompilationMessage().source = from;
+ throw ce;
+ }
+ }
+
+ private OAssign.RValue compileLiteral(LiteralVal from) {
+ Element literal = from.getLiteral();
+ Document newDoc = DOMUtils.newDocument();
+ Element clone = (Element) newDoc.importNode(literal, true);
+ newDoc.appendChild(clone);
+ return new OAssign.Literal(_context.getOProcess(), newDoc);
+ }
+
+ private OAssign.LValue compileTo(To to) {
+ assert to != null;
+
+ try {
+ if (to instanceof PropertyVal) {
+ OAssign.PropertyRef pref = new OAssign.PropertyRef(_context.getOProcess());
+ pref.variable = _context.resolveVariable(((PropertyVal)to).getVariable());
+ pref.propertyAlias = _context.resolvePropertyAlias(pref.variable,((PropertyVal)to).getProperty());
+ return pref;
+ } else if (to instanceof VariableVal) {
+ OAssign.VariableRef vref = new OAssign.VariableRef(_context.getOProcess());
+ vref.variable = _context.resolveVariable(((VariableVal)to).getVariable());
+ if (((VariableVal)to).getPart() != null) {
+ vref.part = _context.resolvePart(vref.variable, ((VariableVal)to).getPart());
+ if (((VariableVal)to).getLocation() != null)
+ vref.location = _context.compileExpr(((VariableVal)to).getLocation());
+ }
+ // TODO: check for irrelevant properties.
+ return vref;
+ } else if (to instanceof ExpressionVal) {
+ return new OAssign.LValueExpression(_context.getOProcess(), _context.compileLValueExpr(((ExpressionValImpl)to).getExpression()));
+ } else if (to instanceof PartnerLinkVal) {
+ OAssign.PartnerLinkRef plref = new OAssign.PartnerLinkRef(_context.getOProcess());
+ plref.partnerLink = _context.resolvePartnerLink(((PartnerLinkVal)to).getPartnerLink());
+ return plref;
+ }
+
+ throw new CompilationException(__cmsgs.errUnknownToSpec().setSource(to));
+ } catch (CompilationException ce) {
+ if (ce.getCompilationMessage().source == null)
+ ce.getCompilationMessage().source = to;
+ throw ce;
+ }
}
- }
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGeneratorMessages.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGeneratorMessages.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGeneratorMessages.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGeneratorMessages.java Tue Oct 17 11:38:35 2006
@@ -26,64 +26,64 @@
public class AssignGeneratorMessages extends CompilationMessageBundle {
- /** Copy missing from-spec. */
- public CompilationMessage errMissingFromSpec() {
- return this.formatCompilationMessage("Copy missing from-spec.");
- }
-
- /** Copy to message variable {0} requires a message for the r-value. */
- public CompilationMessage errCopyToMessageFromNonMessage(String lval) {
- return this.formatCompilationMessage(
- "Copy to message variable {0} requires a message for the r-value.", lval);
- }
-
- /** Copy from message variable {0} requires a message for the l-value. */
- public CompilationMessage errCopyFromMessageToNonMessage(String rval) {
- return this.formatCompilationMessage(
- "Copy from message variable {0} requires a message for the l-value.", rval);
- }
-
- /**
- * Copy to message variable {0} of type {1} from message {2} of type {3} is
- * not permitted (the message types do not match).
- */
- public CompilationMessage errMismatchedMessageAssignment(String lvar, QName tlvalue,
- String rval, QName trvalue) {
- return this.formatCompilationMessage(
- "Copy to message variable {0} of type {1} from message {2}"
- + " of type {3} is not permitted (the message types do not match).", lvar,
- tlvalue, rval, trvalue);
- }
-
- /** Copy to partner link {0} requires the partnerRole to be defined on partner link. */
- public CompilationMessage errCopyToUndeclaredPartnerRole(String lval) {
- return this.formatCompilationMessage(
- "Copy to partner link {0} requires the partnerRole to be defined on partner link.", lval);
- }
-
- /**
- * Copy from partner link {0} with enpoint reference {1} requires
- * the corresponding role to be defined on partner link.
- */
- public CompilationMessage errCopyFromUndeclaredPartnerRole(String rval, String epr) {
- return this.formatCompilationMessage(
- "Copy from partner link {0} with enpoint reference {1} requires" +
- " the corresponding role to be defined on partner link.", rval, epr);
- }
-
- /** Copy missing to-spec. */
- public CompilationMessage errMissingToSpec() {
- return this.formatCompilationMessage("Copy missing to-spec.");
- }
-
- /** From-spec format is unrecognized. */
- public CompilationMessage errUnkownFromSpec() {
- return this.formatCompilationMessage("From-spec format is unrecognized.");
- }
-
- /** To-spec format is unrecognized. */
- public CompilationMessage errUnknownToSpec() {
- return this.formatCompilationMessage("To-spec format is unrecognized.");
- }
+ /** Copy missing from-spec. */
+ public CompilationMessage errMissingFromSpec() {
+ return this.formatCompilationMessage("Copy missing from-spec.");
+ }
+
+ /** Copy to message variable {0} requires a message for the r-value. */
+ public CompilationMessage errCopyToMessageFromNonMessage(String lval) {
+ return this.formatCompilationMessage(
+ "Copy to message variable {0} requires a message for the r-value.", lval);
+ }
+
+ /** Copy from message variable {0} requires a message for the l-value. */
+ public CompilationMessage errCopyFromMessageToNonMessage(String rval) {
+ return this.formatCompilationMessage(
+ "Copy from message variable {0} requires a message for the l-value.", rval);
+ }
+
+ /**
+ * Copy to message variable {0} of type {1} from message {2} of type {3} is
+ * not permitted (the message types do not match).
+ */
+ public CompilationMessage errMismatchedMessageAssignment(String lvar, QName tlvalue,
+ String rval, QName trvalue) {
+ return this.formatCompilationMessage(
+ "Copy to message variable {0} of type {1} from message {2}" +
+ " of type {3} is not permitted (the message types do not match).", lvar,
+ tlvalue, rval, trvalue);
+ }
+
+ /** Copy to partner link {0} requires the partnerRole to be defined on partner link. */
+ public CompilationMessage errCopyToUndeclaredPartnerRole(String lval) {
+ return this.formatCompilationMessage(
+ "Copy to partner link {0} requires the partnerRole to be defined on partner link.", lval);
+ }
+
+ /**
+ * Copy from partner link {0} with enpoint reference {1} requires
+ * the corresponding role to be defined on partner link.
+ */
+ public CompilationMessage errCopyFromUndeclaredPartnerRole(String rval, String epr) {
+ return this.formatCompilationMessage(
+ "Copy from partner link {0} with enpoint reference {1} requires" +
+ " the corresponding role to be defined on partner link.", rval, epr);
+ }
+
+ /** Copy missing to-spec. */
+ public CompilationMessage errMissingToSpec() {
+ return this.formatCompilationMessage("Copy missing to-spec.");
+ }
+
+ /** From-spec format is unrecognized. */
+ public CompilationMessage errUnkownFromSpec() {
+ return this.formatCompilationMessage("From-spec format is unrecognized.");
+ }
+
+ /** To-spec format is unrecognized. */
+ public CompilationMessage errUnknownToSpec() {
+ return this.formatCompilationMessage("To-spec format is unrecognized.");
+ }
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java Tue Oct 17 11:38:35 2006
@@ -54,374 +54,372 @@
* </p>
*/
public class BpelC {
- private static final Log __log = LogFactory.getLog(BpelC.class);
- private static final CommonCompilationMessages __cmsgs =
- MessageBundle.getMessages(CommonCompilationMessages.class);
-
- private BpelProcessBuilderFactory _bpelProcessBuilderFactory;
- private CompileListener _compileListener;
- public OutputStream _outputStream = null;
- private File _outputDir = null;
-
- private File _bpelFile;
- private WsdlFinder _wsdlFinder;
- private XsltFinder _xsltFinder;
- private URI _bpel11wsdl;
-
- public static BpelC newBpelCompiler() {
- return new BpelC();
- }
-
- private BpelC() {
- try {
- _bpelProcessBuilderFactory = BpelProcessBuilderFactory.newProcessBuilderFactory();
- } catch (BpelProcessBuilderFactoryException e) {
- throw new RuntimeException(e);
- }
- _bpelProcessBuilderFactory.setStrict(true);
- }
-
- protected void finalize() throws Throwable
- {
- this.invalidate();
- super.finalize();
- }
-
- private void invalidate() {
- this.setWsdlFinder(null);
- this.setCompileListener(null);
- this.setOutputStream(null);
- this.setOutputDirectory(null);
- }
-
- /**
- * <p>
- * Set a non-default target {@link CompileListener} implementation.
- * </p>
- * @param cl the listener.
- */
- public void setCompileListener(CompileListener cl) {
- _compileListener = cl;
- }
-
- /**
- * <p>
- * Tell the compiler how to locate WSDL imports for a BPEL process. Setting this
- * to <code>null</code> will cause the default behavior.
- * </p>
- * @param finder the {@link WsdlFinder} implementation to use.
- */
- public void setWsdlFinder(WsdlFinder finder) {
- _wsdlFinder = finder;
- }
-
- /**
- * <p>
- * Tell the compiler how to locate XSLT sheets used in assignment withn a BPEL process.
- * Setting this to <code>null</code> will cause the default behavior.
- * </p>
- * @param finder the {@link XsltFinder} implementation to use.
- */
- public void setXsltFinder(XsltFinder finder) {
- _xsltFinder = finder;
- }
-
- /**
- * Register a "global" WSDL import for compilation. This is used to specify WSDL
- * imports for BPEL 1.1 processes that do not support the <code><import></code>
- * BPEL construct.
- * @param wsdl the WSDL URI (resolvable against the resource repository)
- */
- public void setProcessWSDL(URI wsdl) {
- if (__log.isDebugEnabled()) {
- __log.debug("Adding WSDL import: \"" + wsdl.toASCIIString() + "\".");
- }
- _bpel11wsdl = wsdl;
- }
-
- /**
- * Set the output stream to which the compiled representation will be generated.
- * @param os compiled representation output stream
- */
- public void setOutputStream(OutputStream os) {
- if (_outputStream != null) {
- try {
- _outputStream.close();
- }
- catch (IOException ioex) {
- // ignore
- }
- }
-
- _outputStream = os;
-
- if (__log.isDebugEnabled()) {
- __log.debug("Sett output to stream " + os);
- }
- }
-
- /**
- * <p>
- * Set the target directory for output. This overrides {@link #setOutputStream(OutputStream)}.
- * </p>
- * @param outputDir the filesystem directory to write the compiled process to.
- * @see #setOutputStream(OutputStream)
- */
- public void setOutputDirectory(File outputDir) {
- // override any outputStream setting
- this.setOutputStream(null);
-
- // check if this is suitable for output
- if (outputDir != null) {
- if (outputDir.exists() && outputDir.isDirectory() && outputDir.canWrite()) {
- _outputDir = outputDir;
+ private static final Log __log = LogFactory.getLog(BpelC.class);
+ private static final CommonCompilationMessages __cmsgs =
+ MessageBundle.getMessages(CommonCompilationMessages.class);
+
+ private BpelProcessBuilderFactory _bpelProcessBuilderFactory;
+ private CompileListener _compileListener;
+ public OutputStream _outputStream = null;
+ private File _outputDir = null;
+
+ private File _bpelFile;
+ private WsdlFinder _wsdlFinder;
+ private XsltFinder _xsltFinder;
+ private URI _bpel11wsdl;
+
+ public static BpelC newBpelCompiler() {
+ return new BpelC();
+ }
+
+ private BpelC() {
+ try {
+ _bpelProcessBuilderFactory = BpelProcessBuilderFactory.newProcessBuilderFactory();
+ } catch (BpelProcessBuilderFactoryException e) {
+ throw new RuntimeException(e);
+ }
+ _bpelProcessBuilderFactory.setStrict(true);
+ }
+
+ protected void finalize() throws Throwable {
+ this.invalidate();
+ super.finalize();
+ }
+
+ private void invalidate() {
+ this.setWsdlFinder(null);
+ this.setCompileListener(null);
+ this.setOutputStream(null);
+ this.setOutputDirectory(null);
+ }
+
+ /**
+ * <p>
+ * Set a non-default target {@link CompileListener} implementation.
+ * </p>
+ * @param cl the listener.
+ */
+ public void setCompileListener(CompileListener cl) {
+ _compileListener = cl;
+ }
+
+ /**
+ * <p>
+ * Tell the compiler how to locate WSDL imports for a BPEL process. Setting this
+ * to <code>null</code> will cause the default behavior.
+ * </p>
+ * @param finder the {@link WsdlFinder} implementation to use.
+ */
+ public void setWsdlFinder(WsdlFinder finder) {
+ _wsdlFinder = finder;
+ }
+
+ /**
+ * <p>
+ * Tell the compiler how to locate XSLT sheets used in assignment withn a BPEL process.
+ * Setting this to <code>null</code> will cause the default behavior.
+ * </p>
+ * @param finder the {@link XsltFinder} implementation to use.
+ */
+ public void setXsltFinder(XsltFinder finder) {
+ _xsltFinder = finder;
+ }
+
+ /**
+ * Register a "global" WSDL import for compilation. This is used to specify WSDL
+ * imports for BPEL 1.1 processes that do not support the <code><import></code>
+ * BPEL construct.
+ * @param wsdl the WSDL URI (resolvable against the resource repository)
+ */
+ public void setProcessWSDL(URI wsdl) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Adding WSDL import: \"" + wsdl.toASCIIString() + "\".");
+ }
+ _bpel11wsdl = wsdl;
+ }
+
+ /**
+ * Set the output stream to which the compiled representation will be generated.
+ * @param os compiled representation output stream
+ */
+ public void setOutputStream(OutputStream os) {
+ if (_outputStream != null) {
+ try {
+ _outputStream.close();
+ } catch (IOException ioex) {
+ // ignore
+ }
+ }
+
+ _outputStream = os;
+
if (__log.isDebugEnabled()) {
- __log.debug("Set output directory to " + outputDir.toURI());
+ __log.debug("Sett output to stream " + os);
}
- } else {
- throw new IllegalArgumentException("outputDirectory not writeable: " + outputDir.toURI());
- }
- }
- }
-
- /**
- * <p>
- * Compile a BPEL process from a BOM {@link Process} object.
- * </p>
- *
- * @param process
- * the BOM <code>Process</code> to compile.
- *
- * @throws IOException
- * if one occurs while processing (e.g., getting imports) or writing
- * output.
- * @throws CompilationException
- * if one occurs while compiling.
- */
- public void compile(Process process) throws CompilationException, IOException {
- if (process == null)
- throw new NullPointerException("Attempt to compile NULL process.");
-
- logCompilationMessage(__cmsgs.infCompilingProcess());
-
- BpelCompiler compiler;
- WsdlFinder wf;
- XsltFinder xf;
-
- if (_wsdlFinder != null) {
- wf = _wsdlFinder;
- } else {
- wf = new DefaultWsdlFinder(_bpelFile.getParentFile());
- }
-
- if (_xsltFinder != null) {
- xf = _xsltFinder;
- } else {
- xf = new DefaultXsltFinder(_bpelFile.getParentFile());
- }
-
- CompileListener clistener = new CompileListener() {
- public void onCompilationMessage(CompilationMessage compilationMessage) {
- Object location = compilationMessage.source;
- if (location == null) {
- compilationMessage.source = _bpelFile + ":";
- }
- if (location instanceof BpelObject) {
- compilationMessage.source = _bpelFile + ":" + ((BpelObject)location).getLineNo();
- }
- logCompilationMessage(compilationMessage);
- }
- };
-
- switch (process.getBpelVersion()) {
- case Process.BPEL_V200:
- compiler = new BpelCompiler20();
- compiler.setCompileListener(clistener);
- compiler.setWsdlFinder(wf);
- compiler.setXsltFinder(xf);
- initializeXslEngine(compiler);
- if (_bpel11wsdl != null) {
- CompilationMessage cmsg = __cmsgs.warnWsdlUriIgnoredFor20Process();
- logCompilationMessage(cmsg);
- }
- break;
- case Process.BPEL_V110:
- compiler = new BpelCompiler11();
- compiler.setCompileListener(clistener);
- compiler.setWsdlFinder(wf);
- if (_bpel11wsdl != null) {
- compiler.addWsdlImport(_bpelFile, _bpel11wsdl);
+ }
+
+ /**
+ * <p>
+ * Set the target directory for output. This overrides {@link #setOutputStream(OutputStream)}.
+ * </p>
+ * @param outputDir the filesystem directory to write the compiled process to.
+ * @see #setOutputStream(OutputStream)
+ */
+ public void setOutputDirectory(File outputDir) {
+ // override any outputStream setting
+ this.setOutputStream(null);
+
+ // check if this is suitable for output
+ if (outputDir != null) {
+ if (outputDir.exists() && outputDir.isDirectory() && outputDir.canWrite()) {
+ _outputDir = outputDir;
+ if (__log.isDebugEnabled()) {
+ __log.debug("Set output directory to " + outputDir.toURI());
+ }
+ } else {
+ throw new IllegalArgumentException("outputDirectory not writeable: " + outputDir.toURI());
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * Compile a BPEL process from a BOM {@link Process} object.
+ * </p>
+ *
+ * @param process
+ * the BOM <code>Process</code> to compile.
+ *
+ * @throws IOException
+ * if one occurs while processing (e.g., getting imports) or writing
+ * output.
+ * @throws CompilationException
+ * if one occurs while compiling.
+ */
+ public void compile(Process process) throws CompilationException, IOException {
+ if (process == null)
+ throw new NullPointerException("Attempt to compile NULL process.");
+
+ logCompilationMessage(__cmsgs.infCompilingProcess());
+
+ BpelCompiler compiler;
+ WsdlFinder wf;
+ XsltFinder xf;
+
+ if (_wsdlFinder != null) {
+ wf = _wsdlFinder;
} else {
- CompilationMessage cmsg = __cmsgs.errBpel11RequiresWsdl();
- logCompilationMessage(cmsg);
- this.invalidate();
- throw new CompilationException(cmsg);
- }
- break;
- default:
- CompilationMessage cmsg = __cmsgs.errUnrecognizedBpelVersion();
- logCompilationMessage(cmsg);
+ wf = new DefaultWsdlFinder(_bpelFile.getParentFile());
+ }
+
+ if (_xsltFinder != null) {
+ xf = _xsltFinder;
+ } else {
+ xf = new DefaultXsltFinder(_bpelFile.getParentFile());
+ }
+
+ CompileListener clistener = new CompileListener() {
+ public void onCompilationMessage(CompilationMessage compilationMessage) {
+ Object location = compilationMessage.source;
+ if (location == null) {
+ compilationMessage.source = _bpelFile + ":";
+ }
+ if (location instanceof BpelObject) {
+ compilationMessage.source = _bpelFile + ":" + ((BpelObject)location).getLineNo();
+ }
+ logCompilationMessage(compilationMessage);
+ }
+ };
+
+ switch (process.getBpelVersion()) {
+ case Process.BPEL_V200:
+ compiler = new BpelCompiler20();
+ compiler.setCompileListener(clistener);
+ compiler.setWsdlFinder(wf);
+ compiler.setXsltFinder(xf);
+ initializeXslEngine(compiler);
+ if (_bpel11wsdl != null) {
+ CompilationMessage cmsg = __cmsgs.warnWsdlUriIgnoredFor20Process();
+ logCompilationMessage(cmsg);
+ }
+ break;
+ case Process.BPEL_V110:
+ compiler = new BpelCompiler11();
+ compiler.setCompileListener(clistener);
+ compiler.setWsdlFinder(wf);
+ if (_bpel11wsdl != null) {
+ compiler.addWsdlImport(_bpelFile, _bpel11wsdl);
+ } else {
+ CompilationMessage cmsg = __cmsgs.errBpel11RequiresWsdl();
+ logCompilationMessage(cmsg);
+ this.invalidate();
+ throw new CompilationException(cmsg);
+ }
+ break;
+ default:
+ CompilationMessage cmsg = __cmsgs.errUnrecognizedBpelVersion();
+ logCompilationMessage(cmsg);
+ this.invalidate();
+ throw new CompilationException(cmsg);
+ }
+
+ OProcess oprocess;
+ try {
+ oprocess = compiler.compile(_bpelFile, process);
+ }
+ catch (CompilationException cex) {
+ this.invalidate();
+ throw cex;
+ }
+
+ if (_outputStream != null) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Writing compilation results to " + _outputStream.getClass().getName());
+ }
+ } else if (_outputDir != null) {
+ File outFile = new File(_outputDir, oprocess.getName() + ".cbp");
+ this.setOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
+ if (__log.isDebugEnabled()) {
+ __log.debug("Writing compilation results to " + outFile.toURI().toString());
+ }
+ } else {
+ throw new IllegalStateException("must setOutputStream() or setOutputDirectory()!");
+ }
+
+ try {
+ Serializer fileHeader = new Serializer(System.currentTimeMillis(), 1);
+ fileHeader.write(_outputStream);
+ fileHeader.writeOProcess(oprocess, _outputStream);
+
+ // if (_bpelFile.toString().startsWith("file:") && _outputDir != null) {
+ // String filePath = _bpelFile.getFile();
+ // filePath = filePath.substring(0, filePath.lastIndexOf(".")) + ".dd";
+ //
+ // DDHandler ddHandler;
+ // try {
+ // ddHandler = new DDHandler(new File(filePath));
+ // if (!ddHandler.exists()) __log.info("No deployment descriptor found, one will be generated if needed.");
+ // boolean modified = ddHandler.validateAndEnhance(oprocess, compiler.getWsdlDefinitions());
+ // if (ddHandler.exists() || modified)
+ // ddHandler.write(new File(_outputDir, oprocess.getName() + ".dd"));
+ // } catch (DDValidationException e) {
+ // CompilationMessage cm = __cmsgs.errInvalidDeploymentDescriptor(e.getMessage());
+ // logCompilationMessage(cm);
+ // throw new CompilationException(cm);
+ // } catch (DDException e) {
+ // logCompilationMessage(__cmsgs.errInvalidDeploymentDescriptor(e.getMessage()));
+ // }
+ // } else {
+ // __log.warn("Post-compilation using deployment descriptor deactivated (compilation from url or stream).");
+ // }
+ } finally {
+ // close & mark myself invalid
+ this.invalidate();
+ }
+ }
+
+ /**
+ * <p>
+ * Compile a BPEL process from a URL. This method uses a {@link BpelProcessBuilder}
+ * to parse the XML and then calls {@link #compile(Process)}.
+ * </p>
+ * @param bpelFile the URL of the BPEL process to be compiled.
+ * @throws IOException if one occurs while reading the BPEL process or writing the
+ * output.
+ * @throws CompilationException if one occurs while compiling the process.
+ */
+ public void compile(File bpelFile) throws CompilationException, IOException {
+ if (__log.isDebugEnabled()) {
+ __log.debug("compile(URL)");
+ }
+
+ if (bpelFile == null) {
+ this.invalidate();
+ throw new IllegalArgumentException("Null bpelFile");
+ }
+
+ _bpelFile = bpelFile;
+ BpelProcessBuilder bpelProcessBuilder = _bpelProcessBuilderFactory.newBpelProcessBuilder();
+ Process process;
+ try {
+ InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL())));
+ isrc.setSystemId(bpelFile.getAbsolutePath());
+ try {
+ process = bpelProcessBuilder.parse(isrc, bpelFile.getAbsolutePath());
+ } finally {
+ ParseError[] parseErrors = bpelProcessBuilder.getParseErrors();
+ for (ParseError parseError : parseErrors) {
+ CompilationMessage cmsg = toCompilationMessage(parseError);
+ logCompilationMessage(cmsg);
+ }
+ }
+ } catch (BpelParseException e) {
+ CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(bpelFile.getAbsolutePath());
+ this.invalidate();
+ throw new CompilationException(cmsg, e);
+ }
+
+ compile(process);
this.invalidate();
- throw new CompilationException(cmsg);
}
- OProcess oprocess;
- try {
- oprocess = compiler.compile(_bpelFile, process);
- }
- catch (CompilationException cex) {
- this.invalidate();
- throw cex;
- }
-
- if (_outputStream != null) {
- if (__log.isDebugEnabled()) {
- __log.debug("Writing compilation results to " + _outputStream.getClass().getName());
- }
- } else if (_outputDir != null) {
- File outFile = new File(_outputDir, oprocess.getName() + ".cbp");
- this.setOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
- if (__log.isDebugEnabled()) {
- __log.debug("Writing compilation results to " + outFile.toURI().toString());
- }
- } else {
- throw new IllegalStateException("must setOutputStream() or setOutputDirectory()!");
- }
-
- try {
- Serializer fileHeader = new Serializer(System.currentTimeMillis(), 1);
- fileHeader.write(_outputStream);
- fileHeader.writeOProcess(oprocess, _outputStream);
-
-// if (_bpelFile.toString().startsWith("file:") && _outputDir != null) {
-// String filePath = _bpelFile.getFile();
-// filePath = filePath.substring(0, filePath.lastIndexOf(".")) + ".dd";
-//
-// DDHandler ddHandler;
-// try {
-// ddHandler = new DDHandler(new File(filePath));
-// if (!ddHandler.exists()) __log.info("No deployment descriptor found, one will be generated if needed.");
-// boolean modified = ddHandler.validateAndEnhance(oprocess, compiler.getWsdlDefinitions());
-// if (ddHandler.exists() || modified)
-// ddHandler.write(new File(_outputDir, oprocess.getName() + ".dd"));
-// } catch (DDValidationException e) {
-// CompilationMessage cm = __cmsgs.errInvalidDeploymentDescriptor(e.getMessage());
-// logCompilationMessage(cm);
-// throw new CompilationException(cm);
-// } catch (DDException e) {
-// logCompilationMessage(__cmsgs.errInvalidDeploymentDescriptor(e.getMessage()));
-// }
-// } else {
-// __log.warn("Post-compilation using deployment descriptor deactivated (compilation from url or stream).");
-// }
- } finally {
- // close & mark myself invalid
- this.invalidate();
- }
- }
-
- /**
- * <p>
- * Compile a BPEL process from a URL. This method uses a {@link BpelProcessBuilder}
- * to parse the XML and then calls {@link #compile(Process)}.
- * </p>
- * @param bpelFile the URL of the BPEL process to be compiled.
- * @throws IOException if one occurs while reading the BPEL process or writing the
- * output.
- * @throws CompilationException if one occurs while compiling the process.
- */
- public void compile(File bpelFile) throws CompilationException, IOException {
- if (__log.isDebugEnabled()) {
- __log.debug("compile(URL)");
- }
-
- if (bpelFile == null) {
- this.invalidate();
- throw new IllegalArgumentException("Null bpelFile");
- }
-
- _bpelFile = bpelFile;
- BpelProcessBuilder bpelProcessBuilder = _bpelProcessBuilderFactory.newBpelProcessBuilder();
- Process process;
- try {
- InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL())));
- isrc.setSystemId(bpelFile.getAbsolutePath());
- try {
- process = bpelProcessBuilder.parse(isrc, bpelFile.getAbsolutePath());
- } finally {
- ParseError[] parseErrors = bpelProcessBuilder.getParseErrors();
- for (ParseError parseError : parseErrors) {
- CompilationMessage cmsg = toCompilationMessage(parseError);
- logCompilationMessage(cmsg);
- }
- }
- } catch (BpelParseException e) {
- CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(bpelFile.getAbsolutePath());
- this.invalidate();
- throw new CompilationException(cmsg, e);
- }
-
- compile(process);
- this.invalidate();
- }
-
- private void initializeXslEngine(BpelCompiler compiler) {
- TransformerFactory trsf = new net.sf.saxon.TransformerFactoryImpl();
- XslTransformHandler.getInstance().setTransformerFactory(trsf);
-
- XslCompilationErrorListener xe = new XslCompilationErrorListener(compiler);
- XslTransformHandler.getInstance().setXslCompilationErrorListener(xe);
- }
-
- /**
- * Convert a parse error ({@link ParseError}) from the BOM API to a similar
- * {@link CompilationMessage}.
- * @param parseError BOM parse error
- * @return equivalent {@link CompilationMessage}
- */
- private CompilationMessage toCompilationMessage(ParseError parseError) {
- CompilationMessage cmsg = new CompilationMessage();
- switch (parseError.getSeverity()) {
- case ParseError.WARNING:
- cmsg.severity = CompilationMessage.WARN;
- break;
- case ParseError.ERROR:
- case ParseError.FATAL:
- default:
- cmsg.severity = CompilationMessage.ERROR;
- break;
- }
-
- cmsg.phase = 1;
- cmsg.code = parseError.getKey();
- cmsg.messageText = parseError.getMessage();
- cmsg.source = parseError.getLocationURI() + ":" + parseError.getLine();
- return cmsg;
- }
-
-
- /**
- * Log a compilation message, both to the log, and to the listener (if any).
- * @param cmsg
- */
- private void logCompilationMessage(CompilationMessage cmsg) {
- if (_compileListener != null) {
- _compileListener.onCompilationMessage(cmsg);
- } else {
- switch (cmsg.severity) {
- case CompilationMessage.ERROR:
- if (__log.isErrorEnabled())
- __log.error(cmsg.toErrorString());
- break;
- case CompilationMessage.INFO:
- if (__log.isInfoEnabled())
- __log.info(cmsg.toErrorString());
- break;
- case CompilationMessage.WARN:
- if (__log.isWarnEnabled())
- __log.warn(cmsg.toErrorString());
- }
+ private void initializeXslEngine(BpelCompiler compiler) {
+ TransformerFactory trsf = new net.sf.saxon.TransformerFactoryImpl();
+ XslTransformHandler.getInstance().setTransformerFactory(trsf);
+
+ XslCompilationErrorListener xe = new XslCompilationErrorListener(compiler);
+ XslTransformHandler.getInstance().setXslCompilationErrorListener(xe);
+ }
+
+ /**
+ * Convert a parse error ({@link ParseError}) from the BOM API to a similar
+ * {@link CompilationMessage}.
+ * @param parseError BOM parse error
+ * @return equivalent {@link CompilationMessage}
+ */
+ private CompilationMessage toCompilationMessage(ParseError parseError) {
+ CompilationMessage cmsg = new CompilationMessage();
+ switch (parseError.getSeverity()) {
+ case ParseError.WARNING:
+ cmsg.severity = CompilationMessage.WARN;
+ break;
+ case ParseError.ERROR:
+ case ParseError.FATAL:
+ default:
+ cmsg.severity = CompilationMessage.ERROR;
+ break;
+ }
+
+ cmsg.phase = 1;
+ cmsg.code = parseError.getKey();
+ cmsg.messageText = parseError.getMessage();
+ cmsg.source = parseError.getLocationURI() + ":" + parseError.getLine();
+ return cmsg;
+ }
+
+
+ /**
+ * Log a compilation message, both to the log, and to the listener (if any).
+ * @param cmsg
+ */
+ private void logCompilationMessage(CompilationMessage cmsg) {
+ if (_compileListener != null) {
+ _compileListener.onCompilationMessage(cmsg);
+ } else {
+ switch (cmsg.severity) {
+ case CompilationMessage.ERROR:
+ if (__log.isErrorEnabled())
+ __log.error(cmsg.toErrorString());
+ break;
+ case CompilationMessage.INFO:
+ if (__log.isInfoEnabled())
+ __log.info(cmsg.toErrorString());
+ break;
+ case CompilationMessage.WARN:
+ if (__log.isWarnEnabled())
+ __log.warn(cmsg.toErrorString());
+ }
+ }
}
- }
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java Tue Oct 17 11:38:35 2006
@@ -550,7 +550,7 @@
}
}
- OScope procesScope = new OScope(_oprocess);
+ OScope procesScope = new OScope(_oprocess, null);
procesScope.name = "__PROCESS_SCOPE:" + process.getName();
procesScope.debugInfo = createDebugInfo(process, null);
_oprocess.procesScope = compileScope(procesScope, process, new Runnable() {
@@ -691,7 +691,7 @@
}
private OActivity compileSJF(final Activity source) {
- final OScope oscope = new OScope(_oprocess);
+ final OScope oscope = new OScope(_oprocess, getCurrent());
oscope.name = createName(source);
oscope.debugInfo = createDebugInfo(source, "suppress join failure scope for " + source);
DefaultActivityGenerator.defaultExtensibilityElements(oscope, source, _structureStack.topActivity());
@@ -699,7 +699,7 @@
compile(oscope, null, new Runnable() {
public void run() {
oscope.activity = compileSLC(source);
- final OCatch joinFailureCatch = new OCatch(_oprocess);
+ final OCatch joinFailureCatch = new OCatch(_oprocess, getCurrent());
joinFailureCatch.name = "__suppressJoinFailureCatch:" + oscope.name;
joinFailureCatch.debugInfo = createDebugInfo(source, "suppress join failure catch for " + source);
compile(joinFailureCatch, null, new Runnable() {
@@ -719,7 +719,7 @@
}
private OCompensate createDefaultCompensateActivity(BpelObject source, String desc) {
- OCompensate activity = new OCompensate(_oprocess);
+ OCompensate activity = new OCompensate(_oprocess, getCurrent());
activity.name = "__autoGenCompensate:" + _structureStack.topScope().name;
activity.debugInfo = createDebugInfo(source, desc);
return activity;
@@ -728,7 +728,7 @@
public OActivity compileSLC(final Activity source) {
final ScopeLikeConstruct slcsrc = source instanceof ScopeLikeConstruct ? (ScopeLikeConstruct) source : null;
if (slcsrc != null) {
- final OScope implicitScope = new OScope(_oprocess);
+ final OScope implicitScope = new OScope(_oprocess, getCurrent());
implicitScope.name = createName(source);
implicitScope.debugInfo = createDebugInfo(source, "Scope-like construct " + source);
compileScope(implicitScope, slcsrc, new Runnable() {
@@ -897,6 +897,10 @@
oscope.addCorrelationSet(ocset);
}
+public OActivity getCurrent() {
+ return _structureStack.topActivity();
+}
+
public void compile(OActivity context, BpelObject source, Runnable run) {
DefaultActivityGenerator.defaultExtensibilityElements(context, source, _structureStack.topActivity());
_structureStack.push(context);
@@ -1067,7 +1071,7 @@
final OScope oscope = _structureStack.topScope();
assert oscope.eventHandler != null;
- final OEventHandler.OEvent oevent = new OEventHandler.OEvent(_oprocess);
+ final OEventHandler.OEvent oevent = new OEventHandler.OEvent(_oprocess, oscope);
oevent.name = "__eventHandler:";
oevent.debugInfo = createDebugInfo(onEvent,null);
compile(oevent, onEvent, new Runnable() {
@@ -1201,7 +1205,7 @@
private void compile(TerminationHandler terminationHandler) {
OScope oscope = _structureStack.topScope();
- oscope.terminationHandler = new OTerminationHandler(_oprocess);
+ oscope.terminationHandler = new OTerminationHandler(_oprocess, oscope);
oscope.terminationHandler.name = "__terminationHandler:" + oscope.name;
oscope.terminationHandler.debugInfo = createDebugInfo(terminationHandler, null);
if (terminationHandler == null) {
@@ -1218,7 +1222,7 @@
private void compile(CompensationHandler compensationHandler) {
OScope oscope = _structureStack.topScope();
- oscope.compensationHandler = new OCompensationHandler(_oprocess);
+ oscope.compensationHandler = new OCompensationHandler(_oprocess, oscope);
oscope.compensationHandler.name = "__compenationHandler_" + oscope.name;
oscope.compensationHandler.debugInfo = createDebugInfo(compensationHandler,null);
if (compensationHandler == null) {
@@ -1240,14 +1244,14 @@
if (fh == null) {
// The default fault handler compensates all child activities
// AND then rethrows the fault!
- final OCatch defaultCatch = new OCatch(_oprocess);
+ final OCatch defaultCatch = new OCatch(_oprocess, oscope);
defaultCatch.name = "__defaultFaultHandler:" + oscope.name;
defaultCatch.faultName = null; // catch any fault
defaultCatch.faultVariable = null;
- OSequence sequence = new OSequence(_oprocess);
+ OSequence sequence = new OSequence(_oprocess, defaultCatch);
sequence.name = "__defaultFaultHandler_sequence:" + oscope.name;
sequence.debugInfo = createDebugInfo(fh, "Auto-generated sequence activity.");
- ORethrow rethrow = new ORethrow(_oprocess);
+ ORethrow rethrow = new ORethrow(_oprocess, sequence);
rethrow.name = "__defaultFaultHandler_rethrow:" + oscope.name;
rethrow.debugInfo = createDebugInfo(fh, "Auto-generated re-throw activity.");
sequence.sequence.add(createDefaultCompensateActivity(fh, "Default compensation handler for " + oscope));
@@ -1266,7 +1270,7 @@
for (int i = 0; i < catches.length; i++) {
final Catch catchSrc = catches[i];
- final OCatch ctch = new OCatch(_oprocess);
+ final OCatch ctch = new OCatch(_oprocess, oscope);
ctch.debugInfo = createDebugInfo(catchSrc, catchSrc.toString());
ctch.name = "__catch#" +i + ":" +_structureStack.topScope().name;
ctch.faultName = catchSrc.getFaultName();
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java Tue Oct 17 11:38:35 2006
@@ -28,36 +28,36 @@
*/
public class BpelCompiler11 extends BpelCompiler {
- /** URI for the XPath 1.0 expression language. */
- public static final String EXPLANG_XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+ /** URI for the XPath 1.0 expression language. */
+ public static final String EXPLANG_XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";
- public BpelCompiler11() {
- super((WSDLFactory4BPEL) WSDLFactoryBPEL11.newInstance());
+ public BpelCompiler11() {
+ super((WSDLFactory4BPEL) WSDLFactoryBPEL11.newInstance());
- registerActivityCompiler(EmptyActivity.class, new EmptyGenerator());
- registerActivityCompiler(CompensateActivity.class, new CompensateGenerator());
- registerActivityCompiler(FlowActivity.class, new FlowGenerator());
- registerActivityCompiler(SequenceActivity.class, new SequenceGenerator());
- registerActivityCompiler(AssignActivity.class, new AssignGenerator());
- registerActivityCompiler(ThrowActivity.class, new ThrowGenerator());
- registerActivityCompiler(WhileActivity.class, new WhileGenerator());
- registerActivityCompiler(SwitchActivity.class, new SwitchGenerator());
- registerActivityCompiler(PickActivity.class, new PickGenerator());
- registerActivityCompiler(ReplyActivity.class, new ReplyGenerator());
- registerActivityCompiler(ReceiveActivity.class, new ReceiveGenerator());
- registerActivityCompiler(InvokeActivity.class, new InvokeGenerator());
- registerActivityCompiler(WaitActivity.class, new WaitGenerator());
- registerActivityCompiler(TerminateActivity.class, new TerminateGenerator());
+ registerActivityCompiler(EmptyActivity.class, new EmptyGenerator());
+ registerActivityCompiler(CompensateActivity.class, new CompensateGenerator());
+ registerActivityCompiler(FlowActivity.class, new FlowGenerator());
+ registerActivityCompiler(SequenceActivity.class, new SequenceGenerator());
+ registerActivityCompiler(AssignActivity.class, new AssignGenerator());
+ registerActivityCompiler(ThrowActivity.class, new ThrowGenerator());
+ registerActivityCompiler(WhileActivity.class, new WhileGenerator());
+ registerActivityCompiler(SwitchActivity.class, new SwitchGenerator());
+ registerActivityCompiler(PickActivity.class, new PickGenerator());
+ registerActivityCompiler(ReplyActivity.class, new ReplyGenerator());
+ registerActivityCompiler(ReceiveActivity.class, new ReceiveGenerator());
+ registerActivityCompiler(InvokeActivity.class, new InvokeGenerator());
+ registerActivityCompiler(WaitActivity.class, new WaitGenerator());
+ registerActivityCompiler(TerminateActivity.class, new TerminateGenerator());
- registerExpressionLanguage(EXPLANG_XPATH, new XPath10ExpressionCompilerBPEL11());
- }
+ registerExpressionLanguage(EXPLANG_XPATH, new XPath10ExpressionCompilerBPEL11());
+ }
- protected String getBpwsNamespace() {
- return Constants.NS_BPEL4WS_2003_03;
- }
+ protected String getBpwsNamespace() {
+ return Constants.NS_BPEL4WS_2003_03;
+ }
- protected String getDefaultExpressionLanguage() {
- return EXPLANG_XPATH;
- }
+ protected String getDefaultExpressionLanguage() {
+ return EXPLANG_XPATH;
+ }
}
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java Tue Oct 17 11:38:35 2006
@@ -28,39 +28,39 @@
* OASIS BPEL V2.0 Compiler
*/
public class BpelCompiler20 extends BpelCompiler {
- public static final String OASIS_EXPLANG_XPATH_1_0 = "urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0";
+ public static final String OASIS_EXPLANG_XPATH_1_0 = "urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0";
- public static final String OASIS_EXPLANG_XPATH_2_0 = "urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0";
+ public static final String OASIS_EXPLANG_XPATH_2_0 = "urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0";
- public BpelCompiler20() {
- super((WSDLFactory4BPEL) WSDLFactoryBPEL20.newInstance());
+ public BpelCompiler20() {
+ super((WSDLFactory4BPEL) WSDLFactoryBPEL20.newInstance());
- registerActivityCompiler(EmptyActivity.class, new EmptyGenerator());
- registerActivityCompiler(CompensateActivity.class, new CompensateGenerator());
- registerActivityCompiler(FlowActivity.class, new FlowGenerator());
- registerActivityCompiler(SequenceActivity.class, new SequenceGenerator());
- registerActivityCompiler(AssignActivity.class, new AssignGenerator());
- registerActivityCompiler(ThrowActivity.class, new ThrowGenerator());
- registerActivityCompiler(WhileActivity.class, new WhileGenerator());
- registerActivityCompiler(SwitchActivity.class, new SwitchGenerator());
- registerActivityCompiler(PickActivity.class, new PickGenerator());
- registerActivityCompiler(ReplyActivity.class, new ReplyGenerator());
- registerActivityCompiler(ReceiveActivity.class, new ReceiveGenerator());
- registerActivityCompiler(InvokeActivity.class, new InvokeGenerator());
- registerActivityCompiler(WaitActivity.class, new WaitGenerator());
- registerActivityCompiler(TerminateActivity.class, new TerminateGenerator());
- registerActivityCompiler(RethrowActivity.class, new RethrowGenerator());
- registerActivityCompiler(ForEachActivity.class, new ForEachGenerator());
-
- registerExpressionLanguage(OASIS_EXPLANG_XPATH_1_0, new XPath10ExpressionCompilerBPEL20());
- registerExpressionLanguage(OASIS_EXPLANG_XPATH_2_0, new XPath20ExpressionCompilerBPEL20());
- }
-
- protected String getBpwsNamespace() {
- return Constants.NS_WSBPEL_2004_03;
- }
-
- protected String getDefaultExpressionLanguage() {
- return OASIS_EXPLANG_XPATH_1_0;
- }
+ registerActivityCompiler(EmptyActivity.class, new EmptyGenerator());
+ registerActivityCompiler(CompensateActivity.class, new CompensateGenerator());
+ registerActivityCompiler(FlowActivity.class, new FlowGenerator());
+ registerActivityCompiler(SequenceActivity.class, new SequenceGenerator());
+ registerActivityCompiler(AssignActivity.class, new AssignGenerator());
+ registerActivityCompiler(ThrowActivity.class, new ThrowGenerator());
+ registerActivityCompiler(WhileActivity.class, new WhileGenerator());
+ registerActivityCompiler(SwitchActivity.class, new SwitchGenerator());
+ registerActivityCompiler(PickActivity.class, new PickGenerator());
+ registerActivityCompiler(ReplyActivity.class, new ReplyGenerator());
+ registerActivityCompiler(ReceiveActivity.class, new ReceiveGenerator());
+ registerActivityCompiler(InvokeActivity.class, new InvokeGenerator());
+ registerActivityCompiler(WaitActivity.class, new WaitGenerator());
+ registerActivityCompiler(TerminateActivity.class, new TerminateGenerator());
+ registerActivityCompiler(RethrowActivity.class, new RethrowGenerator());
+ registerActivityCompiler(ForEachActivity.class, new ForEachGenerator());
+
+ registerExpressionLanguage(OASIS_EXPLANG_XPATH_1_0, new XPath10ExpressionCompilerBPEL20());
+ registerExpressionLanguage(OASIS_EXPLANG_XPATH_2_0, new XPath20ExpressionCompilerBPEL20());
+ }
+
+ protected String getBpwsNamespace() {
+ return Constants.NS_WSBPEL_2004_03;
+ }
+
+ protected String getDefaultExpressionLanguage() {
+ return OASIS_EXPLANG_XPATH_1_0;
+ }
}