/** * Add a listener that will listen to executions to flows matching the specified criteria. * @param listener the listener * @param criteria the listener criteria */ public void addListener(FlowExecutionListener listener, FlowExecutionListenerCriteria criteria) { if (listener == null) { throw new IllegalArgumentException("The flow execution listener cannot be null"); } if (logger.isDebugEnabled()) { logger.debug("Adding flow execution listener " + listener + " with criteria " + criteria); } ConditionalFlowExecutionListenerHolder conditional = getHolder(listener); if (conditional == null) { conditional = new ConditionalFlowExecutionListenerHolder(listener); listeners.add(conditional); } if (criteria == null) { criteria = new FlowExecutionListenerCriteriaFactory().allFlows(); } conditional.add(criteria); }
/** * Returns the array of flow execution listeners for specified flow. * @param flowDefinition the flow definition associated with the execution to be listened to * @return the flow execution listeners that apply */ public FlowExecutionListener[] getListeners(FlowDefinition flowDefinition) { Assert.notNull(flowDefinition, "The Flow to load listeners for cannot be null"); List<FlowExecutionListener> listenersToAttach = new LinkedList<>(); for (ConditionalFlowExecutionListenerHolder listenerHolder : listeners) { if (listenerHolder.listenerAppliesTo(flowDefinition)) { listenersToAttach.add(listenerHolder.getListener()); } } if (logger.isDebugEnabled()) { logger.debug("Loaded [" + listenersToAttach.size() + "] of possible " + listeners.size() + " listeners for this execution request for flow '" + flowDefinition.getId() + "', the listeners to attach are " + StylerUtils.style(listenersToAttach)); } return listenersToAttach.toArray(new FlowExecutionListener[listenersToAttach.size()]); }
/** * Lookup the listener criteria holder for the listener provided. * @param listener the listener * @return the holder, or null if not found */ private ConditionalFlowExecutionListenerHolder getHolder(FlowExecutionListener listener) { for (ConditionalFlowExecutionListenerHolder holder : listeners) { if (holder.getListener().equals(listener)) { return holder; } } return null; } }
/** * Remove the criteria for the specified listener. * @param listener the listener * @param criteria the criteria */ public void removeListenerCriteria(FlowExecutionListener listener, FlowExecutionListenerCriteria criteria) { if (containsListener(listener)) { ConditionalFlowExecutionListenerHolder listenerHolder = getHolder(listener); listenerHolder.remove(criteria); if (listenerHolder.isCriteriaSetEmpty()) { removeListener(listener); } } }
/** * Lookup the listener criteria holder for the listener provided. * @param listener the listener * @return the holder, or null if not found */ private ConditionalFlowExecutionListenerHolder getHolder(FlowExecutionListener listener) { for (ConditionalFlowExecutionListenerHolder holder : listeners) { if (holder.getListener().equals(listener)) { return holder; } } return null; } }
/** * Returns the array of flow execution listeners for specified flow. * @param flowDefinition the flow definition associated with the execution to be listened to * @return the flow execution listeners that apply */ public FlowExecutionListener[] getListeners(FlowDefinition flowDefinition) { Assert.notNull(flowDefinition, "The Flow to load listeners for cannot be null"); List<FlowExecutionListener> listenersToAttach = new LinkedList<>(); for (ConditionalFlowExecutionListenerHolder listenerHolder : listeners) { if (listenerHolder.listenerAppliesTo(flowDefinition)) { listenersToAttach.add(listenerHolder.getListener()); } } if (logger.isDebugEnabled()) { logger.debug("Loaded [" + listenersToAttach.size() + "] of possible " + listeners.size() + " listeners for this execution request for flow '" + flowDefinition.getId() + "', the listeners to attach are " + StylerUtils.style(listenersToAttach)); } return listenersToAttach.toArray(new FlowExecutionListener[listenersToAttach.size()]); }
/** * Add a listener that will listen to executions to flows matching the specified criteria. * @param listener the listener * @param criteria the listener criteria */ public void addListener(FlowExecutionListener listener, FlowExecutionListenerCriteria criteria) { if (listener == null) { throw new IllegalArgumentException("The flow execution listener cannot be null"); } if (logger.isDebugEnabled()) { logger.debug("Adding flow execution listener " + listener + " with criteria " + criteria); } ConditionalFlowExecutionListenerHolder conditional = getHolder(listener); if (conditional == null) { conditional = new ConditionalFlowExecutionListenerHolder(listener); listeners.add(conditional); } if (criteria == null) { criteria = new FlowExecutionListenerCriteriaFactory().allFlows(); } conditional.add(criteria); }
/** * Is the given listener contained by this Flow execution manager? * @param listener the listener * @return true if yes, false otherwise */ public boolean containsListener(FlowExecutionListener listener) { Iterator it = listeners.iterator(); while (it.hasNext()) { ConditionalFlowExecutionListenerHolder h = (ConditionalFlowExecutionListenerHolder) it.next(); if (h.getListener().equals(listener)) { return true; } } return false; }
/** * Returns the array of flow execution listeners for specified flow. * @param flowDefinition the flow definition associated with the execution to be listened to * @return the flow execution listeners that apply */ public FlowExecutionListener[] getListeners(FlowDefinition flowDefinition) { Assert.notNull(flowDefinition, "The Flow to load listeners for cannot be null"); List listenersToAttach = new LinkedList(); for (Iterator it = listeners.iterator(); it.hasNext();) { ConditionalFlowExecutionListenerHolder listenerHolder = (ConditionalFlowExecutionListenerHolder) it.next(); if (listenerHolder.listenerAppliesTo(flowDefinition)) { listenersToAttach.add(listenerHolder.getListener()); } } if (logger.isDebugEnabled()) { logger.debug("Loaded [" + listenersToAttach.size() + "] of possible " + listeners.size() + " listeners for this execution request for flow '" + flowDefinition.getId() + "', the listeners to attach are " + StylerUtils.style(listenersToAttach)); } return (FlowExecutionListener[]) listenersToAttach.toArray(new FlowExecutionListener[listenersToAttach.size()]); }
/** * Add a listener that will listen to executions to flows matching the specified criteria. * @param listener the listener * @param criteria the listener criteria */ public void addListener(FlowExecutionListener listener, FlowExecutionListenerCriteria criteria) { if (listener == null) { throw new IllegalArgumentException("The flow execution listener cannot be null"); } if (logger.isDebugEnabled()) { logger.debug("Adding flow execution listener " + listener + " with criteria " + criteria); } ConditionalFlowExecutionListenerHolder conditional = getHolder(listener); if (conditional == null) { conditional = new ConditionalFlowExecutionListenerHolder(listener); listeners.add(conditional); } if (criteria == null) { criteria = new FlowExecutionListenerCriteriaFactory().allFlows(); } conditional.add(criteria); }
/** * Remove the flow execution listener from the listener list. * @param listener the listener */ public void removeListener(FlowExecutionListener listener) { Iterator it = listeners.iterator(); while (it.hasNext()) { ConditionalFlowExecutionListenerHolder h = (ConditionalFlowExecutionListenerHolder) it.next(); if (h.getListener().equals(listener)) { it.remove(); } } }
/** * Returns the array of flow execution listeners for specified flow. * @param flowDefinition the flow definition associated with the execution to be listened to * @return the flow execution listeners that apply */ public FlowExecutionListener[] getListeners(FlowDefinition flowDefinition) { Assert.notNull(flowDefinition, "The Flow to load listeners for cannot be null"); List listenersToAttach = new LinkedList(); for (Iterator it = listeners.iterator(); it.hasNext();) { ConditionalFlowExecutionListenerHolder listenerHolder = (ConditionalFlowExecutionListenerHolder) it.next(); if (listenerHolder.listenerAppliesTo(flowDefinition)) { listenersToAttach.add(listenerHolder.getListener()); } } if (logger.isDebugEnabled()) { logger.debug("Loaded [" + listenersToAttach.size() + "] of possible " + listeners.size() + " listeners for this execution request for flow '" + flowDefinition.getId() + "', the listeners to attach are " + StylerUtils.style(listenersToAttach)); } return (FlowExecutionListener[]) listenersToAttach.toArray(new FlowExecutionListener[listenersToAttach.size()]); }
/** * Add a listener that will listen to executions to flows matching the specified criteria. * @param listener the listener * @param criteria the listener criteria */ public void addListener(FlowExecutionListener listener, FlowExecutionListenerCriteria criteria) { if (listener == null) { return; } if (logger.isDebugEnabled()) { logger.debug("Adding flow execution listener " + listener + " with criteria " + criteria); } ConditionalFlowExecutionListenerHolder conditional = getHolder(listener); if (conditional == null) { conditional = new ConditionalFlowExecutionListenerHolder(listener); listeners.add(conditional); } if (criteria == null) { criteria = new FlowExecutionListenerCriteriaFactory().allFlows(); } conditional.add(criteria); }
/** * Lookup the listener criteria holder for the listener provided. * @param listener the listener * @return the holder, or null if not found */ private ConditionalFlowExecutionListenerHolder getHolder(FlowExecutionListener listener) { Iterator it = listeners.iterator(); while (it.hasNext()) { ConditionalFlowExecutionListenerHolder next = (ConditionalFlowExecutionListenerHolder) it.next(); if (next.getListener().equals(listener)) { return next; } } return null; }
/** * Lookup the listener criteria holder for the listener provided. * @param listener the listener * @return the holder, or null if not found */ private ConditionalFlowExecutionListenerHolder getHolder(FlowExecutionListener listener) { Iterator it = listeners.iterator(); while (it.hasNext()) { ConditionalFlowExecutionListenerHolder next = (ConditionalFlowExecutionListenerHolder) it.next(); if (next.getListener().equals(listener)) { return next; } } return null; } }