提交 d64fad8b 编写于 作者: J jbarrez

ACT-134: renamed configuration parameters

上级 587b501c
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="@db@" schema-strategy="check-version">
<database type="@db@" schema-strategy="check-version">
<jdbc url="@jdbc.url@"
driver="@jdbc.driver@"
username="@jdbc.username@"
password="@jdbc.password@" />
</database>
<job-executor auto-activate="on" />
<job-executor activate="on" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="create-drop">
<database type="h2" schema-strategy="create-drop">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
......@@ -63,12 +63,12 @@ public class CycleDbSqlSessionFactory extends DbSqlSessionFactory {
@Override
public void dbSchemaCreate() {
executeSchemaResource("create", databaseName, sqlSessionFactory);
executeSchemaResource("create", databaseType, sqlSessionFactory);
}
@Override
public void dbSchemaDrop() {
executeSchemaResource("drop", databaseName, sqlSessionFactory);
executeSchemaResource("drop", databaseType, sqlSessionFactory);
}
public static void executeSchemaResource(String operation, String databaseName, SqlSessionFactory sqlSessionFactory) {
......
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="create-drop">
<database type="h2" schema-strategy="create-drop">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
......@@ -118,9 +118,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property><name>process.engine.initializer</name><value>org.activiti.spring.SpringProcessEngineInitializer</value></property>
</systemProperties>
<excludes>
<exclude>**/*TestCase.java</exclude>
<exclude>org/activiti/engine/test/concurrency/CompetingJobAcquisitionTest.java</exclude> <!-- ACT-234 -->
......
......@@ -34,7 +34,7 @@ import org.activiti.engine.impl.util.IoUtil;
*
* <pre>
* ProcessEngine processEngine = ProcessEngineBuilder
* .setDatabaseName(&quot;h2&quot;)
* .setDatabaseType(&quot;h2&quot;)
* .setJdbcDriver(&quot;org.h2.Driver&quot;)
* .setJdbcUrl(&quot;jdbc:h2:tcp://localhost/activiti&quot;)
* .setJdbcUsername(&quot;sa&quot;)
......@@ -47,7 +47,7 @@ import org.activiti.engine.impl.util.IoUtil;
*
* <pre>
* ProcessEngine processEngine = ProcessEngineBuilder
* .setDatabaseName(&quot;h2&quot;)
* .setDatabaseType(&quot;h2&quot;)
* .setJdbcDriver(&quot;org.h2.Driver&quot;)
* .setJdbcUrl(&quot;jdbc:h2:mem:activiti&quot;)
* .setJdbcUsername(&quot;sa&quot;)
......@@ -69,8 +69,8 @@ public class ProcessEngineBuilder {
return this;
}
public ProcessEngineBuilder setDatabaseName(String databaseName) {
processEngineConfiguration.setDatabaseName(databaseName);
public ProcessEngineBuilder setDatabaseType(String databaseType) {
processEngineConfiguration.setDatabaseType(databaseType);
return this;
}
......@@ -130,7 +130,7 @@ public class ProcessEngineBuilder {
}
public ProcessEngineBuilder setJobExecutorAutoActivation(boolean jobExecutorAutoActivate) {
processEngineConfiguration.setJobExecutorAutoActivate(jobExecutorAutoActivate);
processEngineConfiguration.setJobExecutorActivate(jobExecutorAutoActivate);
return this;
}
......@@ -165,9 +165,9 @@ public class ProcessEngineBuilder {
}
// Database
String databaseName = cfgParse.getDatabaseName();
if (databaseName != null) {
processEngineConfiguration.setDatabaseName(databaseName);
String databaseType = cfgParse.getDatabaseType();
if (databaseType != null) {
processEngineConfiguration.setDatabaseType(databaseType);
}
String databaseSchemaStrategy = cfgParse.getDatabaseSchemaStrategy();
if (databaseSchemaStrategy != null) {
......@@ -190,6 +190,25 @@ public class ProcessEngineBuilder {
if (databasePassword != null) {
processEngineConfiguration.setJdbcPassword(databasePassword);
}
// Connection pool
Integer maxActiveConnections = cfgParse.getMaxActiveConnections();
if (maxActiveConnections != null) {
processEngineConfiguration.setMaxActiveConnections(maxActiveConnections);
}
Integer maxIdleConnections = cfgParse.getMaxIdleConnections();
if (maxIdleConnections != null) {
processEngineConfiguration.setMaxIdleConnections(maxIdleConnections);
}
Integer maxCheckoutTime = cfgParse.getMaxCheckoutTime();
if (maxCheckoutTime != null) {
processEngineConfiguration.setMaxCheckoutTime(maxCheckoutTime);
}
Integer maxWaitTime = cfgParse.getMaxWaitTime();
if (maxWaitTime != null) {
processEngineConfiguration.setMaxWaitTime(maxWaitTime);
}
}
// Mail
......@@ -215,9 +234,9 @@ public class ProcessEngineBuilder {
}
// Job executor
Boolean jobExecutorAutoActivate = cfgParse.getIsJobExecutorAutoActivate();
if (jobExecutorAutoActivate != null) {
processEngineConfiguration.setJobExecutorAutoActivate(jobExecutorAutoActivate);
Boolean jobExecutorActivate = cfgParse.getJobExecutorActivate();
if (jobExecutorActivate != null) {
processEngineConfiguration.setJobExecutorActivate(jobExecutorActivate);
}
// History
......
......@@ -33,15 +33,19 @@ public class ConfigurationParse extends Parse {
// Database config
protected boolean isJdbcConfigured;
protected String databaseName;
protected String databaseType;
protected String databaseSchemaStrategy;
protected String jdbcUrl;
protected String jdbcDriver;
protected String jdbcUsername;
protected String jdbcPassword;
protected Integer maxActiveConnections;
protected Integer maxIdleConnections;
protected Integer maxCheckoutTime;
protected Integer maxWaitTime;
// Jobexecutor
protected Boolean isJobExecutorAutoActivate;
protected Boolean jobExecutorActivate;
// Mail
protected String mailServerHost;
......@@ -90,7 +94,7 @@ public class ConfigurationParse extends Parse {
protected void parseDatabaseCfg() {
Element databaseElement = rootElement.element("database");
if (databaseElement != null) {
this.databaseName = databaseElement.attribute("name");
this.databaseType = databaseElement.attribute("type");
this.databaseSchemaStrategy = databaseElement.attribute("schema-strategy");
// Jdbc
......@@ -101,6 +105,15 @@ public class ConfigurationParse extends Parse {
this.jdbcDriver = jdbcElement.attribute("driver");
this.jdbcUsername = jdbcElement.attribute("username");
this.jdbcPassword = jdbcElement.attribute("password");
if (jdbcUrl == null || jdbcDriver == null || jdbcUsername == null || jdbcPassword == null) {
addError("Invalid jdbc configuration: need to provide url, driver, username and password", jdbcElement);
}
this.maxActiveConnections = stringToInteger(jdbcElement, "max-active", jdbcElement.attribute("max-active"));
this.maxIdleConnections = stringToInteger(jdbcElement, "max-idle", jdbcElement.attribute("max-idle"));
this.maxCheckoutTime = stringToInteger(jdbcElement, "max-checkout", jdbcElement.attribute("max-checkout"));
this.maxWaitTime = stringToInteger(jdbcElement, "max-wait", jdbcElement.attribute("max-wait"));
}
// Datasource through jndi: TODO
......@@ -114,19 +127,19 @@ public class ConfigurationParse extends Parse {
protected void parseJobExecutorCfg() {
Element jobExecutorElement = rootElement.element("job-executor");
if (jobExecutorElement != null) {
String autoActivateString = jobExecutorElement.attribute("auto-activate");
String activateString = jobExecutorElement.attribute("activate");
if (autoActivateString != null) {
if (activateString != null) {
if (autoActivateString.equals("off")
|| autoActivateString.equals("disabled")
|| autoActivateString.equals("false")) {
this.isJobExecutorAutoActivate = false;
if (activateString.equals("off")
|| activateString.equals("disabled")
|| activateString.equals("false")) {
this.jobExecutorActivate = false;
} else if (autoActivateString.equals("on")
|| autoActivateString.equals("enabled")
|| autoActivateString.equals("true")) {
this.isJobExecutorAutoActivate = true;
} else if (activateString.equals("on")
|| activateString.equals("enabled")
|| activateString.equals("true")) {
this.jobExecutorActivate = true;
} else {
addError("Invalid value for 'auto-activate', current values are supported:"
......@@ -141,15 +154,16 @@ public class ConfigurationParse extends Parse {
protected void parseMailServerCfg() {
Element mailElement = rootElement.element("mail");
if (mailElement != null) {
this.mailServerHost = mailElement.attribute("host");
this.mailServerHost = mailElement.attribute("server");
if(mailServerHost == null) {
addError("server is a required attribute when configuring e-mail", mailElement);
}
this.mailServerUsername = mailElement.attribute("username");
this.mailServerPassword = mailElement.attribute("password");
this.mailDefaultFrom = mailElement.attribute("default-from");
try {
this.mailServerPort = Integer.parseInt(mailElement.attribute("port"));
} catch (NumberFormatException e) {
addError("Invalid port for mail service", mailElement);
}
this.mailServerPort = stringToInteger(mailElement, "mail port", mailElement.attribute("port"));
}
}
......@@ -163,6 +177,17 @@ public class ConfigurationParse extends Parse {
}
}
protected Integer stringToInteger(Element element, String attributeName, String value) {
if (value != null) {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
addError("Invalid: value for " + attributeName + " is not numerical", element);
}
}
return null;
}
// Source definition operations //////////////////////////////////////////////////
@Override
......@@ -209,8 +234,8 @@ public class ConfigurationParse extends Parse {
public boolean isJdbcConfigured() {
return isJdbcConfigured;
}
public String getDatabaseName() {
return databaseName;
public String getDatabaseType() {
return databaseType;
}
public String getDatabaseSchemaStrategy() {
return databaseSchemaStrategy;
......@@ -227,8 +252,8 @@ public class ConfigurationParse extends Parse {
public String getJdbcPassword() {
return jdbcPassword;
}
public Boolean getIsJobExecutorAutoActivate() {
return isJobExecutorAutoActivate;
public Boolean getJobExecutorActivate() {
return jobExecutorActivate;
}
public String getMailServerHost() {
return mailServerHost;
......@@ -248,6 +273,17 @@ public class ConfigurationParse extends Parse {
public Integer getHistoryLevel() {
return historyLevel;
}
public Integer getMaxActiveConnections() {
return maxActiveConnections;
}
public Integer getMaxIdleConnections() {
return maxIdleConnections;
}
public Integer getMaxCheckoutTime() {
return maxCheckoutTime;
}
public Integer getMaxWaitTime() {
return maxWaitTime;
}
}
......@@ -90,7 +90,7 @@ public class ProcessEngineConfiguration {
// Static values (defaults, etc.) ////////////////////////////////////////////
public static final String DEFAULT_DATABASE_NAME = "h2";
public static final String DEFAULT_DATABASE_TYPE = "h2";
public static final String DEFAULT_JDBC_DRIVER = "org.h2.Driver";
public static final String DEFAULT_JDBC_URL = "jdbc:h2:mem:activiti";
public static final String DEFAULT_JDBC_USERNAME = "sa";
......@@ -161,10 +161,10 @@ public class ProcessEngineConfiguration {
// Job executor
protected JobExecutor jobExecutor;
protected JobHandlers jobHandlers;
protected boolean jobExecutorAutoActivate;
protected boolean jobExecutorActivate;
// Database
protected String databaseName;
protected String databaseType;
protected String dbSchemaStrategy;
protected DataSource dataSource;
protected String jdbcDriver;
......@@ -172,6 +172,10 @@ public class ProcessEngineConfiguration {
protected String jdbcUsername;
protected String jdbcPassword;
protected boolean transactionsExternallyManaged;
protected int maxActiveConnections;
protected int maxIdleConnections;
protected int maxCheckoutTime;
protected int maxWaitTime;
// Id generator
protected IdGenerator idGenerator;
......@@ -249,9 +253,9 @@ public class ProcessEngineConfiguration {
jobHandlers = new JobHandlers();
jobHandlers.addJobHandler(new TimerExecuteNestedActivityJobHandler());
jobExecutor = new JobExecutor();
jobExecutorAutoActivate = false;
jobExecutorActivate = false;
databaseName = "h2";
databaseType = "h2";
dbSchemaStrategy = DbSchemaStrategy.CREATE_DROP;
idGenerator = new DbIdGenerator();
idBlockSize = 100;
......@@ -287,7 +291,7 @@ public class ProcessEngineConfiguration {
public ProcessEngine buildProcessEngine() {
// Validation of settings
if (databaseName == null) {
if (databaseType == null) {
throw new ActivitiException("No database name provided. "
+ "This is required for schema creation and query lookup");
}
......@@ -576,12 +580,12 @@ public class ProcessEngineConfiguration {
this.transactionContextFactory = transactionContextFactory;
}
public String getDatabaseName() {
return databaseName;
public String getDatabaseType() {
return databaseType;
}
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
public void setDatabaseType(String databaseType) {
this.databaseType = databaseType;
}
public DataSource getDataSource() {
......@@ -625,11 +629,11 @@ public class ProcessEngineConfiguration {
}
public boolean isJobExecutorAutoActivate() {
return jobExecutorAutoActivate;
return jobExecutorActivate;
}
public void setJobExecutorAutoActivate(boolean jobExecutorAutoActivate) {
this.jobExecutorAutoActivate = jobExecutorAutoActivate;
public void setJobExecutorActivate(boolean jobExecutorActivate) {
this.jobExecutorActivate = jobExecutorActivate;
}
public boolean isTransactionsExternallyManaged() {
......@@ -769,4 +773,38 @@ public class ProcessEngineConfiguration {
public ClassLoader getClassLoader() {
return classLoader;
}
public int getMaxActiveConnections() {
return maxActiveConnections;
}
public void setMaxActiveConnections(int maxActiveConnections) {
this.maxActiveConnections = maxActiveConnections;
}
public int getMaxIdleConnections() {
return maxIdleConnections;
}
public void setMaxIdleConnections(int maxIdleConnections) {
this.maxIdleConnections = maxIdleConnections;
}
public int getMaxCheckoutTime() {
return maxCheckoutTime;
}
public void setMaxCheckoutTime(int maxCheckoutTime) {
this.maxCheckoutTime = maxCheckoutTime;
}
public int getMaxWaitTime() {
return maxWaitTime;
}
public void setMaxWaitTime(int maxWaitTime) {
this.maxWaitTime = maxWaitTime;
}
}
......@@ -62,7 +62,7 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
protected static final Map<String, Map<String, String>> databaseSpecificStatements = new HashMap<String, Map<String,String>>();
static {
//mysql specific
//mysql specific
addDatabaseSpecificStatement("mysql", "selectTaskByQueryCriteria", "selectTaskByQueryCriteria_mysql");
addDatabaseSpecificStatement("mysql", "selectNextJobsToExecute", "selectNextJobsToExecute_mysql");
addDatabaseSpecificStatement("mysql", "selectProcessDefinitionsByQueryCriteria", "selectProcessDefinitionsByQueryCriteria_mysql");
......@@ -78,7 +78,7 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
addDatabaseSpecificStatement("postgres", "selectResourcesByDeploymentId", "selectResourcesByDeploymentId_postgres");
}
protected String databaseName;
protected String databaseType;
protected SqlSessionFactory sqlSessionFactory;
protected IdGenerator idGenerator;
protected Map<String, String> statementMappings;
......@@ -88,37 +88,13 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
protected Map<Class<?>,String> selectStatements = Collections.synchronizedMap(new HashMap<Class<?>, String>());
public void configurationCompleted(ProcessEngineConfiguration processEngineConfiguration) {
this.databaseName = processEngineConfiguration.getDatabaseName();
this.databaseType = processEngineConfiguration.getDatabaseType();
this.idGenerator = processEngineConfiguration.getIdGenerator();
this.statementMappings = databaseSpecificStatements.get(processEngineConfiguration.getDatabaseName());
this.statementMappings = databaseSpecificStatements.get(processEngineConfiguration.getDatabaseType());
DataSource dataSource = processEngineConfiguration.getDataSource();
if (dataSource==null) { // standalone usage
String jdbcDriver = processEngineConfiguration.getJdbcDriver();
String jdbcUrl = processEngineConfiguration.getJdbcUrl();
String jdbcUsername = processEngineConfiguration.getJdbcUsername();
String jdbcPassword = processEngineConfiguration.getJdbcPassword();
if ( (jdbcDriver==null)
|| (jdbcUrl==null)
|| (jdbcUsername==null)
) {
throw new ActivitiException("DataSource or JDBC properties have to be specified in a process engine configuration");
}
PooledDataSource pooledDataSource =
new PooledDataSource(
ReflectUtil.getClassLoader(),
jdbcDriver,
jdbcUrl,
jdbcUsername,
jdbcPassword );
// ACT-233: connection pool of Ibatis is not properely initialized if this is not called!
pooledDataSource.forceCloseAll();
dataSource = pooledDataSource;
dataSource = createPooledDatasource(processEngineConfiguration);
}
TransactionFactory transactionFactory = null;
......@@ -131,10 +107,46 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
this.sqlSessionFactory = createSessionFactory(dataSource, transactionFactory);
}
protected PooledDataSource createPooledDatasource(ProcessEngineConfiguration processEngineConfiguration) {
String jdbcDriver = processEngineConfiguration.getJdbcDriver();
String jdbcUrl = processEngineConfiguration.getJdbcUrl();
String jdbcUsername = processEngineConfiguration.getJdbcUsername();
String jdbcPassword = processEngineConfiguration.getJdbcPassword();
if ( (jdbcDriver==null) || (jdbcUrl==null) || (jdbcUsername==null) ) {
throw new ActivitiException("DataSource or JDBC properties have to be specified in a process engine configuration");
}
PooledDataSource pooledDataSource =
new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword );
// Update with connection pool settings
int maxActiveConnections = processEngineConfiguration.getMaxActiveConnections();
int maxIdleConnections = processEngineConfiguration.getMaxIdleConnections();
int maxCheckoutTime = processEngineConfiguration.getMaxCheckoutTime();
int maxWaitTime = processEngineConfiguration.getMaxWaitTime();
if (maxActiveConnections > 0) {
pooledDataSource.setPoolMaximumActiveConnections(maxActiveConnections);
}
if (maxIdleConnections > 0) {
pooledDataSource.setPoolMaximumIdleConnections(maxIdleConnections);
}
if (maxCheckoutTime > 0) {
pooledDataSource.setPoolMaximumCheckoutTime(maxCheckoutTime);
}
if (maxWaitTime > 0) {
pooledDataSource.setPoolTimeToWait(maxWaitTime);
}
// ACT-233: connection pool of Ibatis is not properely initialized if this is not called!
pooledDataSource.forceCloseAll();
return pooledDataSource;
}
protected SqlSessionFactory createSessionFactory(DataSource dataSource, TransactionFactory transactionFactory) {
InputStream inputStream = null;
try {
inputStream = ReflectUtil.getResourceAsStream("org/activiti/db/ibatis/activiti.ibatis.mem.conf.xml");
// update the jdbc parameters to the configured ones...
......@@ -145,7 +157,7 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
configuration.setEnvironment(environment);
configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler());
configuration = parser.parse();
return new DefaultSqlSessionFactory(configuration);
} catch (Exception e) {
......@@ -155,7 +167,6 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
}
}
public Session openSession() {
return new DbSqlSession(this);
}
......@@ -191,11 +202,11 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
// db specific mappings /////////////////////////////////////////////////////
protected static void addDatabaseSpecificStatement(String databaseName, String activitiStatement, String ibatisStatement) {
Map<String, String> specificStatements = databaseSpecificStatements.get(databaseName);
protected static void addDatabaseSpecificStatement(String databaseType, String activitiStatement, String ibatisStatement) {
Map<String, String> specificStatements = databaseSpecificStatements.get(databaseType);
if (specificStatements == null) {
specificStatements = new HashMap<String, String>();
databaseSpecificStatements.put(databaseName, specificStatements);
databaseSpecificStatements.put(databaseType, specificStatements);
}
specificStatements.put(activitiStatement, ibatisStatement);
}
......@@ -250,20 +261,20 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
}
public void dbSchemaCreate() {
executeSchemaResource("create", databaseName, sqlSessionFactory);
executeSchemaResource("create", databaseType, sqlSessionFactory);
}
public void dbSchemaDrop() {
executeSchemaResource("drop", databaseName, sqlSessionFactory);
executeSchemaResource("drop", databaseType, sqlSessionFactory);
}
public static void executeSchemaResource(String operation, String databaseName, SqlSessionFactory sqlSessionFactory) {
public static void executeSchemaResource(String operation, String databaseType, SqlSessionFactory sqlSessionFactory) {
SqlSession sqlSession = sqlSessionFactory.openSession();
boolean success = false;
InputStream inputStream = null;
try {
Connection connection = sqlSession.getConnection();
String resource = "org/activiti/db/" + operation + "/activiti." + databaseName + "." + operation + ".sql";
String resource = "org/activiti/db/" + operation + "/activiti." + databaseType + "." + operation + ".sql";
inputStream = ReflectUtil.getResourceAsStream(resource);
if (inputStream == null) {
throw new ActivitiException("resource '" + resource + "' is not available for creating the schema");
......
......@@ -42,10 +42,10 @@
<element ref="tns:jdbc" />
<element ref="tns:datasource" />
</choice>
<attribute name="name" use="required" type="string">
<attribute name="type" use="required" type="string">
<annotation>
<documentation>
The name of the database (eg. h2, oracle, mysql, etc.).
The type of database (eg. h2, oracle, mysql, etc.).
See Activiti userguide for supported databases (http://activiti.org/userguide/)
</documentation>
</annotation>
......@@ -72,9 +72,13 @@
<attribute name="driver" use="required" />
<attribute name="username" use="required" />
<attribute name="password" use="required" />
<attribute name="max-active" />
<attribute name="max-idle" />
<attribute name="max-checkout" />
<attribute name="max-wait" />
</complexType>
</element>
<element name="datasource">
<annotation>
<documentation>
......@@ -99,13 +103,23 @@
</documentation>
</annotation>
<complexType>
<attribute name="auto-activate" use="required" type="string">
<attribute name="activate" use="required">
<annotation>
<documentation>
Specifies if the job executor must be activated when the engine starts.
Possible values: on/off enabled/disabled true/false.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="on" />
<enumeration value="off" />
<enumeration value="enabled" />
<enumeration value="disabled" />
<enumeration value="true" />
<enumeration value="false" />
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
......@@ -117,10 +131,10 @@
</documentation>
</annotation>
<complexType>
<attribute name="host" use="required" type="string">
<attribute name="server" use="required" type="string">
<annotation>
<documentation>
Host of the SMTP mail server.
Server host address of the SMTP mail server.
</documentation>
</annotation>
</attribute>
......
......@@ -90,14 +90,14 @@ public class ConfigurationParserTest extends PvmTestCase {
assertNull(parse.getMailServerUsername());
assertNull(parse.getMailServerPassword());
assertEquals("h2", parse.getDatabaseName());
assertEquals("h2", parse.getDatabaseType());
assertEquals("create-if-necessary", parse.getDatabaseSchemaStrategy());
assertEquals("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000", parse.getJdbcUrl());
assertEquals("org.h2.Driver", parse.getJdbcDriver());
assertEquals("sa", parse.getJdbcUsername());
assertEquals("", parse.getJdbcPassword());
assertTrue(parse.getIsJobExecutorAutoActivate());
assertTrue(parse.getJobExecutorActivate());
assertEquals(ProcessEngineConfiguration.parseHistoryLevel("audit"), parse.getHistoryLevel());
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.test.db;
import javax.sql.DataSource;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineBuilder;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.test.PvmTestCase;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
/**
* @author Joram Barrez
*/
public class ConnectionPoolTest extends PvmTestCase {
public void testMyBatisConnectionPoolProperlyConfigured() {
ProcessEngine processEngine = new ProcessEngineBuilder()
.configureFromResource("org/activiti/engine/test/db/connection-pool.activiti.cfg.xml")
.buildProcessEngine();
ProcessEngineConfiguration config = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
// Expected values
int maxActive = 25;
int maxIdle = 10;
int maxCheckoutTime = 30000;
int maxWaitTime = 25000;
assertEquals(maxActive, config.getMaxActiveConnections());
assertEquals(maxIdle, config.getMaxIdleConnections());
assertEquals(maxCheckoutTime, config.getMaxCheckoutTime());
assertEquals(maxWaitTime, config.getMaxWaitTime());
// 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());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
......@@ -4,13 +4,13 @@
xsi:schemaLocation="http://activiti.org/cfg http://activiti.org/cfg/activiti-cfg-5.0.xsd"
process-engine-name="with-schema">
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
<job-executor auto-activate="on" />
<job-executor activate="on" />
<history level="audit" />
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
......
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg process-engine-name="complete-cfg">
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
<job-executor auto-activate="on" />
<job-executor activate="on" />
<history level="audit" />
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
......
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg process-engine-name="only-db">
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
......
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg process-engine-name="only-db">
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
......
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password=""
max-active="25"
max-idle="10"
max-checkout="30000"
max-wait="25000" />
</database>
<job-executor activate="off" />
<mail server="localhost" port="5025" />
</activiti-cfg>
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="drop-create">
<database type="h2" schema-strategy="drop-create">
<jdbc url="jdbc:h2:tcp://non-existing-host/non-existing-db;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="check-version">
<database type="h2" schema-strategy="check-version">
<jdbc url="jdbc:h2:mem:ProcessEngineInitializationTest;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
......@@ -182,8 +182,8 @@ public class ProcessEngineFactoryBean implements FactoryBean<ProcessEngine>, Dis
this.deploymentResources = deploymentResources;
}
public void setDataBaseName(String dataBaseName) {
processEngineConfiguration.setDatabaseName(dataBaseName);
public void setDatabaseType(String databaseType) {
processEngineConfiguration.setDatabaseType(databaseType);
}
public void setDataSource(DataSource dataSource) {
......@@ -211,7 +211,7 @@ public class ProcessEngineFactoryBean implements FactoryBean<ProcessEngine>, Dis
}
public void setJobExecutorAutoActivate(boolean jobExecutorAutoActivate) {
processEngineConfiguration.setJobExecutorAutoActivate(jobExecutorAutoActivate);
processEngineConfiguration.setJobExecutorActivate(jobExecutorAutoActivate);
}
public void setProcessEngineName(String processEngineName) {
......
......@@ -33,7 +33,7 @@
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="dataBaseName" value="h2" />
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="dbSchemaStrategy" value="create-drop" />
......
<?xml version="1.0" encoding="UTF-8"?>
<activiti-cfg>
<database name="h2" schema-strategy="create-if-necessary">
<database type="h2" schema-strategy="create-if-necessary">
<jdbc url="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
driver="org.h2.Driver"
username="sa"
password="" />
</database>
<job-executor auto-activate="off" />
<job-executor activate="off" />
<mail host="localhost" port="5025" />
<mail server="localhost" port="5025" />
</activiti-cfg>
......@@ -24,7 +24,7 @@
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="dataBaseName" value="h2" />
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="dbSchemaStrategy" value="drop-create" />
......
......@@ -24,7 +24,7 @@
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="dataBaseName" value="h2" />
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="dbSchemaStrategy" value="check-version" />
......
......@@ -24,7 +24,7 @@
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="dataBaseName" value="h2" />
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="dbSchemaStrategy" value="drop-create" />
......
......@@ -56,7 +56,7 @@
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="dataBaseName" value="h2" />
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="dbSchemaStrategy" value="drop-create" />
......
......@@ -24,7 +24,7 @@
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="dataBaseName" value="h2" />
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="dbSchemaStrategy" value="drop-create" />
......
......@@ -50,8 +50,8 @@
<echo message=" jdbc.password: ${jdbc.password}"/>
<replaceregexp file="./target/test-classes/activiti.cfg.xml" flags="s"
match='database name=".*?"'
replace='database name="${database}"'/>
match='database type=".*?"'
replace='database type="${database}"'/>
<replaceregexp file="./target/test-classes/activiti.cfg.xml" flags="s"
match='driver=".*?"'
replace='driver="${jdbc.driver}"'/>
......
......@@ -23,7 +23,7 @@
<listitem><para><emphasis role="bold">process.engine.name</emphasis>: The process engine name. Only relevant if you're using
multiple process engines in one classloading scope.
</para></listitem>
<listitem><para><emphasis role="bold">database</emphasis>: one of the database names specified in <xref linkend="databasenames" /> </para></listitem>
<listitem><para><emphasis role="bold">database</emphasis>: one of the database names specified in <xref linkend="databaseTypes" /> </para></listitem>
<listitem><para><emphasis role="bold">jdbc.driver</emphasis>, <emphasis role="bold">jdbc.url</emphasis>, <emphasis role="bold">jdbc.username</emphasis>
and <emphasis role="bold">jdbc.password</emphasis>: JDBC properties pointing to the database Activiti will use.</para></listitem>
<listitem><para><emphasis role="bold">db.schema.strategy</emphasis>: { <literal>check-version</literal> | <literal>create-drop</literal> } <literal>check-version</literal>
......@@ -41,7 +41,7 @@
<section id="supporteddatabases">
<title>Supported databases</title>
<para>Following are the names (case sensitive!) that Activiti uses to refer to databases.</para>
<table id="databasenames">
<table id="databaseTypes">
<title>Supported databases</title>
<tgroup cols='3'>
<thead>
......
......@@ -23,7 +23,7 @@
<listitem><para><literal>processEngineName</literal> (String) see <xref linkend="configurationproperties"/></para> </listitem>
<listitem><para><literal>transactionManager</literal> (PlatformTransactionManager)</para> </listitem>
<listitem><para><literal>dataSource</literal> (DataSource)</para> </listitem>
<listitem><para><literal>dataBaseName</literal> (dataBaseName) see <xref linkend="supporteddatabases"/></para></listitem>
<listitem><para><literal>databaseType</literal> (databaseType) see <xref linkend="supporteddatabases"/></para></listitem>
<listitem><para><literal>dbSchemaStrategy</literal> (String) see <xref linkend="configurationproperties"/></para></listitem>
<listitem><para><literal>deploymentName</literal> (String)</para> </listitem>
<listitem><para><literal>deploymentResources</literal> (Resource[])</para> </listitem>
......@@ -74,7 +74,7 @@
&lt;/bean&gt;
&lt;bean id=&quot;processEngine&quot; class=&quot;org.activiti.spring.ProcessEngineFactoryBean&quot;&gt;
&lt;property name=&quot;dataBaseName&quot; value=&quot;h2&quot; /&gt;
&lt;property name=&quot;databaseType&quot; value=&quot;h2&quot; /&gt;
&lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
&lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManager&quot; /&gt;
&lt;property name=&quot;dbSchemaStrategy&quot; value=&quot;check-version&quot; /&gt;
......
......@@ -93,7 +93,7 @@ ProcessEngine engine = new ProcessEngineBuilder()
&lt;/bean&gt;
&lt;bean id=&quot;processEngine&quot; class=&quot;org.activiti.spring.ProcessEngineFactoryBean&quot;&gt;
&lt;property name=&quot;dataBaseName&quot; value=&quot;h2&quot; /&gt;
&lt;property name=&quot;dataBaseType&quot; value=&quot;h2&quot; /&gt;
&lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
&lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManager&quot; /&gt;
&lt;property name=&quot;dbSchemaStrategy&quot; value=&quot;create-drop&quot; /&gt;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册