04-06-2013 07:00 AM
SaveUserCmd.execute(CommandContext) line: 40
SaveUserCmd.execute(CommandContext) line: 27
CommandExecutorImpl.execute(Command<T>) line: 24
CommandContextInterceptor.execute(Command<T>) line: 60
SpringTransactionInterceptor$1.doInTransaction(TransactionStatus) line: 42
TransactionTemplate.execute(TransactionCallback<T>) line: 130
SpringTransactionInterceptor.execute(Command<T>) line: 40
LogInterceptor.execute(Command<T>) line: 32
IdentityServiceImpl.saveUser(User) line: 66
NewUserPopupWindow.createUser() line: 177
NewUserPopupWindow.handleFormSubmit() line: 150
[/size]
public class SaveUserCmd implements Command<Void>, Serializable {
…
}
—-
public class [b]SpringTransactionIntercepto[/b]r extends CommandInterceptor {
protected PlatformTransactionManager transactionManager;
protected int transactionPropagation;
public SpringTransactionInterceptor(PlatformTransactionManager transactionManager, int transactionPropagation) {
this.transactionManager = transactionManager;
this.transactionPropagation = transactionPropagation;
}
@SuppressWarnings("unchecked")
public <T> T execute(final Command<T> command) {
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
transactionTemplate.setPropagationBehavior(transactionPropagation);
T result = (T) [b]transactionTemplate.execute[/b](new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
[b] return next.execute(command);[/b]
}
});
return result;
}
}
—-
org.activiti.engine.impl.cmd.SaveUserCmd.[b]execute(CommandContext)[/b]
—–
org.activiti.engine.impl.interceptor.CommandContextInterceptor…{…}
org.activiti.engine.impl.interceptor.CommandContextInterceptor.[b]execute(Command<T>) [/b]{
CommandContext context = Context.getCommandContext();
….
try {
// Push on stack
Context.setCommandContext(context);
Context.setProcessEngineConfiguration(processEngineConfiguration);
return next.execute(command);
} catch (Exception e) {
context.exception(e);
} finally {
try {
if (!contextReused) {
context.close();
}
……..
}
}
—-
org.activiti.engine.impl.interceptor.CommandContext.close() {..
…
if (exception == null) {
[b] flushSessions();[/b]
}
…..
}
org.activiti.engine.impl.interceptor.CommandContext.flushSessions()
{
for (Session session : sessions.values()) {
[b] session.flush();[/b]
}
}
interface org.activiti.engine.impl.interceptor.Session
—-
public class org.activiti.spring.SpringProcessEngineConfiguration extends ProcessEngineConfigurationImpl
{…
protected Collection< ? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequired() {
if (transactionManager==null) {
throw new ActivitiException("transactionManager is required property for SpringProcessEngineConfiguration, use "+StandaloneProcessEngineConfiguration.class.getName()+" otherwise");
}
List<CommandInterceptor> defaultCommandInterceptorsTxRequired = new ArrayList<CommandInterceptor>();
defaultCommandInterceptorsTxRequired.add(new LogInterceptor());
defaultCommandInterceptorsTxRequired.add(new SpringTransactionInterceptor(transactionManager, [b]TransactionTemplate.PROPAGATION_REQUIRED[/b]));
CommandContextInterceptor commandContextInterceptor = new CommandContextInterceptor(commandContextFactory, this);
commandContextInterceptor.setContextReusePossible(true);
defaultCommandInterceptorsTxRequired.add(commandContextInterceptor);
return defaultCommandInterceptorsTxRequired;
}
protected Collection< ? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequiresNew() {
List<CommandInterceptor> defaultCommandInterceptorsTxRequiresNew = new ArrayList<CommandInterceptor>();
defaultCommandInterceptorsTxRequiresNew.add(new LogInterceptor());
defaultCommandInterceptorsTxRequiresNew.add(new SpringTransactionInterceptor(transactionManager, [b]TransactionTemplate.PROPAGATION_REQUIRES_NEW[/b]));
CommandContextInterceptor commandContextInterceptor = new CommandContextInterceptor(commandContextFactory, this);
commandContextInterceptor.setContextReusePossible(false);
defaultCommandInterceptorsTxRequiresNew.add(commandContextInterceptor);
return defaultCommandInterceptorsTxRequiresNew;
}
}
—-
public abstract class org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl extends org.activiti.engine.ProcessEngineConfiguration { }
{….
protected void initCommandInterceptorsTxRequired() {
if (commandInterceptorsTxRequired==null) {
if (customPreCommandInterceptorsTxRequired!=null) {
commandInterceptorsTxRequired = new ArrayList<CommandInterceptor>(customPreCommandInterceptorsTxRequired);
} else {
commandInterceptorsTxRequired = new ArrayList<CommandInterceptor>();
}
commandInterceptorsTxRequired.addAll(getDefaultCommandInterceptorsTxRequired());
if (customPostCommandInterceptorsTxRequired!=null) {
commandInterceptorsTxRequired.addAll(customPostCommandInterceptorsTxRequired);
}
commandInterceptorsTxRequired.add(actualCommandExecutor);
}
}
…
protected void initCommandInterceptorsTxRequiresNew() {
if (commandInterceptorsTxRequiresNew==null) {
if (customPreCommandInterceptorsTxRequiresNew!=null) {
commandInterceptorsTxRequiresNew = new ArrayList<CommandInterceptor>(customPreCommandInterceptorsTxRequiresNew);
} else {
commandInterceptorsTxRequiresNew = new ArrayList<CommandInterceptor>();
}
commandInterceptorsTxRequiresNew.addAll(getDefaultCommandInterceptorsTxRequiresNew());
if (customPostCommandInterceptorsTxRequiresNew!=null) {
commandInterceptorsTxRequiresNew.addAll(customPostCommandInterceptorsTxRequiresNew);
}
commandInterceptorsTxRequiresNew.add(actualCommandExecutor);
}
}
…
}
04-06-2013 08:04 AM
04-06-2013 03:19 PM
04-10-2013 10:09 AM
TransactionTemplate.PROPAGATION_REQUIRED or TransactionTemplate.PROPAGATION_REQUIRES_NEW may be used
But which propagation behavior used exact??
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.