[jBPM Users] - Re: Awesome job with jBPM 4.1
by unsavory
@koen
I've been meaning to setup a blog for years and have not gotten around to it. But would be happy to blog about it if I ever get the time. =)
@lperea
Here are my configuration files:
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
| <!--
| Application context definition for PetClinic on JPA.
| -->
| <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
| xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
| xmlns:tx="http://www.springframework.org/schema/tx"
| xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
| xsi:schemaLocation="
| http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
| http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
| http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
| http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
| http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
| http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd">
|
| <!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
| <!--
| Activates a load-time weaver for the context. Any bean within the context that
| implements LoadTimeWeaverAware (such as LocalContainerEntityManagerFactoryBean)
| will receive a reference to the auto-detected load-time weaver.
| -->
| <context:load-time-weaver aspectj-weaving="on" />
| <!-- Use this to specify exactly which load-time weaver should be used, but
| it should get auto-detected. -->
| <!-- <context:load-time-weaver aspectj-weaving="on" weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver" /> -->
|
| <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
| <!-- (in this case, JDBC-related settings for the dataSource definition below) -->
| <context:property-placeholder location="classpath:/META-INF/lf.properties" />
|
| <!-- Apply dependency injection to non-managed classes annotated with the @Configurable -->
| <context:spring-configured />
|
| <!-- Auto scan and load Spring components -->
| <context:component-scan base-package="com.lf.service" />
|
| <!-- enables interpretation of the @Required annotation to ensure that dependency injection actually occures -->
| <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
|
| <!-- enables interpretation of the @PersistenceUnit/@PersistenceContext annotations providing convenient
| access to EntityManagerFactory/EntityManager -->
| <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
|
| <bean id="partnerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
| <property name="transactionManager" ref="jotm" />
| <property name="driverName" value="${jdbc.driverClassName}"/>
| <property name="url" value="${jdbc.partnerUrl}"/>
| <property name="user" value="${jdbc.partnerUsername}"/>
| <property name="password" value="${jdbc.partnerPassword}"/>
| </bean>
|
| <!-- Required because the stand-alone JOTM transaction manager is not auto-detected by the
| JtaTransactionManager because it requires a static accessor method. -->
| <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean">
| <property name="defaultTimeout" value="100000"/>
| </bean>
|
| <!-- Single XA data-source -->
| <bean id="xaDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
| <property name="transactionManager" ref="jotm" />
| <property name="driverName" value="${jdbc.driverClassName}"/>
| <property name="url" value="${jdbc.url}"/>
| <property name="user" value="${jdbc.username}"/>
| <property name="password" value="${jdbc.password}"/>
| </bean>
| <!-- XA data-source pool -->
| <!-- <bean id="xaDataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
| <property name="transactionManager" ref="jotm" />
| <property name="dataSource" ref="dataSource"/>
| <property name="user" value="${jdbc.username}"/>
| <property name="password" value="${jdbc.password}"/>
| </bean> -->
|
| <!-- supplying the JotmFactoryBean merely to the userTransaction property because JtaTransactionManager
| auto-detects that the object returned by the JotmFactoryBean implements both the
| UserTransaction and the TransactionManager interface -->
| <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
| <property name="userTransaction" ref="jotm"/>
| <!-- <property name="userTransactionName" value="java:comp/UserTransaction" /> -->
| <property name="transactionManager" ref="jotm"/>
| <property name="allowCustomIsolationLevels" value="true"/>
| </bean>
|
| <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
| p:database="${jpa.database}" p:showSql="${jpa.showSql}" />
|
| <!-- JPA EntityManagerFactory -->
| <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
| p:dataSource-ref="xaDataSource" p:jpaVendorAdapter-ref="jpaVendorAdapter" p:jpaDialect-ref="jpaDialect" >
|
| <!-- configure Hibernate to participate in JTA transactions using the JOTM transaction manager and
| specify further Hibernate specific configuration properties -->
| <property name="jpaPropertyMap">
| <map>
| <!-- Database Configuration -->
| <entry key="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
| <entry key="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}" />
| <entry key="hibernate.format_sql" value="false" />
| <entry key="hibernate.use_sql_comments" value="true" />
| <entry key="hibernate.default_batch_fetch_size" value="25" />
| <entry key="hibernate.order_updates" value="true" />
| <!-- Cache Configuration -->
| <!-- <entry key="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider" /> -->
| <!-- <entry key="net.sf.ehcache.configurationResourceName" value="ehcache.xml" /> -->
| <entry key="hibernate.cache.use_second_level_cache" value="false" />
| <entry key="hibernate.cache.use_query_cache" value="false" />
| <!-- Transaction Management -->
| <entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JOTMTransactionManagerLookup" />
| <!-- <entry key="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" /> -->
| <entry key="hibernate.connection.autocommit" value="false" />
| <entry key="hibernate.connection.release_mode" value="auto" />
| <entry key="hibernate.transaction.auto_close_session" value="false" />
| <entry key="hibernate.transaction.flush_before_completion" value="false" />
| <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
| <!-- Hibernate Search -->
| <!-- <entry key="hibernate.search.default.directory_provider" value="false" />
| <entry key="hibernate.search.default.indexBase" value="C:/Temp/hibernate_test_indexes" />
| <entry key="hibernate.search.default.batch.merge_factor" value="10" />
| <entry key="hibernate.search.default.batch.max_buffered_docs" value="10" />
| <entry key="hibernate.search.default.optimizer.operation_limit" value="500" />
| <entry key="hibernate.search.default.optimizer.transaction_limit.max" value="100" /> -->
| </map>
| </property>
| <property name="persistenceUnitName" value="LeapforcePU" />
| <!-- Custom implementation to enrich the PersistenceUnitInfo read from the persistence.xml
| JPA configuration file with the JTA datasource. specifying the JTA datasource directly in
| the Spring configuration file has the advantage that we can use a direct reference to the
| datasource instead of using a JNDI name as requied by the jta-data-source setting in the
| persistence.xml file -->
| <property name="persistenceUnitPostProcessors">
| <bean class="com.lf.service.jta.JtaPersistenceUnitPostProcessor">
| <property name="jtaDataSource" ref="xaDataSource" />
| </bean>
| </property>
| <property name="loadTimeWeaver">
| <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver" />
| </property>
| </bean>
|
| <bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory"/>
|
| <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
|
| <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
|
| <!--
| Activates various annotations to be detected in bean classes: Spring's
| @Required and @Autowired, as well as JSR 250's @PostConstruct,
| @PreDestroy and @Resource (if available) and JPA's @PersistenceContext
| and @PersistenceUnit (if available).
| -->
| <context:annotation-config transaction-manager="transactionManager" />
|
| <!--
| Instruct Spring to perform declarative transaction management
| automatically on annotated classes.
| -->
| <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
|
| <!--
| Instruct Spring to retrieve and apply @AspectJ aspects which are defined
| as beans in this context (such as the CallMonitoringAspect below).
| -->
| <aop:aspectj-autoproxy />
|
| <!--
| Post-processor to perform exception translation on @Repository classes (from native
| exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
| -->
| <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
|
|
| <!-- JBPM Spring Configuration File -->
| <import resource="classpath:com/lf/jbpm/applicationContext-process.xml" />
| </beans>
applicationContext-process.xml:
<?xml version="1.0" encoding="UTF-8"?>
|
| <beans xmlns="http://www.springframework.org/schema/beans"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
| <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
| <constructor-arg value="com/lf/jbpm/jbpm.cfg.xml" />
| </bean>
|
| <!-- <bean class="com.lf.jbpm.JobExecutorServlet" /> -->
|
| <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
| <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
| <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
| <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
| <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
| <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
| <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
|
| </beans>
jbpm.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
|
| <jbpm-configuration>
|
| <import resource="jbpm.jpdl.cfg.xml" />
| <import resource="jbpm.identity.cfg.xml" />
| <!-- Uncomment this to enable job executor -->
| <import resource="jbpm.jobexecutor.cfg.xml" />
|
| <process-engine-context>
| <repository-service />
| <repository-cache />
| <execution-service />
| <history-service />
| <management-service />
| <identity-service />
| <task-service />
|
| <!-- <job-executor threads="1" idle="15000" idle-max="60000" lock-millis="3600000" /> -->
|
|
| <!-- Here we needed to change the transaction interceptor -->
| <command-service>
| <retry-interceptor />
| <environment-interceptor />
| <spring-transaction-interceptor />
| </command-service>
|
| <!-- Added spring as read-context -->
| <script-manager default-expression-language="juel"
| default-script-language="juel"
| read-contexts="execution, environment, process-engine, spring"
| write-context="">
| <script-language name="juel"
| factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
| </script-manager>
|
| <id-generator />
| <types resource="jbpm.variable.types.xml" />
|
| <address-resolver />
|
| </process-engine-context>
|
|
| <transaction-context>
| <!-- Remove transaction tag to force jBPM to lookup transaction from Spring -->
| <!-- <transaction type="jta" /> -->
| <repository-session />
| <db-session />
|
| <message-session />
| <timer-session />
| <history-session />
| <mail-session>
| <mail-server>
| <session-properties resource="jbpm.mail.properties" />
| </mail-server>
| </mail-session>
|
| <!-- Need to set explicitly that we don't want jbpm to create sessions -->
| <hibernate-session current="true" />
| </transaction-context>
| </jbpm-configuration>
Hope that helps.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4258004#4258004
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4258004
15 years, 2 months