📄 abstractflowexpression.java
字号:
{ return getExpressionPool().lookupVariable(this, variableName); } /** * Sets the workflowInstanceId of this expression (used when * initing a flow) */ public void initWorkflowInstanceId (final String workflowInstanceId) { if (this.parent != null) this.parent.setWorkflowInstanceId(workflowInstanceId); this.id.setWorkflowInstanceId(workflowInstanceId); } public String getAttributeValue (final String attributeName) { return (String)this.attributes.get(attributeName); } /** * Sets the lastExpressionId of the workItem as 'this' id */ public void tag (final InFlowWorkItem wi) { if (wi == null) { log.warn("tag() wi is null ??? for "+this.getId()); return; } wi.setLastExpressionId(this.getId()); } /** * Use this method when you want to ensure that the changes in the * fields of your expression will be kept, even if the expression * gets swapped to disk (to the ExpressionStore). * Expressions decide by themselves when they have to be stored. */ public void storeItself () { log.debug ("storeItself() invoked for "+this.getId()+ " ("+this.getClass().getName()+")"); //Utils.logStackTrace(log); if (this.applicationContext == null || getExpressionPool() == null) { log.debug ("storeItself() no applicationContext or expressionPool, "+ "cannot store."); return; } try { getExpressionPool().update(this); } catch (final PoolException pe) { log.warn("storeItself() failure", pe); } } /** * A shortcut to fetch the expression pool from this application context */ public ExpressionPool getExpressionPool () { return Definitions.getExpressionPool(this.applicationContext); } /** * A shortcut to fetch the expression map from this application context */ public ExpressionMap getExpressionMap () { return Definitions.getExpressionMap(this.applicationContext); } /** * A shortcut to fetch the participant map from this application context */ public ParticipantMap getParticipantMap () { return Definitions.getParticipantMap(this.applicationContext); } /** * A shortcut to fetch the launcher from this application context */ public Launcher getLauncher () { return Definitions.getLauncher(this.applicationContext); } /* * * Returns the history service */ private History getHistory () { return Definitions.getHistory(this.applicationContext); } /** * This method enables child expressions to log events. * If the history component is not found, nothing will get logged. */ public void historyLog (final WorkItem wi, final String eventCode, final String participantName, final String message) { final History h = getHistory(); if (h == null) { //log.debug // ("historyLog() cannot log as there is no History service."); return; } h.log (this.getId(), wi, eventCode, participantName, message); } /** * Cancels an expression. */ public InFlowWorkItem cancel () throws ApplyException { // // no need for an implementation return null; } /** * replies to this FlowExpression parent */ public void replyToParent (final InFlowWorkItem wi) throws ReplyException { //log.debug("replyToParent()"); this.tag(wi); getExpressionPool().replyToParent(this, wi); } /** * This method may be a bit misnamed, it's simply a replyToParent() * wrapped so that it throws an ApplyException instead of a * ReplyException */ public void applyToParent (final InFlowWorkItem wi) throws ApplyException { //log.debug("applyToParent()"); try { replyToParent(wi); } catch (ReplyException re) { throw new ApplyException ("replyToParent() failed", re); } } /** * Returns the number of milliseconds elapsed since the expression * was applied */ public long getTimeSinceApplied () { try { return System.currentTimeMillis() - Time.fromIsoDate(this.applyTime); } catch (java.text.ParseException pe) { return 0L; } } // // equality methods /** * Checks whether a flowExpression is equal to another. This is mainly * done based on the hashcode. */ public boolean equals (final Object o) { if (o == null || ! (o.getClass().equals(this.getClass()))) return false; return o.hashCode() == this.hashCode(); } /** * Computes the hashCode for the flowExpression. This is simply the * hashCode of the flowExpressionId designating the flowExpression. */ public int hashCode () { if (this.getId() != null) return this.getId().hashCode(); return super.hashCode(); } public Object clone () { final AbstractFlowExpression clone = (AbstractFlowExpression)ReflectionUtils.newInstance(this); clone.setId(getId().copy()); if (getParent() != null) clone.setParent(getParent().copy()); if (getNext() != null) clone.setNext(getNext().copy()); clone.applicationContext = context(); clone.setAttributes(copyMap(getAttributes())); // variables are not cloned. return clone; } public void init (final ApplicationContext context, final FlowExpressionId parentId, final FlowExpressionId id, final RawExpression generatingExpression, final Object raw, final InFlowWorkItem currentWi) throws BuildException { setApplicationContext(context); this.setParent(parentId); this.setId(id); this.setAttributes(getLauncher().fetchAttributes(raw)); //this.debugAttributes("init()"); if (generatingExpression != null) this.variables.putAll(generatingExpression.getVariables()); } /** * If an ExpressionState is present, the expression pool will use it * for any apply() or reply() instead of directly working with * the apply() and reply() of the expression. */ public ExpressionState getState () { return this.state; } /** * Sets the ExpressionState of the FlowExpression (ie FrozenState, * PausedState or null). */ public void setState (final ExpressionState es) { this.state = es; //this.storeItself(); // // No, not here ! // This is a bean method, it's used when the expression // gets deserialized. } // // SOME STATIC METHODS /** * returns a deep copy of the source list, each flowExpressionId in the * source list is cloned. */ public static java.util.List deepCopy (java.util.List source) { if (source == null) return new java.util.ArrayList(0); java.util.List result = new java.util.ArrayList(source.size()); java.util.Iterator it = source.iterator(); while (it.hasNext()) { result.add(((FlowExpressionId)it.next()).clone()); } return result; } /** * Copies a map (returns a brand new map). */ public static java.util.Map copyMap (final java.util.Map m) { if (m == null) return null; final java.util.Map copy = new java.util.HashMap(m.size()); final java.util.Iterator it = m.keySet().iterator(); while (it.hasNext()) { final Object key = it.next(); copy.put(key, m.get(key)); } return copy; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -