public void afterPropertiesSet() { listenerLoader = new ConditionalFlowExecutionListenerLoader(); for (Map.Entry<FlowExecutionListener, String> entry : listenersWithCriteria.entrySet()) { FlowExecutionListener listener = entry.getKey(); String criteria = entry.getValue(); listenerLoader.addListener(listener, listenerCriteriaFactory.getListenerCriteria(criteria)); } }
/** * 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); }
public void testAddListenerButNoMatch() { FlowExecutionListener listener = new FlowExecutionListener() {}; loader.addListener(listener, criteriaFactory.flow("bar")); Flow flow = new Flow("foo"); FlowExecutionListener[] listeners = loader.getListeners(flow); assertEquals(0, listeners.length); } }
/** * Set the list of flow execution listeners with corresponding criteria. Allows for bean style configuration. The * given map should have {@link FlowExecutionListener} objects as keys and Strings ("*", "flowId", * "flowId1,flowId2") or {@link FlowExecutionListenerCriteria} objects as values. This will clear any listeners * registered with this object using the <tt>addListener</tt> methods. * @param listenersWithCriteria the map of listeners and their corresponding criteria */ public void setListeners(Map listenersWithCriteria) { removeAllListeners(); for (Iterator it = listenersWithCriteria.entrySet().iterator(); it.hasNext();) { Entry entry = (Entry) it.next(); Assert.isInstanceOf(FlowExecutionListener.class, entry.getKey(), "The key in the listenersWithCriteria map needs to be a FlowExecutionListener object"); FlowExecutionListener listener = (FlowExecutionListener) entry.getKey(); FlowExecutionListenerCriteria criteria = null; if (entry.getValue() instanceof String) { criteria = getCriteria((String) entry.getValue()); } else if (entry.getValue() instanceof FlowExecutionListenerCriteria) { criteria = (FlowExecutionListenerCriteria) entry.getValue(); } else if (entry.getValue() != null) { throw new IllegalArgumentException("The value in the listenersWithCriteria map needs to be a " + "String or a FlowExecutionListenerCriteria object"); } addListener(listener, criteria); } }
/** * 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); } } }
/** * Add a listener that will listen to executions for all flows. * @param listener the listener to add */ public void addListener(FlowExecutionListener listener) { addListener(listener, null); }
protected void setUp() { loader = new ConditionalFlowExecutionListenerLoader(); criteriaFactory = new FlowExecutionListenerCriteriaFactory(); }
public void testAddConditionalListener() { FlowExecutionListener listener = new FlowExecutionListener() {}; loader.addListener(listener, criteriaFactory.allFlows()); Flow flow = new Flow("foo"); FlowExecutionListener[] listeners = loader.getListeners(flow); assertEquals(1, listeners.length); assertSame(listener, listeners[0]); }
/** * Adds a collection of listeners that share a matching criteria. * @param listeners the listeners * @param criteria the criteria where these listeners apply */ public void addListeners(FlowExecutionListener[] listeners, FlowExecutionListenerCriteria criteria) { for (int i = 0; i < listeners.length; i++) { addListener(listeners[i], criteria); } }
/** * Register a {@link FlowExecutionListener} that observes the lifecycle of flow * executions launched by this executor. * @param listener the listener to be registered * @param criteria the criteria that determines the flow definitions a listener * should observe, delimited by commas or '*' for "all". * Example: 'flow1,flow2,flow3'. */ public FlowExecutorBuilder addFlowExecutionListener(FlowExecutionListener listener, String criteria) { if (this.listenerLoader == null) { this.listenerLoader = new ConditionalFlowExecutionListenerLoader(); } this.listenerLoader.addListener(listener, this.listenerCriteriaFactory.getListenerCriteria(criteria)); return this; }
public void testAddMultipleListeners() { FlowExecutionListener listener1 = new FlowExecutionListener() {}; FlowExecutionListener listener2 = new FlowExecutionListener() {}; loader.addListener(listener1, criteriaFactory.allFlows()); loader.addListener(listener2, criteriaFactory.allFlows()); Flow flow = new Flow("foo"); FlowExecutionListener[] listeners = loader.getListeners(flow); assertEquals(2, listeners.length); assertSame(listener1, listeners[0]); assertSame(listener2, listeners[1]); }
/** * 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); }
/** * Register a {@link FlowExecutionListener} that observes the lifecycle of flow * executions launched by this executor. * @param listener the listener to be registered * @param criteria the criteria that determines the flow definitions a listener * should observe, delimited by commas or '*' for "all". * Example: 'flow1,flow2,flow3'. */ public FlowExecutorBuilder addFlowExecutionListener(FlowExecutionListener listener, String criteria) { if (this.listenerLoader == null) { this.listenerLoader = new ConditionalFlowExecutionListenerLoader(); } this.listenerLoader.addListener(listener, this.listenerCriteriaFactory.getListenerCriteria(criteria)); return this; }
/** * 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); }
public void afterPropertiesSet() { listenerLoader = new ConditionalFlowExecutionListenerLoader(); for (Map.Entry<FlowExecutionListener, String> entry : listenersWithCriteria.entrySet()) { FlowExecutionListener listener = entry.getKey(); String criteria = entry.getValue(); listenerLoader.addListener(listener, listenerCriteriaFactory.getListenerCriteria(criteria)); } }
/** * 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); }
public void afterPropertiesSet() { listenerLoader = new ConditionalFlowExecutionListenerLoader(); Iterator it = listenersWithCriteria.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); FlowExecutionListener listener = (FlowExecutionListener) entry.getKey(); String criteria = (String) entry.getValue(); listenerLoader.addListener(listener, listenerCriteriaFactory.getListenerCriteria(criteria)); } }