- 浏览: 185041 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
springdata_spring:
java程序语言学习教程 地址http://www.zuida ...
JAVA开发者最常去的20个英文网站 -
love-_-java:
那么请问怎么单独导出jar包?我刚单独到处时:Unhandle ...
解决Eclipse中Java工程间循环引用而报错的问题 -
Hello_June:
...
使用Spring2.5的Autowired实现注释型的IOC -
两两ACE:
棒棒哒
使用Spring2.5的Autowired实现注释型的IOC -
liubang201010:
Foglight 监控OC4j 旧系统9.0.3/9.0.4等 ...
OC4J
1.首先我们要介绍
web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>xj</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<!-- Spring XML 文件读入 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext-resources.xml
classpath:/applicationContext-dao.xml
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<!-- Spring框架中对请求的编码方式进行统一管理 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<!-- 配置Struts2框架的核心Filter -->
<filter>
<filter-name>struts</filter-name>
<!-- 配置Struts 2核心Filter的实现类 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置Struts 2的核心FilterDispatcher拦截所有用户请求 -->
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- 启动Spring Listener contextConfigLocation -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- Listener log4jConfigLocation -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.然后我们介绍
applicationContext_resources.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- For mail settings and future properties files -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:mail.properties</value>
</list>
</property>
</bean>
<!-- 配置数据源 使用Apache DBCP 连接池-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${sqlserver.driverClassName}" />
<property name="url" value="${sqlserver.url}" />
<property name="username" value="${sqlserver.username}" />
<property name="password" value="${sqlserver.password}" />
<property name="maxActive" value="100"/>
<property name="maxWait" value="1000"/>
<property name="poolPreparedStatements" value="true"/>
<property name="defaultAutoCommit" value="true"/>
</bean>
</beans>
然后这个文件就要使用到辅助文件jdbc.properties:
sqlserver.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
sqlserver.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=AOP_JBPM;SelectMethod=cursor;
sqlserver.username=sa
sqlserver.password=sa
sqlserver.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
mysql.driverClassName=com.mysql.jdbc.Driver
mysql.url=jdbc:mysql://localhost/itsm?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8
mysql.username=root
mysql.password=
mysql.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
3.介绍applicationContext-dao.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeDefinitions" ref="jbpmTypes"/>
<!-- 导入用户自定义的*.hbm.xml文件 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/dhcc/itsm/</value>
</list>
</property>
<!--
throw error:
cvc-complex-type.2.3: Element 'list' cannot have character [children],
because the type's content type is element-only.
<property name="mappingJarLocations">
<list>
<value>WEB-INF/lib/jbpm-jpdl.jar</value>
<value>WEB-INF/lib/jbpm-identity.jar</value>
</list>
</property>
-->
<!-- 可以导入包里的所有文件。但是此写法不适用WEBLOGIC -->
<property name="mappingLocations">
<value>classpath*:/org/jbpm/**/*.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<!--
为了使HIBERNATE3查询的时候使用正确的语法需要指明查询工厂类,如果不指定回出现
ClassNotFoundException: org.hibernate.hql.ast.HqlToken 的错误!
<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
-->
<!--
Hibernate3.0 采用新的基于ANTLR的HQL/SQL查询翻译器,
在Hibernate的配置文件中,hibernate.query.factory_class
属性用来选择查询翻译器。
(1)选择Hibernate3.0的查询翻译器:
hibernate.query.factory_class=
org.hibernate.hql.ast.ASTQueryTranslatorFactory
(2)选择Hibernate2.1的查询翻译器hibernate.query.factory_class=
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
-->
</props>
</property>
</bean>
<!-- JPBM的大字段处理类型 -->
<bean id="jbpmTypes" class="org.springframework.orm.hibernate3.TypeDefinitionBean">
<property name="typeName" value="string_max" />
<property name="typeClass" value="org.jbpm.db.hibernate.StringMax" />
</bean>
<!-- 定义processdefinition.xml是否自动发布 -->
<bean id="processDefinitionFactoryBean"
class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
<property name="definitionLocation"
value="classpath:com/dhcc/itsm/jbpm/process/simple/processdefinition.xml" />
</bean>
<!-- 配置spring-modules-jbpm31.jar中提供的JbpmConfiguration -->
<bean id="jbpmConfiguration"
class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<property name="sessionFactory" ref="sessionFactory" />
<property name="configuration" value="classpath:jbpm.cfg.xml" />
<property name="createSchema" value="false" />
<!-- 定义processdefinition.xml是否自动发布 -->
<property name="processDefinitions">
<list>
<ref local="processDefinitionFactoryBean" />
</list>
</property>
</bean>
<bean id="jbpmTemplate"
class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<constructor-arg index="0" ref="jbpmConfiguration" />
</bean>
<!-- 使用BeanNameAutoProxyCreator的代理方法 -->
<!--
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactoryForJbpm" />
</bean>
<bean id="beanNameProxy"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<value>*Manager</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="myTransactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
-->
<!-- TransactionManager 自动创建代理,使用时必须获取实现类,工厂创建代理可以添加所要继承的接口 -->
<bean id="transactionProxyFactoryBean"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="singleton">
<value>false</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionAttributes">
<props>
<prop key="find*">
PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
</prop>
<prop key="*">
PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-Exception
</prop>
</props>
</property>
<property name="transactionManager">
<ref bean="hibernateTransactionManager" />
</property>
</bean>
<!-- TransactionManager spring拦截器中的事务管理 -->
<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
4.最后就是用到用户自定义的applicationContext.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 自定义类 -->
<bean id="serviceTemplate" parent="transactionProxyFactoryBean">
<property name="target">
<bean class="com.。。。.service.ServiceTemplate">
<property name="jbpmManage" ref="jbpmManage" />
</bean>
</property>
</bean>
<!-- Add new Managers here -->
<bean id="jbpmManage" class="com.。。。。.manage.JbpmManage">
<property name="jbpmDao">
<ref bean="jbpmDao" />
</property>
</bean>
<!-- Add new DAOs here -->
<bean id="jbpmDao" class="com.。。。。.dao.JbpmDao">
<property name="jbpmTemplate">
<ref bean="jbpmTemplate" />
</property>
</bean>
<!-- Add new Actions here -->
<bean id="deployProcessDefinition" class="com.。。。.actions.DeployProcessDefinition">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<bean id="startProcess" class="com.。。。。.actions.StartProcess">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<bean id="itsmMemu" class="com.。。。actions.ItsmMemu">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<bean id="processInstanceMemu" class="com.。。。.actions.ProcessInstanceMemu">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<!-- 事务通知 -->
<!--
<tx:advice id="txAdvice" transaction-manager="hibernateTransactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" propagation="REQUIRES_NEW" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
-->
<!-- aop代理设置 -->
<!--
<aop:config proxy-target-class="true">
<aop:pointcut id="txPointcut" expression="execution(* com...*Service.*(..))"/>
<aop:pointcut id="logPointcut" expression="execution(* com.r..*Service.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" order="1"/>
<aop:aspect id="logAspect" ref="logInterceptor" order="2" >
<aop:after-throwing
pointcut-ref="logPointcut"
method="serviceIntercept" />
</aop:aspect>
</aop:config>
-->
</beans>
5.介绍JBPM的配置信息jbpm.cfg.xml:在这里我们应该注意我们用到的是SPRING .所以我就没有用HIBRENATE来产生sessionFactory。。
<jbpm-configuration>
<!--
The default configurations can be found in org/jbpm/default.jbpm.cfg.xml
Those configurations can be overwritten by putting this file called
jbpm.cfg.xml on the root of the classpath and put in the customized values.
-->
<jbpm-context>
<service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
<!--
<service name="persistence">
<factory>
<bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
<field name="isTransactionEnabled">
<false />
</field>
<field name="isCurrentSessionEnabled">
<true/>
</field>
</bean>
</factory>
</service>
-->
<service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
<service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
<service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
<service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
<service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
</jbpm-context>
<--<string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />-->
<!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
<string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
<string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
<string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
<string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
<string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
<string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
<string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
<string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
<long name="jbpm.msg.wait.timout" value="5000" singleton="true" /> <!-- 5 seconds -->
<int name="jbpm.byte.block.size" value="1024" singleton="true" />
<bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
<bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
<string name="jbpm.mail.smtp.host" value="localhost" />
<bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
<bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">
<field name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></field>
<field name="name"><string value="JbpmJobExector" /></field>
<field name="nbrOfThreads"><int value="1" /></field>
<field name="idleInterval"><int value="5000" /></field>
<field name="maxIdleInterval"><int value="3600000" /></field>
<field name="historyMaxSize"><int value="20" /></field>
<field name="maxLockTime"><int value="600000" /></field>
<field name="lockMonitorInterval"><int value="60000" /></field>
<field name="lockBufferTime"><int value="5000" /></field>
</bean>
</jbpm-configuration>
6.hibernate.cfg.xml文件。。我置空。。
<hibernate-configuration>
<session-factory>
</session-factory>
</hibernate-configuration>
7.介绍struts2的配置文件struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="false"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.action.extension" value="html"/>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.custom.i18n.resources" value="ApplicationResources,errors"/>
<constant name="struts.multipart.maxSize" value="2097152"/>
<constant name="struts.ui.theme" value="css_xhtml"/>
<constant name="struts.codebehind.pathPrefix" value="/WEB-INF/pages/"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<include file="struts_itsm.xml" />
<!-- Add packages here -->
</struts>
8.然后会用到struts_itsm.xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- package提供了将多个Action组织为一个模块的方式
package的名字必须是唯一的 package可以扩展 当一个package扩展自
另一个package时该package会在本身配置的基础上加入扩展的package
的配置 父package必须在子package前配置
name:package名称
extends:继承的父package名称
abstract:设置package的属性为抽象的 抽象的package不能定义action 值true:false
namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action
-->
<package name="itsm" extends="struts-default">
<action name="ItsmMemu" class="com.。。。.actions.ItsmMemu">
<result>/itsm/ItsmMemu.jsp</result>
</action>
<action name="*" class="com.。。。.actions.ItsmMemu">
<result>/itsm/{1}.jsp</result>
</action>
<action name="ChooseProcessDefinition" class="com.。。。.actions.ChooseProcessDefinition">
<result>/itsm/ChooseProcessDefinition.jsp</result>
</action>
<action name="DeployProcessDefinition" class="com.。。。.actions.DeployProcessDefinition">
<result name="input">/itsm/Missing.jsp</result>
<result name="success" type="redirect-action">ItsmMemu</result>
</action>
<action name="ProcessInstanceMemu" class="com.。。。.actions.ProcessInstanceMemu">
<result>/itsm/ProcessInstanceMemu.jsp</result>
</action>
<action name="StartProcess" class="com。。。.actions.StartProcess">
<result>/itsm/StartProcess.jsp</result>
</action>
<action name="NextProcess" class="com.。。。.actions.NextProcess">
<result>/itsm/NextProcess.jsp</result>
</action>
<!-- Add actions here -->
</package>
</struts>
当然首页INDEX.JSP就不重复了啊
9.当然如果用到上诉框架。肯定是不能缺少一些JAR包的。
这样就可以把上诉框架配置完毕。。
有什么不周的地方。。请大家多提建议。。。
http://blog.csdn.net/gabriel80/archive/2008/05/23/2472237.aspx
web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>xj</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<!-- Spring XML 文件读入 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext-resources.xml
classpath:/applicationContext-dao.xml
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<!-- Spring框架中对请求的编码方式进行统一管理 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<!-- 配置Struts2框架的核心Filter -->
<filter>
<filter-name>struts</filter-name>
<!-- 配置Struts 2核心Filter的实现类 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置Struts 2的核心FilterDispatcher拦截所有用户请求 -->
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- 启动Spring Listener contextConfigLocation -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- Listener log4jConfigLocation -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.然后我们介绍
applicationContext_resources.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- For mail settings and future properties files -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:mail.properties</value>
</list>
</property>
</bean>
<!-- 配置数据源 使用Apache DBCP 连接池-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${sqlserver.driverClassName}" />
<property name="url" value="${sqlserver.url}" />
<property name="username" value="${sqlserver.username}" />
<property name="password" value="${sqlserver.password}" />
<property name="maxActive" value="100"/>
<property name="maxWait" value="1000"/>
<property name="poolPreparedStatements" value="true"/>
<property name="defaultAutoCommit" value="true"/>
</bean>
</beans>
然后这个文件就要使用到辅助文件jdbc.properties:
sqlserver.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
sqlserver.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=AOP_JBPM;SelectMethod=cursor;
sqlserver.username=sa
sqlserver.password=sa
sqlserver.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
mysql.driverClassName=com.mysql.jdbc.Driver
mysql.url=jdbc:mysql://localhost/itsm?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8
mysql.username=root
mysql.password=
mysql.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
3.介绍applicationContext-dao.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeDefinitions" ref="jbpmTypes"/>
<!-- 导入用户自定义的*.hbm.xml文件 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/dhcc/itsm/</value>
</list>
</property>
<!--
throw error:
cvc-complex-type.2.3: Element 'list' cannot have character [children],
because the type's content type is element-only.
<property name="mappingJarLocations">
<list>
<value>WEB-INF/lib/jbpm-jpdl.jar</value>
<value>WEB-INF/lib/jbpm-identity.jar</value>
</list>
</property>
-->
<!-- 可以导入包里的所有文件。但是此写法不适用WEBLOGIC -->
<property name="mappingLocations">
<value>classpath*:/org/jbpm/**/*.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<!--
为了使HIBERNATE3查询的时候使用正确的语法需要指明查询工厂类,如果不指定回出现
ClassNotFoundException: org.hibernate.hql.ast.HqlToken 的错误!
<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
-->
<!--
Hibernate3.0 采用新的基于ANTLR的HQL/SQL查询翻译器,
在Hibernate的配置文件中,hibernate.query.factory_class
属性用来选择查询翻译器。
(1)选择Hibernate3.0的查询翻译器:
hibernate.query.factory_class=
org.hibernate.hql.ast.ASTQueryTranslatorFactory
(2)选择Hibernate2.1的查询翻译器hibernate.query.factory_class=
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
-->
</props>
</property>
</bean>
<!-- JPBM的大字段处理类型 -->
<bean id="jbpmTypes" class="org.springframework.orm.hibernate3.TypeDefinitionBean">
<property name="typeName" value="string_max" />
<property name="typeClass" value="org.jbpm.db.hibernate.StringMax" />
</bean>
<!-- 定义processdefinition.xml是否自动发布 -->
<bean id="processDefinitionFactoryBean"
class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
<property name="definitionLocation"
value="classpath:com/dhcc/itsm/jbpm/process/simple/processdefinition.xml" />
</bean>
<!-- 配置spring-modules-jbpm31.jar中提供的JbpmConfiguration -->
<bean id="jbpmConfiguration"
class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<property name="sessionFactory" ref="sessionFactory" />
<property name="configuration" value="classpath:jbpm.cfg.xml" />
<property name="createSchema" value="false" />
<!-- 定义processdefinition.xml是否自动发布 -->
<property name="processDefinitions">
<list>
<ref local="processDefinitionFactoryBean" />
</list>
</property>
</bean>
<bean id="jbpmTemplate"
class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<constructor-arg index="0" ref="jbpmConfiguration" />
</bean>
<!-- 使用BeanNameAutoProxyCreator的代理方法 -->
<!--
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactoryForJbpm" />
</bean>
<bean id="beanNameProxy"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<value>*Manager</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="myTransactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
-->
<!-- TransactionManager 自动创建代理,使用时必须获取实现类,工厂创建代理可以添加所要继承的接口 -->
<bean id="transactionProxyFactoryBean"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="singleton">
<value>false</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionAttributes">
<props>
<prop key="find*">
PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
</prop>
<prop key="*">
PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-Exception
</prop>
</props>
</property>
<property name="transactionManager">
<ref bean="hibernateTransactionManager" />
</property>
</bean>
<!-- TransactionManager spring拦截器中的事务管理 -->
<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
4.最后就是用到用户自定义的applicationContext.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 自定义类 -->
<bean id="serviceTemplate" parent="transactionProxyFactoryBean">
<property name="target">
<bean class="com.。。。.service.ServiceTemplate">
<property name="jbpmManage" ref="jbpmManage" />
</bean>
</property>
</bean>
<!-- Add new Managers here -->
<bean id="jbpmManage" class="com.。。。。.manage.JbpmManage">
<property name="jbpmDao">
<ref bean="jbpmDao" />
</property>
</bean>
<!-- Add new DAOs here -->
<bean id="jbpmDao" class="com.。。。。.dao.JbpmDao">
<property name="jbpmTemplate">
<ref bean="jbpmTemplate" />
</property>
</bean>
<!-- Add new Actions here -->
<bean id="deployProcessDefinition" class="com.。。。.actions.DeployProcessDefinition">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<bean id="startProcess" class="com.。。。。.actions.StartProcess">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<bean id="itsmMemu" class="com.。。。actions.ItsmMemu">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<bean id="processInstanceMemu" class="com.。。。.actions.ProcessInstanceMemu">
<property name="serviceTemplate" ref="serviceTemplate" />
</bean>
<!-- 事务通知 -->
<!--
<tx:advice id="txAdvice" transaction-manager="hibernateTransactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" propagation="REQUIRES_NEW" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
-->
<!-- aop代理设置 -->
<!--
<aop:config proxy-target-class="true">
<aop:pointcut id="txPointcut" expression="execution(* com...*Service.*(..))"/>
<aop:pointcut id="logPointcut" expression="execution(* com.r..*Service.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" order="1"/>
<aop:aspect id="logAspect" ref="logInterceptor" order="2" >
<aop:after-throwing
pointcut-ref="logPointcut"
method="serviceIntercept" />
</aop:aspect>
</aop:config>
-->
</beans>
5.介绍JBPM的配置信息jbpm.cfg.xml:在这里我们应该注意我们用到的是SPRING .所以我就没有用HIBRENATE来产生sessionFactory。。
<jbpm-configuration>
<!--
The default configurations can be found in org/jbpm/default.jbpm.cfg.xml
Those configurations can be overwritten by putting this file called
jbpm.cfg.xml on the root of the classpath and put in the customized values.
-->
<jbpm-context>
<service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
<!--
<service name="persistence">
<factory>
<bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
<field name="isTransactionEnabled">
<false />
</field>
<field name="isCurrentSessionEnabled">
<true/>
</field>
</bean>
</factory>
</service>
-->
<service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
<service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
<service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
<service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
<service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
</jbpm-context>
<--<string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />-->
<!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
<string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
<string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
<string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
<string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
<string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
<string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
<string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
<string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
<long name="jbpm.msg.wait.timout" value="5000" singleton="true" /> <!-- 5 seconds -->
<int name="jbpm.byte.block.size" value="1024" singleton="true" />
<bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
<bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
<string name="jbpm.mail.smtp.host" value="localhost" />
<bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
<bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">
<field name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></field>
<field name="name"><string value="JbpmJobExector" /></field>
<field name="nbrOfThreads"><int value="1" /></field>
<field name="idleInterval"><int value="5000" /></field>
<field name="maxIdleInterval"><int value="3600000" /></field>
<field name="historyMaxSize"><int value="20" /></field>
<field name="maxLockTime"><int value="600000" /></field>
<field name="lockMonitorInterval"><int value="60000" /></field>
<field name="lockBufferTime"><int value="5000" /></field>
</bean>
</jbpm-configuration>
6.hibernate.cfg.xml文件。。我置空。。
<hibernate-configuration>
<session-factory>
</session-factory>
</hibernate-configuration>
7.介绍struts2的配置文件struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="false"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.action.extension" value="html"/>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.custom.i18n.resources" value="ApplicationResources,errors"/>
<constant name="struts.multipart.maxSize" value="2097152"/>
<constant name="struts.ui.theme" value="css_xhtml"/>
<constant name="struts.codebehind.pathPrefix" value="/WEB-INF/pages/"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<include file="struts_itsm.xml" />
<!-- Add packages here -->
</struts>
8.然后会用到struts_itsm.xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- package提供了将多个Action组织为一个模块的方式
package的名字必须是唯一的 package可以扩展 当一个package扩展自
另一个package时该package会在本身配置的基础上加入扩展的package
的配置 父package必须在子package前配置
name:package名称
extends:继承的父package名称
abstract:设置package的属性为抽象的 抽象的package不能定义action 值true:false
namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action
-->
<package name="itsm" extends="struts-default">
<action name="ItsmMemu" class="com.。。。.actions.ItsmMemu">
<result>/itsm/ItsmMemu.jsp</result>
</action>
<action name="*" class="com.。。。.actions.ItsmMemu">
<result>/itsm/{1}.jsp</result>
</action>
<action name="ChooseProcessDefinition" class="com.。。。.actions.ChooseProcessDefinition">
<result>/itsm/ChooseProcessDefinition.jsp</result>
</action>
<action name="DeployProcessDefinition" class="com.。。。.actions.DeployProcessDefinition">
<result name="input">/itsm/Missing.jsp</result>
<result name="success" type="redirect-action">ItsmMemu</result>
</action>
<action name="ProcessInstanceMemu" class="com.。。。.actions.ProcessInstanceMemu">
<result>/itsm/ProcessInstanceMemu.jsp</result>
</action>
<action name="StartProcess" class="com。。。.actions.StartProcess">
<result>/itsm/StartProcess.jsp</result>
</action>
<action name="NextProcess" class="com.。。。.actions.NextProcess">
<result>/itsm/NextProcess.jsp</result>
</action>
<!-- Add actions here -->
</package>
</struts>
当然首页INDEX.JSP就不重复了啊
9.当然如果用到上诉框架。肯定是不能缺少一些JAR包的。
这样就可以把上诉框架配置完毕。。
有什么不周的地方。。请大家多提建议。。。
http://blog.csdn.net/gabriel80/archive/2008/05/23/2472237.aspx
发表评论
-
jboss ESB 服务编排
2011-05-02 20:03 4085jboss ESB 是企业服务总线,应用很广,但资料很少,而且 ... -
jBPM相关概念
2009-06-18 10:54 1086jBPM相关概念 1. JPDL的流程定义元 ... -
jBPM相关概念
2008-11-25 16:53 1331jBPM相关概念2008-07-10 17:15关键字:jbp ... -
jbpm]在JSP页面中显示JBPM流程图
2008-11-25 16:50 6710[jbpm]在JSP页面中显示JBPM流程图2008-07-1 ... -
把jbpm流程图显示在jsp页面中2008-07-10 15:08把jbpm流程图显示在jsp页面中
2008-11-25 16:48 2544把jbpm流程图显示在jsp页面中2008-07-10 15: ...
相关推荐
在这个配置中,我们将探讨如何将这些框架集成在一起,创建一个基于Spring 2.5.4、Hibernate 3.2.6、Struts2和jbpm3.2.2的应用。 1. **Spring框架**: - Spring 2.5.4作为应用的核心容器,负责管理应用的bean(对象...
在这个场景中,我们讨论的是如何将Spring 2.5.4、Hibernate 3.2.6、Struts2以及jbpm 3.2.2这四个组件集成到一个项目中。下面将分别介绍这些组件以及它们在整合过程中的配置细节。 1. **Spring 2.5.4**: Spring 是...
标题 "compass-2.2.0+hibernate-3.2+struts-2.1.8.1+spring-framework-2.5.4" 指的是一个集成开发环境,它结合了四个关键的技术组件:Compass、Hibernate、Struts 2 和 Spring Framework,这些都是Java Web开发中的...
资源包含flex-2.5.4+bison-2.4.1+mingw,此外包含本人写的测试源码,编译命令及详细过程,另附一些有用的文章pdf,用于编译原理课程学习。详细使用参考文章:...
dubbo-admin-2.5.4 + 用法教程。 使用方法: 1. 删除tomcat webapps下面的ROOT目录 2. 解压本文件,然后把ROOT目录整体copy过去 3. 运行tomcat,然后访问tomcat根目录地址 (注意里面的WEB-INF/dubbo.properties中...
2. **对象持久化**:通过Spring的Hibernate模板或者JPA抽象层,开发者可以轻松地将Java对象持久化到数据库中,无需直接编写SQL语句。 3. **数据访问抽象**:Spring的Data Access/Integration模块提供了一种抽象层,...
这是一个基于Spring 4.3.9.RELEASE、Maven、Dubbo 2.5.4和Zookeeper 3.4.9的SOA(Service-Oriented Architecture)简单架构项目,旨在为初学者提供一个可运行的学习平台。下面将详细阐述这个项目中涉及的核心技术和...
Python 2.5.4 和 wxPython 2.8 是两个重要的开源软件工具,它们在IT领域中扮演着重要角色,特别是在开发图形用户界面(GUI)应用方面。 Python 2.5.4 是 Python 语言的一个旧版本,发布于2007年,它提供了丰富的...
标题 "spring2.54+struts2+hibernater3.1" 指的是一个集成开发环境,其中包含了三个关键的Java企业级框架:Spring 2.5.4、Struts 2和Hibernate 3.1。这些框架在Web应用开发中扮演着重要角色,特别是对于大型的企业级...
Visual SVN 2.5.4是该软件的一个特定版本,它提供了稳定且高效的SVN服务器服务。此版本可能包含了性能优化、安全性更新和一些新功能。在安装Visual SVN时,通常会配置SVN仓库,设置用户权限,以及与网络环境的集成,...
Struts2、Spring 2.5.4 和 Hibernate 3.1 是经典的Java Web开发框架组合,它们在2000年代末至2010年代初被广泛使用。这个组合为开发者提供了一个强大而灵活的平台,用于构建企业级应用,如本案例中的网上书店商城。 ...
《Spring Framework 2.5.4深度解析》 Spring Framework是Java开发中广泛使用的轻量级框架,2.5.4版本是其历史上的一个重要里程碑。这个版本在前代的基础上进行了许多优化和改进,旨在提高开发效率,增强应用的可...
1、开发环境:MyEclipse6.0, Struts 2.0.11, Spring2.5.4, struts2-spring-plugin-2.0.11.1,JFreeChart 1.0.9, JCommon 1.0.12,struts2-jfreechart-plugin-2.0.11.1,JDK1.5+ 2、下载地址: ...
《Spring Framework 2.5.4 全面解析:核心组件与依赖剖析》 Spring Framework 2.5.4 是一款历史悠久且极具影响力的Java企业级应用开发框架,它以其强大的功能和灵活的设计理念,深受开发者喜爱。这个版本的Spring...
Spring 2.5.4版本是该框架的一个重要里程碑,尽管现在已经有了更新的版本,但理解2.5.4的源码对于深入学习Spring的工作原理仍然非常有价值。这个压缩包"spring-framework-2.5.4源码.rar"包含了Spring框架的核心组件...
Spring Framework 2.5.4 是该框架的一个较早版本,但即便如此,它仍包含了大量重要的概念和技术,对理解 Spring 的发展历程以及其核心原理有着重要意义。 首先,Spring 框架的核心特性之一是依赖注入(Dependency ...
4. **数据访问集成**:Spring 支持多种数据访问技术,包括 JDBC、Hibernate、JPA 等,提供了统一的编程模型,简化了数据访问层的开发。 5. **Web 框架**:Spring MVC 是一个强大的 Web 应用开发框架,提供了模型-...
Spring AOP(面向切面编程)是Spring框架的重要组成部分,它提供了一种在不修改源代码的情况下对程序进行功能增强的机制。这个"spring2.5AOPdemo详细资料"很可能是针对Spring 2.5版本的一个AOP实战示例,帮助开发者...
struts2.3.1, spring2.5.4, hibernate3.2.5,包含mysql脚本,可测试。该整合方式下,hibernate.cfg.xml整合到了applicationContext.xml文件里,并且在applicationContext.xml里配置了c3p0数据源连接池。
4. **数据访问集成**:Spring 2.5.4支持JDBC、Hibernate、JPA等多种数据访问技术。例如,`JdbcTemplate`简化了SQL操作,而`HibernateTemplate`则为使用Hibernate提供了一层抽象。 5. **Spring MVC**:Spring的Web ...