📄 bpelcompiler.java
字号:
case CompilationMessage.WARN: if (__log.isWarnEnabled()) { __log.warn(bce.toErrorMessage()); } break; case CompilationMessage.ERROR: if (__log.isErrorEnabled()) { __log.error(bce.toErrorMessage()); } } } else { if (__log.isDebugEnabled()) { __log.debug(bce.toErrorMessage(), bce); } _compileListener.onCompilationMessage(bce.getCompilationMessage()); } _errors.add(bce.getCompilationMessage()); } /** * Compile a process. */ public OProcess compile(final Process process, ResourceFinder rf) throws CompilationException { if (process == null) throw new NullPointerException("Null process parameter"); setResourceFinder(rf); _processURI = process.getURI(); _processDef = process; _generatedDate = new Date(); _structureStack.clear(); String bpelVersionUri = null; switch (process.getBpelVersion()) { case BPEL11: bpelVersionUri = Bpel11QNames.NS_BPEL4WS_2003_03; break; case BPEL20_DRAFT: bpelVersionUri = Bpel20QNames.NS_WSBPEL2_0; break; case BPEL20: bpelVersionUri = Bpel20QNames.NS_WSBPEL2_0_FINAL_EXEC; break; default: throw new IllegalStateException("Bad bpel version: " + process.getBpelVersion()); } _oprocess = new OProcess(bpelVersionUri); _oprocess.guid = new GUID().toString(); _oprocess.constants = makeConstants(); _oprocess.debugInfo = createDebugInfo(process, "process"); if (process.getTargetNamespace() == null) { _oprocess.targetNamespace = "--UNSPECIFIED--"; recoveredFromError(process, new CompilationException(__cmsgs.errProcessNamespaceNotSpecified())); } else { _oprocess.targetNamespace = _processDef.getTargetNamespace(); } if (process.getName() == null) { _oprocess.processName = "--UNSPECIFIED--"; recoveredFromError(process, new CompilationException(__cmsgs.errProcessNameNotSpecified())); } else { _oprocess.processName = _processDef.getName(); } _oprocess.compileDate = _generatedDate; _konstExprLang = new OExpressionLanguage(_oprocess, null); _konstExprLang.debugInfo = createDebugInfo(_processDef, "Constant Value Expression Language"); _konstExprLang.expressionLanguageUri = "uri:www.fivesight.com/konstExpression"; _konstExprLang.properties.put("runtime-class", "org.apache.ode.bpel.runtime.explang.konst.KonstExpressionLanguageRuntimeImpl"); _oprocess.expressionLanguages.add(_konstExprLang); // Process the imports. Note, we expect all processes (Event BPEL 1.1) // to have an import declaration. This should be automatically generated // by the 1.1 parser. for (Import imprt : _processDef.getImports()) { try { compile(_processURI, imprt); } catch (CompilationException bce) { // We try to recover from import problems by continuing recoveredFromError(imprt, bce); } } switch (_processDef.getSuppressJoinFailure()) { case NO: case NOTSET: _supressJoinFailure = false; break; case YES: _supressJoinFailure = true; break; } // compile ALL wsdl properties; needed for property extraction Definition4BPEL[] defs = _wsdlRegistry.getDefinitions(); for (Definition4BPEL def : defs) { for (Property property : def.getProperties()) { compile(property); } } // compile ALL wsdl property aliases for (Definition4BPEL def1 : defs) { for (PropertyAlias propertyAlias : def1.getPropertyAliases()) { compile(propertyAlias); } } OScope procesScope = new OScope(_oprocess, null); procesScope.name = "__PROCESS_SCOPE:" + process.getName(); procesScope.debugInfo = createDebugInfo(process, null); _oprocess.procesScope = compileScope(procesScope, process, new Runnable() { public void run() { if (process.getRootActivity() == null) { throw new CompilationException(__cmsgs.errNoRootActivity()); } // Process custom properties are created as variables associated // with the top scope if (_customProcessProperties != null) { for (Map.Entry<QName, Node> customVar : _customProcessProperties.entrySet()) { final OScope oscope = _structureStack.topScope(); OVarType varType = new OConstantVarType(_oprocess, customVar.getValue()); OScope.Variable ovar = new OScope.Variable(_oprocess, varType); ovar.name = customVar.getKey().getLocalPart(); ovar.declaringScope = oscope; ovar.debugInfo = createDebugInfo(null, "Process custom property variable"); oscope.addLocalVariable(ovar); if (__log.isDebugEnabled()) __log.debug("Compiled custom property variable " + ovar); } } _structureStack.topScope().activity = compile(process.getRootActivity()); } }); assert _structureStack.size() == 0; boolean hasErrors = false; StringBuffer sb = new StringBuffer(); for (CompilationMessage msg : _errors) { if (msg.severity >= CompilationMessage.ERROR) { hasErrors = true; sb.append('\t'); sb.append(msg.toErrorString()); sb.append('\n'); } } if (hasErrors) { throw new CompilationException(__cmsgs.errCompilationErrors(_errors.size(), sb.toString())); } return _oprocess; } private OConstants makeConstants() { OConstants constants = new OConstants(_oprocess); constants.qnConflictingReceive = new QName(getBpwsNamespace(), "conflictingReceive"); constants.qnCorrelationViolation = new QName(getBpwsNamespace(), "correlationViolation"); constants.qnForcedTermination = new QName(getBpwsNamespace(), "forcedTermination"); constants.qnJoinFailure = new QName(getBpwsNamespace(), "joinFailure"); constants.qnMismatchedAssignmentFailure = new QName(getBpwsNamespace(), "mismatchedAssignment"); constants.qnMissingReply = new QName(getBpwsNamespace(), "missingReply"); constants.qnMissingRequest = new QName(getBpwsNamespace(), "missingRequest"); constants.qnSelectionFailure = new QName(getBpwsNamespace(), "selectionFailure"); constants.qnUninitializedVariable = new QName(getBpwsNamespace(), "uninitializedVariable"); constants.qnXsltInvalidSource = new QName(getBpwsNamespace(), "xsltInvalidSource"); constants.qnSubLanguageExecutionFault = new QName(getBpwsNamespace(), "subLanguageExecutionFault"); constants.qnUninitializedPartnerRole = new QName(getBpwsNamespace(), "uninitializedPartnerRole"); constants.qnForEachCounterError = new QName(getBpwsNamespace(), "forEachCounterError"); constants.qnInvalidBranchCondition = new QName(getBpwsNamespace(), "invalidBranchCondition"); constants.qnInvalidExpressionValue = new QName(getBpwsNamespace(), "invalidExpressionValue"); return constants; } // TODO unused? // private String getBpelPartnerLinkUri(){ // switch(_processDef.getBpelVersion()){ // case Process.BPEL_V110: // return Constants.NS_BPEL4WS_PARTNERLINK_2003_05; // case Process.BPEL_V200: // return Constants.NS_WSBPEL_PARTNERLINK_2004_03; // default: // throw new IllegalStateException("Bad bpel version."); // } // } /** * Compile an import declaration. According to the specification: * <blockquote> A BPEL4WSWS-BPEL process definition relies on XML Schema and * WSDL 1.1 for the definition of datatypes and service interfaces. Process * definitions also rely on other constructs such as partner link types, * message properties and property aliases (defined later in this * specification) which are defined within WSDL 1.1 documents using the WSDL * 1.1 language extensibility feature. * * The <import> element is used within a BPEL4WSWS-BPEL process to * explicitly indicate a dependency on external XML Schema or WSDL * definitions. Any number of <import> elements may appear as initial * children of the <process> element, before any other child element. Each * <import> element contains three mandatory attributes: * <ol> * <li>namespace -- The namespace attribute specifies the URI namespace of * the imported definitions. </li> * <li>location -- The location attribute contains a URI indicating the * location of a document that contains relevant definitions in the * namespace specified. The document located at the URI MUST contain * definitions belonging to the same namespace as indicated by the namespace * attribute. </li> * <li>importType -- The importType attribute identifies the type of * document being imported by providing the URI of the encoding language. * The value MUST be set to "http://www.w3.org/2001/XMLSchema" when * importing XML Schema 1.0 documents, and to * "http://schemas.xmlsoap.org/wsdl/" when importing WSDL 1.1 documents. * * @param imprt * BOM representation of the import */ private void compile(URI current, Import imprt) { try { if (imprt.getImportType() == null) throw new CompilationException(__cmsgs.errUnspecifiedImportType().setSource(imprt)); if (imprt.getLocation() == null) throw new CompilationException(__cmsgs.errMissingImportLocation().setSource(imprt)); if (Import.IMPORTTYPE_WSDL11.equals(imprt.getImportType())) { addWsdlImport(current, imprt.getLocation(), imprt); } else if (Import.IMPORTTYPE_XMLSCHEMA10.equals(imprt.getImportType())) { addXsdImport(current, imprt.getLocation(), imprt); } else throw new CompilationException(__cmsgs.errUnknownImportType(imprt.getImportType()).setSource(imprt)); } catch (CompilationException ce) { if (ce.getCompilationMessage().source == null) ce.getCompilationMessage().setSource(imprt); throw ce; } } public OActivity compile(final Activity source) { if (source == null) throw new IllegalArgumentException("null-argument"); boolean previousSupressJoinFailure = _supressJoinFailure; switch (source.getSuppressJoinFailure()) { case NO: _supressJoinFailure = false; break; case YES: _supressJoinFailure = true; break; } OActivity compiled; try { compiled = (source instanceof ScopeLikeActivity) ? compileSLC((ScopeLikeActivity) source, new OScope.Variable[0]) : compileActivity(true, source); compiled.suppressJoinFailure = _supressJoinFailure; } finally { _supressJoinFailure = previousSupressJoinFailure; } if (__log.isDebugEnabled()) __log.debug("Compiled activity " + compiled); return compiled; } private OCompensate createDefaultCompensateActivity(BpelObject source, String desc) { OCompensate activity = new OCompensate(_oprocess, getCurrent()); activity.name = "__autoGenCompensate:" + _structureStack.topScope().name; activity.debugInfo = createDebugInfo(source, desc); return activity; } public OScope compileSLC(final ScopeLikeActivity source, final OScope.Variable[] variables) { final OScope implicitScope = new OScope(_oprocess, getCurrent()); implicitScope.implicitScope = true; implicitScope.name = createName(source, "implicit-scope"); implicitScope.debugInfo = createDebugInfo(source, "Scope-like construct " + source); compileScope(implicitScope, source.getScope(), new Runnable() { public void run() { compileLinks(source); for (OScope.Variable v : variables) { v.declaringScope = implicitScope; implicitScope.addLocalVariable(v); } if (source instanceof ScopeActivity) { Activity scopeChild = ((ScopeActivity) source).getChildActivity(); if (scopeChild == null) throw new CompilationException(__cmsgs.errEmptyScope().setSource(source)); implicitScope.activity = compile(scopeChild); } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -