Search in sources :

Example 1 with ProcessApplicationReference

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

the class DeployCmd method registerProcessApplication.

protected ProcessApplicationRegistration registerProcessApplication(CommandContext commandContext, DeploymentEntity deployment, Set<String> processKeysToRegisterFor) {
    ProcessApplicationDeploymentBuilderImpl appDeploymentBuilder = (ProcessApplicationDeploymentBuilderImpl) deploymentBuilder;
    final ProcessApplicationReference appReference = appDeploymentBuilder.getProcessApplicationReference();
    // build set of deployment ids this process app should be registered for:
    Set<String> deploymentsToRegister = new HashSet<String>(Collections.singleton(deployment.getId()));
    if (appDeploymentBuilder.isResumePreviousVersions()) {
        if (ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY.equals(appDeploymentBuilder.getResumePreviousVersionsBy())) {
            deploymentsToRegister.addAll(resumePreviousByProcessDefinitionKey(commandContext, deployment, processKeysToRegisterFor));
        } else if (ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME.equals(appDeploymentBuilder.getResumePreviousVersionsBy())) {
            deploymentsToRegister.addAll(resumePreviousByDeploymentName(commandContext, deployment));
        }
    }
    // register process application for deployments
    return new RegisterProcessApplicationCmd(deploymentsToRegister, appReference).execute(commandContext);
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationDeploymentBuilderImpl(org.camunda.bpm.engine.impl.repository.ProcessApplicationDeploymentBuilderImpl) HashSet(java.util.HashSet)

Example 2 with ProcessApplicationReference

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

the class DeleteDeploymentCmd method execute.

public Void execute(final CommandContext commandContext) {
    ensureNotNull("deploymentId", deploymentId);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkDeleteDeployment(deploymentId);
    }
    UserOperationLogManager logManager = commandContext.getOperationLogManager();
    List<PropertyChange> propertyChanges = Arrays.asList(new PropertyChange("cascade", null, cascade));
    logManager.logDeploymentOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, deploymentId, propertyChanges);
    commandContext.getDeploymentManager().deleteDeployment(deploymentId, cascade, skipCustomListeners, skipIoMappings);
    ProcessApplicationReference processApplicationReference = Context.getProcessEngineConfiguration().getProcessApplicationManager().getProcessApplicationForDeployment(deploymentId);
    DeleteDeploymentFailListener listener = new DeleteDeploymentFailListener(deploymentId, processApplicationReference, Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew());
    try {
        commandContext.runWithoutAuthorization(new Callable<Void>() {

            public Void call() throws Exception {
                new UnregisterProcessApplicationCmd(deploymentId, false).execute(commandContext);
                new UnregisterDeploymentCmd(Collections.singleton(deploymentId)).execute(commandContext);
                return null;
            }
        });
    } finally {
        try {
            commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener);
        } catch (Exception e) {
            TX_LOG.debugTransactionOperation("Could not register transaction synchronization. Probably the TX has already been rolled back by application code.");
            listener.execute(commandContext);
        }
    }
    return null;
}
Also used : UserOperationLogManager(org.camunda.bpm.engine.impl.persistence.entity.UserOperationLogManager) ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) DeleteDeploymentFailListener(org.camunda.bpm.engine.impl.persistence.deploy.DeleteDeploymentFailListener) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 3 with ProcessApplicationReference

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

the class ProcessApplicationContextUtil method getTargetProcessApplication.

public static ProcessApplicationReference getTargetProcessApplication(String deploymentId) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager();
    ProcessApplicationReference processApplicationForDeployment = processApplicationManager.getProcessApplicationForDeployment(deploymentId);
    return processApplicationForDeployment;
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationManager(org.camunda.bpm.engine.impl.application.ProcessApplicationManager) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 4 with ProcessApplicationReference

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

the class ProcessApplicationContextUtil method requiresContextSwitch.

public static boolean requiresContextSwitch(ProcessApplicationReference processApplicationReference) {
    final ProcessApplicationReference currentProcessApplication = Context.getCurrentProcessApplication();
    if (processApplicationReference == null) {
        return false;
    }
    if (currentProcessApplication == null) {
        return true;
    } else {
        if (!processApplicationReference.getName().equals(currentProcessApplication.getName())) {
            return true;
        } else {
            // check whether the thread context has been manipulated since last context switch. This can happen as a result of
            // an operation causing the container to switch to a different application.
            // Example: JavaDelegate implementation (inside PA) invokes an EJB from different application which in turn interacts with the Process engine.
            ClassLoader processApplicationClassLoader = ProcessApplicationClassloaderInterceptor.getProcessApplicationClassLoader();
            ClassLoader currentClassloader = ClassLoaderUtil.getContextClassloader();
            return currentClassloader != processApplicationClassLoader;
        }
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference)

Example 5 with ProcessApplicationReference

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

the class ProcessApplicationContextInterceptor method getPaReference.

protected ProcessApplicationReference getPaReference(ProcessApplicationIdentifier processApplicationIdentifier) {
    if (processApplicationIdentifier.getReference() != null) {
        return processApplicationIdentifier.getReference();
    } else if (processApplicationIdentifier.getProcessApplication() != null) {
        return processApplicationIdentifier.getProcessApplication().getReference();
    } else if (processApplicationIdentifier.getName() != null) {
        RuntimeContainerDelegate runtimeContainerDelegate = RuntimeContainerDelegate.INSTANCE.get();
        ProcessApplicationReference reference = runtimeContainerDelegate.getDeployedProcessApplication(processApplicationIdentifier.getName());
        if (reference == null) {
            throw LOG.paWithNameNotRegistered(processApplicationIdentifier.getName());
        } else {
            return reference;
        }
    } else {
        throw LOG.cannotReolvePa(processApplicationIdentifier);
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) RuntimeContainerDelegate(org.camunda.bpm.container.RuntimeContainerDelegate)

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