Search in sources :

Example 1 with CommandInterceptor

use of org.activiti.engine.impl.interceptor.CommandInterceptor in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initCommandExecutor.

protected void initCommandExecutor() {
    if (commandExecutor == null) {
        CommandInterceptor first = initInterceptorChain(commandInterceptors);
        commandExecutor = new CommandExecutorImpl(getDefaultCommandConfig(), first);
    }
}
Also used : CommandInterceptor(org.activiti.engine.impl.interceptor.CommandInterceptor)

Example 2 with CommandInterceptor

use of org.activiti.engine.impl.interceptor.CommandInterceptor in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method getDefaultCommandInterceptors.

protected Collection<? extends CommandInterceptor> getDefaultCommandInterceptors() {
    List<CommandInterceptor> interceptors = new ArrayList<CommandInterceptor>();
    interceptors.add(new LogInterceptor());
    CommandInterceptor transactionInterceptor = createTransactionInterceptor();
    if (transactionInterceptor != null) {
        interceptors.add(transactionInterceptor);
    }
    interceptors.add(new CommandContextInterceptor(commandContextFactory, this));
    return interceptors;
}
Also used : ArrayList(java.util.ArrayList) LogInterceptor(org.activiti.engine.impl.interceptor.LogInterceptor) CommandInterceptor(org.activiti.engine.impl.interceptor.CommandInterceptor) CommandContextInterceptor(org.activiti.engine.impl.interceptor.CommandContextInterceptor)

Example 3 with CommandInterceptor

use of org.activiti.engine.impl.interceptor.CommandInterceptor in project Activiti by Activiti.

the class CompetingSignalsTest method testCompetingSignalsWithRetry.

@Deployment(resources = { "org/activiti/engine/test/concurrency/CompetingSignalsTest.testCompetingSignals.bpmn20.xml" })
public void testCompetingSignalsWithRetry() throws Exception {
    RuntimeServiceImpl runtimeServiceImpl = (RuntimeServiceImpl) runtimeService;
    CommandExecutorImpl before = (CommandExecutorImpl) runtimeServiceImpl.getCommandExecutor();
    try {
        CommandInterceptor retryInterceptor = new RetryInterceptor();
        retryInterceptor.setNext(before.getFirst());
        runtimeServiceImpl.setCommandExecutor(new CommandExecutorImpl(before.getDefaultConfig(), retryInterceptor));
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("CompetingSignalsProcess");
        String processInstanceId = processInstance.getId();
        log.debug("test thread starts thread one");
        SignalThread threadOne = new SignalThread(processInstanceId);
        threadOne.startAndWaitUntilControlIsReturned();
        log.debug("test thread continues to start thread two");
        SignalThread threadTwo = new SignalThread(processInstanceId);
        threadTwo.startAndWaitUntilControlIsReturned();
        log.debug("test thread notifies thread 1");
        threadOne.proceedAndWaitTillDone();
        assertNull(threadOne.exception);
        log.debug("test thread notifies thread 2");
        threadTwo.proceedAndWaitTillDone();
        assertNull(threadTwo.exception);
    } finally {
        // restore the command executor
        runtimeServiceImpl.setCommandExecutor(before);
    }
}
Also used : CommandExecutorImpl(org.activiti.engine.impl.cfg.CommandExecutorImpl) CommandInterceptor(org.activiti.engine.impl.interceptor.CommandInterceptor) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) RuntimeServiceImpl(org.activiti.engine.impl.RuntimeServiceImpl) RetryInterceptor(org.activiti.engine.impl.interceptor.RetryInterceptor) Deployment(org.activiti.engine.test.Deployment)

Aggregations

CommandInterceptor (org.activiti.engine.impl.interceptor.CommandInterceptor)3 ArrayList (java.util.ArrayList)1 RuntimeServiceImpl (org.activiti.engine.impl.RuntimeServiceImpl)1 CommandExecutorImpl (org.activiti.engine.impl.cfg.CommandExecutorImpl)1 CommandContextInterceptor (org.activiti.engine.impl.interceptor.CommandContextInterceptor)1 LogInterceptor (org.activiti.engine.impl.interceptor.LogInterceptor)1 RetryInterceptor (org.activiti.engine.impl.interceptor.RetryInterceptor)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Deployment (org.activiti.engine.test.Deployment)1