本文整理汇总了Java中org.activiti.engine.impl.cfg.TransactionState类的典型用法代码示例。如果您正苦于以下问题:Java TransactionState类的具体用法?Java TransactionState怎么用?Java TransactionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionState类属于org.activiti.engine.impl.cfg包,在下文中一共展示了TransactionState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: schedule
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void schedule(TimerEntity timer) {
Date duedate = timer.getDuedate();
if (duedate==null) {
throw new ActivitiException("duedate is null");
}
CommandContext commandContext = Context.getCommandContext();
commandContext
.getDbSqlSession()
.insert(timer);
// Check if this timer fires before the next time the job executor will check for new timers to fire.
// This is highly unlikely because normally waitTimeInMillis is 5000 (5 seconds)
// and timers are usually set further in the future
JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
int waitTimeInMillis = jobExecutor.getWaitTimeInMillis();
if (duedate.getTime() < (ClockUtil.getCurrentTime().getTime()+waitTimeInMillis)) {
// then notify the job executor.
commandContext
.getTransactionContext()
.addTransactionListener(TransactionState.COMMITTED, new MessageAddedNotification(jobExecutor));
}
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:26,代码来源:JobManager.java
示例2: execute
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
JobEntity job = Context
.getCommandContext()
.getJobManager()
.findJobById(jobId);
job.setRetries(job.getRetries() - 1);
job.setLockOwner(null);
job.setLockExpirationTime(null);
if(exception != null) {
job.setExceptionMessage(exception.getMessage());
job.setExceptionStacktrace(getExceptionStacktrace());
}
JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor);
TransactionContext transactionContext = commandContext.getTransactionContext();
transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification);
return null;
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:22,代码来源:DecrementJobRetriesCmd.java
示例3: execute
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
JobEntity job = Context
.getCommandContext()
.getJobEntityManager()
.findJobById(jobId);
job.setRetries(job.getRetries() - 1);
job.setLockOwner(null);
job.setLockExpirationTime(null);
if(exception != null) {
job.setExceptionMessage(exception.getMessage());
job.setExceptionStacktrace(getExceptionStacktrace());
}
JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor);
TransactionContext transactionContext = commandContext.getTransactionContext();
transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification);
return null;
}
开发者ID:springvelocity,项目名称:xbpm5,代码行数:22,代码来源:DecrementJobRetriesCmd.java
示例4: abortProcess
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
private void abortProcess(CommandContext commandContext, String processId) {
LOGGER.info(MessageFormat.format(Messages.PROCESS_WILL_BE_AUTO_ABORTED, processId));
RuntimeService runtimeService = getRuntimeService(commandContext);
TransactionContext transactionContext = commandContext.getTransactionContext();
transactionContext.addTransactionListener(TransactionState.COMMITTED, (context) -> {
runtimeService.deleteProcessInstance(processId, abortReason);
});
}
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:10,代码来源:AbortFailedProcessCommandFactory.java
示例5: addTransactionListener
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
@Override
public void addTransactionListener(TransactionState transactionState, TransactionListener transactionListener) {
if (stateTransactionListeners == null) {
stateTransactionListeners = new HashMap<>();
}
List<TransactionListener> transactionListeners = stateTransactionListeners.get(transactionState);
if (transactionListeners == null) {
transactionListeners = new ArrayList<>();
stateTransactionListeners.put(transactionState, transactionListeners);
}
transactionListeners.add(transactionListener);
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:13,代码来源:StandaloneMybatisTransactionContext.java
示例6: commit
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
@Override
public void commit() {
LOGGER.debug("firing event committing...");
fireTransactionEvent(TransactionState.COMMITTING, false);
LOGGER.debug("committing the ibatis sql session...");
getDbSqlSession().commit();
LOGGER.debug("firing event committed...");
fireTransactionEvent(TransactionState.COMMITTED, true);
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:13,代码来源:StandaloneMybatisTransactionContext.java
示例7: beforeCompletion
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
@Override
public void beforeCompletion() {
if (TransactionState.COMMITTING == transactionState
|| TransactionState.ROLLINGBACK == transactionState) {
transactionListener.execute(commandContext);
}
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:8,代码来源:JtaTransactionContext.java
示例8: afterCompletion
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
@Override
public void afterCompletion(int status) {
if (Status.STATUS_ROLLEDBACK == status && TransactionState.ROLLED_BACK == transactionState) {
transactionListener.execute(commandContext);
} else if (Status.STATUS_COMMITTED == status && TransactionState.COMMITTED == transactionState) {
transactionListener.execute(commandContext);
}
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:9,代码来源:JtaTransactionContext.java
示例9: addTransactionListener
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void addTransactionListener(final TransactionState transactionState, final TransactionListener transactionListener) {
if (transactionState.equals(TransactionState.COMMITTING)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void beforeCommit(boolean readOnly) {
transactionListener.execute(commandContext);
}
});
} else if (transactionState.equals(TransactionState.COMMITTED)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
transactionListener.execute(commandContext);
}
});
} else if (transactionState.equals(TransactionState.ROLLINGBACK)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void beforeCompletion() {
transactionListener.execute(commandContext);
}
});
} else if (transactionState.equals(TransactionState.ROLLED_BACK)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCompletion(int status) {
transactionListener.execute(commandContext);
}
});
}
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:41,代码来源:SpringTransactionContext.java
示例10: addTransactionListener
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void addTransactionListener(TransactionState transactionState, TransactionListener transactionListener) {
if (stateTransactionListeners==null) {
stateTransactionListeners = new HashMap<TransactionState, List<TransactionListener>>();
}
List<TransactionListener> transactionListeners = stateTransactionListeners.get(transactionState);
if (transactionListeners==null) {
transactionListeners = new ArrayList<TransactionListener>();
stateTransactionListeners.put(transactionState, transactionListeners);
}
transactionListeners.add(transactionListener);
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:12,代码来源:StandaloneMybatisTransactionContext.java
示例11: commit
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void commit() {
log.fine("firing event committing...");
fireTransactionEvent(TransactionState.COMMITTING);
log.fine("committing the ibatis sql session...");
getDbSqlSession().commit();
log.fine("firing event committed...");
fireTransactionEvent(TransactionState.COMMITTED);
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:9,代码来源:StandaloneMybatisTransactionContext.java
示例12: fireTransactionEvent
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
protected void fireTransactionEvent(TransactionState transactionState) {
if (stateTransactionListeners==null) {
return;
}
List<TransactionListener> transactionListeners = stateTransactionListeners.get(transactionState);
if (transactionListeners==null) {
return;
}
for (TransactionListener transactionListener: transactionListeners) {
transactionListener.execute(commandContext);
}
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:13,代码来源:StandaloneMybatisTransactionContext.java
示例13: send
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void send(MessageEntity message) {
CommandContext commandContext = Context.getCommandContext();
commandContext
.getDbSqlSession()
.insert(message);
JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
commandContext
.getTransactionContext()
.addTransactionListener(TransactionState.COMMITTED, new MessageAddedNotification(jobExecutor));
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:14,代码来源:JobManager.java
示例14: execute
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
if(jobId == null) {
throw new ActivitiException("jobId is null");
}
if (log.isLoggable(Level.FINE)) {
log.fine("Executing job " + jobId);
}
JobEntity job = commandContext
.getJobManager()
.findJobById(jobId);
if (job == null) {
throw new ActivitiException("No job found with id '" + jobId + "'");
}
try {
job.execute(commandContext);
} catch (RuntimeException exception) {
// When transaction is rolled back, decrement retries
CommandExecutor commandExecutor = Context
.getProcessEngineConfiguration()
.getCommandExecutorTxRequiresNew();
commandContext.getTransactionContext().addTransactionListener(
TransactionState.ROLLED_BACK,
new DecrementJobRetriesListener(commandExecutor, jobId, exception));
// throw the original exception to indicate the ExecuteJobCmd failed
throw exception;
}
return null;
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:34,代码来源:ExecuteJobsCmd.java
示例15: commit
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void commit() {
log.debug("firing event committing...");
fireTransactionEvent(TransactionState.COMMITTING);
log.debug("committing the ibatis sql session...");
getDbSqlSession().commit();
log.debug("firing event committed...");
fireTransactionEvent(TransactionState.COMMITTED);
}
开发者ID:springvelocity,项目名称:xbpm5,代码行数:9,代码来源:StandaloneMybatisTransactionContext.java
示例16: afterCompletion
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public void afterCompletion(int status) {
if(Status.STATUS_ROLLEDBACK == status && TransactionState.ROLLED_BACK.equals(transactionState)) {
transactionListener.execute(commandContext);
} else if(Status.STATUS_COMMITTED == status && TransactionState.COMMITTED.equals(transactionState)) {
transactionListener.execute(commandContext);
}
}
开发者ID:springvelocity,项目名称:xbpm5,代码行数:8,代码来源:JtaTransactionContext.java
示例17: addTransactionListener
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
@Override
public void addTransactionListener(final TransactionState transactionState, final TransactionListener transactionListener) {
if (transactionState == TransactionState.COMMITTING) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void beforeCommit(boolean readOnly) {
transactionListener.execute(commandContext);
}
});
} else if (transactionState == TransactionState.COMMITTED) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
transactionListener.execute(commandContext);
}
});
} else if (transactionState == TransactionState.ROLLINGBACK) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void beforeCompletion() {
transactionListener.execute(commandContext);
}
});
} else if (transactionState == TransactionState.ROLLED_BACK) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCompletion(int status) {
if (TransactionSynchronization.STATUS_ROLLED_BACK == status) {
transactionListener.execute(commandContext);
}
}
});
}
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:42,代码来源:SpringTransactionContext.java
示例18: TransactionStateSynchronization
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public TransactionStateSynchronization(TransactionState transactionState, TransactionListener transactionListener, CommandContext commandContext) {
this.transactionState = transactionState;
this.transactionListener = transactionListener;
this.commandContext = commandContext;
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:6,代码来源:JtaTransactionContext.java
示例19: execute
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
@Override
public Object execute(CommandContext commandContext) {
if (jobId == null && job == null) {
throw new ActivitiIllegalArgumentException("jobId and job is null");
}
if (job == null) {
job = commandContext
.getJobEntityManager()
.findJobById(jobId);
}
if (job == null) {
throw new JobNotFoundException(jobId);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Executing job {}", job.getId());
}
JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();
if (jobExecutorContext != null) { // if null, then we are not called by the job executor
jobExecutorContext.setCurrentJob(job);
}
FailedJobListener failedJobListener = null;
try {
// When transaction is rolled back, decrement retries
failedJobListener = new FailedJobListener(commandContext.getProcessEngineConfiguration().getCommandExecutor(), job.getId());
commandContext.getTransactionContext().addTransactionListener(
TransactionState.ROLLED_BACK,
failedJobListener);
job.execute(commandContext);
if (commandContext.getEventDispatcher().isEnabled()) {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(
FlowableEngineEventType.JOB_EXECUTION_SUCCESS, job));
}
} catch (Throwable exception) {
failedJobListener.setException(exception);
// Dispatch an event, indicating job execution failed in a try-catch block, to prevent the original
// exception to be swallowed
if (commandContext.getEventDispatcher().isEnabled()) {
try {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(
FlowableEngineEventType.JOB_EXECUTION_FAILURE, job, exception));
} catch (Throwable ignore) {
LOGGER.warn("Exception occurred while dispatching job failure event, ignoring.", ignore);
}
}
// Finally, Throw the exception to indicate the ExecuteJobCmd failed
if (!(exception instanceof ActivitiException)) {
throw new ActivitiException("Job " + jobId + " failed", exception);
} else {
throw (ActivitiException) exception;
}
} finally {
if (jobExecutorContext != null) {
jobExecutorContext.setCurrentJob(null);
}
}
return null;
}
开发者ID:flowable,项目名称:flowable-engine,代码行数:69,代码来源:ExecuteJobsCmd.java
示例20: execute
import org.activiti.engine.impl.cfg.TransactionState; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
if(jobId == null) {
throw new ActivitiException("jobId is null");
}
if (log.isLoggable(Level.FINE)) {
log.fine("Executing job " + jobId);
}
JobEntity job = commandContext
.getJobManager()
.findJobById(jobId);
if (job == null) {
throw new ActivitiException("No job found with id '" + jobId + "'");
}
JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();
if(jobExecutorContext != null) { // if null, then we are not called by the job executor
jobExecutorContext.setCurrentJob(job);
}
try {
job.execute(commandContext);
} catch (RuntimeException exception) {
// When transaction is rolled back, decrement retries
CommandExecutor commandExecutor = Context
.getProcessEngineConfiguration()
.getCommandExecutorTxRequiresNew();
commandContext.getTransactionContext().addTransactionListener(
TransactionState.ROLLED_BACK,
new DecrementJobRetriesListener(commandExecutor, jobId, exception));
// throw the original exception to indicate the ExecuteJobCmd failed
throw exception;
} finally {
if(jobExecutorContext != null) {
jobExecutorContext.setCurrentJob(null);
}
}
return null;
}
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:43,代码来源:ExecuteJobsCmd.java
注:本文中的org.activiti.engine.impl.cfg.TransactionState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论