📄 bpelcompiler.java
字号:
} }); } finally { _atomicScope = previousAtomicScope; } return oscope; } private void compile(final OnAlarm onAlarm) { OScope oscope = _structureStack.topScope(); assert oscope.eventHandler != null; final OEventHandler.OAlarm oalarm = new OEventHandler.OAlarm(_oprocess); oalarm.debugInfo = createDebugInfo(onAlarm, "OnAlarm Event Handler: " + onAlarm); if (onAlarm.getFor() != null && onAlarm.getUntil() == null) { oalarm.forExpr = compileExpr(onAlarm.getFor()); } else if (onAlarm.getFor() == null && onAlarm.getUntil() != null) { oalarm.untilExpr = compileExpr(onAlarm.getUntil()); } else if (onAlarm.getFor() != null && onAlarm.getUntil() != null) { throw new CompilationException(__cmsgs.errInvalidAlarm().setSource(onAlarm)); } else if (onAlarm.getRepeatEvery() == null) { throw new CompilationException(__cmsgs.errInvalidAlarm().setSource(onAlarm)); } if (onAlarm.getRepeatEvery() != null) oalarm.repeatExpr = compileExpr(onAlarm.getRepeatEvery()); oalarm.activity = compile(onAlarm.getActivity()); // Check links crossing restrictions. for (OLink link : oalarm.incomingLinks) try { throw new CompilationException(__cmsgs.errLinkCrossesEventHandlerBoundary(link.name).setSource(onAlarm)); } catch (CompilationException ce) { recoveredFromError(onAlarm, ce); } for (OLink link : oalarm.outgoingLinks) try { throw new CompilationException(__cmsgs.errLinkCrossesEventHandlerBoundary(link.name).setSource(onAlarm)); } catch (CompilationException ce) { recoveredFromError(onAlarm, ce); } oscope.eventHandler.onAlarms.add(oalarm); } private void compile(final OnEvent onEvent) { final OScope oscope = _structureStack.topScope(); assert oscope.eventHandler != null; final OEventHandler.OEvent oevent = new OEventHandler.OEvent(_oprocess, oscope); oevent.name = "__eventHandler:"; oevent.debugInfo = createDebugInfo(onEvent, null); compile(oevent, onEvent, new Runnable() { public void run() { switch (_processDef.getBpelVersion()) { case BPEL11: oevent.variable = resolveMessageVariable(onEvent.getVariable()); break; case BPEL20_DRAFT: case BPEL20: if (onEvent.getMessageType() == null && onEvent.getElementType() == null) throw new CompilationException(__cmsgs.errVariableDeclMissingType(onEvent.getVariable()) .setSource(onEvent)); if (onEvent.getMessageType() != null && onEvent.getElementType() != null) throw new CompilationException(__cmsgs.errVariableDeclInvalid(onEvent.getVariable()).setSource( onEvent)); OVarType varType; if (onEvent.getMessageType() != null) varType = resolveMessageType(onEvent.getMessageType()); else if (onEvent.getElement() != null) varType = resolveElementType(onEvent.getElementType()); else throw new CompilationException(__cmsgs .errUnrecognizedVariableDeclaration(onEvent.getVariable())); oevent.variable = new OScope.Variable(_oprocess, varType); oevent.variable.name = onEvent.getVariable(); oevent.variable.declaringScope = _structureStack.topScope(); oevent.addLocalVariable(oevent.variable); break; default: throw new AssertionError("Unexpected BPEL VERSION constatnt: " + _processDef.getBpelVersion()); } oevent.partnerLink = resolvePartnerLink(onEvent.getPartnerLink()); oevent.operation = resolveMyRoleOperation(oevent.partnerLink, onEvent.getOperation()); oevent.messageExchangeId = onEvent.getMessageExchangeId(); if (onEvent.getPortType() != null && !onEvent.getPortType().equals(oevent.partnerLink.myRolePortType.getQName())) throw new CompilationException(__cmsgs.errPortTypeMismatch(onEvent.getPortType(), oevent.partnerLink.myRolePortType.getQName())); for (Correlation correlation : onEvent.getCorrelations()) { OScope.CorrelationSet cset = resolveCorrelationSet(correlation.getCorrelationSet()); switch (correlation.getInitiate()) { case UNSET: case NO: if (oevent.matchCorrelation != null) throw new CompilationException(__cmsgs.errTODO("Matching multiple correlations sets.")); oevent.matchCorrelation = cset; oevent.partnerLink.addCorrelationSetForOperation(oevent.operation, cset); break; case YES: oevent.initCorrelations.add(cset); break; case JOIN: throw new CompilationException(__cmsgs.errTODO("Rendezvous.")); } for (OProcess.OProperty property : cset.properties) { // Force resolution of alias, to make sure that we have // one for this variable-property pair. resolvePropertyAlias(oevent.variable, property.name); } } oevent.activity = compile(onEvent.getActivity()); } }); // Check links crossing restrictions. for (OLink link : oevent.incomingLinks) try { throw new CompilationException(__cmsgs.errLinkCrossesEventHandlerBoundary(link.name)); } catch (CompilationException ce) { recoveredFromError(onEvent, ce); } for (OLink link : oevent.outgoingLinks) try { throw new CompilationException(__cmsgs.errLinkCrossesEventHandlerBoundary(link.name)); } catch (CompilationException ce) { recoveredFromError(onEvent, ce); } oscope.eventHandler.onMessages.add(oevent); } private DebugInfo createDebugInfo(BpelObject bpelObject, String description) { int lineNo = bpelObject == null ? -1 : bpelObject.getLineNo(); String str = description == null && bpelObject != null ? bpelObject.toString() : null; Map<QName, Object> extElmt = bpelObject == null ? null : bpelObject.getExtensibilityElements(); DebugInfo debugInfo = new DebugInfo(_processDef.getSource(), lineNo, extElmt); debugInfo.description = str; return debugInfo; } private void compile(final Variable src) { final OScope oscope = _structureStack.topScope(); if (src.getKind() == null) throw new CompilationException(__cmsgs.errVariableDeclMissingType(src.getName()).setSource(src)); if (oscope.getLocalVariable(src.getName()) != null) throw new CompilationException(__cmsgs.errDuplicateVariableDecl(src.getName()).setSource(src)); if (src.getTypeName() == null) throw new CompilationException(__cmsgs.errUnrecognizedVariableDeclaration(src.getName())); OVarType varType; switch (src.getKind()) { case ELEMENT: varType = resolveElementType(src.getTypeName()); break; case MESSAGE: varType = resolveMessageType(src.getTypeName()); break; case SCHEMA: varType = resolveXsdType(src.getTypeName()); break; default: throw new CompilationException(__cmsgs.errUnrecognizedVariableDeclaration(src.getName())); } OScope.Variable ovar = new OScope.Variable(_oprocess, varType); ovar.name = src.getName(); ovar.declaringScope = oscope; ovar.debugInfo = createDebugInfo(src, null); ovar.extVar = compileExtVar(src); oscope.addLocalVariable(ovar); if (__log.isDebugEnabled()) __log.debug("Compiled variable " + ovar); } private void compile(TerminationHandler terminationHandler) { OScope oscope = _structureStack.topScope(); oscope.terminationHandler = new OTerminationHandler(_oprocess, oscope); oscope.terminationHandler.name = "__terminationHandler:" + oscope.name; oscope.terminationHandler.debugInfo = createDebugInfo(terminationHandler, null); if (terminationHandler == null) { oscope.terminationHandler.activity = createDefaultCompensateActivity(null, "Auto-generated 'compensate all' pseudo-activity for default termination handler on " + oscope.toString()); } else { _recoveryContextStack.push(oscope); try { oscope.terminationHandler.activity = compile(terminationHandler.getActivity()); } finally { _recoveryContextStack.pop(); } } } private void compile(CompensationHandler compensationHandler) { OScope oscope = _structureStack.topScope(); oscope.compensationHandler = new OCompensationHandler(_oprocess, oscope); oscope.compensationHandler.name = "__compenationHandler_" + oscope.name; oscope.compensationHandler.debugInfo = createDebugInfo(compensationHandler, null); if (compensationHandler == null) { oscope.compensationHandler.activity = createDefaultCompensateActivity(compensationHandler, "Auto-generated 'compensate all' pseudo-activity for default compensation handler on " + oscope.toString()); } else { _recoveryContextStack.push(oscope); try { oscope.compensationHandler.activity = compile(compensationHandler.getActivity()); } finally { _recoveryContextStack.pop(); } } } private void compile(FaultHandler fh) { OScope oscope = _structureStack.topScope(); oscope.faultHandler = new OFaultHandler(_oprocess); if (fh == null) { // The default fault handler compensates all child activities // AND then rethrows the fault! 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, defaultCatch); sequence.name = "__defaultFaultHandler_sequence:" + oscope.name; sequence.debugInfo = createDebugInfo(fh, "Auto-generated sequence activity."); 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)); sequence.sequence.add(rethrow); defaultCatch.activity = sequence; oscope.faultHandler.catchBlocks.add(defaultCatch); if (__log.isDebugEnabled()) __log.debug("Compiled default catch block " + defaultCatch + " for " + oscope); } else { _recoveryContextStack.push(oscope); try { int i = 0; for (final Catch catchSrc : fh.getCatches()) { final OCatch ctch = new OCatch(_oprocess, oscope); ctch.debugInfo = createDebugInfo(catchSrc, catchSrc.toString()); ctch.name = "__catch#" + i + ":" + _structureStack.topScope().name; ctch.faultName = catchSrc.getFaultName(); compile(ctch, catchSrc, new Runnable() { public void run() { if (catchSrc.getFaultVariable() != null) { OScope.Variable faultVar; switch (_processDef.getBpelVersion()) { case BPEL11: faultVar = resolveVariable(catchSrc.getFaultVariable()); if (!(faultVar.type instanceof OMessageVarType)) throw new CompilationException(__cmsgs.errMessageVariableRequired( catchSrc.getFaultVariable()).setSource(catchSrc)); break; case BPEL20_DRAFT: case BPEL20: if (catchSrc.getFaultVariableMessageType() == null && catchSrc.getFaultVariableElementType() == null) throw new CompilationException(__cmsgs.errVariableDeclMissingType( catchSrc.getFaultVariable()).setSource(catchSrc)); if (catchSrc.getFaultVariableMessageType() != null && catchSrc.getFaultVariableElementType() != null) throw new CompilationException(__cmsgs.errVariableDeclMissingType( catchSrc.getFaultVariable()).setSource(catchSrc)); OVarType faultVarType; if (catchSrc.getFaultVariableMessageType() != null) faultVarType = resolveMessageType(catchSrc.getFaultVariableMessageType()); else if (catchSrc.getFaultVar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -