com.jpattern.core.command.ConcurrentCommandChainStrategy Maven / Gradle / Ivy
package com.jpattern.core.command;
import com.jpattern.shared.result.IResult;
/**
* This Strategy is particularly powerful. This let the management of every single command of the chain
* to the main chain executor.
* This means that if an asynchronous executor is used then every command is passed to the executor an every single command
* will be executed in a separated thread. In this case the commands are executed without waiting the execution end of the previous commands in the chain.
* If a pool executor is used every single command will be put in the pool and then executed based on the pool strategy.
* Due to the independence of the commands, when this strategy is used and an error is thrown by a command
* the chain is not rollbacked.
*
* @author Francesco Cina'
*
* 11/set/2011
*/
public class ConcurrentCommandChainStrategy implements ICommandChainStrategy {
private static final long serialVersionUID = 1L;
@Override
public boolean executeNext(IResult result) {
return true;
}
@Override
public boolean executeRollback() {
return false;
}
@Override
public void doExec(ICommand> command, ACommandResult commandResult, boolean catchRuntimeException, ICommandExecutor commandExecutor) {
command.exec(commandExecutor, catchRuntimeException, commandResult);
}
@Override
public void doRollback(ICommand> command, ACommandResult commandResult, boolean catchRuntimeException, ICommandExecutor commandExecutor) {
command.rollback(commandExecutor, catchRuntimeException, commandResult);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy