首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2,spring,jbpm实战——spring跟jbpm的详细配置

2012-10-26 
struts2,spring,jbpm实战——spring和jbpm的详细配置!--!--!--bean idsessionFactory //property

struts2,spring,jbpm实战——spring和jbpm的详细配置

<!----><!----><!---->

<bean id="sessionFactory" /></property><property name="mappingLocations"><list> <!-- jbpm's hbm.xml --> <value>classpath*:/org/jbpm/**/*.hbm.xml</value> <!-- other hbm.xml --> <value>classpath*:/com/resoft/system/domain/*.hbm.xml</value> </list></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop><prop key="show_sql">true</prop><prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop></props></property></bean>

?

<!----><!----><!---->

<property name="mappingLocations"><list> <!-- jbpm's 的hbm.xml --> <value>classpath*:/org/jbpm/**/*.hbm.xml</value> <!-- 其它地方自己配置的 hbm.xml --> <value>classpath*:/com/resoft/system/domain/*.hbm.xml</value> </list></property>?

?

<!----><!----><!---->

<property name="configLocations"> <list> <value>classpath:/hibernate.cfg.xml</value>   ...... </list> </property>?

<!-- 关于jbpmConfiguration的配置 --><bean id="jbpmConfiguration" ref="sessionFactory" /><property name="configuration" value="classpath:jbpm.cfg.xml" /><!-- 第一处需要注意的地方 --><property name="processDefinitions"><list><ref local="holidayWorkflow" /></list></property><!-- 没什么好说的,是否需要重新建表 --><property name="createSchema" value="${jbpmConfiguration.createSchema}" /></bean><bean id="holidayWorkflow" value="classpath:jbmp/workflow/holiday/holiday.zip" /></bean><bean id="holidayTemplate" ref="jbpmConfiguration" /><!-- 第三处需要注意的地方 --><constructor-arg index="1" ref="holidayWorkflow" /></bean>

?

?

<!----><!----><!---->

<!-- 第一处需要注意的地方 --><property name="processDefinitions"><list><ref local="holidayWorkflow" /></list></property>

?

<!----><!----><!---->

<!-- 第二处需要注意的地方 --><property name="definitionLocation" value="classpath:jbmp/workflow/holiday/holiday.zip" />?

?

<!----><!----><!---->

InputStream inputStream = null;try {inputStream = this.definitionLocation.getInputStream();this.processDefinition = ProcessDefinition.parseXmlInputStream(inputStream);}?

ZipInputStream inputStream = null;try {inputStream = new ZipInputStream(definitionLocation.getURL().openStream());this.processDefinition = ProcessDefinition.parseParZipInputStream(inputStream);}

?

<!----><!----><!---->

<!-- 第三处需要注意的地方 --><constructor-arg index="1" ref="holidayWorkflow" />?

?

<!----><!----><!---->

public JbpmTemplate(JbpmConfiguration jbpmConfiguration) {this.jbpmConfiguration = jbpmConfiguration;}?

?

public List findProcessInstances() {return (List) execute(new JbpmCallback() {public Object doInJbpm(JbpmContext context) {return context.getGraphSession().findProcessInstances(processDefinition.getId());//这里就使用到了processDefinition}});}?

?

<bean id="applyAssignmentHandler" ref="userService" /></bean>

?

<!----><!----><!---->

public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {   userService.find(hql); // 现在可以使用注入后的userServiceassignable.setActorId(Constants.USER);// 将任务分配给单个用户}?

?

<!----><!----><!---->

<assignment config-type="bean"><factoryKey>jbpmConfiguration</factoryKey><targetBean>applyAssignmentHandler</targetBean></assignment>

?

?

<!----><!----><!----><!---->

//得到jbpm的SessionFactorypublic synchronized SessionFactory getSessionFactory() { if (sessionFactory==null) { //与spring整合后,这里永远不会为null if (sessionFactoryJndiName!=null) { log.debug("looking up hibernate session factory in jndi '"+sessionFactoryJndiName+"'"); sessionFactory = (SessionFactory) JndiUtil.lookup(sessionFactoryJndiName, SessionFactory.class); } else { log.debug("building hibernate session factory"); sessionFactory = getConfiguration().buildSessionFactory(); //注意这一句中的getConfiguration() } } return sessionFactory; }?

<!----><!----><!---->

public synchronized Configuration getConfiguration() { if (configuration==null) { String hibernateCfgXmlResource = null; if (JbpmConfiguration.Configs.hasObject("resource.hibernate.cfg.xml")) { hibernateCfgXmlResource = JbpmConfiguration.Configs.getString("resource.hibernate.cfg.xml"); //取得jbpm.cfg.xml中配置的hibernate.cfg.xml } String hibernatePropertiesResource = null; if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties")) { hibernatePropertiesResource = JbpmConfiguration.Configs.getString("resource.hibernate.properties"); //取得jbpm.cfg.xml中配置的hibernate.properties } configuration = HibernateHelper.createConfiguration(hibernateCfgXmlResource, hibernatePropertiesResource); } return configuration; }

?

?

<!----><!----><!---->

<string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />

?

<!----><!----><!---->

<string name="resource.hibernate.properties" value="hibernate.properties" />?

?

<!----><!----><!---->

<!-- 没什么好说的,是否需要重新建表 --><property name="createSchema" value="true" />?

Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found

?

<!----><!----><!---->

if (cfgXmlResource!=null) { // use the configured file name log.debug("creating hibernate configuration resource '"+cfgXmlResource+"'"); configuration.configure(cfgXmlResource); } else { log.debug("using default hibernate configuration resource (hibernate.cfg.xml)"); configuration.configure(); }?

?

public Configuration configure() throws HibernateException {configure( "/hibernate.cfg.xml" );return this;}?

,我把hibernate.cfg.xml换成applicationContext.xml后出现错:
16:12:24,531 [http-8080-3] DEBUG HibernateHelper : creating hibernate configuration resource 'applicationContext.xml'
16:12:24,531 [http-8080-3] INFO  Configuration : configuring from resource: applicationContext.xml
16:12:24,531 [http-8080-3] INFO  Configuration : Configuration resource: applicationContext.xml

您觉得是什么原因,知道的话 麻烦告诉我:QQ:16753810 十分感谢

热点排行