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);
}
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;
}
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;
}
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;
}
}
}
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);
}
}
Aggregations