use of org.camunda.bpm.application.ProcessApplicationInterface 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();
}
use of org.camunda.bpm.application.ProcessApplicationInterface in project camunda-bpm-platform by camunda.
the class ProcessApplicationStopService method stop.
@Override
public void stop(StopContext arg0) {
ManagedReference reference = null;
try {
// get the process application component
ProcessApplicationInterface processApplication = null;
ComponentView componentView = paComponentViewInjector.getOptionalValue();
if (componentView != null) {
reference = componentView.createInstance();
processApplication = (ProcessApplicationInterface) reference.getInstance();
} else {
processApplication = noViewProcessApplication.getValue();
}
BpmPlatformPlugins bpmPlatformPlugins = platformPluginsInjector.getValue();
List<BpmPlatformPlugin> plugins = bpmPlatformPlugins.getPlugins();
for (BpmPlatformPlugin bpmPlatformPlugin : plugins) {
bpmPlatformPlugin.postProcessApplicationUndeploy(processApplication);
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Exception while invoking BpmPlatformPlugin.postProcessApplicationUndeploy", e);
} finally {
if (reference != null) {
reference.release();
}
}
}
use of org.camunda.bpm.application.ProcessApplicationInterface 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);
}
}
use of org.camunda.bpm.application.ProcessApplicationInterface 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);
}
}
use of org.camunda.bpm.application.ProcessApplicationInterface 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);
}
}
Aggregations