Java Code Examples for org.activiti.engine.ProcessEngineConfiguration#createProcessEngineConfigurationFromResource()

The following examples show how to use org.activiti.engine.ProcessEngineConfiguration#createProcessEngineConfigurationFromResource() . 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: JPAEnhancedVariableTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeProcessEngine() {
  if (cachedProcessEngine == null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml");

    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

    EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class);

    entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();

    setupJPAVariables();
  }
  processEngine = cachedProcessEngine;
}
 
Example 2
Source File: HistoricJPAVariableTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeProcessEngine() {
	if (cachedProcessEngine==null) {
		ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
			.createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml");

		cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

		EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration
			.getSessionFactories()
			.get(EntityManagerSession.class);

		entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
	}
	processEngine = cachedProcessEngine;
}
 
Example 3
Source File: LeaveJpaEntityTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
protected void initializeProcessEngine() {
    if (cachedProcessEngine == null) {
        ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti.jpa.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration
                .getSessionFactories()
                .get(EntityManagerSession.class);

        System.out.println("entityManagerSessionFactory=" + entityManagerSessionFactory);
        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
    }
    processEngine = cachedProcessEngine;
}
 
Example 4
Source File: JPAVariableTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void initializeProcessEngine() {
  if (cachedProcessEngine==null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource("org/activiti5/standalone/jpa/activiti.cfg.xml");
    
    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
    
    org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl) 
        ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getActiviti5CompatibilityHandler().getRawProcessConfiguration();

    EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) activiti5ProcessEngineConfig
      .getSessionFactories()
      .get(EntityManagerSession.class);
    
    entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
  }
  processEngine = cachedProcessEngine;
}
 
Example 5
Source File: JPAEnhancedVariableTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeProcessEngine() {
  if (cachedProcessEngine == null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("org/activiti5/standalone/jpa/activiti.cfg.xml");

    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
    
    activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl) 
        ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getActiviti5CompatibilityHandler().getRawProcessConfiguration();

    EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) activiti5ProcessEngineConfig
        .getSessionFactories()
        .get(EntityManagerSession.class);

    entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();

    setupJPAVariables();
  }
  processEngine = cachedProcessEngine;
}
 
Example 6
Source File: HistoricJPAVariableTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeProcessEngine() {
  if (cachedProcessEngine==null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource("org/activiti5/standalone/jpa/activiti.cfg.xml");
    
    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
    
    org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl) 
        ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getActiviti5CompatibilityHandler().getRawProcessConfiguration();

    EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) activiti5ProcessEngineConfig
      .getSessionFactories()
      .get(EntityManagerSession.class);
    
    entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
  }
  processEngine = cachedProcessEngine;
}
 
Example 7
Source File: ProcessEngineCreationIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenDifferentBeanNameInXMLConfig_whenGetProcessEngineConfig_thenGotResult() {
    ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource("my.activiti.cfg.xml", "myProcessEngineConfiguration");
    ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
    assertNotNull(processEngine);
    assertEquals("baeldung", processEngine.getProcessEngineConfiguration().getJdbcUsername());
}
 
Example 8
Source File: JobExecutorJMXClientTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobExecutorJMXClient() throws InterruptedException, IOException, MalformedObjectNameException, AttributeNotFoundException, InstanceNotFoundException, MBeanException,
    ReflectionException {
  String hostName = Utils.getHostName();
  JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/activiti");

  ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
  processEngineConfig.buildProcessEngine();

  // wait for jmx server to come up
  Thread.sleep(500);
  JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

  MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
  ObjectName jobExecutorBeanName = new ObjectName("org.activiti.jmx.Mbeans:type=JobExecutor");

  processEngineConfig.getAsyncExecutor().shutdown();

  // first check that job executor is not activated and correctly reported
  // as being inactive
  assertFalse(processEngineConfig.isAsyncExecutorActivate());
  assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
  // now activate it remotely
  mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[] { true }, new String[] { Boolean.class.getName() });

  // check if it has the effect and correctly reported
  // assertTrue(processEngineConfig.getJobExecutor().isActive());
  assertTrue((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));

  // agani disable and check it
  mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[] { false }, new String[] { Boolean.class.getName() });

  // check if it has the effect and correctly reported
  assertFalse(processEngineConfig.isAsyncExecutorActivate());
  assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
}
 
Example 9
Source File: ProcessEngineCreationIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenDifferentNameXMLConfig_whenGetProcessEngineConfig_thenGotResult() {
    ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("my.activiti.cfg.xml");
    ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
    assertNotNull(processEngine);
    assertEquals("baeldung", processEngine.getProcessEngineConfiguration().getJdbcUsername());
}
 
Example 10
Source File: LeaveJpaEntityTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
    if (cachedProcessEngine == null) {
        ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti.jpa.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration
                .getSessionFactories()
                .get(EntityManagerSession.class);

        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
    }
    processEngine = cachedProcessEngine;
}
 
Example 11
Source File: LeaveJpaEntityTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
    if (cachedProcessEngine == null) {
        ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti.jpa.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration
                .getSessionFactories()
                .get(EntityManagerSession.class);

        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
    }
    processEngine = cachedProcessEngine;
}
 
Example 12
Source File: LeaveJpaEntityTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
    if (cachedProcessEngine == null) {
        ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti.jpa.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration
                .getSessionFactories()
                .get(EntityManagerSession.class);

        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
    }
    processEngine = cachedProcessEngine;
}
 
Example 13
Source File: DisabledDefinitionInfoCacheTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
  if (cachedProcessEngine==null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("org/activiti5/engine/test/bpmn/usertask/activiti.cfg.xml");
    
    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
  }
  processEngine = cachedProcessEngine;
}
 
Example 14
Source File: ConnectionPoolTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testMyBatisConnectionPoolProperlyConfigured() {
  ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("org/activiti5/engine/test/db/connection-pool.activiti.cfg.xml");
  
  config.buildProcessEngine();
  
  // Expected values
  int maxActive = 25;
  int maxIdle = 10;
  int maxCheckoutTime = 30000;
  int maxWaitTime = 25000;
  
  assertEquals(maxActive, config.getJdbcMaxActiveConnections());
  assertEquals(maxIdle, config.getJdbcMaxIdleConnections());
  assertEquals(maxCheckoutTime, config.getJdbcMaxCheckoutTime());
  assertEquals(maxWaitTime, config.getJdbcMaxWaitTime());
  
  // Verify that these properties are correctly set in the MyBatis datasource
  DataSource datasource = config.getDbSqlSessionFactory().getSqlSessionFactory().getConfiguration().getEnvironment().getDataSource();
  assertTrue(datasource instanceof PooledDataSource);
  
  PooledDataSource pooledDataSource = (PooledDataSource) datasource;
  assertEquals(maxActive, pooledDataSource.getPoolMaximumActiveConnections());
  assertEquals(maxIdle, pooledDataSource.getPoolMaximumIdleConnections());
  assertEquals(maxCheckoutTime, pooledDataSource.getPoolMaximumCheckoutTime());
  assertEquals(maxWaitTime, pooledDataSource.getPoolTimeToWait());
}
 
Example 15
Source File: JPAVariableTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
  if (cachedProcessEngine == null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml");

    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

    EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class);

    entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
  }
  processEngine = cachedProcessEngine;
}
 
Example 16
Source File: DisabledDefinitionInfoCacheTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
  if (cachedProcessEngine==null) {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("org/activiti/engine/test/bpmn/usertask/activiti.cfg.xml");
    
    cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
  }
  processEngine = cachedProcessEngine;
}
 
Example 17
Source File: ConnectionPoolTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testMyBatisConnectionPoolProperlyConfigured() {
  ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource("org/activiti/engine/test/db/connection-pool.activiti.cfg.xml");

  config.buildProcessEngine();

  // Expected values
  int maxActive = 25;
  int maxIdle = 10;
  int maxCheckoutTime = 30000;
  int maxWaitTime = 25000;

  assertEquals(maxActive, config.getJdbcMaxActiveConnections());
  assertEquals(maxIdle, config.getJdbcMaxIdleConnections());
  assertEquals(maxCheckoutTime, config.getJdbcMaxCheckoutTime());
  assertEquals(maxWaitTime, config.getJdbcMaxWaitTime());

  // Verify that these properties are correctly set in the MyBatis
  // datasource
  DataSource datasource = config.getDbSqlSessionFactory().getSqlSessionFactory().getConfiguration().getEnvironment().getDataSource();
  assertTrue(datasource instanceof PooledDataSource);

  PooledDataSource pooledDataSource = (PooledDataSource) datasource;
  assertEquals(maxActive, pooledDataSource.getPoolMaximumActiveConnections());
  assertEquals(maxIdle, pooledDataSource.getPoolMaximumIdleConnections());
  assertEquals(maxCheckoutTime, pooledDataSource.getPoolMaximumCheckoutTime());
  assertEquals(maxWaitTime, pooledDataSource.getPoolTimeToWait());
}
 
Example 18
Source File: ResourceActivitiTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
  ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(activitiConfigurationResource);
  if (processEngineName != null) {
    logger.info("Initializing process engine with name '" + processEngineName + "'");
    config.setProcessEngineName(processEngineName);
  }
  additionalConfiguration(config);
  processEngine = config.buildProcessEngine();
}