Search in sources :

Example 16 with ProcessApplicationReference

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

the class ScriptingEngines method getScriptEngineForLanguage.

/**
 * Loads the given script engine by language name. Will throw an exception if no script engine can be loaded for the given language name.
 *
 * @param language the name of the script language to lookup an implementation for
 * @return the script engine
 * @throws ProcessEngineException if no such engine can be found.
 */
public ScriptEngine getScriptEngineForLanguage(String language) {
    if (language != null) {
        language = language.toLowerCase();
    }
    ProcessApplicationReference pa = Context.getCurrentProcessApplication();
    ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
    ScriptEngine engine = null;
    if (config.isEnableFetchScriptEngineFromProcessApplication()) {
        if (pa != null) {
            engine = getPaScriptEngine(language, pa);
        }
    }
    if (engine == null) {
        engine = getGlobalScriptEngine(language);
    }
    return engine;
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ScriptEngine(javax.script.ScriptEngine)

Example 17 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference 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 18 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference 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 19 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference 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 20 with ProcessApplicationReference

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

the class GetProcessApplicationForDeploymentCmd method execute.

public String execute(CommandContext commandContext) {
    commandContext.getAuthorizationManager().checkCamundaAdmin();
    ProcessApplicationReference reference = Context.getProcessEngineConfiguration().getProcessApplicationManager().getProcessApplicationForDeployment(deploymentId);
    if (reference != null) {
        return reference.getName();
    } else {
        return null;
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference)

Aggregations

ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)39 Deployment (org.camunda.bpm.engine.repository.Deployment)10 Test (org.junit.Test)10 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)7 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)6 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5 ProcessApplicationInterface (org.camunda.bpm.application.ProcessApplicationInterface)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 RepositoryService (org.camunda.bpm.engine.RepositoryService)4 Command (org.camunda.bpm.engine.impl.interceptor.Command)4 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)4 InvocationContext (org.camunda.bpm.application.InvocationContext)3 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)3 ProcessApplicationManager (org.camunda.bpm.engine.impl.application.ProcessApplicationManager)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1