⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bpelcompiler.java

📁 bpel执行引擎用来执行bpel业务流程
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.  See the NOTICE file * distributed with this work for additional information * regarding copyright ownership.  The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License.  You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied.  See the License for the * specific language governing permissions and limitations * under the License. */package org.apache.ode.bpel.compiler;import java.io.IOException;import java.io.InputStream;import java.net.MalformedURLException;import java.net.URI;import java.net.URISyntaxException;import java.util.ArrayList;import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Stack;import javax.wsdl.Definition;import javax.wsdl.Message;import javax.wsdl.Operation;import javax.wsdl.Part;import javax.wsdl.PortType;import javax.wsdl.WSDLException;import javax.wsdl.xml.WSDLReader;import javax.xml.namespace.QName;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.ode.bpel.compiler.api.CompilationException;import org.apache.ode.bpel.compiler.api.CompilationMessage;import org.apache.ode.bpel.compiler.api.CompileListener;import org.apache.ode.bpel.compiler.api.CompilerContext;import org.apache.ode.bpel.compiler.api.ExpressionCompiler;import org.apache.ode.bpel.compiler.api.SourceLocation;import org.apache.ode.bpel.compiler.bom.Activity;import org.apache.ode.bpel.compiler.bom.Bpel11QNames;import org.apache.ode.bpel.compiler.bom.Bpel20QNames;import org.apache.ode.bpel.compiler.bom.BpelObject;import org.apache.ode.bpel.compiler.bom.Catch;import org.apache.ode.bpel.compiler.bom.CompensationHandler;import org.apache.ode.bpel.compiler.bom.Correlation;import org.apache.ode.bpel.compiler.bom.CorrelationSet;import org.apache.ode.bpel.compiler.bom.Expression;import org.apache.ode.bpel.compiler.bom.Expression11;import org.apache.ode.bpel.compiler.bom.FaultHandler;import org.apache.ode.bpel.compiler.bom.Import;import org.apache.ode.bpel.compiler.bom.LinkSource;import org.apache.ode.bpel.compiler.bom.LinkTarget;import org.apache.ode.bpel.compiler.bom.OnAlarm;import org.apache.ode.bpel.compiler.bom.OnEvent;import org.apache.ode.bpel.compiler.bom.PartnerLink;import org.apache.ode.bpel.compiler.bom.PartnerLinkType;import org.apache.ode.bpel.compiler.bom.Process;import org.apache.ode.bpel.compiler.bom.Property;import org.apache.ode.bpel.compiler.bom.PropertyAlias;import org.apache.ode.bpel.compiler.bom.Scope;import org.apache.ode.bpel.compiler.bom.ScopeActivity;import org.apache.ode.bpel.compiler.bom.ScopeLikeActivity;import org.apache.ode.bpel.compiler.bom.TerminationHandler;import org.apache.ode.bpel.compiler.bom.Variable;import org.apache.ode.bpel.compiler.wsdl.Definition4BPEL;import org.apache.ode.bpel.compiler.wsdl.WSDLFactory4BPEL;import org.apache.ode.bpel.o.DebugInfo;import org.apache.ode.bpel.o.OActivity;import org.apache.ode.bpel.o.OAssign;import org.apache.ode.bpel.o.OCatch;import org.apache.ode.bpel.o.OCompensate;import org.apache.ode.bpel.o.OCompensationHandler;import org.apache.ode.bpel.o.OConstantExpression;import org.apache.ode.bpel.o.OConstantVarType;import org.apache.ode.bpel.o.OConstants;import org.apache.ode.bpel.o.OElementVarType;import org.apache.ode.bpel.o.OEventHandler;import org.apache.ode.bpel.o.OExpression;import org.apache.ode.bpel.o.OExpressionLanguage;import org.apache.ode.bpel.o.OExtVar;import org.apache.ode.bpel.o.OFaultHandler;import org.apache.ode.bpel.o.OFlow;import org.apache.ode.bpel.o.OLValueExpression;import org.apache.ode.bpel.o.OLink;import org.apache.ode.bpel.o.OMessageVarType;import org.apache.ode.bpel.o.OPartnerLink;import org.apache.ode.bpel.o.OProcess;import org.apache.ode.bpel.o.ORethrow;import org.apache.ode.bpel.o.OScope;import org.apache.ode.bpel.o.OSequence;import org.apache.ode.bpel.o.OTerminationHandler;import org.apache.ode.bpel.o.OVarType;import org.apache.ode.bpel.o.OXsdTypeVarType;import org.apache.ode.bpel.o.OXslSheet;import org.apache.ode.utils.GUID;import org.apache.ode.utils.NSContext;import org.apache.ode.utils.StreamUtils;import org.apache.ode.utils.fs.FileUtils;import org.apache.ode.utils.msg.MessageBundle;import org.apache.ode.utils.stl.CollectionsX;import org.apache.ode.utils.stl.MemberOfFunction;import org.apache.ode.utils.stl.UnaryFunction;import org.apache.ode.utils.xsd.XSUtils;import org.apache.ode.utils.xsd.XsdException;import org.apache.ode.utils.xsd.SchemaModel;import org.apache.xerces.xni.parser.XMLEntityResolver;import org.w3c.dom.Node;/** * Compiler for converting BPEL process descriptions (and their associated WSDL * and XSD documents) into compiled representations suitable for execution by * the ODE BPEL Service Provider. TODO: Move process validation into this class. */abstract class BpelCompiler implements CompilerContext {    /** Class-severity logger. */    protected static final Log __log = LogFactory.getLog(BpelCompiler.class);    /** Standardized compiler messages. */    private static final CommonCompilationMessages __cmsgs = MessageBundle.getMessages(CommonCompilationMessages.class);    private org.apache.ode.bpel.compiler.bom.Process _processDef;    private Date _generatedDate;    private HashMap<Class, ActivityGenerator> _actGenerators = new HashMap<Class, ActivityGenerator>();    private boolean _supressJoinFailure = false;    private boolean _atomicScope = false;    /** Syntactic scope stack. */    private StructureStack _structureStack = new StructureStack();    /** Fault/compensate recovery stack. */    private Stack<OScope> _recoveryContextStack = new Stack<OScope>();    /** History of compiled activities */    private List<OActivity> _compiledActivities = new ArrayList<OActivity>();    private OProcess _oprocess;    private ResourceFinder _resourceFinder;    private WSDLRegistry _wsdlRegistry;    private final List<CompilationMessage> _errors = new ArrayList<CompilationMessage>();    private CompileListener _compileListener;    private final HashMap<String, ExpressionCompiler> _expLanguageCompilers = new HashMap<String, ExpressionCompiler>();    private final HashMap<String, OExpressionLanguage> _expLanguages = new HashMap<String, OExpressionLanguage>();    private WSDLFactory4BPEL _wsdlFactory;    private OExpressionLanguage _konstExprLang;    private Map<QName, Node> _customProcessProperties;    private URI _processURI;    BpelCompiler(WSDLFactory4BPEL wsdlFactory) {        _wsdlFactory = wsdlFactory;        _wsdlRegistry = new WSDLRegistry(this);    }    public void addWsdlImport(URI from, URI wsdlImport, SourceLocation sloc) {        Definition4BPEL def;        try {            WSDLReader r = _wsdlFactory.newWSDLReader();            WSDLLocatorImpl locator = new WSDLLocatorImpl(_resourceFinder, from.resolve(wsdlImport));            def = (Definition4BPEL) r.readWSDL(locator);        } catch (WSDLException e) {            recoveredFromError(sloc, new CompilationException(__cmsgs.errWsdlParseError(e                    .getFaultCode(), e.getLocation(), e.getMessage())));            throw new CompilationException(__cmsgs.errWsdlImportFailed(wsdlImport.toASCIIString(), e.getFaultCode())                    .setSource(sloc), e);        }        try {            _wsdlRegistry.addDefinition(def, _resourceFinder, from.resolve(wsdlImport));            if (__log.isDebugEnabled())                __log.debug("Added WSDL Definition: " + wsdlImport);        } catch (CompilationException ce) {            recoveredFromError(sloc, ce);        }    }    public void addXsdImport(URI from, URI location, SourceLocation sloc) {        URI resFrom = from.resolve(location);        if (__log.isDebugEnabled())            __log.debug("Adding XSD import from " + resFrom + " location " + location);        XMLEntityResolver resolver = new WsdlFinderXMLEntityResolver(_resourceFinder,                location, new HashMap<URI,String>(), true);        try {            Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom.toString(), resolver);            InputStream xsdStream = _resourceFinder.openResource(resFrom);            byte[] data;            try {                data = StreamUtils.read(xsdStream);            } finally {                xsdStream.close();            }            schemas.put(resFrom, data);            _wsdlRegistry.addSchemas(schemas);        } catch (XsdException e) {            CompilationException ce =  new CompilationException(__cmsgs.errInvalidImport(location.toString()));            recoveredFromError(sloc, ce);        } catch (MalformedURLException e) {            CompilationException ce =  new CompilationException(__cmsgs.errInvalidImport(location.toString()));            recoveredFromError(sloc, ce);        } catch (IOException e) {            CompilationException ce =  new CompilationException(__cmsgs.errInvalidImport(location.toString()));            recoveredFromError(sloc, ce);        }    }    public void setResourceFinder(ResourceFinder finder) {        if (finder == null) {            _resourceFinder = new DefaultResourceFinder();        } else {            _resourceFinder = finder;        }    }    public void setCompileListener(CompileListener compileListener) {        _compileListener = compileListener;    }    public CompileListener getCompileListener() {        return _compileListener;    }    public void setCustomProperties(Map<QName, Node> customProperties) {        _customProcessProperties = customProperties;    }    /**     * Get the process definition.     *      * @return the process definition     */    public Process getProcessDef() {        return _processDef;    }    public PortType resolvePortType(final QName portTypeName) {        if (portTypeName == null)            throw new NullPointerException("Null portTypeName argument!");        PortType portType = _wsdlRegistry.getPortType(portTypeName);        if (portType == null)            throw new CompilationException(__cmsgs.errUndeclaredPortType(portTypeName));        return portType;    }    public OLink resolveLink(String linkName) {        OLink ret = null;        // Fist find where the link is declared.        for (Iterator<OActivity> i = _structureStack.iterator(); i.hasNext();) {            OActivity oact = i.next();            if (oact instanceof OFlow)                ret = ((OFlow) oact).getLocalLink(linkName);            if (ret != null)                return ret;        }        throw new CompilationException(__cmsgs.errUndeclaredLink(linkName));    }    public OScope.Variable resolveVariable(String varName) {        for (Iterator<OScope> i = _structureStack.oscopeIterator(); i.hasNext();) {            OScope.Variable var = i.next().getLocalVariable(varName);            if (var != null)                return var;        }        // A "real" variable couldn't be found, checking if we're dealing with a        // process custom property        if (_customProcessProperties != null && _customProcessProperties.get(varName) != null) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -