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

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

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ((ProcessEngineConfigurationImpl) cachedProcessEngine
                .getProcessEngineConfiguration()).getFlowable5CompatibilityHandler().getRawProcessConfiguration();

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

        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
    }
    processEngine = cachedProcessEngine;
}
 
Example 2
Source File: JPAEnhancedVariableTest.java    From flowable-engine 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/flowable.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ((ProcessEngineConfigurationImpl) cachedProcessEngine.getProcessEngineConfiguration()).getFlowable5CompatibilityHandler()
                .getRawProcessConfiguration();

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

        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();

        setupJPAVariables();
    }
    processEngine = cachedProcessEngine;
}
 
Example 3
Source File: HistoricJPAVariableTest.java    From flowable-engine 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/flowable.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

        org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ((ProcessEngineConfigurationImpl) cachedProcessEngine
                .getProcessEngineConfiguration()).getFlowable5CompatibilityHandler().getRawProcessConfiguration();

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

        entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
    }
    processEngine = cachedProcessEngine;
}
 
Example 4
Source File: JobExecutorJMXClientTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobExecutorJMXClient() throws Exception {
    String hostName = Utils.getHostName();
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/flowable");

    ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("flowable.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.flowable.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"));

    // again 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 5
Source File: ConnectionPoolTest.java    From flowable-engine 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.flowable.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 6
Source File: DisabledDefinitionInfoCacheTest.java    From flowable-engine 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/flowable.cfg.xml");

        cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
    }
    processEngine = cachedProcessEngine;
}
 
Example 7
Source File: ResourceFlowableExtension.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ProcessEngine initializeProcessEngine() {
    ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(configurationResource);
    if (processEngineName != null) {
        logger.info("Initializing process engine with name '{}'", processEngineName);
        config.setEngineName(processEngineName);
    }
    configurationConsumer.accept(config);
    ProcessEngine processEngine = config.buildProcessEngine();
    ProcessEngines.setInitialized(true);
    return processEngine;
}
 
Example 8
Source File: ConnectionPoolTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void testMyBatisConnectionPoolProperlyConfigured() {
    ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
            .createProcessEngineConfigurationFromResource("org/flowable/engine/test/db/connection-pool.flowable.cfg.xml");

    config.buildProcessEngine();

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

    assertThat(config.getJdbcMaxActiveConnections()).isEqualTo(maxActive);
    assertThat(config.getJdbcMaxIdleConnections()).isEqualTo(maxIdle);
    assertThat(config.getJdbcMaxCheckoutTime()).isEqualTo(maxCheckoutTime);
    assertThat(config.getJdbcMaxWaitTime()).isEqualTo(maxWaitTime);

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

    PooledDataSource pooledDataSource = (PooledDataSource) datasource;
    assertThat(pooledDataSource.getPoolMaximumActiveConnections()).isEqualTo(maxActive);
    assertThat(pooledDataSource.getPoolMaximumIdleConnections()).isEqualTo(maxIdle);
    assertThat(pooledDataSource.getPoolMaximumCheckoutTime()).isEqualTo(maxCheckoutTime);
    assertThat(pooledDataSource.getPoolTimeToWait()).isEqualTo(maxWaitTime);
}