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

📄 simplexmllauncher.java

📁 一个工作流设计及定义的系统,可以直接与数据库结合进行系统工作流程的定义及应用.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2005, John Mettraux, OpenWFE.org * All rights reserved. *  * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions are met: *  * . Redistributions of source code must retain the above copyright notice, this *   list of conditions and the following disclaimer.   *  * . Redistributions in binary form must reproduce the above copyright notice,  *   this list of conditions and the following disclaimer in the documentation  *   and/or other materials provided with the distribution. *  * . Neither the name of the "OpenWFE" nor the names of its contributors may be *   used to endorse or promote products derived from this software without *   specific prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  * POSSIBILITY OF SUCH DAMAGE. * * $Id: SimpleXmlLauncher.java,v 1.26 2005/07/27 15:59:02 jmettraux Exp $ *///// SimpleXmlLauncher.java//// john.mettraux@openwfe.org//// generated with // jtmpl 1.1.01 2004/05/19 (john.mettraux@openwfe.org)//package openwfe.org.engine.impl.launch;import openwfe.org.Utils;import openwfe.org.ReflectionUtils;import openwfe.org.AbstractService;import openwfe.org.xml.XmlUtils;import openwfe.org.engine.Definitions;import openwfe.org.engine.launch.Launcher;import openwfe.org.engine.launch.LaunchException;import openwfe.org.engine.expool.ExpressionPool;import openwfe.org.engine.workitem.Attribute;import openwfe.org.engine.workitem.XmlAttribute;import openwfe.org.engine.workitem.LaunchItem;import openwfe.org.engine.workitem.InFlowWorkItem;import openwfe.org.engine.dispatch.DispatchingException;import openwfe.org.engine.expressions.ApplyException;import openwfe.org.engine.expressions.BuildException;import openwfe.org.engine.expressions.FlowExpression;import openwfe.org.engine.expressions.FlowExpressionId;import openwfe.org.engine.expressions.DefineExpression;import openwfe.org.engine.expressions.ProcessDefinition;import openwfe.org.engine.expressions.raw.RawExpression;import openwfe.org.engine.expressions.map.ExpressionMap;import openwfe.org.engine.participants.Participant;import openwfe.org.engine.participants.ParticipantMap;/** * The vanilla XML openwfe launcher. * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Id: SimpleXmlLauncher.java,v 1.26 2005/07/27 15:59:02 jmettraux Exp $ </font> * * @author john.mettraux@openwfe.org */public class SimpleXmlLauncher     extends AbstractService    implements Launcher{    private final static org.apache.log4j.Logger log = org.apache.log4j.Logger        .getLogger(SimpleXmlLauncher.class.getName());    //    // CONSTANTS & co    /**     * This constant is the name of a system property, when it has a value     * of 'true', 'ok' or 'yes', XML schema validation will be used     * against process definitions.     */    public final static String VALIDATE        = "openwfe.org.engine.launcher.validate";    //    // FIELDS    //    // CONSTRUCTORS    //    // METHODS from Launcher    public String launch (final LaunchItem li)        throws LaunchException    {        final InFlowWorkItem wi = new InFlowWorkItem(li);        return launch(wi, li.getReplyTo(), li.getWorkflowDefinitionUrl());    }    private org.jdom.Element parseXmlDefinition         (final String url,          final InFlowWorkItem wi,          final boolean shouldValidate)    throws        Exception    {        if (url.startsWith("field:"))        {            final String fieldName = url.substring(6);            final Attribute a = wi.getAttribute(fieldName);            if (a == null)             {                throw new IllegalArgumentException                    ("Field '"+fieldName+                     "' is not present, cannot launch flow defined in it");            }            if (a instanceof XmlAttribute)                return ((XmlAttribute)a).getContent();            final String sXmlDefinition = a.toString();            //log.debug("parseXmlDefinition()\n"+sXmlDefinition);            return XmlUtils.extractXmlElement(sXmlDefinition);        }        return XmlUtils.extractXml(url, shouldValidate);    }    /**     * Returns the workflowInstanceId of the newly launched flow.     */    public String launch         (final InFlowWorkItem wi,          FlowExpressionId parentId,         final String wfdUrl)     throws         LaunchException    {        //        // remote launch ?        if (wfdUrl.indexOf("::") > -1)            return launchExternalProcess(wi, wfdUrl, parentId);        //        // local launch        final String url = Utils.expandUrl(wfdUrl);        log.debug("launch() request for "+url);        try        {            final ExpressionMap expMap = Definitions                .getExpressionMap(getContext());            final org.jdom.Element elt =                 //XmlUtils.extractXml(url, shouldValidate());                parseXmlDefinition(url, wi, shouldValidate());            final RawExpression rootExpression = (RawExpression)ReflectionUtils                .buildNewInstance(expMap.getRawExpressionClass().getName());            //            // misc data            final String wfdName = elt.getAttributeValue("name");            final String wfdRevision = elt.getAttributeValue("revision");            if (wfdName == null || wfdRevision == null)            {                throw new LaunchException                    ("Process definition is missing a 'name' "+                     "and/or a 'revision' attribute.");            }            //            // determine root expression ids            if (parentId == null)                //                // brand new flow            {                parentId = new FlowExpressionId();                parentId.setEngineId(getContext().getApplicationName());                parentId.setInitialEngineId(getContext().getApplicationName());                parentId.setWorkflowDefinitionUrl(url);                parentId.setWorkflowDefinitionName(wfdName);                parentId.setWorkflowDefinitionRevision(wfdRevision);                // expression name and id remain to null !!                parentId.setWorkflowInstanceId                    (RawExpression.determineNewWorkflowInstanceId());                //                // init the expression                rootExpression.init(getContext(), parentId, 0, elt);                    // starting at expressionId '0'            }            else                //                // determine root expression id manually            {                final FlowExpressionId id = new FlowExpressionId();                id.setEngineId(getContext().getApplicationName());                id.setInitialEngineId(getContext().getApplicationName());                id.setWorkflowDefinitionUrl(url);                id.setWorkflowDefinitionName(wfdName);                id.setWorkflowDefinitionRevision(wfdRevision);                id.setExpressionName(elt.getName());                id.setExpressionId("0");                id.setWorkflowInstanceId                    (RawExpression.determineNewWorkflowInstanceId());                //                // init the expression                rootExpression.init(getContext(), parentId, id, elt);            }            getExpressionPool().add(rootExpression);            getExpressionPool().apply(rootExpression.getId(), wi);            return rootExpression.getId().getWorkflowInstanceId();        }        catch (final Throwable t)        {            throw new LaunchException("launch failed", t);        }    }    /**     * Launches an inner subflow (for example for 'iterator' or 'when').     */    public FlowExpressionId launchSub        (final InFlowWorkItem wi,         final FlowExpressionId parentId,         final FlowExpressionId templateId)    throws         LaunchException    {        log.debug("launchSub() for template "+templateId);        log.debug("launchSub() parentId is "+parentId);        RawExpression rawExp = (RawExpression)getExpressionPool()            .fetch(templateId);        FlowExpressionId id = null;        try        {            rawExp = rawExp.newInstance(parentId);            log.debug("launchSub() rawExp.parent was "+rawExp.getParent());            rawExp.setParent(parentId);                // especially if it's null            id = rawExp.getId();            log.debug("launchSub() rawExp.id is     "+id);            log.debug("launchSub() rawExp.parent is "+rawExp.getParent());            //            // applying

⌨️ 快捷键说明

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