1-0 创建ProcessEngineConfiguration实例

ProcessEngineConfiguration对象代表activiti流程引擎的全部配置,ProcessEngineConfiguration提供静态方法解析配置文件,返回ProcessEngineConfiguration实例。

  1. 默认从classpath下读取activiti.cfg.xml的文件,启动名为processEngineConfiguration的bean实例。
    ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault()
  2. classpath读取指定配置文件,也可自定义processEngineConfiguration的bean名称  
  // 指定配置文件创建ProcessEngineConfiguration实例

  ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("my-activiti.xml");



  //指定配置文件创建bean名称为myconfig的ProcessEngineConfiguration

  ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("my-activiti.xml", "myconfig");

  3.根据配置文件输入流创建

        File file = new File("resource/input-stream.xml");

        // 得到文件输入流

        InputStream fis = new FileInputStream(file);

        // 根据配置文件流创建ProcessEngineConfiguration

        ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(fis);

  4.不从配置文件中创建,在代码中创建

  StandaloneInMemProcessEngineConfiguration 是StandaloneProcessEngineConfiguration的子类,StandaloneInMemProcessEngineConfiguration 特别指定

  了DatabaseSchemaUpdate(create-drop) 和 JdbcUrl(jdbc:h2:mem:activiti) 。

        //ProcessEngineConfiguration config = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();

        ProcessEngineConfiguration config = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();

        // 默认值为false

        System.out.println(config.getDatabaseSchemaUpdate());

        // 默认值为jdbc:h2:tcp://localhost/activiti

        System.out.println(config.getJdbcUrl());

        //使用自定义配置

        config.setJdbcUrl("jdbcUrl");

可以将StandaloneInMemProcessEngineConfiguration配置为bean的class来使用,但是要注意属性的默认值是不是业务所需要的。

 

你可能感兴趣的:(configuration)