Search in sources :

Example 6 with ProcessApplicationInterface

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();
}
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 7 with ProcessApplicationInterface

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();
        }
    }
}
Also used : BpmPlatformPlugins(org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins) BpmPlatformPlugin(org.camunda.bpm.container.impl.plugin.BpmPlatformPlugin) ComponentView(org.jboss.as.ee.component.ComponentView) ManagedReference(org.jboss.as.naming.ManagedReference) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface) StartException(org.jboss.msc.service.StartException)

Example 8 with ProcessApplicationInterface

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);
    }
}
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 9 with ProcessApplicationInterface

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);
    }
}
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 10 with ProcessApplicationInterface

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);
    }
}
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)12 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)7 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)4 ComponentView (org.jboss.as.ee.component.ComponentView)4 ManagedReference (org.jboss.as.naming.ManagedReference)4 StartException (org.jboss.msc.service.StartException)4 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 ProcessApplicationDeploymentInfo (org.camunda.bpm.application.ProcessApplicationDeploymentInfo)1 ProcessApplicationDeploymentInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationDeploymentInfoImpl)1 ProcessApplicationInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationInfoImpl)1 BpmPlatformPlugin (org.camunda.bpm.container.impl.plugin.BpmPlatformPlugin)1 BpmPlatformPlugins (org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 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