Search in sources :

Example 1 with ProcessApplicationUnavailableException

use of org.camunda.bpm.application.ProcessApplicationUnavailableException in project camunda-bpm-platform by camunda.

the class TypedValueField method getCurrentPaSerializers.

protected static VariableSerializers getCurrentPaSerializers() {
    if (Context.getCurrentProcessApplication() != null) {
        ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication();
        try {
            ProcessApplicationInterface processApplicationInterface = processApplicationReference.getProcessApplication();
            ProcessApplicationInterface rawPa = processApplicationInterface.getRawObject();
            if (rawPa instanceof AbstractProcessApplication) {
                return ((AbstractProcessApplication) rawPa).getVariableSerializers();
            } else {
                return null;
            }
        } catch (ProcessApplicationUnavailableException e) {
            throw LOG.cannotDeterminePaDataformats(e);
        }
    } else {
        return null;
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface)

Example 2 with ProcessApplicationUnavailableException

use of org.camunda.bpm.application.ProcessApplicationUnavailableException in project camunda-bpm-platform by camunda.

the class AbstractPaLocalScriptEngineTest method getProcessApplication.

protected ProcessApplicationInterface getProcessApplication() {
    ProcessApplicationReference reference = processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<ProcessApplicationReference>() {

        public ProcessApplicationReference execute(CommandContext commandContext) {
            ProcessDefinitionEntity definition = commandContext.getProcessDefinitionManager().findLatestProcessDefinitionByKey(PROCESS_ID);
            String deploymentId = definition.getDeploymentId();
            ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager();
            return processApplicationManager.getProcessApplicationForDeployment(deploymentId);
        }
    });
    assertNotNull(reference);
    ProcessApplicationInterface processApplication = null;
    try {
        processApplication = reference.getProcessApplication();
    } catch (ProcessApplicationUnavailableException e) {
        fail("Could not retrieve process application");
    }
    return processApplication.getRawObject();
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessApplicationManager(org.camunda.bpm.engine.impl.application.ProcessApplicationManager) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface)

Example 3 with ProcessApplicationUnavailableException

use of org.camunda.bpm.application.ProcessApplicationUnavailableException in project camunda-bpm-platform by camunda.

the class ProcessApplicationEventListenerDelegate method notifyExecutionListener.

protected void notifyExecutionListener(DelegateExecution execution) throws Exception {
    ProcessApplicationReference processApp = Context.getCurrentProcessApplication();
    try {
        ProcessApplicationInterface processApplication = processApp.getProcessApplication();
        ExecutionListener executionListener = processApplication.getExecutionListener();
        if (executionListener != null) {
            executionListener.notify(execution);
        } else {
            LOG.paDoesNotProvideExecutionListener(processApp.getName());
        }
    } catch (ProcessApplicationUnavailableException e) {
        // Process Application unavailable => ignore silently
        LOG.cannotInvokeListenerPaUnavailable(processApp.getName(), e);
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener)

Example 4 with ProcessApplicationUnavailableException

use of org.camunda.bpm.application.ProcessApplicationUnavailableException in project camunda-bpm-platform by camunda.

the class ProcessApplicationEventListenerDelegate method notifyTaskListener.

protected void notifyTaskListener(DelegateTask task) throws Exception {
    ProcessApplicationReference processApp = Context.getCurrentProcessApplication();
    try {
        ProcessApplicationInterface processApplication = processApp.getProcessApplication();
        TaskListener taskListener = processApplication.getTaskListener();
        if (taskListener != null) {
            taskListener.notify(task);
        } else {
            LOG.paDoesNotProvideTaskListener(processApp.getName());
        }
    } catch (ProcessApplicationUnavailableException e) {
        // Process Application unavailable => ignore silently
        LOG.cannotInvokeListenerPaUnavailable(processApp.getName(), e);
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface)

Example 5 with ProcessApplicationUnavailableException

use of org.camunda.bpm.application.ProcessApplicationUnavailableException in project camunda-bpm-platform by camunda.

the class Context method executeWithinProcessApplication.

public static <T> T executeWithinProcessApplication(Callable<T> callback, ProcessApplicationReference processApplicationReference, InvocationContext invocationContext) {
    String paName = processApplicationReference.getName();
    try {
        ProcessApplicationInterface processApplication = processApplicationReference.getProcessApplication();
        setCurrentProcessApplication(processApplicationReference);
        try {
            // wrap callback
            ProcessApplicationClassloaderInterceptor<T> wrappedCallback = new ProcessApplicationClassloaderInterceptor<T>(callback);
            // execute wrapped callback
            return processApplication.execute(wrappedCallback, invocationContext);
        } catch (Exception e) {
            // unwrap exception
            if (e.getCause() != null && e.getCause() instanceof RuntimeException) {
                throw (RuntimeException) e.getCause();
            } else {
                throw new ProcessEngineException("Unexpected exeption while executing within process application ", e);
            }
        } finally {
            removeCurrentProcessApplication();
        }
    } catch (ProcessApplicationUnavailableException e) {
        throw new ProcessEngineException("Cannot switch to process application '" + paName + "' for execution: " + e.getMessage(), e);
    }
}
Also used : ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

ProcessApplicationInterface (org.camunda.bpm.application.ProcessApplicationInterface)7 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)7 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)4 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)1 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 ProcessApplicationManager (org.camunda.bpm.engine.impl.application.ProcessApplicationManager)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1