Search in sources :

Example 51 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class JuelFormEngine method executeScript.

protected Object executeScript(String scriptSrc, VariableScope scope) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    ScriptFactory scriptFactory = processEngineConfiguration.getScriptFactory();
    ExecutableScript script = scriptFactory.createScriptFromSource(ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, scriptSrc);
    ScriptInvocation invocation = new ScriptInvocation(script, scope);
    try {
        processEngineConfiguration.getDelegateInterceptor().handleInvocation(invocation);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new ProcessEngineException(e);
    }
    return invocation.getInvocationResult();
}
Also used : ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ScriptFactory(org.camunda.bpm.engine.impl.scripting.ScriptFactory) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ScriptInvocation(org.camunda.bpm.engine.impl.delegate.ScriptInvocation)

Example 52 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class JobEntity method createFailedJobIncident.

protected void createFailedJobIncident() {
    final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    if (processEngineConfiguration.isCreateIncidentOnFailedJobEnabled()) {
        String incidentHandlerType = Incident.FAILED_JOB_HANDLER_TYPE;
        // make sure job has an ID set:
        if (id == null) {
            id = processEngineConfiguration.getIdGenerator().getNextId();
        } else {
            // check whether there exists already an incident
            // for this job
            List<Incident> failedJobIncidents = Context.getCommandContext().getIncidentManager().findIncidentByConfigurationAndIncidentType(id, incidentHandlerType);
            if (!failedJobIncidents.isEmpty()) {
                return;
            }
        }
        IncidentContext incidentContext = createIncidentContext();
        incidentContext.setActivityId(getActivityId());
        processEngineConfiguration.getIncidentHandler(incidentHandlerType).handleIncident(incidentContext, exceptionMessage);
    }
}
Also used : IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext) Incident(org.camunda.bpm.engine.runtime.Incident) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 53 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class TimerEntity method preExecute.

@Override
protected void preExecute(CommandContext commandContext) {
    if (getJobHandler() instanceof TimerEventJobHandler) {
        TimerJobConfiguration configuration = (TimerJobConfiguration) getJobHandlerConfiguration();
        if (repeat != null && !configuration.isFollowUpJobCreated()) {
            // this timer is a repeating timer and
            // a follow up timer job has not been scheduled yet
            Date newDueDate = calculateRepeat();
            if (newDueDate != null) {
                // the listener is added to the transaction as SYNC on ROLLABCK,
                // when it is necessary to schedule a new timer job invocation.
                // If the transaction does not rollback, it is ignored.
                ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
                CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew();
                RepeatingFailedJobListener listener = createRepeatingFailedJobListener(commandExecutor);
                commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener);
                // create a new timer job
                createNewTimerJob(newDueDate);
            }
        }
    }
}
Also used : RepeatingFailedJobListener(org.camunda.bpm.engine.impl.jobexecutor.RepeatingFailedJobListener) TimerEventJobHandler(org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) TimerJobConfiguration(org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Date(java.util.Date)

Example 54 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class HistoricTaskInstanceManager method updateHistoricTaskInstance.

public void updateHistoricTaskInstance(final TaskEntity taskEntity) {
    ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
    HistoryLevel historyLevel = configuration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_UPDATE, taskEntity)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

            @Override
            public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                return producer.createTaskInstanceUpdateEvt(taskEntity);
            }
        });
    }
}
Also used : HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventProcessor(org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor) HistoryEventProducer(org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 55 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class IncidentEntity method fireHistoricIncidentEvent.

protected void fireHistoricIncidentEvent(final HistoryEventType eventType) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(eventType, this)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

            @Override
            public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                HistoryEvent event = null;
                if (HistoryEvent.INCIDENT_CREATE.equals(eventType.getEventName())) {
                    event = producer.createHistoricIncidentCreateEvt(IncidentEntity.this);
                } else if (HistoryEvent.INCIDENT_RESOLVE.equals(eventType.getEventName())) {
                    event = producer.createHistoricIncidentResolveEvt(IncidentEntity.this);
                } else if (HistoryEvent.INCIDENT_DELETE.equals(eventType.getEventName())) {
                    event = producer.createHistoricIncidentDeleteEvt(IncidentEntity.this);
                }
                return event;
            }
        });
    }
}
Also used : HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventProcessor(org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor) HistoryEventProducer(org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Aggregations

ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)161 Test (org.junit.Test)35 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)22 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)18 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)17 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)17 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)13 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)12 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)12 Before (org.junit.Before)11 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)8 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)8 After (org.junit.After)8 Date (java.util.Date)7 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)7 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)7 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)7 IdentityService (org.camunda.bpm.engine.IdentityService)7 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)6