📄 genericsyncexpression.java
字号:
/* * 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: GenericSyncExpression.java,v 1.11 2005/07/27 15:59:01 jmettraux Exp $ *///// GenericSyncExpression.java//// jmettraux@openwfe.org//// generated with // jtmpl 1.1.00 16.08.2003 John Mettraux (jmettraux@openwfe.org)//package openwfe.org.engine.expressions.sync;import java.util.Collections;import openwfe.org.Utils;import openwfe.org.engine.workitem.InFlowWorkItem;import openwfe.org.engine.expressions.ApplyException;import openwfe.org.engine.expressions.ReplyException;import openwfe.org.engine.expressions.FlowExpression;import openwfe.org.engine.expressions.FlowExpressionId;import openwfe.org.engine.expressions.CompositeFlowExpression;/** * All the concurrence (multi-choice) patterns may be resolved by this * sync expression. * <br> * <pre> * <concurrence * sync="generic" * count="x|*" * merge="first|last|highest|lowest" * merge-type="mix|override" * remaining="cancel|forget" * > * </pre> * <ul> * <li><i>count</i>: on how many concurrence branches should we wait ?</li> * <li><i>merge</i>: which branch shall have priority for the merge ?</li> * <li><i>merge-type</i>: mixing fields or completely obsfucating with fields * of the 'winning' incoming workitem ?</li> * <li><i>remaining</i>: when count is reached, should we cancel or let * other branches die (forgotten) ?</li> * </ul> * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Id: GenericSyncExpression.java,v 1.11 2005/07/27 15:59:01 jmettraux Exp $ </font> * * @author john.mettraux@openwfe.org */public class GenericSyncExpression extends ClassicalSyncExpression{ private final static org.apache.log4j.Logger log = org.apache.log4j.Logger .getLogger(GenericSyncExpression.class.getName()); // // CONSTANTS & co /** * Since OpenWFE 1.5.0, this generic sync expression is able * to act like the other sync expressions (whose classes became * obsolete). */ public final static String A_SYNC = "sync"; public final static String A_COUNT = "count"; public final static String A_MERGE = "merge"; public final static String A_MERGE_TYPE = "merge-type"; public final static String A_REMAINING = "remaining"; public final static String MG_FIRST = "first"; public final static String MG_LAST = "last"; public final static String MG_HIGHEST = "highest"; public final static String MG_LOWEST = "lowest"; public final static String DEFAULT_MG = MG_FIRST; public final static String MT_MIX = "mix"; public final static String MT_OVERRIDE = "override"; public final static String DEFAULT_MT = MT_MIX; public final static String REM_CANCEL = "cancel"; public final static String REM_FORGET = "forget"; public final static String DEFAULT_REM = REM_CANCEL; // // FIELDS // config fields private int count = -1; private String merge = null; private String mergeType = null; private String remaining = null; // run fields private java.util.List childrenAltitudes = null; private java.util.List incomingWorkitems = new java.util.ArrayList(30); // // CONSTRUCTORS /** * This method is called by SyncUtils.determineSyncExpression(). * It parses the attributes of the parent [synchable]Expression to * determine on this sync should behave. */ public void init (final SynchableExpression se, final java.util.List childList, final InFlowWorkItem wi) { // // do the job log.debug("init() on behalf of "+se.getId()); // // count final String sCount = se.lookupAttribute(A_COUNT, wi); try { this.count = Integer.parseInt(sCount); } catch (final Exception e) { this.count = -1; } log.debug("init() count : "+this.count); // // merge this.merge = se.lookupAttribute(A_MERGE, wi); if ( ! (MG_FIRST.equals(this.merge) || MG_LAST.equals(this.merge) || MG_HIGHEST.equals(this.merge) || MG_LOWEST.equals(this.merge))) { this.merge = DEFAULT_MG; } log.debug("init() merge : '"+this.merge+"'"); // // merge type this.mergeType = se.lookupAttribute(A_MERGE_TYPE, wi); if ( ! (MT_MIX.equals(this.mergeType) || MT_OVERRIDE.equals(this.mergeType))) { this.mergeType = DEFAULT_MT; } log.debug("init() merge : '"+this.mergeType+"'"); // // remaining this.remaining = se.lookupAttribute(A_REMAINING, wi); if ( ! (REM_CANCEL.equals(this.remaining) || REM_FORGET.equals(this.remaining))) { this.remaining = DEFAULT_REM; } log.debug("init() remaining : '"+this.remaining+"'"); // // keep track of the order among children // (which is the highest ?) if (this.merge.equals(MG_LAST) || this.merge.equals(MG_FIRST)) // // don't do the following [unnecessary operations] { return; } //this.childrenAltitudes = Collections.unmodifiableList(childList); this.childrenAltitudes = childList; } // // BEAN METHODS // config fields public int getCount () { return this.count; } public String getMerge () { return this.merge; } public String getMergeType () { return this.mergeType; } public String getRemaining () { return this.remaining; } public void setCount (final int i) { this.count = i; } public void setMerge (final String s) { this.merge = s; } public void setMergeType (final String s) { this.mergeType = s; } public void setRemaining (final String s) { this.remaining = s; } // run fields /** * The list of workitems already arrived back from the children. */ public java.util.List getIncomingWorkitems () { return this.incomingWorkitems; } /** * The returned list is used by this expression to keep track of * the 'altitude' of each child. * This measurement is used in case of 'highest' or 'lowest' merge * style. */ public java.util.List getChildrenAltitudes () { return this.childrenAltitudes; } public void setIncomingWorkitems (final java.util.List l) { this.incomingWorkitems = l; } public void setChildrenAltitudes (final java.util.List l) { this.childrenAltitudes = l; } // // METHODS from SyncExpression public synchronized boolean replaceChild (final FlowExpressionId thisFei, final FlowExpressionId thatFei) { /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -