首先,確認手邊有一份jbpm3的user guide,有一份還有JBPM3.0源碼的壓縮包
JBPM中是通過org.jbpm.db. JbpmSessionFactory.getInstance()返回一個JbpmSessionFactory實例,
下面通過分析getInstance()的過程,說明怎么設置相關配置文件
1、JbpmSessionFactory.getInstance()方法首先查找類路徑中的jbpm.properties文件
jbpm.scheduler.service.factory=org.jbpm.scheduler.impl.SchedulerServiceImpl jbpm.task.instance.class=org.jbpm.taskmgmt.exe.TaskInstance # uncomment the next line if JbpmSessionFactory.getInstance() # should lookup the singleton instance from JNDI instead of creating # a default one. # jbpm.session.factory.jndi.name=java:/jbpm/JbpmSessionFactory # uncomment the next line to use the file system instead of the database for # storing files related to a process definition # # jbpm.files.dir=c:/jbpm.data # resource path to a properties file that will overwrite all the hibernate # properties. For database specific builds in db project there is a different # hibernate.properties file on the classpath for each database. You could change # the default database for any testing runs by uncommenting the next line and # adding a hibernate.properties file in the basedir. # jbpm.hibernate.cfg.xml=jbpm.hibernate.cfg.xml jbpm.hibernate.properties=jbpm.hibernate.properties |
找到最基本的設置,jbpm.session.factory.jndi.name=java:/jbpm/JbpmSessionFactory
這行表示從jndi獲取一個JbpmSessionFactory的一個實例,如果你可以用JBPM3 demo中java:/jbpm/JbpmSessionFactory是與DataSource DefaultDS綁定在一起的(在jboss-service.xml中)。要部署在tomcat中,這行必須注釋掉。
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jbpm.db.jmx.JbpmService" name="jboss.jbpm:name=DefaultJbpm,service=JbpmService" description="Default jBPM Service"> <attribute name="JndiName">java:/jbpm/JbpmSessionFactory</attribute> <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends> </mbean> </server> |
jboss-service.xml文件內容,如果你用源碼包成功部署了websale的話,可以在JBOSS_HOME"server"jbpm"deploy"jbpm.sar"META-INF"目錄下找到該文件
2、如果getInstance()沒有找到jbpm.session.factory.jndi.name的值,會繼續查找jbpm.hibernate.properties的值,找到jbpm.hibernate.properties的值后,會用該值作為配置文件取創建JbpmSessionFactory
jbpm.hibernate.properties內容:
hibernate.dialect=org.hibernate.dialect.HSQLDialect hibernate.connection.datasource=java:/DefaultDS # hibernate.show_sql=true |
是用DataSource來創建JbpmSessionFactory,DataSource需要在Server.xml中配置,如果你不想配置DataSource的話,把這行也注釋掉
3、上面兩項內容都被注釋掉的話,getInstance()會查找jbpm.hibernate.cfg.xml的值,用該值作為配置文件創建一個JbpmSessionFactory。
說明,這里只是講了怎么配置相關文件,沒有說到怎么部署,關于這方面內容,請參考User Guide chapter 5