<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    網路冷眼@BlogJava

    熙熙攘攘一閑人 以冷靜的眼光觀察技術
    posts - 88, comments - 193, trackbacks - 0, articles - 28
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    Chapter 3. Configuration(配置)

    Table of Contents

    Creating a ProcessEngine(建立一個流程引擎)
    ProcessEngineConfiguration bean
    Database configuration(數據庫配置)
    Job executor activation(作業執行器激活)
    Mail server configuration(郵件服務器配置)
    History configuration(歷史配置)
    Supported databases(支持的數據庫)
    Changing the database(改變數據庫)
    Downloading the Oracle driver(下載Oracle)

    Creating a ProcessEngine(建立一個流程引擎)

    The Activiti process engine is configured through a xml file called activiti.cfg.xml. Note that this is not applicable if you're using the Spring style of building a process engine.

    Activiti流程引擎通過一個叫做的xml文件來配置。注意你采用構建流程引擎的Spring風格的方式the Spring style of building a process engine,這種方式并不適合

    The easiest way to obtain a ProcessEngine, is to use the org.activiti.engine.ProcessEngines class:

    獲取ProcessEngine最容易的方式是使用org.activiti.engine.ProcessEngines類:

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine()

    This will look for an activiti.cfg.xml file on the classpath and construct an engine based on the configuration in that file. The following snippet shows an example configuration. The following sections will give a detailed overview of the configuration properties.

    這將在classpath上尋找 activiti.cfg.xml文件,并在那個文件的配置之上構建一個引擎。下列片段顯示了一個示例配置。下面部分將給出詳細的配置特性的總體概觀。

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <property name="databaseType" value="h2" />
    <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="false" />
    <property name="mailServerHost" value="mail.my-corp.com" />
    <property name="mailServerPort" value="5025" />
    </bean>
    </beans>

    Note that the configuration xml is in fact a Spring configuration. This does not mean that Activiti can only be used in a Spring environment! We are simply leveraging the parsing and dependency injection capabilitities of Spring internally for building up the engine.

    注意配置文件事實上是一個Spring配置。這并不意味著Activiti只能在Spring環境下使用! 為了構建引擎,我們在內部簡單地平衡了解析和Spring的依賴注入的能力。

    The ProcessEngineConfiguration object can also be created programmatically using the configuration file. It is also possible to use a different bean id (eg. see line 3).

    通過使用配置文件,也能通過編程方式建立ProcessEngineConfiguration對象。使用一個不同的bean id也是可能的。(例如,見第3行)。

    ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
    ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource);
    ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource, String beanName);
    ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(InputStream inputStream);
    ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(InputStream inputStream, String beanName);

    It is also possible not to use a configuration file, and create a configuration based on defaults (see the different supported classes for more information).

    不使用配置文件也是可能的,基于缺省建立一個配置(詳情參見不同支持的類(the different supported classes))

    ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
    ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();

    All these ProcessEngineConfiguration.createXXX() methods return a ProcessEngineConfiguration that can further be tweaked if needed. After calling the buildProcessEngine() operation, aProcessEngine is created:

    如果需要所有 ProcessEngineConfiguration.createXXX()的方法返回一個能進一步配置的ProcessEngineConfiguration 。在調用操作之后,建立一個ProcessEngine

    ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
    .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
    .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
    .setJobExecutorActivate(true)
    .buildProcessEngine();

    ProcessEngineConfiguration bean

    The activiti.cfg.xml must contain a bean that has the id 'processEngineConfiguration'.

    dd activiti.cfg.xml 必須包括具有id 'processEngineConfiguration'的bean。

     <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">

    This bean is then used to construct the ProcessEngine. There are multiple classes available that can be used to define the processEngineConfiguration. These classes represent different environments, and set defaults accordingly. It's a best practice to select the class the matches (the most) your environment, to minimalise the number of properties needed to configure the engine. Following classes are currently available (more will follow in future releases):

    得到這個bean然后用來構建e ProcessEngine。可以定義processEngineConfiguration的類有多個。這些類表示不同的環境,響應地設置為缺省。為了減少需要配置引擎的屬性數量,選擇的類以匹配環境是最佳實踐。當前可獲得的類如下(將來的版本將推出新的類)

    • org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration: the process engine is used in a standalone way. Activiti will take care of the transactions. By default, the database will only be checked when the engine boots (and an exception is thrown if there is no Activiti schema or the schema version is incorrect).

      org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration:以獨立方式運行的流程引擎。Activiti將考慮事務。缺省地,只有在引擎引導時檢查數據庫(如果沒有Activiti schema或者schema版本不正確,將拋出異常)。

    • org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration: this is a convience class for unit testing purposes. Activiti will take care of the transactions. An H2 in-memory database is used by default. The database will be created and dropped when the engine boots and shuts down. When using this, probably no additional configuration is needed (except when using for example the job executor or mail capabilities).

      org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration: 這是一個針對單元測試目的的便捷類。Activiti將考慮事務。缺省使用H2內存數據庫。當引擎引導并關閉時,數據庫將被建立和刪除。當使用時,可能需要額外的配置(當使用作業執行器或者郵件能力的示例除外)

    • org.activiti.spring.SpringProcessEngineConfiguration: To be used when the process engine is used in a Spring environment. See the Spring integration section for more information.

      org.activiti.spring.SpringProcessEngineConfiguration: 當在Spring環境下使用流程引擎時使用。詳情參見Spring集成部分the Spring integration section

    • org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration: ([EXPERIMENTAL]) to be used when the engine runs in standalone mode, with JTA transactions.

      org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration: ([EXPERIMENTAL])當引擎以帶有JTA事務的單獨模式運行時使用。

    Database configuration(數據庫配置)

    There are two ways to configure the database that the Activiti engine will use. The first option is to define the jdbc properties of the database:

    有兩種方式類配置引擎將使用的數據庫。第一個選項是定義數據庫的jdbc屬性:

    • jdbcUrl: jdbc url of the database.

      jdbcUrl: 數據庫的jdbc url。

    • jdbcDriver: implementation of the driver for the specific database type.

      jdbcDriver: 特定數據庫驅動的實現。

    • jdbcUsername: username to connect to the database.

      jdbcUsername: 連接到數據的用戶名。

    • jdbcPassword: password to connect to the database.

      jdbcPassword: 連接到數據庫的密碼。

    The datasource that is constructed based on the provided jdbc properties will have the default MyBatis connection pool settings. Following attributes can optionally be set to tweak that connection pool (taken from the MyBatis documentation):

    基于所提供的jdbc屬性所構建的數據源將有的連接池設置。

    • jdbcMaxActiveConnections: The number of active connections that the connection pool at maximum at any time can contain. Default is 10.

      jdbcMaxActiveConnections: 在任何時刻連接池最大能夠包含的可以激活的連接數。缺省為10.

    • jdbcMaxIdleConnections: The number of idle connections that the connection pool at maximum at any time can contain.

      jdbcMaxIdleConnections:在任何時刻連接池最大能夠包含的空閑的連接數

    • jdbcMaxCheckoutTime: The amount of time in milliseconds a connection can be 'checked out' from the connection pool before it is forcefully returned. Default is 20000 (20 seconds).

      jdbcMaxCheckoutTime: 在連接強制返回之前,能夠從連接池檢出一個連接所需的以毫秒計算的時間值。

    • jdbcMaxWaitTime: This is a low level setting that gives the pool a chance to print a log status and re-attempt the acquisition of a connection in the case that it’s taking unusually long (to avoid failing silently forever if the pool is misconfigured) Default is 20000 (20 seconds).

      jdbcMaxWaitTime: 這是一個底層的設置,給連接池一個打印日志狀態并重試連接獲取的機會。在這種情況下通常占用很長時間(以避免如果連接池位置不好導致導致悄無聲息地失敗),缺省時20000(20秒)。

    Example database configuration:

    示例數據庫配置:

    <property name="databaseType" value="h2" />
    <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />
    

    Alternatively, a javax.sql.DataSource implementation can be used (eg. DBCP from ):

    可選,可以使用 javax.sql.DataSource的實現(例如Apache Commons的DBCP):

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/activiti" />
    <property name="username" value="activiti" />
    <property name="password" value="activiti" />
    <property name="defaultAutoCommit" value="false" />
    </bean>
    <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    ...
    

    Note that Activiti does not ship with a library that allows to define such datasource. So you have to make sure that the libraries (eg. from DBCP) are on your classpath.

    注意Activiti并不包含允許定義如此數據源的Java庫。所以,確保這些(例如,從DBCP而來)在你的classpath里面。

    Following properties can be set, regardless of using the jdbc or datasource approach:

    不管采用jdbc還是數據源方法,可以設置下列屬性:

    • databaseType: indicates the type of database. This property is required when not using the default H2 database This setting will determine which create/drop scripts and queries will be used. See the 'supported databases' section for an overview of which types are supported.

      databaseType: 指示數據庫類型。當不是采用缺省的H2數據庫時xuyao 需要。這個設置將決定將要使用哪個建立/刪除腳本。要了解支持哪些類型的概要,請參見the 'supported databases' section

    • databaseSchemaUpdate: allows to set the strategy to handle the database schema on process engine boot and shutdown.

      databaseSchemaUpdate:允許當流程引擎引導和關閉時,設置處理數據庫結構采取的策略。

      • false (default): Checks the version of the DB schema against the library when the process engine is being created and throws an exception if the versions don't match.

        false (缺省):當流程引擎建立時,檢查DB和庫的版本。如果版本不匹配,將拋出異常。

      • true: Upon building of the process engine, a check is performed and an update of the schema is performed if it is necessary. If the schema doesn't exist, it is created.

        true:一旦流程引擎構建完成,執行一個檢查。如果有必要,更新數據庫的結構。如果結構不存在,就創建它。

      • create-drop: Creates the schema when the process engine is being created and drops the schema when the process engine is being closed.

        create-drop:在流程引擎創建時創建結構;當流程引擎時到達刪除結構。

    Job executor activation(作業執行器激活)

    The JobExecutor is a component that manages a couple of threads to fire timers (and later also asynchronous messages). For unit testing scenarios, it is cumbersome to work with multiple threads. Therefor the API allows to query for (ManagementService.createJobQuery) and execute jobs (ManagementService.executeJob) through the API so that job execution can be controlled from within a unit test. To avoid that the job executor interferes, it can be turned off.

    作業執行器是一個管理點火定時器一對線程的組件(之后也叫異步消息)。對于單元測試場景,和多個線程一道工作是麻煩的。所以API允許通過API查詢 (ManagementService.createJobQuery) 并執行作業 (ManagementService.executeJob) 以便從一個單元測試里控制作業執行。為了避免作業干擾,可以關掉它。

    By default, the JobExecutor is activated when the process engine boots. Specify

    缺省地,當流程引擎引導時激活JobExecutor。指定

    <property name="jobExecutorActivate" value="false" />

    when you don't want the JobExecutor to be activated upon process engine boot.

    當流程引擎引導時,并不想激活 JobExecutor。

    Mail server configuration(郵件服務器配置)

    Optional. Activiti supports sending e-mails in business processes. To actually send an e-mail, a valid SMTP mail server configuration is required. See the e-mail task for the configuration options.

    可選。. Activiti 支持在業務流程里發送電子郵件。事實上,為了發送郵件,需要配置一個有效的SMTP郵件服務器配置。這個配置可選項參見e-mail task

    History configuration(歷史配置)

    Optional. Allows to tweak settings that influence the history capabilities of the engine. See history configuration for more details.

    可選項。允許影響引擎的歷史能力history capabilities的設置。詳情參見history configuration

    <property name="history" value="audit" />

    Supported databases(支持的數據庫)

    Following are the types (case sensitive!) that Activiti uses to refer to databases.

    下表是Activiti所使用的數據庫表類型(大小寫敏感的)。

    Table 1.1. Supported databases

    Activiti database type
    Versions tested
    Notes

    h2
    1.2.132
    Default configured database

    mysql
    5.1.11

    oracle
    10.2.0

    postgres
    8.4

    db2
    not yet supported (coming soon, see ACT-330)

    mssql
    not yet supported (coming soon)

    Changing the database(改變數據庫)

    One of the things you probably want to do at some point, is configuring Activiti to use a different database. To configure the demo setup or to generate a configuration file for a different database, follow these steps:

    在某些點你可能想做的其中一件事是配置來使用不同的數據庫。為了配置演示安裝或者為不同數據庫產生一個配置文件,遵從這些步驟:

    • Edit setup/build.properties and change the db parameter to your type of database {oracle | mysql | postgresql | h2}.

      編輯 setup/build.properties 并將db參數變為你的數據庫的類型 {oracle | mysql | postgresql | h2}。

    • Edit setup/build.${db}.properties and change the JDBC connection parameters to those of your database installation.

      編輯setup/build.${db}.properties并將JDBC連接參數變為你所安裝數據庫的那些參數。

    To create a configuration file for your database based on the properties you've specified in the build.*.properties files run

    為了建立一個基于你所指定build.*.properties 文件的屬性的配置文件。請運行

    ant cfg.create

    from within the setup folder. The generate configuration file can now be found in setup/build/activiti-cfg. Also, for convenience, a jar called containing the configuration file can be found in setup/build

    setup 文件夾。產生的配置文件在setup/build/activiti-cfg里能夠找到。 為了方便起見,一個叫activiti-cfg.jar的jar包包含了能夠在setup/build 里找到的配置文件。

    If you want to run the demo setup on another database, first stop the demo setup with

    如果你想在另一個數據庫上運行演示安裝,首先用下面的命令停止示例安裝

    ant demo.stop demo.clean demo.start

    Then clean and re-start the demo setup with

    然后清除并重新啟動演示安裝:

    ant demo.clean demo.start

    Downloading the Oracle driver(下載Oracle)

    When you want to run the demo setup using oracle as datasource, an extra step is required BEFORE you call the ant target demo.start.

    當你想使用oracle作為數據源來運行演示安裝,在調用ant目標 demo.start,必須要有額外的步驟:

    主站蜘蛛池模板: 亚洲国产精品人人做人人爽| 亚洲第一永久在线观看| 未满十八18禁止免费无码网站| 亚洲图片校园春色| 高清在线亚洲精品国产二区| 久久精品中文字幕免费| 亚洲精品亚洲人成在线| 国产亚洲精品久久久久秋霞| 波多野结衣在线免费观看| 免费无遮挡无遮羞在线看| 亚洲国产成人精品无码一区二区| 免费在线观看一级毛片| 最近免费中文字幕大全免费 | 国产午夜无码片免费| 亚洲国产亚洲综合在线尤物| 亚洲免费日韩无码系列| 我的小后妈韩剧在线看免费高清版| 四虎影视久久久免费观看| 亚洲国产成人在线视频| 亚洲一级Av无码毛片久久精品| 在线视频观看免费视频18| 中文字幕免费在线观看动作大片| 波多野结衣亚洲一级| 亚洲VA成无码人在线观看天堂| 国产精品成人四虎免费视频| 18禁美女裸体免费网站| a高清免费毛片久久| 亚洲精品女同中文字幕| 亚洲国产综合人成综合网站00| 亚洲欧洲自拍拍偷午夜色无码| 国产精品四虎在线观看免费 | 超清首页国产亚洲丝袜| 麻豆国产VA免费精品高清在线 | 99久久国产免费-99久久国产免费| 国产亚洲高清在线精品不卡| 亚洲国产成人va在线观看网址| 亚洲va中文字幕无码久久| 亚洲成AⅤ人影院在线观看| 四虎影视大全免费入口| 无码乱肉视频免费大全合集| 久久国产免费观看精品|