/** * 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 FlowExecutionListenerCriteria getListenerCriteria(String encodedCriteria) { if ("*".equals(encodedCriteria)) { return allFlows(); } else { String[] flowIds = StringUtils.commaDelimitedListToStringArray(encodedCriteria); for (int i = 0; i < flowIds.length; i++) { flowIds[i] = flowIds[i].trim(); } return flows(flowIds); } }
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)); } }
/** * Decode given string value into one of the well known criteria types. * @see FlowExecutionListenerCriteriaFactory */ protected FlowExecutionListenerCriteria getCriteria(String value) { if ("*".equals(value)) { return new FlowExecutionListenerCriteriaFactory().allFlows(); } else { String[] flowIds = StringUtils.commaDelimitedListToStringArray(value); for (int i = 0; i < flowIds.length; i++) { flowIds[i] = flowIds[i].trim(); } return new FlowExecutionListenerCriteriaFactory().flows(flowIds); } }
public void testAllFlows() { FlowExecutionListenerCriteria c = factory.allFlows(); assertEquals(true, c.appliesTo(new Flow("foo"))); }
protected void setUp() { loader = new ConditionalFlowExecutionListenerLoader(); criteriaFactory = new FlowExecutionListenerCriteriaFactory(); }
public void testMultipleFlowMatch() { FlowExecutionListenerCriteria c = factory.flows("foo", "bar"); assertEquals(true, c.appliesTo(new Flow("foo"))); assertEquals(true, c.appliesTo(new Flow("bar"))); assertEquals(false, c.appliesTo(new Flow("baz"))); } }
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); } }
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]); }
public void testFlowMatch() { FlowExecutionListenerCriteria c = factory.flow("foo"); assertEquals(true, c.appliesTo(new Flow("foo"))); assertEquals(false, c.appliesTo(new Flow("baz"))); }
/** * 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 FlowExecutionListenerCriteria getListenerCriteria(String encodedCriteria) { if ("*".equals(encodedCriteria)) { return allFlows(); } else { String[] flowIds = StringUtils.commaDelimitedListToStringArray(encodedCriteria); for (int i = 0; i < flowIds.length; i++) { flowIds[i] = flowIds[i].trim(); } return flows(flowIds); } }
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]); }
/** * 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 FlowExecutionListenerCriteria getListenerCriteria(String encodedCriteria) { if ("*".equals(encodedCriteria)) { return allFlows(); } else { String[] flowIds = StringUtils.commaDelimitedListToStringArray(encodedCriteria); for (int i = 0; i < flowIds.length; i++) { flowIds[i] = flowIds[i].trim(); } return flows(flowIds); } }
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)); } }
/** * 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(); for (Map.Entry<FlowExecutionListener, String> entry : listenersWithCriteria.entrySet()) { FlowExecutionListener listener = entry.getKey(); String criteria = entry.getValue(); listenerLoader.addListener(listener, listenerCriteriaFactory.getListenerCriteria(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; }