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

📄 abstractflowexpression.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: AbstractFlowExpression.java,v 1.29 2005/07/13 20:53:40 jmettraux Exp $ *///// FlowExpression.java//// jmettraux@openwfe.org//// generated with // jtmpl 1.0.04 20.11.2001 John Mettraux (jmettraux@openwfe.org)//package openwfe.org.engine.expressions;import openwfe.org.Utils;import openwfe.org.ReflectionUtils;import openwfe.org.ApplicationContext;import openwfe.org.time.Time;import openwfe.org.misc.Text;import openwfe.org.engine.Definitions;import openwfe.org.engine.launch.Launcher;import openwfe.org.engine.expool.PoolException;import openwfe.org.engine.expool.ExpressionPool;import openwfe.org.engine.history.History;import openwfe.org.engine.workitem.WorkItem;import openwfe.org.engine.workitem.InFlowWorkItem;import openwfe.org.engine.expressions.raw.RawExpression;import openwfe.org.engine.expressions.map.ExpressionMap;import openwfe.org.engine.expressions.state.ExpressionState;import openwfe.org.engine.participants.ParticipantMap;/** * For each XML tag in an OpenWFE process definition, there is a FlowExpression * instance. * Each expression is tagged with (designated by) a flowExpressionId. You may * think of expression as pieces of workflow instance pointing to each other * through references (FlowExpressionId instances). * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Date: 2005/07/13 20:53:40 $ * <br>$Id: AbstractFlowExpression.java,v 1.29 2005/07/13 20:53:40 jmettraux Exp $ </font> * * @author john.mettraux@openwfe.org */public abstract class AbstractFlowExpression    implements FlowExpression{    private final static org.apache.log4j.Logger log = org.apache.log4j.Logger        .getLogger(AbstractFlowExpression.class.getName());    //    // FIELDS    /* *     * The flowExpressionId of this flowExpression     */    private FlowExpressionId id = null;    /* *     * The flowExpressionId of the parent of this expression, if it's set      * to null, then the expression has no parent, is a root.     */    private FlowExpressionId parent = null;    private FlowExpressionId next = null;    private FlowExpressionId previous = null;    /* *     * The apply time when set means that the flow expression got 'applied'     * and will contain a datetime string for this apply time.     */    private String applyTime = null;    /* *     * The engine, when manipulating a flowExpression for 'running' a flow     * instance gives it a reference to the applicationContext, the expression     * may then use this reference to talk back to the engine and for example     * ask for the participantMap for dispatching purposes.     */    private transient ApplicationContext applicationContext = null;    /* *     * This map contains the attributes (key, value as string) of the     * XML tag corresponding to this flowExpression.     * For instance, if the tag in the flow definition was :<br>     * <pre>&lt;participant ref="toto" timeout="2h"/&gt;</pre><br>     * the attributes map will contain { 'ref': 'toto', 'timeout': '2h' }.     */    private java.util.Map attributes = null;    /* *     * Where 'variables' are linked in the scope defined by the flowExpression.     * Such a scope is more useful for a composite expression than for an     * expression with no children.     */    private java.util.Map variables = null;    private ExpressionState state = null;    //    // CONSTRUCTORS    /**     * The constructor for a flow expression. The bulk work of initialization     * is though done in the 'build()' method.     */    public AbstractFlowExpression ()    {        super();        this.attributes = new java.util.HashMap(7);        this.variables = new java.util.HashMap(7);    }    //    // BEAN METHODS    /**     * Returns the FlowExpressionId of this expression.     */    public FlowExpressionId getId () { return this.id; }    /**     * Returns the FlowExpressionId of the parent expression of this     * expression.     */    public FlowExpressionId getParent () { return this.parent; }    /**     * Sometimes (especially in the case of a sequence), having children     * expressions always replying to the parent is not necessary, they     * can directly apply their neighbor, this 'next' member is here to     * allow such behaviour.     */    public FlowExpressionId getNext () { return this.next; }    /**     * A parallel to the 'next' field : this 'previous' points to the     * previous expression in the flat sequence, this is used mainly     * in cancel() where a parent knows only about the last expression     * in a sequence and thus calls cancel on it, this last expression then     * calls cancel() on its previous expression (if they are still around).     */    public FlowExpressionId getPrevious () { return this.previous; }    /**     * Returns the string representing the moment at which this expression     * got applied (or null if it was not yet applied).     */    public String getApplyTime () { return this.applyTime; }    /**     * Returns the attribute of this expression (they tune the behaviour     * of the expression).     */    public java.util.Map getAttributes () { return this.attributes; }    /**     * Returns the variables bound at this expression's level.     */    public java.util.Map getVariables () { return this.variables; }    public void setId (FlowExpressionId fei) { this.id = fei; }    public void setParent (FlowExpressionId fei) { this.parent = fei; }    public void setNext (FlowExpressionId fei) { this.next = fei; }    public void setPrevious (FlowExpressionId fei) { this.previous = fei; }    public void setApplyTime (String isoDate) { this.applyTime = isoDate; }    public void setAttributes (java.util.Map m) { this.attributes = m; }    public void setVariables (java.util.Map m) { this.variables = m; }    public void setApplicationContext (ApplicationContext ac) { this.applicationContext = ac; }    //    // METHODS    /**     * This method returns the applicationContext currently attached to this      * FlowExpression.     */    public ApplicationContext context ()    {        return this.applicationContext;    }    /**     * This method will return false if the given String contains some     * $ notation element, it's generally used from inside lookupAttribute().     * For instance <pre>referencesNoVariable("field-${name}")</pre> will yield     * false.     */    protected static boolean referencesNoVariable (final String attributeValue)    {        return (attributeValue == null || attributeValue.indexOf("${") < 0);    }    /**     * Looks a process definition attribute ie in the example<br>     * &lt;participant ref="toto" /&gt;<br>     * lookupAttribute("ref");<br>     * will return "toto".     * If it were<br>     * &lt;participant ref="toto_${index}" /&gt;<br>     * and the variable "index" would be set to "2",<br>     * lookupAttribute("ref");<br>     * would have returned "toto_2".     */    public String lookupAttribute         (final String attributeName,         final InFlowWorkItem wi)    {        log.debug("lookupAttribute() '"+attributeName+"'");        final String attributeValue =             (String)this.attributes.get(attributeName);        log.debug("lookupAttribute() value is '"+attributeValue+"'");        if (referencesNoVariable(attributeValue)) return attributeValue;        log.debug("lookupAttribute() doing substitution...");        final VariableMap vMap = new VariableMap(this, wi);        return Text.substitute(attributeValue, vMap);    }    /**     * sets the apply time to now     */    public void touchApplyTime ()    {        this.setApplyTime(Time.toIsoDate());    }    /**     * Looks up a variable set in this expression, will return null if     * no such variable is set here.     */    public Object lookupLocalVariable (final String variableName)    {        return this.variables.get(variableName);    }    /**     * Looks for a boolean result variable in the current scope.     * Used by the 'if' and the 'when' expression.     */    public boolean lookupLocalBooleanResult ()        throws ReplyException    {        Object o = lookupLocalVariable(ValueUtils.BOOLEAN_RESULT);        if (o == null)        {            throw new ReplyException                 ("lookupLocalBooleanVariable() no boolean result found");        }        //log.debug("o.class is "+o.getClass().getName());        if ( ! (o instanceof Boolean))        {            throw new ReplyException                ("lookupLocalBooleanVariable() boolean type expected, "+                 "found "+o.getClass());        }        return ((Boolean)o).booleanValue();    }    /**     * removes any boolean result variable in this expression     * (used by CondExpression)     */    public void cleanBooleanResult ()    {        this.setLocalVariable(ValueUtils.BOOLEAN_RESULT, null);    }    /**     * Sets a variable locally.     * This method should not be called directly by an expression but by     * the expression pool.<br>     * When an expression wants to set a variable, it should do     * so by calling ExpressionPool.setVariableInParent()     */    public void setLocalVariable (final String variableName, final Object value)    {        log.debug            ("setLocalVariable() setting '"+variableName+"' in "+this.getId());        this.variables.put(variableName, value);        this.storeItself();    }    /**     * Takes care of looking up a variable (locally or from the expression      * pool).     */    public Object lookupVariable (final String variableName)

⌨️ 快捷键说明

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