org.camunda.bpm.application.ProcessApplicationReference Java Examples
The following examples show how to use
org.camunda.bpm.application.ProcessApplicationReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeploymentAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testUnregisterProcessApplicationWithoutAuthorization() { // given EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); String deploymentId = createDeployment(null, FIRST_RESOURCE).getId(); ProcessApplicationReference reference = processApplication.getReference(); registerProcessApplication(deploymentId, reference); try { // when managementService.unregisterProcessApplication(deploymentId, true); fail("Exception expected: It should not be possible to unregister a process application"); } catch (AuthorizationException e) { //then String message = e.getMessage(); assertTextPresent(REQUIRED_ADMIN_AUTH_EXCEPTION, message); } deleteDeployment(deploymentId); }
Example #2
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected static TestProvider decisionRequirementsDefinitionTestProvider() { return new TestProvider() { @Override public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) { return new Command<ProcessApplicationReference>() { public ProcessApplicationReference execute(CommandContext commandContext) { ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration(); DeploymentCache deploymentCache = configuration.getDeploymentCache(); DecisionRequirementsDefinitionEntity definition = deploymentCache.findDeployedDecisionRequirementsDefinitionById(definitionId); return ProcessApplicationContextUtil.getTargetProcessApplication(definition); } }; } @Override public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) { return repositoryService.createDecisionRequirementsDefinitionQuery().decisionRequirementsDefinitionKey(key).latestVersion().singleResult().getId(); } }; }
Example #3
Source File: ProcessApplicationContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExecutionInPAContextByName() throws Exception { Assert.assertNull(Context.getCurrentProcessApplication()); ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext( new Callable<ProcessApplicationReference>() { @Override public ProcessApplicationReference call() throws Exception { return getCurrentContextApplication(); } }, pa.getName()); Assert.assertEquals(contextPA.getProcessApplication(), pa); Assert.assertNull(Context.getCurrentProcessApplication()); }
Example #4
Source File: ProcessApplicationContextUtil.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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; } } }
Example #5
Source File: DeploymentAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testGetProcessApplicationForDeploymentAsCamundaAdmin() { // given identityService.setAuthentication(userId, Collections.singletonList(Groups.CAMUNDA_ADMIN)); EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); String deploymentId = createDeployment(null, FIRST_RESOURCE).getId(); ProcessApplicationReference reference = processApplication.getReference(); registerProcessApplication(deploymentId, reference); // when String application = managementService.getProcessApplicationForDeployment(deploymentId); // then assertNotNull(application); deleteDeployment(deploymentId); }
Example #6
Source File: ProcessApplicationContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void testExecuteWithInvocationContext() throws Exception { // given a process application which extends the default one // - using a spy for verify the invocations TestApplicationWithoutEngine processApplication = spy(pa); ProcessApplicationReference processApplicationReference = mock(ProcessApplicationReference.class); when(processApplicationReference.getProcessApplication()).thenReturn(processApplication); // when execute with context InvocationContext invocationContext = new InvocationContext(mock(BaseDelegateExecution.class)); Context.executeWithinProcessApplication(mock(Callable.class), processApplicationReference, invocationContext); // then the execute method should be invoked with context verify(processApplication).execute(any(Callable.class), eq(invocationContext)); // and forward to call to the default execute method verify(processApplication).execute(any(Callable.class)); }
Example #7
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected static TestProvider decisionDefinitionTestProvider() { return new TestProvider() { @Override public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) { return new Command<ProcessApplicationReference>() { public ProcessApplicationReference execute(CommandContext commandContext) { ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration(); DeploymentCache deploymentCache = configuration.getDeploymentCache(); DecisionDefinitionEntity definition = deploymentCache.findDeployedDecisionDefinitionById(definitionId); return ProcessApplicationContextUtil.getTargetProcessApplication(definition); } }; } @Override public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) { return repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).latestVersion().singleResult().getId(); } }; }
Example #8
Source File: CommandContext.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void performOperation(final CmmnAtomicOperation executionOperation, final CaseExecutionEntity execution) { ProcessApplicationReference targetProcessApplication = getTargetProcessApplication(execution); if(requiresContextSwitch(targetProcessApplication)) { Context.executeWithinProcessApplication(new Callable<Void>() { public Void call() throws Exception { performOperation(executionOperation, execution); return null; } }, targetProcessApplication, new InvocationContext(execution)); } else { try { Context.setExecutionContext(execution); LOG.debugExecutingAtomicOperation(executionOperation, execution); executionOperation.execute(execution); } finally { Context.removeExecutionContext(); } } }
Example #9
Source File: ProcessApplicationContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExecutionInPAContextByReference() throws Exception { Assert.assertNull(Context.getCurrentProcessApplication()); ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext( new Callable<ProcessApplicationReference>() { @Override public ProcessApplicationReference call() throws Exception { return getCurrentContextApplication(); } }, pa.getReference()); Assert.assertEquals(contextPA.getProcessApplication(), pa); Assert.assertNull(Context.getCurrentProcessApplication()); }
Example #10
Source File: DeploymentAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testUnregisterProcessApplicationAsCamundaAdmin() { // given identityService.setAuthentication(userId, Collections.singletonList(Groups.CAMUNDA_ADMIN)); EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); String deploymentId = createDeployment(null, FIRST_RESOURCE).getId(); ProcessApplicationReference reference = processApplication.getReference(); registerProcessApplication(deploymentId, reference); // when managementService.unregisterProcessApplication(deploymentId, true); // then assertNull(getProcessApplicationForDeployment(deploymentId)); deleteDeployment(deploymentId); }
Example #11
Source File: ProcessApplicationContextUtil.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public static ProcessApplicationReference getTargetProcessApplication(ResourceDefinitionEntity definition) { ProcessApplicationReference reference = getTargetProcessApplication(definition.getDeploymentId()); if (reference == null && areProcessApplicationsRegistered()) { ResourceDefinitionEntity previous = definition.getPreviousDefinition(); // do it in a iterative way instead of recursive to avoid // a possible StackOverflowException in cases with a lot // of versions of a definition while (previous != null) { reference = getTargetProcessApplication(previous.getDeploymentId()); if (reference == null) { previous = previous.getPreviousDefinition(); } else { return reference; } } } return reference; }
Example #12
Source File: DefaultDelegateInterceptor.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void handleInvocation(final DelegateInvocation invocation) throws Exception { final ProcessApplicationReference processApplication = getProcessApplicationForInvocation(invocation); if (processApplication != null && ProcessApplicationContextUtil.requiresContextSwitch(processApplication)) { Context.executeWithinProcessApplication(new Callable<Void>() { @Override public Void call() throws Exception { handleInvocation(invocation); return null; } }, processApplication, new InvocationContext(invocation.getContextExecution())); } else { handleInvocationInContext(invocation); } }
Example #13
Source File: DelegateFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected <T> T performContextSwitch(final Callable<T> callable) { ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication(deploymentId); if(targetProcessApplication != null) { return Context.executeWithinProcessApplication(new Callable<T>() { public T call() throws Exception { return doCall(callable); } }, targetProcessApplication); } else { return doCall(callable); } }
Example #14
Source File: DeploymentAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testRegisterProcessApplicationAsCamundaAdmin() { // given identityService.setAuthentication(userId, Collections.singletonList(Groups.CAMUNDA_ADMIN)); EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); ProcessApplicationReference reference = processApplication.getReference(); String deploymentId = createDeployment(null, FIRST_RESOURCE).getId(); // when ProcessApplicationRegistration registration = managementService.registerProcessApplication(deploymentId, reference); // then assertNotNull(registration); assertNotNull(getProcessApplicationForDeployment(deploymentId)); deleteDeployment(deploymentId); }
Example #15
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected static TestProvider caseDefinitionTestProvider() { return new TestProvider() { @Override public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) { return new Command<ProcessApplicationReference>() { public ProcessApplicationReference execute(CommandContext commandContext) { ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration(); DeploymentCache deploymentCache = configuration.getDeploymentCache(); CaseDefinitionEntity definition = deploymentCache.findDeployedCaseDefinitionById(definitionId); return ProcessApplicationContextUtil.getTargetProcessApplication(definition); } }; } @Override public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) { return repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult().getId(); } }; }
Example #16
Source File: ProcessApplicationContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testExecutionInPAContextbyRawPA() throws Exception { Assert.assertNull(Context.getCurrentProcessApplication()); ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext( new Callable<ProcessApplicationReference>() { @Override public ProcessApplicationReference call() throws Exception { return getCurrentContextApplication(); } }, pa); Assert.assertEquals(contextPA.getProcessApplication(), pa); Assert.assertNull(Context.getCurrentProcessApplication()); }
Example #17
Source File: DeploymentAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testGetProcessApplicationForDeploymentWithoutAuthorization() { // given EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); String deploymentId = createDeployment(null, FIRST_RESOURCE).getId(); ProcessApplicationReference reference = processApplication.getReference(); registerProcessApplication(deploymentId, reference); try { // when managementService.getProcessApplicationForDeployment(deploymentId); fail("Exception expected: It should not be possible to get the process application"); } catch (AuthorizationException e) { //then String message = e.getMessage(); assertTextPresent(REQUIRED_ADMIN_AUTH_EXCEPTION, message); } deleteDeployment(deploymentId); }
Example #18
Source File: AbstractPaLocalScriptEngineTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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(); }
Example #19
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void registrationNotFoundByDeploymentId() { // given ProcessApplicationReference reference = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); assertEquals(reference, getProcessApplicationForDeployment(deployment1.getId())); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); // then assertNull(getProcessApplicationForDeployment(deployment2.getId())); }
Example #20
Source File: ProcessApplicationEventListenerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); } }
Example #21
Source File: ProcessApplicationEventListenerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void performNotification(final DelegateExecution execution, Callable<Void> notification) throws Exception { final ProcessApplicationReference processApp = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); if (processApp == null) { // ignore silently LOG.noTargetProcessApplicationForExecution(execution); } else { if (ProcessApplicationContextUtil.requiresContextSwitch(processApp)) { // this should not be necessary since context switch is already performed by OperationContext and / or DelegateInterceptor Context.executeWithinProcessApplication(notification, processApp, new InvocationContext(execution)); } else { // context switch already performed notification.call(); } } }
Example #22
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected static TestProvider processDefinitionTestProvider() { return new TestProvider() { @Override public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) { return new Command<ProcessApplicationReference>() { public ProcessApplicationReference execute(CommandContext commandContext) { ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration(); DeploymentCache deploymentCache = configuration.getDeploymentCache(); ProcessDefinitionEntity definition = deploymentCache.findDeployedProcessDefinitionById(definitionId); return ProcessApplicationContextUtil.getTargetProcessApplication(definition); } }; } @Override public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) { return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId(); } }; }
Example #23
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void registrationFoundFromPreviousDefinition() { // given ProcessApplicationReference reference = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String definitionId = getLatestDefinitionIdByKey(definitionKey1); // then assertEquals(reference, getProcessApplicationForDefinition(definitionId)); // and the reference is not cached assertNull(getProcessApplicationForDeployment(deployment2.getId())); }
Example #24
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void registrationFoundFromLatestDeployment() { // given ProcessApplicationReference reference1 = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference1) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); // when ProcessApplicationReference reference2 = processApplication.getReference(); Deployment deployment2 = repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String definitionId = getLatestDefinitionIdByKey(definitionKey1); // then assertEquals(reference2, getProcessApplicationForDefinition(definitionId)); assertEquals(reference2, getProcessApplicationForDeployment(deployment2.getId())); }
Example #25
Source File: TypedValueField.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected static VariableSerializers getCurrentPaSerializers() { if (Context.getCurrentProcessApplication() != null) { ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication(); try { ProcessApplicationInterface processApplicationInterface = processApplicationReference.getProcessApplication(); ProcessApplicationInterface rawPa = processApplicationInterface.getRawObject(); if (rawPa instanceof AbstractProcessApplication) { return ((AbstractProcessApplication) rawPa).getVariableSerializers(); } else { return null; } } catch (ProcessApplicationUnavailableException e) { throw LOG.cannotDeterminePaDataformats(e); } } else { return null; } }
Example #26
Source File: RedeploymentProcessApplicationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public ProcessApplicationReference getReference() { if (reference == null) { reference = super.getReference(); } return reference; }
Example #27
Source File: ProcessApplicationContextUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static ProcessApplicationReference getTargetProcessApplication(CoreExecution execution) { if (execution instanceof ExecutionEntity) { return getTargetProcessApplication((ExecutionEntity) execution); } else { return getTargetProcessApplication((CaseExecutionEntity) execution); } }
Example #28
Source File: ProcessApplicationContextUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static ProcessApplicationReference getTargetProcessApplication(String deploymentId) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager(); ProcessApplicationReference processApplicationForDeployment = processApplicationManager.getProcessApplicationForDeployment(deploymentId); return processApplicationForDeployment; }
Example #29
Source File: ProcessApplicationContextUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static ProcessApplicationReference getTargetProcessApplication(TaskEntity task) { if (task.getProcessDefinition() != null) { return getTargetProcessApplication(task.getProcessDefinition()); } else if (task.getCaseDefinition() != null) { return getTargetProcessApplication(task.getCaseDefinition()); } else { return null; } }
Example #30
Source File: Context.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static ProcessApplicationReference getCurrentProcessApplication() { Deque<ProcessApplicationReference> stack = getStack(processApplicationContext); if(stack.isEmpty()) { return null; } else { return stack.peek(); } }