[jboss-user] [jBPM] - Adding a Database Axis
Administrator Administrator
do-not-reply at jboss.com
Thu Jan 20 11:15:12 EST 2011
Administrator Administrator [http://community.jboss.org/people/admin] modified the document:
"Adding a Database Axis"
To view the document, visit: http://community.jboss.org/docs/DOC-12931
--------------------------------------------------------------
***
#Specify_Connection_Properties Specify Connection Properties
***
#Provide_Data_Source Provide Data Source
***
#Create_Maven_Profile Create Maven Profile
***
#Fill_in_Connection_Parameters Fill in Connection Parameters
***
#Specify_Connection_Properties_For_Update Specify Connection Properties For Update
***
#List_Database_as_Installation_Choice List Database as Installation Choice
***
#Set_Up_DBMS Set Up DBMS
***
#Run_Test_Suite Run Test Suite
***
#Add_Database_Axis_To_Hudson_Jobs Add Database Axis To Hudson Jobs
h3. Specify Connection Properties
Let's add a PostgreSQL axis.
jBPM3 already generates the DDL scripts for many databases. Edit http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml hibernate.properties.postgresql.xml
<!-- hibernate dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- JDBC connection properties (begin) -->
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">${jdbc.postgresql.url}</property>
<property name="hibernate.connection.username">${jdbc.postgresql.username}</property>
<property name="hibernate.connection.password">${jdbc.postgresql.password}</property>
<!-- JDBC connection properties (end) -->
h3. Provide Data Source
Create jbpm-postgresql-ds.xml in http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/jpdl/core/src/main/resources modules/core/src/main/resources. Use http://community.jboss.org/docs/DOC-9328 ConfigDataSources as a reference.
<xa-datasource>
<jndi-name>JbpmDS</jndi-name>
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<xa-datasource-property name="ServerName">${jdbc.postgresql.server}</xa-datasource-property>
<xa-datasource-property name="PortNumber">${jdbc.postgresql.port}</xa-datasource-property>
<xa-datasource-property name="DatabaseName">${jdbc.postgresql.database}</xa-datasource-property>
<user-name>${jdbc.postgresql.username}</user-name>
<password>${jdbc.postgresql.password}</password>
<!-- disable transaction interleaving -->
<track-connection-by-tx />
<!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
<metadata>
<type-mapping>PostgreSQL 8.0</type-mapping>
</metadata>
</xa-datasource>
h3. Create Maven Profile
In the root POM add a profile that contains the dependency on the JDBC driver
<dependencyManagement>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>postgresql</id>
<activation>
<property>
<name>database</name>
<value>postgresql</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
h3. Fill in Connection Parameters
Specify the connection property values that correspond to the target environment in the following locations.
|| Environment || File || Location ||
| jBPM Dev | profiles.xml | ${basedir} |
| Local Dev *** | settings.xml | ${user.home}/.m2 |
| Local QA | profiles.xml.local.qa | ${basedir}/hudson |
| Red Hat QA | profiles.xml.redhat.qa | ${basedir}/hudson |
*** Useful if you have multiple jBPM branches checked out
For a local PostgreSQL installation the property values would look like this:
<properties>
<jdbc.postgresql.server>localhost</jdbc.postgresql.server>
<jdbc.postgresql.port>5432</jdbc.postgresql.port>
<jdbc.postgresql.database>jbpmtest</jdbc.postgresql.database>
<jdbc.postgresql.url>jdbc:postgresql://${jdbc.postgresql.server}:${jdbc.postgresql.port}/${jdbc.postgresql.database}</jdbc.postgresql.url>
<jdbc.postgresql.username>jbpmtest</jdbc.postgresql.username>
<jdbc.postgresql.password></jdbc.postgresql.password>
</properties>
h3. Specify Connection Properties For Update
Generating the DB schema update script requires access to an alternate database hosting the schema from a previous version. Create postgresql.properties in http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/jpdl/db/src/main/resources modules/db/src/main/resources.
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#
# This uses the jbpm322 database schema as reference for the SchemaUpdate task
#
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://${jdbc.postgresql.server}:${jdbc.postgresql.port}/jbpm322
hibernate.connection.username=${jdbc.postgresql.username}
hibernate.connection.password=${jdbc.postgresql.password}
http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/db/scripts/antrun-jbpmschema.xml antrun-jbpmschema.xml
<target name="update-schema" depends="setup-schema" description="Generate jBPM Database Update Scripts">
<jbpmschema output="${scriptsdir}/jbpm.jpdl.postgresql.update322.sql" config="hibernate.cfg.postgresql.xml" properties="postgresql.properties" action="update" delimiter=";"/>
</target>
h3. List Database as Installation Choice
http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/distribution/src/main/resources/installer/install-definition.xml install-definition.xml
<conditions>
<condition type="variable" id="isPostgreSQL">
<name>dbSelection</name>
<value>postgresql</value>
</condition>
</conditions>
<packs>
<!--
********************************
* JBoss Integration *
********************************
-->
<pack name="jBPM3 JBoss Integration" required="no" preselected="yes">
<!-- Database configs to docs/examples/jbpm -->
<fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config" targetdir="${jbossInstallPath}/docs/examples/jbpm" override="true">
<include name="hibernate.cfg.postgresql.xml"/>
<include name="jbpm-postgresql-ds.xml"/>
</fileset>
<!-- Database PostgreSQL -->
<file src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/jbpm-postgresql-ds.xml" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" condition="isPostgreSQL"/>
<singlefile src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/hibernate.cfg.postgresql.xml" condition="isPostgreSQL"
target="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml" />
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true" condition="isPostgreSQL">
<include name="postgresql.jar" />
</fileset>
</pack>
</packs>
http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/distribution/src/main/resources/installer/user-input-spec.xml user-input-spec.xml
<panel order="2">
<createForPack name="jBPM3 JBoss Integration" />
<field type="radio" variable="dbSelection">
<spec>
<choice txt="PostgreSQL" value="postgresql"/>
</spec>
</field>
</panel>
http://anonsvn.jboss.org/repos/jbpm/jbpm3/trunk/modules/distribution/scripts/antrun-installer.xml antrun-installer.xml
<target name="configure" depends="init">
<property name="postgresql.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.postgresql.xml"/>
<macro-disable file="${postgresql.cfg.xml}" section="JDBC connection properties"/>
<macro-disable file="${postgresql.cfg.xml}" section="Automatic schema creation"/>
<macro-enable file="${postgresql.cfg.xml}" section="DataSource properties"/>
<macro-enable file="${postgresql.cfg.xml}" section="JTA transaction properties"/>
</target>
h3. Set Up DBMS
See http://community.jboss.org/docs/DOC-13270 Install PostgreSQL on Fedora
h3. Run Test Suite
Finally you should be able to run the jBPM3 tests against PostgreSQL using the *-Ddatabase* option
[tdiesler at tddell core]$ mvn -Ddatabase=postgresql -Dtest=EndTasksDbTest test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss jBPM - jPDL Core
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
check-database:
[echo] Concat hibernate.cfg.xml using hibernate.properties.postgresql.xml
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.jbpm.taskmgmt.exe.EndTasksDbTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 25.799 sec
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
h3. Add Database Axis To Hudson Jobs
When the Maven build is setup to use the database for testing, you simple need to add the axis to the Hudson config.
<axis>
<name>database</name>
<values>
<string>hsqldb</string>
<string>mysql</string>
<string>postgresql</string>
</values>
</axis>
This can also be done from the web interface.
Good Luck
--------------------------------------------------------------
Comment by going to Community
[http://community.jboss.org/docs/DOC-12931]
Create a new document in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110120/b302d3fb/attachment-0001.html
More information about the jboss-user
mailing list