Java Code Examples for org.flowable.common.engine.impl.interceptor.CommandContext#addCloseListener()

The following examples show how to use org.flowable.common.engine.impl.interceptor.CommandContext#addCloseListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonType.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void traceValue(JsonNode value, ValueFields valueFields) {
    if (trackObjects && valueFields instanceof VariableInstanceEntity) {
        CommandContext commandContext = Context.getCommandContext();
        if (commandContext != null) {
            if (commandContext.getCurrentEngineConfiguration() instanceof HasVariableServiceConfiguration) {
                HasVariableServiceConfiguration engineConfiguration = (HasVariableServiceConfiguration)
                                commandContext.getCurrentEngineConfiguration();
                VariableServiceConfiguration variableServiceConfiguration = (VariableServiceConfiguration) engineConfiguration.getVariableServiceConfiguration();
                commandContext.addCloseListener(new TraceableVariablesCommandContextCloseListener(
                    new TraceableObject<>(this, value, value.deepCopy(), (VariableInstanceEntity) valueFields, variableServiceConfiguration)
                ));
                variableServiceConfiguration.getInternalHistoryVariableManager().initAsyncHistoryCommandContextCloseListener();
            }
        }
    }
}
 
Example 2
Source File: SerializableType.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void traceValue(Object value, byte[] valueBytes, ValueFields valueFields) {
    if (trackDeserializedObjects && valueFields instanceof VariableInstanceEntity) {
        CommandContext commandContext = Context.getCommandContext();
        if (commandContext != null) {
            if (commandContext.getCurrentEngineConfiguration() instanceof HasVariableServiceConfiguration) {
                HasVariableServiceConfiguration engineConfiguration = (HasVariableServiceConfiguration)
                                commandContext.getCurrentEngineConfiguration();
                VariableServiceConfiguration variableServiceConfiguration = (VariableServiceConfiguration) engineConfiguration.getVariableServiceConfiguration();
                commandContext.addCloseListener(new TraceableVariablesCommandContextCloseListener(
                    new TraceableObject<>(this, value, valueBytes, (VariableInstanceEntity) valueFields, variableServiceConfiguration)
                ));
                variableServiceConfiguration.getInternalHistoryVariableManager().initAsyncHistoryCommandContextCloseListener();
            }
        }
    }
}
 
Example 3
Source File: CmmnHistoryVariableManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void initAsyncHistoryCommandContextCloseListener() {
	if (cmmnEngineConfiguration.isAsyncHistoryEnabled()) {
		CommandContext commandContext = CommandContextUtil.getCommandContext();
    	commandContext.addCloseListener(new AsyncHistorySessionCommandContextCloseListener(
    			commandContext.getSession(AsyncHistorySession.class), cmmnEngineConfiguration.getAsyncHistoryListener()));
    }
}
 
Example 4
Source File: DefaultHistoryVariableManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void initAsyncHistoryCommandContextCloseListener() {
	if (processEngineConfiguration.isAsyncHistoryEnabled()) {
		CommandContext commandContext = CommandContextUtil.getCommandContext();
    	commandContext.addCloseListener(new AsyncHistorySessionCommandContextCloseListener(
    			commandContext.getSession(AsyncHistorySession.class), processEngineConfiguration.getAsyncHistoryListener()));
    }
}
 
Example 5
Source File: DefaultJobManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void createHintListeners(AsyncExecutor asyncExecutor, JobInfoEntity job) {
    CommandContext commandContext = CommandContextUtil.getCommandContext();
    if (Context.getTransactionContext() != null) {
        JobAddedTransactionListener jobAddedTransactionListener = new JobAddedTransactionListener(job, asyncExecutor,
                        CommandContextUtil.getJobServiceConfiguration(commandContext).getCommandExecutor());
        Context.getTransactionContext().addTransactionListener(TransactionState.COMMITTED, jobAddedTransactionListener);
        
    } else {
        AsyncJobAddedNotification jobAddedNotification = new AsyncJobAddedNotification(job, asyncExecutor);
        commandContext.addCloseListener(jobAddedNotification);
        
    }
}
 
Example 6
Source File: ExecuteJobCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {

    if (jobId == null) {
        throw new FlowableIllegalArgumentException("JobId is null");
    }

    Job job = CommandContextUtil.getJobEntityManager(commandContext).findById(jobId);

    if (job == null) {
        throw new JobNotFoundException(jobId);
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Executing job {}", job.getId());
    }

    JobServiceConfiguration jobServiceConfiguration = CommandContextUtil.getJobServiceConfiguration(commandContext);
    InternalJobCompatibilityManager internalJobCompatibilityManager = jobServiceConfiguration.getInternalJobCompatibilityManager();
    if (internalJobCompatibilityManager != null && internalJobCompatibilityManager.isFlowable5Job(job)) {
        internalJobCompatibilityManager.executeV5Job(job);
        return null;
    }

    commandContext.addCloseListener(new FailedJobListener(jobServiceConfiguration.getCommandExecutor(), job));

    try {
        CommandContextUtil.getJobManager(commandContext).execute(job);
    } catch (Throwable exception) {
        // Finally, Throw the exception to indicate the ExecuteJobCmd failed
        throw new FlowableException("Job " + jobId + " failed", exception);
    }

    return null;
}
 
Example 7
Source File: OptimisticLockingExceptionTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {
    commandContext.addCloseListener(new OptimisticLockingTestCommandContextCloseListener());
    return super.execute(commandContext);
}