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

📄 bpelprocess.java

📁 bpel执行引擎用来执行bpel业务流程
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    String extractProperty(Element msgData, OProcess.OPropertyAlias alias, String target) throws FaultException {        markused();        PropertyAliasEvaluationContext ectx = new PropertyAliasEvaluationContext(msgData, alias);        Node lValue = ectx.getRootNode();        if (alias.location != null) {            try {                lValue = _expLangRuntimeRegistry.evaluateNode(alias.location, ectx);            } catch (EvaluationException ec) {                throw new FaultException(getOProcess().constants.qnSelectionFailure, alias.getDescription());            }        }        if (lValue == null) {            String errmsg = __msgs.msgPropertyAliasReturnedNullSet(alias.getDescription(), target);            if (__log.isErrorEnabled()) {                __log.error(errmsg);            }            throw new FaultException(getOProcess().constants.qnSelectionFailure, errmsg);        }        if (lValue.getNodeType() == Node.ELEMENT_NODE) {            // This is a bit hokey, we concatenate all the children's values; we            // really should be checking to make sure that we are only dealing            // with text and attribute nodes.            StringBuffer val = new StringBuffer();            NodeList nl = lValue.getChildNodes();            for (int i = 0; i < nl.getLength(); ++i) {                Node n = nl.item(i);                val.append(n.getNodeValue());            }            return val.toString();        } else if (lValue.getNodeType() == Node.TEXT_NODE) {            return ((Text) lValue).getWholeText();        } else            return null;    }    /**     * Get the element name for a given WSDL part. If the part is an <em>element</em> part, the name of that element is returned.     * If the part is an XML schema typed part, then the name of the part is returned in the null namespace.     *      * @param part     *            WSDL {@link javax.wsdl.Part}     * @return name of element containing said part     */    static QName getElementNameForPart(OMessageVarType.Part part) {        return (part.type instanceof OElementVarType) ? ((OElementVarType) part.type).elementType : new QName(null, part.name);    }    /**     * Process the message-exchange interceptors.     *      * @param mex     *            message exchange     * @return <code>true</code> if execution should continue, <code>false</code> otherwise     */    boolean processInterceptors(MyRoleMessageExchangeImpl mex, InterceptorInvoker invoker) {        InterceptorContextImpl ictx = new InterceptorContextImpl(_engine._contexts.dao.getConnection(), getProcessDAO(), _pconf);        for (MessageExchangeInterceptor i : _mexInterceptors)            if (!mex.processInterceptor(i, mex, ictx, invoker))                return false;        for (MessageExchangeInterceptor i : getEngine().getGlobalInterceptors())            if (!mex.processInterceptor(i, mex, ictx, invoker))                return false;        return true;    }    /**     * @see org.apache.ode.bpel.engine.BpelProcess#handleWorkEvent(java.util.Map<java.lang.String,java.lang.Object>)     */    public void handleWorkEvent(Map<String, Object> jobData) {        try {            _hydrationLatch.latch(1);            markused();            if (__log.isDebugEnabled()) {                __log.debug(ObjectPrinter.stringifyMethodEnter("handleWorkEvent", new Object[] { "jobData", jobData }));            }            WorkEvent we = new WorkEvent(jobData);            // Process level events            if (we.getType().equals(WorkEvent.Type.INVOKE_INTERNAL)) {                if (__log.isDebugEnabled()) {                    __log.debug("InvokeInternal event for mexid " + we.getMexId());                }                MyRoleMessageExchangeImpl mex = (MyRoleMessageExchangeImpl) _engine.getMessageExchange(we.getMexId());                invokeProcess(mex);            } else {                // Instance level events                ProcessInstanceDAO procInstance = getProcessDAO().getInstance(we.getIID());                if (procInstance == null) {                    if (__log.isDebugEnabled()) {                        __log.debug("handleWorkEvent: no ProcessInstance found with iid " + we.getIID() + "; ignoring.");                    }                    return;                }                BpelRuntimeContextImpl processInstance = createRuntimeContext(procInstance, null, null);                switch (we.getType()) {                case TIMER:                    if (__log.isDebugEnabled()) {                        __log.debug("handleWorkEvent: TimerWork event for process instance " + processInstance);                    }                    processInstance.timerEvent(we.getChannel());                    break;                case RESUME:                    if (__log.isDebugEnabled()) {                        __log.debug("handleWorkEvent: ResumeWork event for iid " + we.getIID());                    }                    processInstance.execute();                    break;                case INVOKE_RESPONSE:                    if (__log.isDebugEnabled()) {                        __log.debug("InvokeResponse event for iid " + we.getIID());                    }                    processInstance.invocationResponse(we.getMexId(), we.getChannel());                    processInstance.execute();                    break;                case MATCHER:                    if (__log.isDebugEnabled()) {                        __log.debug("Matcher event for iid " + we.getIID());                    }                    processInstance.matcherEvent(we.getCorrelatorId(), we.getCorrelationKey());                }            }        } finally {            _hydrationLatch.release(1);        }    }    private void setRoles(OProcess oprocess) {        _partnerRoles = new HashMap<OPartnerLink, PartnerLinkPartnerRoleImpl>();        _myRoles = new HashMap<OPartnerLink, PartnerLinkMyRoleImpl>();        _endpointToMyRoleMap = new HashMap<PartnerLinkMyRoleImpl, Endpoint>();        // Create myRole endpoint name mapping (from deployment descriptor)        HashMap<OPartnerLink, Endpoint> myRoleEndpoints = new HashMap<OPartnerLink, Endpoint>();        for (Map.Entry<String, Endpoint> provide : _pconf.getProvideEndpoints().entrySet()) {            OPartnerLink plink = oprocess.getPartnerLink(provide.getKey());            if (plink == null) {                String errmsg = "Error in deployment descriptor for process " + _pid + "; reference to unknown partner link "                        + provide.getKey();                __log.error(errmsg);                throw new BpelEngineException(errmsg);            }            myRoleEndpoints.put(plink, provide.getValue());        }        // Create partnerRole initial value mapping        for (Map.Entry<String, Endpoint> invoke : _pconf.getInvokeEndpoints().entrySet()) {            OPartnerLink plink = oprocess.getPartnerLink(invoke.getKey());            if (plink == null) {                String errmsg = "Error in deployment descriptor for process " + _pid + "; reference to unknown partner link "                        + invoke.getKey();                __log.error(errmsg);                throw new BpelEngineException(errmsg);            }            __log.debug("Processing <invoke> element for process " + _pid + ": partnerlink " + invoke.getKey() + " --> "                    + invoke.getValue());        }        for (OPartnerLink pl : oprocess.getAllPartnerLinks()) {            if (pl.hasMyRole()) {                Endpoint endpoint = myRoleEndpoints.get(pl);                if (endpoint == null)                    throw new IllegalArgumentException("No service name for myRole plink " + pl.getName());                PartnerLinkMyRoleImpl myRole = new PartnerLinkMyRoleImpl(this, pl, endpoint);                _myRoles.put(pl, myRole);                _endpointToMyRoleMap.put(myRole, endpoint);            }            if (pl.hasPartnerRole()) {            	Endpoint endpoint = _pconf.getInvokeEndpoints().get(pl.getName());                if (endpoint == null && pl.initializePartnerRole)                    throw new IllegalArgumentException(pl.getName() + " must be bound to an endpoint in deploy.xml");                PartnerLinkPartnerRoleImpl partnerRole = new PartnerLinkPartnerRoleImpl(this, pl, endpoint);                _partnerRoles.put(pl, partnerRole);            }        }    }    ProcessDAO getProcessDAO() {        return _pconf.isTransient() ? _engine._contexts.inMemDao.getConnection().getProcess(_pid) : getEngine()._contexts.dao                .getConnection().getProcess(_pid);    }    static String genCorrelatorId(OPartnerLink plink, String opName) {        return plink.getId() + "." + opName;    }    /**     * De-serialize the compiled process representation from a stream.     *      * @param is     *            input stream     * @return process information from configuration database     */    private OProcess deserializeCompiledProcess(InputStream is) throws Exception {        OProcess compiledProcess;        Serializer ofh = new Serializer(is);        compiledProcess = ofh.readOProcess();        return compiledProcess;    }    /**     * Get all the services that are implemented by this process.     *      * @return list of qualified names corresponding to the myroles.     */    public Set<Endpoint> getServiceNames() {        Set<Endpoint> endpoints = new HashSet<Endpoint>();        for (Endpoint provide : _pconf.getProvideEndpoints().values()) {            endpoints.add(provide);        }        return endpoints;    }    void activate(BpelEngineImpl engine) {        _engine = engine;        _debugger = new DebuggerSupport(this);        __log.debug("Activating " + _pid);        // Activate all the my-role endpoints.        for (Map.Entry<String, Endpoint> entry : _pconf.getProvideEndpoints().entrySet()) {            EndpointReference initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue());            __log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR);            _myEprs.put(entry.getValue(), initialEPR);        }        __log.debug("Activated " + _pid);        markused();    }    void deactivate() {        // Deactivate all the my-role endpoints.        for (Endpoint endpoint : _myEprs.keySet())            _engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);        // TODO Deactivate all the partner-role channels    }    EndpointReference getInitialPartnerRoleEPR(OPartnerLink link) {        try {            _hydrationLatch.latch(1);            PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(link);            if (prole == null)                throw new IllegalStateException("Unknown partner link " + link);            return prole.getInitialEPR();        } finally {            _hydrationLatch.release(1);        }    }    Endpoint getInitialPartnerRoleEndpoint(OPartnerLink link) {        try {            _hydrationLatch.latch(1);            PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(link);            if (prole == null)                throw new IllegalStateException("Unknown partner link " + link);            return prole._initialPartner;        } finally {            _hydrationLatch.release(1);        }    }    EndpointReference getInitialMyRoleEPR(OPartnerLink link) {        try {            _hydrationLatch.latch(1);            PartnerLinkMyRoleImpl myRole = _myRoles.get(link);            if (myRole == null)                throw new IllegalStateException("Unknown partner link " + link);            return myRole.getInitialEPR();        } finally {            _hydrationLatch.release(1);        }

⌨️ 快捷键说明

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