org.camunda.bpm.container.RuntimeContainerDelegate Java Examples

The following examples show how to use org.camunda.bpm.container.RuntimeContainerDelegate. 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: SpringBootProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
  processApplicationNameFromAnnotation(applicationContext)
    .apply(springApplicationName)
    .ifPresent(this::setBeanName);

  if (camundaBpmProperties.getGenerateUniqueProcessApplicationName()) {
    setBeanName(CamundaBpmProperties.getUniqueName(CamundaBpmProperties.UNIQUE_APPLICATION_NAME_PREFIX));
  }

  String processEngineName = processEngine.getName();
  setDefaultDeployToEngineName(processEngineName);

  RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngine);

  properties.put(PROP_SERVLET_CONTEXT_PATH, contextPath);
  super.afterPropertiesSet();
}
 
Example #2
Source File: CdiProcessEngineTestCase.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpCdiProcessEngineTestCase() throws Exception {

  if(BpmPlatform.getProcessEngineService().getDefaultProcessEngine() == null) {
    RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngineRule.getProcessEngine());
  }

  beanManager = ProgrammaticBeanLookup.lookup(BeanManager.class);
  processEngine = processEngineRule.getProcessEngine();
  processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngineRule.getProcessEngine().getProcessEngineConfiguration();
  formService = processEngine.getFormService();
  historyService = processEngine.getHistoryService();
  identityService = processEngine.getIdentityService();
  managementService = processEngine.getManagementService();
  repositoryService = processEngine.getRepositoryService();
  runtimeService = processEngine.getRuntimeService();
  taskService = processEngine.getTaskService();
  authorizationService = processEngine.getAuthorizationService();
  filterService = processEngine.getFilterService();
  externalTaskService = processEngine.getExternalTaskService();
  caseService = processEngine.getCaseService();
  decisionService = processEngine.getDecisionService();
}
 
Example #3
Source File: CdiProcessEngineTestCase.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@After
public void tearDownCdiProcessEngineTestCase() throws Exception {
  RuntimeContainerDelegate.INSTANCE.get().unregisterProcessEngine(processEngine);
  beanManager = null;
  processEngine = null;
  processEngineConfiguration = null;
  formService = null;
  historyService = null;
  identityService = null;
  managementService = null;
  repositoryService = null;
  runtimeService = null;
  taskService = null;
  authorizationService = null;
  filterService = null;
  externalTaskService = null;
  caseService = null;
  decisionService = null;
  processEngineRule = null;
}
 
Example #4
Source File: SpringBootProcessApplication.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
  processApplicationNameFromAnnotation(applicationContext)
    .apply(springApplicationName)
    .ifPresent(this::setBeanName);

  if (camundaBpmProperties.getGenerateUniqueProcessApplicationName()) {
    setBeanName(CamundaBpmProperties.getUniqueName(CamundaBpmProperties.UNIQUE_APPLICATION_NAME_PREFIX));
  }

  String processEngineName = processEngine.getName();
  setDefaultDeployToEngineName(processEngineName);

  RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngine);

  properties.put(PROP_SERVLET_CONTEXT_PATH, contextPath);
  super.afterPropertiesSet();
}
 
Example #5
Source File: ProcessDefinitionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpRuntimeData() {
  ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
  setUpRuntimeDataForDefinition(mockDefinition);

  managementServiceMock = mock(ManagementService.class);
  when(processEngine.getManagementService()).thenReturn(managementServiceMock);
  when(managementServiceMock.getProcessApplicationForDeployment(MockProvider.EXAMPLE_DEPLOYMENT_ID)).thenReturn(MockProvider.EXAMPLE_PROCESS_APPLICATION_NAME);

  // replace the runtime container delegate & process application service with a mock

  ProcessApplicationService processApplicationService = mock(ProcessApplicationService.class);
  ProcessApplicationInfo appMock = MockProvider.createMockProcessApplicationInfo();
  when(processApplicationService.getProcessApplicationInfo(MockProvider.EXAMPLE_PROCESS_APPLICATION_NAME)).thenReturn(appMock);

  RuntimeContainerDelegate delegate = mock(RuntimeContainerDelegate.class);
  when(delegate.getProcessApplicationService()).thenReturn(processApplicationService);
  RuntimeContainerDelegate.INSTANCE.set(delegate);
}
 
Example #6
Source File: ProcessApplicationContextInterceptor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example #7
Source File: AbstractProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void deploy() {
  if (isDeployed) {
    LOG.alreadyDeployed();
  } else {
    // deploy the application
    RuntimeContainerDelegate.INSTANCE.get().deployProcessApplication(this);
    isDeployed = true;
  }
}
 
Example #8
Source File: ProcessApplicationElResolverTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void setUp() throws Exception {
  runtimeContainerDelegate = RuntimeContainerDelegate.INSTANCE.get();
  runtimeContainerDelegate.registerProcessEngine(processEngine);

  callingApp = new CallingProcessApplication();
  calledApp = new CalledProcessApplication();

  callingApp.deploy();
  calledApp.deploy();
}
 
Example #9
Source File: PlatformJobExecutorActivateTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void undeployPlatform() {
  RuntimeContainerDelegateImpl containerDelegate = (RuntimeContainerDelegateImpl) RuntimeContainerDelegate.INSTANCE.get();
  containerDelegate.getServiceContainer().createUndeploymentOperation("deploy BPM platform")
    .addStep(new StopJobExecutorStep())
    .addStep(new StopProcessEnginesStep())
    .addStep(new StopManagedThreadPoolStep())
    .execute();
}
 
Example #10
Source File: PlatformJobExecutorActivateTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void deployPlatform(BpmPlatformXmlImpl bpmPlatformXml) {
  RuntimeContainerDelegateImpl containerDelegate = (RuntimeContainerDelegateImpl) RuntimeContainerDelegate.INSTANCE.get();
  containerDelegate.getServiceContainer().createDeploymentOperation("deploy BPM platform")
    .addAttachment(Attachments.BPM_PLATFORM_XML, bpmPlatformXml)
    .addStep(new StartManagedThreadPoolStep())
    .addStep(new StartJobExecutorStep())
    .addStep(new PlatformXmlStartProcessEnginesStep())
    .execute();
}
 
Example #11
Source File: RuntimeContainerJobExecutor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Runnable getExecuteJobsRunnable(List<String> jobIds, ProcessEngineImpl processEngine) {
  final RuntimeContainerDelegate runtimeContainerDelegate = getRuntimeContainerDelegate();
  final ExecutorService executorService = runtimeContainerDelegate.getExecutorService();

  return executorService.getExecuteJobsRunnable(jobIds, processEngine);
}
 
Example #12
Source File: RuntimeContainerJobExecutor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void executeJobs(List<String> jobIds, ProcessEngineImpl processEngine) {

    final RuntimeContainerDelegate runtimeContainerDelegate = getRuntimeContainerDelegate();
    final ExecutorService executorService = runtimeContainerDelegate.getExecutorService();

    Runnable executeJobsRunnable = getExecuteJobsRunnable(jobIds, processEngine);

    // delegate job execution to runtime container
    if(!executorService.schedule(executeJobsRunnable, false)) {

      logRejectedExecution(processEngine, jobIds.size());
      rejectedJobsHandler.jobsRejected(jobIds, processEngine, this);
    }
  }
 
Example #13
Source File: AbstractProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void undeploy() {
  if (!isDeployed) {
    LOG.notDeployed();
  } else {
    // delegate stopping of the process application to the runtime container.
    RuntimeContainerDelegate.INSTANCE.get().undeployProcessApplication(this);
    isDeployed = false;
  }
}
 
Example #14
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void start(StartContext context) throws StartException {
  serviceContainer = context.getController().getServiceContainer();
  childTarget = context.getChildTarget();

  startTrackingServices();
  createJndiBindings();

  // set this implementation as Runtime Container
  RuntimeContainerDelegate.INSTANCE.set(this);
}
 
Example #15
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void start(StartContext context) throws StartException {
  serviceContainer = context.getController().getServiceContainer();
  childTarget = context.getChildTarget();

  startTrackingServices();
  createJndiBindings();

  // set this implementation as Runtime Container
  RuntimeContainerDelegate.INSTANCE.set(this);
}
 
Example #16
Source File: ManagedProcessEngineFactoryBean.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessEngine getObject() throws Exception {
  ProcessEngine processEngine = super.getObject();
  
  RuntimeContainerDelegate runtimeContainerDelegate = getRuntimeContainerDelegate();
  runtimeContainerDelegate.registerProcessEngine(processEngine);
  
  return processEngine;
}
 
Example #17
Source File: Activator.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
@Override
public void init(BundleContext context, DependencyManager manager)
		throws Exception {

	RuntimeContainerDelegate.INSTANCE.set(new OSGiRuntimeContainerDelegate(
			context));
	manager.add(createComponent().setImplementation(
			ProcessApplicationDeployer.class).add(
			createServiceDependency().setService(
					ProcessApplicationInterface.class).setCallbacks(
					"addProcessApplication", "removeProcessApplication")));
}
 
Example #18
Source File: RuntimeContainerJobExecutor.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected RuntimeContainerDelegate getRuntimeContainerDelegate() {
  return RuntimeContainerDelegate.INSTANCE.get();
}
 
Example #19
Source File: EjbBpmPlatformBootstrap.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected RuntimeContainerDelegateImpl getContainerDelegate() {
  return (RuntimeContainerDelegateImpl) RuntimeContainerDelegate.INSTANCE.get();
}
 
Example #20
Source File: TaskRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Before
public void setUpRuntimeData() {
  taskServiceMock = mock(TaskService.class);
  when(processEngine.getTaskService()).thenReturn(taskServiceMock);

  mockTask = MockProvider.createMockTask();
  mockQuery = mock(TaskQuery.class);
  when(mockQuery.initializeFormKeys()).thenReturn(mockQuery);
  when(mockQuery.taskId(anyString())).thenReturn(mockQuery);
  when(mockQuery.singleResult()).thenReturn(mockTask);
  when(taskServiceMock.createTaskQuery()).thenReturn(mockQuery);

  List<IdentityLink> identityLinks = new ArrayList<>();
  mockAssigneeIdentityLink = MockProvider.createMockUserAssigneeIdentityLink();
  identityLinks.add(mockAssigneeIdentityLink);
  mockOwnerIdentityLink = MockProvider.createMockUserOwnerIdentityLink();
  identityLinks.add(mockOwnerIdentityLink);
  mockCandidateGroupIdentityLink = MockProvider.createMockCandidateGroupIdentityLink();
  identityLinks.add(mockCandidateGroupIdentityLink);
  mockCandidateGroup2IdentityLink = MockProvider.createAnotherMockCandidateGroupIdentityLink();
  identityLinks.add(mockCandidateGroup2IdentityLink);
  when(taskServiceMock.getIdentityLinksForTask(EXAMPLE_TASK_ID)).thenReturn(identityLinks);

  mockTaskComment = MockProvider.createMockTaskComment();
  when(taskServiceMock.getTaskComment(EXAMPLE_TASK_ID, EXAMPLE_TASK_COMMENT_ID)).thenReturn(mockTaskComment);
  mockTaskComments = MockProvider.createMockTaskComments();
  when(taskServiceMock.getTaskComments(EXAMPLE_TASK_ID)).thenReturn(mockTaskComments);
  when(taskServiceMock.createComment(EXAMPLE_TASK_ID, null, EXAMPLE_TASK_COMMENT_FULL_MESSAGE)).thenReturn(mockTaskComment);

  mockTaskAttachment = MockProvider.createMockTaskAttachment();
  when(taskServiceMock.getTaskAttachment(EXAMPLE_TASK_ID, EXAMPLE_TASK_ATTACHMENT_ID)).thenReturn(mockTaskAttachment);
  mockTaskAttachments = MockProvider.createMockTaskAttachments();
  when(taskServiceMock.getTaskAttachments(EXAMPLE_TASK_ID)).thenReturn(mockTaskAttachments);
  when(taskServiceMock.createAttachment(anyString(), anyString(), anyString(), anyString(), anyString(), anyString())).thenReturn(mockTaskAttachment);
  when(taskServiceMock.createAttachment(anyString(), anyString(), anyString(), anyString(), anyString(), any(InputStream.class))).thenReturn(mockTaskAttachment);
  when(taskServiceMock.getTaskAttachmentContent(EXAMPLE_TASK_ID, EXAMPLE_TASK_ATTACHMENT_ID)).thenReturn(new ByteArrayInputStream(createMockByteData()));

  formServiceMock = mock(FormService.class);
  when(processEngine.getFormService()).thenReturn(formServiceMock);
  TaskFormData mockFormData = MockProvider.createMockTaskFormData();
  when(formServiceMock.getTaskFormData(anyString())).thenReturn(mockFormData);

  VariableMap variablesMock = MockProvider.createMockFormVariables();
  when(formServiceMock.getTaskFormVariables(eq(EXAMPLE_TASK_ID), Matchers.<Collection<String>>any(), anyBoolean())).thenReturn(variablesMock);

  repositoryServiceMock = mock(RepositoryService.class);
  when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
  ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
  when(repositoryServiceMock.getProcessDefinition(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(mockDefinition);

  managementServiceMock = mock(ManagementService.class);
  when(processEngine.getManagementService()).thenReturn(managementServiceMock);
  when(managementServiceMock.getProcessApplicationForDeployment(MockProvider.EXAMPLE_DEPLOYMENT_ID)).thenReturn(MockProvider.EXAMPLE_PROCESS_APPLICATION_NAME);
  when(managementServiceMock.getHistoryLevel()).thenReturn(ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL);

  HistoryService historyServiceMock = mock(HistoryService.class);
  when(processEngine.getHistoryService()).thenReturn(historyServiceMock);
  historicTaskInstanceQueryMock = mock(HistoricTaskInstanceQuery.class);
  when(historyServiceMock.createHistoricTaskInstanceQuery()).thenReturn(historicTaskInstanceQueryMock);
  when(historicTaskInstanceQueryMock.taskId(eq(EXAMPLE_TASK_ID))).thenReturn(historicTaskInstanceQueryMock);
  HistoricTaskInstance historicTaskInstanceMock = createMockHistoricTaskInstance();
  when(historicTaskInstanceQueryMock.singleResult()).thenReturn(historicTaskInstanceMock);

  // replace the runtime container delegate & process application service with a mock

  ProcessApplicationService processApplicationService = mock(ProcessApplicationService.class);
  ProcessApplicationInfo appMock = MockProvider.createMockProcessApplicationInfo();
  when(processApplicationService.getProcessApplicationInfo(MockProvider.EXAMPLE_PROCESS_APPLICATION_NAME)).thenReturn(appMock);

  RuntimeContainerDelegate delegate = mock(RuntimeContainerDelegate.class);
  when(delegate.getProcessApplicationService()).thenReturn(processApplicationService);
  RuntimeContainerDelegate.INSTANCE.set(delegate);
}
 
Example #21
Source File: PlatformJobExecutorActivateTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected ProcessEngine getProcessEngine(String engineName) {
  RuntimeContainerDelegateImpl containerDelegate = (RuntimeContainerDelegateImpl) RuntimeContainerDelegate.INSTANCE.get();
  return containerDelegate.getProcessEngine(engineName);
}
 
Example #22
Source File: ManagedProcessEngineFactoryBean.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected RuntimeContainerDelegate getRuntimeContainerDelegate() {
  return RuntimeContainerDelegate.INSTANCE.get();
}
 
Example #23
Source File: TomcatBpmPlatformBootstrap.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.START_EVENT.equals(event.getType())) {

      // the Apache Tomcat integration uses the Jmx Container for managing process engines and applications.
      containerDelegate = (RuntimeContainerDelegateImpl) RuntimeContainerDelegate.INSTANCE.get();

      deployBpmPlatform(event);

    }
    else if (Lifecycle.STOP_EVENT.equals(event.getType())) {

      undeployBpmPlatform(event);

    }

  }
 
Example #24
Source File: BpmPlatform.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static ProcessApplicationService getProcessApplicationService() {
  return RuntimeContainerDelegate.INSTANCE.get().getProcessApplicationService();
}
 
Example #25
Source File: BpmPlatform.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static ProcessEngineService getProcessEngineService() {
  return RuntimeContainerDelegate.INSTANCE.get().getProcessEngineService();
}
 
Example #26
Source File: InjectDefaultProcessEngineTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void tearDownCdiProcessEngineTestCase() throws Exception {
  RuntimeContainerDelegate.INSTANCE.get().unregisterProcessEngine(processEngineRule.getProcessEngine());
}
 
Example #27
Source File: InjectDefaultProcessEngineTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Before
public void init() {
  if(BpmPlatform.getProcessEngineService().getDefaultProcessEngine() == null) {
    RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngineRule.getProcessEngine());
  }
}
 
Example #28
Source File: InjectCustomProcessEngineTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void tearDownCdiProcessEngineTestCase() throws Exception {
  RuntimeContainerDelegate.INSTANCE.get().unregisterProcessEngine(processEngineRule.getProcessEngine());
}
 
Example #29
Source File: InjectCustomProcessEngineTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Before
public void init() {
  if(BpmPlatform.getProcessEngineService().getDefaultProcessEngine() == null) {
    RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngineRule.getProcessEngine());
  }
}
 
Example #30
Source File: SpringBootProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void destroy() throws Exception {
  super.destroy();
  RuntimeContainerDelegate.INSTANCE.get().unregisterProcessEngine(processEngine);
}