How to use the Example Database?
jimknopf Nov 7, 2006 8:15 AMHi, I am new in Jbpm and still at learning it.
How can i use the Database from the Starter-Kit-Example from my own test-code?
I allready wrote a little Code to deploy some Process-Definitions and get all of them from the Engine (they are not persistent).
Now I want to but them in the Database so that i can use the Web-Application from the Starter-Kit to test and monitoring them. But I don`t know how to do that (I allready read the manual and even Chapter 7-9).
ArcaViaController avc = ArcaViaController.getInstance(); String processDefinition = "<process-definition name='Timos die erste'>" + " <start-state>" + " <transition to='Timo 1' />" + " </start-state>" + " <state name='Timo 1'>" + " <transition to='Timo 2' />" + " </state>" + " <state name='Timo 2'>" + " <transition to='end' />" + " </state>" + " <end-state name='end' />" + "</process-definition>"; avc.deploy( processDefinition ); processDefinition = "<process-definition name='hello world'>" + " <start-state>" + " <transition to='s' />" + " </start-state>" + " <state name='s'>" + " <transition to='end' />" + " </state>" + " <end-state name='end' />" + "</process-definition>"; avc.deploy( processDefinition ); for( Object o : avc.getProcessDefinitions() ){ System.err.println( o ); } System.err.println(avc.getLatestProcessDefinition("hello world")); avc.commitAndCloseSession();
The config-file i am using is the default config-file
<project name="jbpm.deploy" basedir="." default="create.jbpm.configuration"> <description>jbpm deployment build file</description> <!-- ================== --> <!-- === PROPERTIES === --> <!-- ================== --> <property file="${user.home}/jbpm/build/build.local.properties" /> <property file="build.properties" /> <!-- ================= --> <!-- === CLASSPATH === --> <!-- ================= --> <path id="classpath.ant"> <pathelement path="build/classes.identity" /> <pathelement path="build/classes.jbpm" /> <pathelement path="build/classes.webapp" /> <pathelement path="src/config.files" /> <fileset dir="lib" includes="**/*.jar" /> </path> <path id="classpath.hsqldb"> <fileset dir="${jboss.home}/server/default/lib" includes="hsqldb.jar" /> </path> <!-- ============= --> <!-- === CLEAN === --> <!-- ============= --> <target name="delete.jbpm.configuration" description="removes the jbpm configuration from jboss"> <delete dir="${jboss.home}/server/jbpm" /> <delete dir="${jboss.home}/server/data" /> <delete dir="${jboss.home}/server/log" /> <delete dir="${jboss.home}/server/tmp" /> <delete dir="${jboss.home}/server/work" /> </target> <target name="clean" description="removes all generated files"> <delete dir="build" /> </target> <!-- ============== --> <!-- === SERVER === --> <!-- ============== --> <target name="create.db" depends="declare.jbpm.tasks, db.clean, db.start" description="creates a hypersonic database with the jbpm tables and loads the processes in there"> <jbpmschema actions="create" cfg="${basedir}/src/config.files/hibernate.cfg.xml" properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"/> <loadidentities file="${basedir}/src/resources/hsqldb/identity.db.xml" cfg="${basedir}/src/config.files/hibernate.cfg.xml" properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"/> <ant antfile="build.xml" target="build.processes" inheritall="false" /> <deployprocess cfg="${basedir}/src/config.files/hibernate.cfg.xml" properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"> <fileset dir="build" includes="*.process" /> </deployprocess> <antcall target="db.stop" /> </target> <target name="create.jbpm.configuration" depends="delete.jbpm.configuration, build.webapp, build.service.archive, create.db" description="creates a jbpm configuration"> <mkdir dir="${jboss.home}/server/jbpm" /> <copy todir="${jboss.home}/server/jbpm"> <fileset dir="${jboss.home}/server/${jboss.source.configuration}"> <exclude name="data/**" /> <exclude name="log/**" /> <exclude name="tmp/**" /> <exclude name="work/**" /> <exclude name="jms/jbossmq-destination-service.xml" /> <exclude name="deploy/jboss-aop.deployer/**" /> <exclude name="deploy/jboss-ws4ee.sar/**" /> <exclude name="deploy/management/**" /> <exclude name="deploy/bsh-deployer.xml" /> <exclude name="deploy/jboss-ha-local-jdbc.rar" /> <exclude name="deploy/jboss-ha-xa-jdbc.rar" /> <exclude name="deploy/jboss-ha-local-jdbc.rar" /> <exclude name="deploy/mail*" /> <exclude name="deploy/monitoring-service.xml" /> <exclude name="deploy/properties-service.xml" /> <exclude name="deploy/schedule*" /> <exclude name="deploy/uuid-key-generator.sar" /> </fileset> </copy> <!-- copy the prefabricated resources --> <copy todir="${jboss.home}/server/jbpm" overwrite="true"> <fileset dir="src/resources/jboss-${jboss.version}" /> </copy> <!-- deploy the jbpm service archive --> <ant antfile="build.xml" target="build" inheritall="false" /> <mkdir dir="${jboss.home}/server/jbpm/deploy/jbpm.sar" /> <unzip src="build/jbpm.sar" dest="${jboss.home}/server/jbpm/deploy/jbpm.sar" /> <!-- deploy the jbpm web application --> <antcall target="build.webapp" /> <copy todir="${jboss.home}/server/jbpm/deploy" file="build/jbpm.war" /> <!-- copy the jbpm database --> <mkdir dir="${jboss.home}/server/jbpm/data/hypersonic" /> <copy todir="${jboss.home}/server/jbpm/data/hypersonic"> <fileset dir="build/db" /> </copy> </target> <target name="redeploy"> <antcall target="stop.jboss" /> <sleep seconds="5" /> <antcall target="create.jbpm.configuration" /> <exec dir="${jboss.home}/bin" executable="${jboss.home}/bin/run.bat" os="Windows XP, Windows 95, Windows 98, Windows 2000, Windows NT" > <arg line="-c jbpm" /> </exec> </target> <!-- ============= --> <!-- === BUILD === --> <!-- ============= --> <target name="build.webapp" description="builds jbpm.war"> <ant antfile="build.xml" target="build.webapp" /> <mkdir dir="build/jbpm.war.dir" /> <copy todir="build/jbpm.war.dir"> <fileset dir="src/resources/jbpm.war" /> </copy> <copy todir="build/jbpm.war.dir/WEB-INF/lib"> <fileset dir="build" includes="jbpm-webapp-${jbpm.version}.jar" /> <fileset dir="lib/jsf" includes="*.jar" /> <fileset dir="lib/dom4j" includes="*.jar" /> <fileset dir="lib/hibernate" includes="jaxen-*.jar" /> <fileset dir="lib/commons" includes="commons-digester-*.jar, commons-beanutils-*.jar, commons-fileupload-*.jar" /> </copy> <jar destfile="build/jbpm.war"> <fileset dir="build/jbpm.war.dir" /> </jar> </target> <target name="build.service.archive" description="builds jbpm.sar"> <ant antfile="build.xml" target="build.service.archive" /> </target> <!-- ============== --> <!-- === DEPLOY === --> <!-- ============== --> <target name="deploy.webapp" depends="build.webapp" description="deploys the jbpm webapp"> <ant antfile="build.xml" target="build.jbpm" /> <get dest="build/deployresult.html" src="http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=redeploy&argType=java.net.URL&arg0=file://${basedir}/build/jbpm.war" /> </target> <target name="undeploy.webapp" description="undeploys the jbpm webapp"> <get dest="build/undeployresult.html" src="http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=undeploy&argType=java.net.URL&arg0=file://${basedir}/build/jbpm.war" /> </target> <target name="deploy.service.archive" depends="build.service.archive" description="deploys jbpm.sar"> <get dest="build/deployresult.html" src="http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=redeploy&argType=java.net.URL&arg0=file://${basedir}/build/jbpm.sar" /> </target> <target name="undeploy.service.archive" description="undeploys the service archive"> <get dest="build/undeployresult.html" src="http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=undeploy&argType=java.net.URL&arg0=file://${basedir}/build/jbpm.sar" /> </target> <target name="deploy.processes" depends="declare.jbpm.tasks" description="deploys the jbpm processes"> <ant antfile="build.xml" target="build.processes" inheritall="false" /> <deployprocess cfg="src/config.files/hibernate.cfg.xml" properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"> <fileset dir="build" includes="*.process" /> </deployprocess> </target> <!-- =========== --> <!-- === RUN === --> <!-- =========== --> <target name="start.jboss" depends="declare.jbpm.tasks"> <startjboss configuration="jbpm" /> </target> <target name="stop.jboss" depends="declare.jbpm.tasks"> <exec dir="${jboss.home}/bin" executable="${jboss.home}/bin/shutdown.bat" os="Windows XP, Windows 95, Windows 98, Windows 2000, Windows NT" > <arg line="-S" /> </exec> </target> <property name="hsqldb.database" value="${basedir}/build/db/localDB" /> <property name="hsqldb.port" value="1701" /> <target name="db.start" depends="declare.jbpm.tasks"> <starthsqldb lib="${jboss.home}/server/default/lib/hsqldb.jar" database="${hsqldb.database}" port="${hsqldb.port}" /> </target> <target name="db.start.mgr"> <java classname="org.hsqldb.util.DatabaseManager" fork="true"> <classpath refid="classpath.hsqldb"/> <arg line="-url jdbc:hsqldb:hsql://localhost:${hsqldb.port}"/> </java> </target> <target name="db.stop"> <java classname="org.hsqldb.util.ShutdownServer" fork="true"> <classpath refid="classpath.hsqldb"/> <arg line="-url jdbc:hsqldb:hsql://localhost:${hsqldb.port} -user sa"/> </java> </target> <target name="db.clean"> <delete dir="build/db" /> <mkdir dir="build/db" /> </target> <!-- ================= --> <!-- TASK DECLARATIONS --> <!-- ================= --> <target name="declare.jbpm.tasks"> <ant antfile="build.xml" target="build" /> <taskdef file="src/java.jbpm/org/jbpm/ant/jbpm.ant.tasks.properties" format="properties"> <classpath refid="classpath.ant" /> </taskdef> </target> </project>
Thanks for ur help.