org.activiti.engine.delegate.event.ActivitiEventListener Java Examples
The following examples show how to use
org.activiti.engine.delegate.event.ActivitiEventListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegateExpressionActivitiEventListener.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void onEvent(ActivitiEvent event) { if (isValidEvent(event)) { Object delegate = DelegateExpressionUtil.resolveDelegateExpression(expression, new NoExecutionVariableScope()); if (delegate instanceof ActivitiEventListener) { // Cache result of isFailOnException() from delegate-instance // until next event is received. This prevents us from having to resolve // the expression twice when an error occurs. failOnException = ((ActivitiEventListener) delegate).isFailOnException(); // Call the delegate ((ActivitiEventListener) delegate).onEvent(event); } else { // Force failing, since the exception we're about to throw // cannot be ignored, because it did not originate from the listener itself failOnException = true; throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + ActivitiEventListener.class.getName()); } } }
Example #2
Source File: DefaultListenerFactory.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public ActivitiEventListener createEventThrowingEventListener(EventListener eventListener) { BaseDelegateEventListener result = null; if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.equals(eventListener.getImplementationType())) { result = new SignalThrowingEventListener(); ((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation()); ((SignalThrowingEventListener) result).setProcessInstanceScope(true); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.equals(eventListener.getImplementationType())) { result = new SignalThrowingEventListener(); ((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation()); ((SignalThrowingEventListener) result).setProcessInstanceScope(false); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.equals(eventListener.getImplementationType())) { result = new MessageThrowingEventListener(); ((MessageThrowingEventListener) result).setMessageName(eventListener.getImplementation()); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.equals(eventListener.getImplementationType())) { result = new ErrorThrowingEventListener(); ((ErrorThrowingEventListener) result).setErrorCode(eventListener.getImplementation()); } if (result == null) { throw new ActivitiIllegalArgumentException("Cannot create an event-throwing event-listener, unknown implementation type: " + eventListener.getImplementationType()); } result.setEntityClass(getEntityType(eventListener.getEntityType())); return result; }
Example #3
Source File: DelegateExpressionActivitiEventListener.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void onEvent(ActivitiEvent event) { if(isValidEvent(event)) { Object delegate = DelegateExpressionUtil.resolveDelegateExpression(expression, new NoExecutionVariableScope()); if (delegate instanceof ActivitiEventListener) { // Cache result of isFailOnException() from delegate-instance until next // event is received. This prevents us from having to resolve the expression twice when // an error occurs. failOnException = ((ActivitiEventListener) delegate).isFailOnException(); // Call the delegate ((ActivitiEventListener) delegate).onEvent(event); } else { // Force failing, since the exception we're about to throw cannot be ignored, because it // did not originate from the listener itself failOnException = true; throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + ActivitiEventListener.class.getName()); } } }
Example #4
Source File: ProcessEngineConfiguration.java From open-cloud with MIT License | 5 votes |
@Bean public SpringProcessEngineConfiguration springProcessEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager, SpringAsyncExecutor springAsyncExecutor ) throws IOException { SpringProcessEngineConfiguration engineConfiguration = baseSpringProcessEngineConfiguration( dataSource, transactionManager, springAsyncExecutor); Map<String, List<ActivitiEventListener>> typedListeners = new HashMap<>(); typedListeners.put("TASK_CREATED", Collections.singletonList(taskCreatedListener())); typedListeners.put("TASK_COMPLETED", Collections.singletonList(taskCompletedListener())); engineConfiguration.setTypedEventListeners(typedListeners); return engineConfiguration; }
Example #5
Source File: ActivitiEventSupport.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected synchronized void addTypedEventListener(ActivitiEventListener listener, ActivitiEventType type) { List<ActivitiEventListener> listeners = typedListeners.get(type); if (listeners == null) { // Add an empty list of listeners for this type listeners = new CopyOnWriteArrayList<ActivitiEventListener>(); typedListeners.put(type, listeners); } if (!listeners.contains(listener)) { listeners.add(listener); } }
Example #6
Source File: ActivitiEventSupport.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void dispatchEvent(ActivitiEvent event, ActivitiEventListener listener) { try { listener.onEvent(event); } catch (Throwable t) { if (listener.isFailOnException()) { throw new ActivitiException("Exception while executing event-listener", t); } else { // Ignore the exception and continue notifying remaining listeners. The listener // explicitly states that the exception should not bubble up LOG.warn("Exception while executing event-listener, which was ignored", t); } } }
Example #7
Source File: ActivitiEventSupport.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void removeEventListener(ActivitiEventListener listenerToRemove) { eventListeners.remove(listenerToRemove); for (List<ActivitiEventListener> listeners : typedListeners.values()) { listeners.remove(listenerToRemove); } }
Example #8
Source File: ActivitiEventSupport.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public synchronized void addEventListener(ActivitiEventListener listenerToAdd, ActivitiEventType... types) { if (listenerToAdd == null) { throw new ActivitiIllegalArgumentException("Listener cannot be null."); } if (types == null || types.length == 0) { addEventListener(listenerToAdd); } else { for (ActivitiEventType type : types) { addTypedEventListener(listenerToAdd, type); } } }
Example #9
Source File: ActivitiEventSupport.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public synchronized void addEventListener(ActivitiEventListener listenerToAdd) { if (listenerToAdd == null) { throw new ActivitiIllegalArgumentException("Listener cannot be null."); } if (!eventListeners.contains(listenerToAdd)) { eventListeners.add(listenerToAdd); } }
Example #10
Source File: EventRecorderTestUtils.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void closeProcessEngine(ProcessEngine processEngine, ActivitiEventListener listener) { if (listener != null) { final ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration(); processEngineConfiguration.getEventDispatcher().removeEventListener(listener); } processEngine.close(); }
Example #11
Source File: ReplayRunTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private ProcessEngineConfigurationImpl getProcessEngineConfiguration() { ProcessEngineConfigurationImpl configuration = new org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration(); configuration. setHistory("full"). setDatabaseSchemaUpdate("drop-create"); configuration.setCustomDefaultBpmnParseHandlers( Arrays.<BpmnParseHandler>asList( new AddListenerUserTaskParseHandler(TaskListener.EVENTNAME_CREATE, new UserTaskExecutionListener(USER_TASK_COMPLETED_EVENT_TYPE, USER_TASK_COMPLETED_EVENT_TYPE, listener.getSimulationEvents())) )); configuration.setEventListeners(Arrays.<ActivitiEventListener>asList(listener)); return configuration; }
Example #12
Source File: DefaultListenerFactory.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public ActivitiEventListener createEventThrowingEventListener(EventListener eventListener) { BaseDelegateEventListener result = null; if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.equals(eventListener.getImplementationType())) { result = new SignalThrowingEventListener(); ((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation()); ((SignalThrowingEventListener) result).setProcessInstanceScope(true); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.equals(eventListener.getImplementationType())) { result = new SignalThrowingEventListener(); ((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation()); ((SignalThrowingEventListener) result).setProcessInstanceScope(false); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.equals(eventListener.getImplementationType())) { result = new MessageThrowingEventListener(); ((MessageThrowingEventListener) result).setMessageName(eventListener.getImplementation()); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.equals(eventListener.getImplementationType())) { result = new ErrorThrowingEventListener(); ((ErrorThrowingEventListener) result).setErrorCode(eventListener.getImplementation()); } if (result == null) { throw new ActivitiIllegalArgumentException("Cannot create an event-throwing event-listener, unknown implementation type: " + eventListener.getImplementationType()); } result.setEntityClass(getEntityType(eventListener.getEntityType())); return result; }
Example #13
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public ProcessEngineConfigurationImpl setEventListeners(List<ActivitiEventListener> eventListeners) { this.eventListeners = eventListeners; return this; }
Example #14
Source File: ActivitiEventDispatcherImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void removeEventListener(ActivitiEventListener listenerToRemove) { eventSupport.removeEventListener(listenerToRemove); }
Example #15
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public ProcessEngineConfigurationImpl setTypedEventListeners(Map<String, List<ActivitiEventListener>> typedListeners) { this.typedEventListeners = typedListeners; return this; }
Example #16
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public List<ActivitiEventListener> getEventListeners() { return eventListeners; }
Example #17
Source File: DelegateEventListener.java From lemon with Apache License 2.0 | 4 votes |
public void setListeners(List<ActivitiEventListener> listeners) { this.listeners = listeners; }
Example #18
Source File: DelegateEventListener.java From lemon with Apache License 2.0 | 4 votes |
public void onEvent(ActivitiEvent event) { for (ActivitiEventListener listener : listeners) { listener.onEvent(event); } }
Example #19
Source File: DefaultListenerFactory.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public ActivitiEventListener createDelegateExpressionEventListener(EventListener eventListener) { return new DelegateExpressionActivitiEventListener(expressionManager.createExpression(eventListener.getImplementation()), getEntityType(eventListener.getEntityType())); }
Example #20
Source File: RuntimeServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void addEventListener(ActivitiEventListener listenerToAdd) { commandExecutor.execute(new AddEventListenerCommand(listenerToAdd)); }
Example #21
Source File: RuntimeServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void addEventListener(ActivitiEventListener listenerToAdd, ActivitiEventType... types) { commandExecutor.execute(new AddEventListenerCommand(listenerToAdd, types)); }
Example #22
Source File: RuntimeServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void removeEventListener(ActivitiEventListener listenerToRemove) { commandExecutor.execute(new RemoveEventListenerCommand(listenerToRemove)); }
Example #23
Source File: DefaultListenerFactory.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public ActivitiEventListener createClassDelegateEventListener(EventListener eventListener) { return new DelegateActivitiEventListener(eventListener.getImplementation(), getEntityType(eventListener.getEntityType())); }
Example #24
Source File: RemoveEventListenerCommand.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public RemoveEventListenerCommand(ActivitiEventListener listener) { super(); this.listener = listener; }
Example #25
Source File: AddEventListenerCommand.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public AddEventListenerCommand(ActivitiEventListener listener, ActivitiEventType[] types) { this.listener = listener; this.types = types; }
Example #26
Source File: AddEventListenerCommand.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public AddEventListenerCommand(ActivitiEventListener listener) { super(); this.listener = listener; }
Example #27
Source File: AddEventListenerCommand.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public AddEventListenerCommand(ActivitiEventListener listener) { super(); this.listener = listener; }
Example #28
Source File: RuntimeServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void addEventListener(ActivitiEventListener listenerToAdd) { commandExecutor.execute(new AddEventListenerCommand(listenerToAdd)); }
Example #29
Source File: RuntimeServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void addEventListener(ActivitiEventListener listenerToAdd, ActivitiEventType... types) { commandExecutor.execute(new AddEventListenerCommand(listenerToAdd, types)); }
Example #30
Source File: RuntimeServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public void removeEventListener(ActivitiEventListener listenerToRemove) { commandExecutor.execute(new RemoveEventListenerCommand(listenerToRemove)); }