Search in sources :

Example 1 with ListenerFactory

use of org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory in project Activiti by Activiti.

the class ListenerNotificationHelper method executeExecutionListeners.

public void executeExecutionListeners(HasExecutionListeners elementWithExecutionListeners, DelegateExecution execution, String eventType) {
    List<ActivitiListener> listeners = elementWithExecutionListeners.getExecutionListeners();
    if (listeners != null && listeners.size() > 0) {
        ListenerFactory listenerFactory = Context.getProcessEngineConfiguration().getListenerFactory();
        for (ActivitiListener activitiListener : listeners) {
            if (eventType.equals(activitiListener.getEvent())) {
                BaseExecutionListener executionListener = null;
                if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getImplementationType())) {
                    executionListener = listenerFactory.createClassDelegateExecutionListener(activitiListener);
                } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
                    executionListener = listenerFactory.createExpressionExecutionListener(activitiListener);
                } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
                    if (activitiListener.getOnTransaction() != null) {
                        executionListener = listenerFactory.createTransactionDependentDelegateExpressionExecutionListener(activitiListener);
                    } else {
                        executionListener = listenerFactory.createDelegateExpressionExecutionListener(activitiListener);
                    }
                } else if (ImplementationType.IMPLEMENTATION_TYPE_INSTANCE.equalsIgnoreCase(activitiListener.getImplementationType())) {
                    executionListener = (ExecutionListener) activitiListener.getInstance();
                }
                if (executionListener != null) {
                    if (activitiListener.getOnTransaction() != null) {
                        planTransactionDependentExecutionListener(listenerFactory, execution, (TransactionDependentExecutionListener) executionListener, activitiListener);
                    } else {
                        // eventName is used to differentiate the event when reusing an execution listener for various events
                        execution.setEventName(eventType);
                        execution.setCurrentActivitiListener(activitiListener);
                        ((ExecutionListener) executionListener).notify(execution);
                        execution.setEventName(null);
                        execution.setCurrentActivitiListener(null);
                    }
                }
            }
        }
    }
}
Also used : BaseExecutionListener(org.activiti.engine.delegate.BaseExecutionListener) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) ListenerFactory(org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory) BaseExecutionListener(org.activiti.engine.delegate.BaseExecutionListener) ExecutionListener(org.activiti.engine.delegate.ExecutionListener) TransactionDependentExecutionListener(org.activiti.engine.delegate.TransactionDependentExecutionListener)

Example 2 with ListenerFactory

use of org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory in project Activiti by Activiti.

the class ListenerNotificationHelper method createCustomPropertiesResolver.

protected CustomPropertiesResolver createCustomPropertiesResolver(ActivitiListener activitiListener) {
    CustomPropertiesResolver customPropertiesResolver = null;
    ListenerFactory listenerFactory = Context.getProcessEngineConfiguration().getListenerFactory();
    if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getCustomPropertiesResolverImplementationType())) {
        customPropertiesResolver = listenerFactory.createClassDelegateCustomPropertiesResolver(activitiListener);
    } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getCustomPropertiesResolverImplementationType())) {
        customPropertiesResolver = listenerFactory.createExpressionCustomPropertiesResolver(activitiListener);
    } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getCustomPropertiesResolverImplementationType())) {
        customPropertiesResolver = listenerFactory.createDelegateExpressionCustomPropertiesResolver(activitiListener);
    }
    return customPropertiesResolver;
}
Also used : ListenerFactory(org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory) CustomPropertiesResolver(org.activiti.engine.delegate.CustomPropertiesResolver)

Example 3 with ListenerFactory

use of org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory in project Activiti by Activiti.

the class ListenerNotificationHelper method createTaskListener.

protected BaseTaskListener createTaskListener(ActivitiListener activitiListener) {
    BaseTaskListener taskListener = null;
    ListenerFactory listenerFactory = Context.getProcessEngineConfiguration().getListenerFactory();
    if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getImplementationType())) {
        taskListener = listenerFactory.createClassDelegateTaskListener(activitiListener);
    } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
        taskListener = listenerFactory.createExpressionTaskListener(activitiListener);
    } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
        if (activitiListener.getOnTransaction() != null) {
            taskListener = listenerFactory.createTransactionDependentDelegateExpressionTaskListener(activitiListener);
        } else {
            taskListener = listenerFactory.createDelegateExpressionTaskListener(activitiListener);
        }
    } else if (ImplementationType.IMPLEMENTATION_TYPE_INSTANCE.equalsIgnoreCase(activitiListener.getImplementationType())) {
        taskListener = (TaskListener) activitiListener.getInstance();
    }
    return taskListener;
}
Also used : BaseTaskListener(org.activiti.engine.delegate.BaseTaskListener) BaseTaskListener(org.activiti.engine.delegate.BaseTaskListener) TaskListener(org.activiti.engine.delegate.TaskListener) TransactionDependentTaskListener(org.activiti.engine.delegate.TransactionDependentTaskListener) ListenerFactory(org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory)

Aggregations

ListenerFactory (org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory)3 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)1 BaseExecutionListener (org.activiti.engine.delegate.BaseExecutionListener)1 BaseTaskListener (org.activiti.engine.delegate.BaseTaskListener)1 CustomPropertiesResolver (org.activiti.engine.delegate.CustomPropertiesResolver)1 ExecutionListener (org.activiti.engine.delegate.ExecutionListener)1 TaskListener (org.activiti.engine.delegate.TaskListener)1 TransactionDependentExecutionListener (org.activiti.engine.delegate.TransactionDependentExecutionListener)1 TransactionDependentTaskListener (org.activiti.engine.delegate.TransactionDependentTaskListener)1