📄 bpelcompiler.java
字号:
implicitScope.activity = compileActivity(false, source); } } }); return implicitScope; } private OActivity compileActivity(final boolean doLinks, final Activity source) { final ActivityGenerator actgen = findActivityGen(source); final OActivity oact = actgen.newInstance(source); oact.name = createName(source, "activity"); oact.debugInfo = createDebugInfo(source, "Activity body for " + source); _compiledActivities.add(oact); compile(oact, source, new Runnable() { public void run() { if (doLinks) compileLinks(source); actgen.compile(oact, source); } }); return oact; } private void compileLinks(Activity source) { /* Source Links Fixup */ for (LinkSource ls : source.getLinkSources()) compileLinkSource(ls); /* Target Links Fixup */ for (LinkTarget lt : source.getLinkTargets()) compileLinkTarget(lt); _structureStack.topActivity().joinCondition = (source.getJoinCondition() == null || source.getLinkTargets() .isEmpty()) ? null : compileJoinCondition(source.getJoinCondition()); } private String createName(Activity source, String type) { if (source.getName() != null) return source.getName(); return source.getType().getLocalPart() + "-" + type + "-line-" + source.getLineNo(); } private OProcess.OProperty compile(Property property) { OProcess.OProperty oproperty = new OProcess.OProperty(_oprocess); oproperty.name = property.getName(); oproperty.debugInfo = createDebugInfo(_processDef, "Property " + property.getName()); if (!_wsdlRegistry.getSchemaModel().isSimpleType(property.getPropertyType())) throw new CompilationException(__cmsgs.errPropertyDeclaredWithComplexType(property.getName(), property.getPropertyType()).setSource(property)); _oprocess.properties.add(oproperty); if (__log.isDebugEnabled()) __log.debug("Compiled property " + oproperty); return oproperty; } private OProcess.OPropertyAlias compile(PropertyAlias src) { OProcess.OProperty property = resolveProperty(src.getPropertyName()); OProcess.OPropertyAlias alias = new OProcess.OPropertyAlias(_oprocess); alias.debugInfo = createDebugInfo(_processDef, "PropertyAlias " + src.getPropertyName() + " for " + src.getMessageType()); if (src.getMessageType() == null){ throw new CompilationException(__cmsgs.errAliasUndeclaredMessage(src.getPropertyName(), src.getQuery().getPath())); } OMessageVarType messageType = resolveMessageType(src.getMessageType()); alias.varType = messageType; // bpel 2.0 excludes declaration of part; // bpel 1.1 requires it if (src.getPart() != null) { alias.part = messageType.parts.get(src.getPart()); if (alias.part == null) throw new CompilationException(__cmsgs.errUnknownPartInAlias(src.getPart(), messageType.messageType.toString())); } if (src.getQuery() != null) alias.location = compileExpr(src.getQuery()); property.aliases.add(alias); alias.debugInfo = createDebugInfo(_processDef, src.getMessageType() + " --> " + src.getPropertyName()); return alias; } private void compileLinkTarget(LinkTarget target) { OLink ol = resolveLink(target.getLinkName()); assert ol != null; ol.debugInfo = createDebugInfo(target, target.toString()); if (ol.target != null) throw new CompilationException(__cmsgs.errDuplicateLinkTarget(target.getLinkName()).setSource(target)); ol.target = _structureStack.topActivity(); _structureStack.topActivity().targetLinks.add(ol); } private void compileLinkSource(LinkSource linksrc) { OLink ol = resolveLink(linksrc.getLinkName()); assert ol != null; ol.debugInfo = createDebugInfo(linksrc, linksrc.toString()); if (ol.source != null) throw new CompilationException(__cmsgs.errDuplicateLinkSource(linksrc.getLinkName()).setSource(linksrc)); ol.source = _structureStack.topActivity(); ol.transitionCondition = linksrc.getTransitionCondition() == null ? constantExpr(true) : compileExpr(linksrc .getTransitionCondition()); _structureStack.topActivity().sourceLinks.add(ol); _structureStack.topActivity().outgoingLinks.add(ol); } private void compile(final PartnerLink plink) { OPartnerLink oplink = new OPartnerLink(_oprocess); oplink.debugInfo = createDebugInfo(plink, plink.toString()); try { PartnerLinkType plinkType = resolvePartnerLinkType(plink.getPartnerLinkType()); oplink.partnerLinkType = plinkType.getName(); oplink.name = plink.getName(); oplink.initializePartnerRole = plink.isInitializePartnerRole(); if (plink.hasMyRole()) { PartnerLinkType.Role myRole = plinkType.getRole(plink.getMyRole()); if (myRole == null) throw new CompilationException(__cmsgs.errUndeclaredRole(plink.getMyRole(), plinkType.getName())); oplink.myRoleName = myRole.getName(); QName portType = myRole.getPortType(); if (portType == null) throw new CompilationException(__cmsgs.errMissingMyRolePortType(portType, plink.getMyRole(), plinkType.getName())); oplink.myRolePortType = resolvePortType(portType); } if (plink.isInitializePartnerRole() && !plink.hasPartnerRole()) { throw new CompilationException(__cmsgs.errPartnerLinkNoPartnerRoleButInitialize(plink.getName())); } if (plink.hasPartnerRole()) { PartnerLinkType.Role partnerRole = plinkType.getRole(plink.getPartnerRole()); if (partnerRole == null) throw new CompilationException(__cmsgs.errUndeclaredRole(plink.getPartnerRole(), plinkType .getName())); oplink.partnerRoleName = partnerRole.getName(); QName portType = partnerRole.getPortType(); if (portType == null) throw new CompilationException(__cmsgs.errMissingPartnerRolePortType(portType, plink.getPartnerRole(), plinkType.getName())); oplink.partnerRolePortType = resolvePortType(portType); } oplink.declaringScope = _structureStack.topScope(); if (oplink.declaringScope.partnerLinks.containsKey(oplink.name)) throw new CompilationException(__cmsgs.errDuplicatePartnerLinkDecl(oplink.name)); oplink.declaringScope.partnerLinks.put(oplink.name, oplink); _oprocess.allPartnerLinks.add(oplink); } catch (CompilationException ce) { ce.getCompilationMessage().setSource(plink); throw ce; } } private void compile(CorrelationSet cset) { OScope oscope = _structureStack.topScope(); OScope.CorrelationSet ocset = new OScope.CorrelationSet(_oprocess); ocset.name = cset.getName(); ocset.declaringScope = oscope; ocset.debugInfo = createDebugInfo(cset, cset.toString()); QName[] setprops = cset.getProperties(); for (int j = 0; j < setprops.length; ++j) ocset.properties.add(resolveProperty(setprops[j])); oscope.addCorrelationSet(ocset); } public OActivity getCurrent() { return _structureStack.topActivity(); } public void compile(OActivity context, BpelObject source, Runnable run) { DefaultActivityGenerator.defaultExtensibilityElements(context, source); _structureStack.push(context,source); try { run.run(); } finally { OActivity popped = _structureStack.pop(); OActivity newtop = _structureStack.topActivity(); OScope topScope = _structureStack.topScope(); if (newtop != null) { newtop.nested.add(popped); // Transfer outgoing and incoming links, excluding the locally defined links. newtop.incomingLinks.addAll(popped.incomingLinks); if (newtop instanceof OFlow) newtop.incomingLinks.removeAll(((OFlow) newtop).localLinks); newtop.outgoingLinks.addAll(popped.outgoingLinks); if (newtop instanceof OFlow) newtop.outgoingLinks.removeAll(((OFlow) newtop).localLinks); // Transfer variables read/writen newtop.variableRd.addAll(popped.variableRd); newtop.variableWr.addAll(popped.variableWr); } if (topScope != null && popped instanceof OScope) topScope.compensatable.add((OScope) popped); } } private OScope compileScope(final OScope oscope, final Scope src, final Runnable init) { if (oscope.name == null) throw new IllegalArgumentException("Unnamed scope:" + src); oscope.debugInfo = createDebugInfo(src, src.toString()); boolean previousAtomicScope = _atomicScope; if (src.getAtomicScope() != null) { boolean newValue = src.getAtomicScope().booleanValue(); if (_atomicScope) throw new CompilationException(__cmsgs.errAtomicScopeNesting(newValue)); oscope.atomicScope = _atomicScope = newValue; } try { compile(oscope, src, new Runnable() { public void run() { for (Variable var : src.getVariables()) { try { compile(var); } catch (CompilationException ce) { recoveredFromError(var, ce); } } for (CorrelationSet cset : src.getCorrelationSetDecls()) { try { compile(cset); } catch (CompilationException ce) { recoveredFromError(cset, ce); } } for (PartnerLink plink : src.getPartnerLinks()) { try { compile(plink); } catch (CompilationException ce) { recoveredFromError(plink, ce); } } if (!src.getEvents().isEmpty() || !src.getAlarms().isEmpty()) { oscope.eventHandler = new OEventHandler(_oprocess); oscope.eventHandler.debugInfo = createDebugInfo(src, "Event Handler for " + src); } for (OnEvent onEvent : src.getEvents()) { try { compile(onEvent); } catch (CompilationException ce) { recoveredFromError(src, ce); } } for (OnAlarm onAlarm : src.getAlarms()) { try { compile(onAlarm); } catch (CompilationException ce) { recoveredFromError(src, ce); } } if (init != null) try { init.run(); } catch (CompilationException ce) { recoveredFromError(src, ce); } try { compile(src.getCompensationHandler()); } catch (CompilationException bce) { recoveredFromError(src.getCompensationHandler(), bce); } try { compile(src.getTerminationHandler()); } catch (CompilationException bce) { recoveredFromError(src.getTerminationHandler(), bce); } try { compile(src.getFaultHandler()); } catch (CompilationException bce) { recoveredFromError(src.getFaultHandler(), bce); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -