版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 简述 pm工作流框架与现有ssh框架的集成工作其实很简单,但国外的资料太小,所以会在集成时走入太多误区,本文是在struts1.2,spring2.5,hibernate3.2上集成成功的详细步骤。其中解决了,pm的访问数据库session与原有hibernate的session不同的问题,string-max大字段问题。完成了流程部署web与后台程序。利用spring-modules-0.8当中的spring31做为集成的桥梁(其实它已经做好了集成,但文档和实例实在是太简单)。 使用pm-starters-kit-3.1.4生成数据库表与安装eclipse图形化配置插件 1下载pm-sta
2、rters-kit-3.1.4到其,包含所有需要的工具与jar包。 2数据库的安装以oracle为例,其它数据库可按此例修改。 2.1创建所需用户与表空间,如果有了用户和表空间就不需要了。 2.2 找到pm-starters-kit-3.1.4文件夹,在其下的pm文件夹的下级文件夹lib中加入oracle的驱动包ojdbc14.jar. 2.3 在pmsrcresources文件夹下建立oracle文件夹, 将pmsrcresourceshsqldb里的perties和identity.db.xml文件copy到刚刚建立的oracle文件夹当中.
3、2.4 修改perties文件,修改目标数据库的连接属性如下: # these properties are used by the build script to create # a hypersonic database in the build/db directory that contains # the pm tables and a process deployed in there hibernate.dialect=org.hibernate.dialect.OracleDialect hibernate.connection.
4、driver_class=oracle.jdbc.driver.OracleDriver hibernate.connection.url=jdbc:oracle:thin:2:1521:oracle hibernate.connection.username=dpf hibernate.connection.password=dpf hibernate.show_sql=true vider_class=org.hibernate.cache.HashtableCacheProvider 2.5 修改pmsrcconfig.filesh
5、ibernate.cfg.xml文件,同样是配置数据库的连接属性如下: <!- jdbc connection properties -> <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> <property name="hibernate.connection.driver_class"
6、>oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.url">jdbc:oracle:thin:2:1521:oracle</property> <property name="hibernate.connection.username">dpf</property>
7、0; <property name="hibernate.connection.password">dpf</property> <property name="vider_class">org.hibernate.cache.HashtableCacheProvider</property> 2.6 修改pmbuild.deploy.xml文件.找到create.db项并进行如下修改: <!- = -> <!-
8、 = SERVER = -> <!- = -> <target name="create.db" depends="declare.pm.tasks, db.clean, db.start" description="creates a hypersonic database with the pm tables and loads the processes in there"> <pmschema actions="cr
9、eate" cfg="$basedir/src/config.files/hibernate.cfg.xml" properties="$basedir/src/resources/oracle/
10、perties"/> <loadidentities file="$basedir/src/resources/oracle/identity.db.xml" cfg="$basedir/src/config.files/hibernate.cfg.xml"
11、 properties="$basedir/src/resources/oracle/perties"/> <ant antfile="build.xml" target="cesses" inheritall="false" />
12、 <deployprocess cfg="$basedir/src/config.files/hibernate.cfg.xml" properties="$basedir/src/resources/oracle/perties">
13、; <fileset dir="build" includes="*.process" /> </deployprocess> <antcall target="db.stop" /> </target> 2.7 配置ant,在pm目录执行 ant create.db buildfile build.deploy.xml命令。 会有一些小错误的提示,没
14、有关系数据库的表已经建立完成。 2.8 eclipse的图形化配置插件安装文件可以到pm-starters-kit-3.1.4pm-designer pm-gpd-featureeclipse下找到,需注意版本。 部署pm的jar包和moudle的jar包 1 把如下jar包放入WEB-INFlib文件夹下, spring-modules-pm31.jar可以在 spring-modules-0.8下找到,其它的都属于pm工具包。 bsh-1.3.0.jar bsf.jar spring-modules-pm31.jar pm-webapp-3.1.4.jar pm-identity-3.1.
15、4.jar pm-3.1.4.jar 部署hbm文件到项目 1 在pm文件夹中找到所有的*.hbm.xml数据库映射文件。放到项目的一个文件夹当中。本例放到gresoftsecuritymodelhbm文件夹中。并且在hibernate的sessionfactory建立时,设置为相关路径配置。 2 此文件需在spring管理的hibernate配置文件下修改,本例为 dataAccessContext-hibernate.xml,如下: <!-Hibernate SessionFatory-> <bean id="session
16、Factory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <
17、property name="annotatedClasses"> <list> </list> </property> <property
18、 name="hibernateProperties"> <props> <prop key="hibernate.dialect">
19、60; org.hibernate.dialect.Oracle9Dialect </prop> <prop key="hibernate.show_sql"&g
20、t;true</prop> <prop key="vider_class"> org.hibernate.cache.EhCacheProvider
21、160; </prop> <prop key="hibernate.cache.use_query_cache">true</prop>
22、0; </props> </property> <property name="typeDefinitions"> <ref bean="pmTypes" />
23、60; </property> <property name="mappingDirectoryLocations"> <list> <value&
24、gt; classpath*:/gresoft/security/model/hbm/ </value>
25、 </list> </property> </bean> 设置大字段string-max 1 此文件需在spring管理的hibernate配置文件下修改,本例为 dataAccessContext-hibernate.xml,如下: <!- 处理大字段 ->
26、0; <bean id="pmTypes" class="org.springframework.orm.hibernate3.TypeDefinitionBean"> <property name="typeName" value="string_max" /> <property name="typeClass" v
27、alue="org.pm.db.hibernate.StringMax" /> </bean> 配置configration、template 说明: pmConfiguration是根据springmodules所提供的 LocalpmConfigurationFactoryBean进行配置,其集成好对pmConfiguration的管理。在系统使用时pmConfiguration需调用pmTemplate的pmTemplate.getpmConfiguration()方法得到。 1 此文件需在spring管理的hi
28、bernate配置文件下修改,本例为 dataAccessContext-hibernate.xml,如下: <!- PM configuration-> <bean id="pmConfiguration" class="org.springmodules.workflow.pm31.LocalpmConfigurationFactoryBean"> <property nam
29、e="sessionFactory" ref="sessionFactory" /> <property name="configuration" value="classpath:/datasql/pm.cfg.xml" /> </bean> <
30、!- PM template -> <bean id="pmTemplate" class="org.springmodules.workflow.pm31.pmTemplate"> <constructor-arg index="0" ref="pmConfiguration" /> </bean>
31、160; 2 增加类路径中pm.cfg.xml文件,可以根据 pm-starters-kit-3.1.4pmsrcjava.pmorgpmdefault.pm.cfg.xml 复制后修改。本例放到/datasql/pm.cfg.xml下。上面配置文件有相关配置。全部容如下: <pm-configuration> <! - 增加如下容 - à <pm-context> <service name="persistence">
32、 <factory> <bean class="org.pm.persistence.db.DbPersistenceServiceFactory">
33、60; <field name="isTransactionEnabled"> <false />
34、; </field> <field name="isCurrentSessionEnabled">
35、; <true /> </field>
36、60; </bean> </factory> </service> <service name=
37、"message" factory="org.pm.msg.db.DbMessageServiceFactory" /> <service name="scheduler" factory="org.pm.scheduler.db.DbSchedulerServiceFactory" /> <service name="logging" factory="org.pm.logging.d
38、b.DbLoggingServiceFactory" /> <service name="authentication" factory="org.pm.security.authentication.DefaultAuthenticationServiceFactory" /> </pm-context> <!- configuration resource files pointing to default configuration fi
39、les in pm-version.jar -> <!- 不再使用<string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />-> <string name="resource.business.calendar" value="org/pm/calendar/perties" /> <string n
40、ame="resource.default.modules" value="org/pm/graph/def/perties" /> <string name="resource.converter" value="org/pm/db/hibernate/perties" /> <string name="resource.action.types" value=&qu
41、ot;org/pm/graph/action/action.types.xml" /> <string name="resource.node.types" value="org/pm/graph/node/node.types.xml" /> <string name="resource.parsers" value="org/pm/jpdl/par/pm.parsers.xml" /> <string name="
42、resource.varmapping" value="org/pm/context/exe/pm.varmapping.xml" /> <long name="pm.msg.wait.timout" value="5000" singleton="true" /> <int name="pm.byte.block.size" value="1024" s
43、ingleton="true" /> <string name="mail.smtp.host" value="localhost" /> <bean name="pm.task.instance.factory" class="org.pm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" /> <
44、bean name="pm.variable.resolver" class="org.pm.jpdl.el.impl.pmVariableResolver" singleton="true" /> <bean name="pm.mail.address.resolver" class="org.pm.identity.mail.IdentityAddressResolver" singleton="true&q
45、uot; /> </pm-configuration> 过滤器的设置与建立 过滤器的建立是为了保证一个session的正常工作。 1 web.xml中的修改 本例中描述如下: <!- 注入pm过滤器,使用统一的Session -> <filter> <filter-name>pmContextFilter</filter-name> <filter-class&
46、gt;.gresoft ponents.pm.pmContextHolder</filter-class> </filter> 2建立对应的类文件 本例中描述如下: package .gresoft ponents.pm; import java.io.IOException; import java.io.Serializable; import java.security.Principal; import javax.servlet.Filter; import javax.servlet.FilterChain; impor
47、t javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet. . ServletRequest; import org.pm.pmConfiguration; import org.pm.pmContext; import org.springframework.web.context.WebApplicationContext
48、; public class pmContextHolder implements Filter, Serializable private static final long serialVersionUID = 1L; String pmConfigurationResource = null; St
49、ring pmContextName = null; boolean isAuthenticationEnabled = true; public void init(FilterConfig filterConfig) throws ServletException &
50、#160; / get the pm configuration resource this.pmConfigurationResource = filterConfig
51、60; .getInitParameter("pm.configuration.resource");
52、0; / get the pm context to be used from the pm configuration this.pmContextName = filterConfig
53、 .getInitParameter(""); if (pmCont
54、extName = null) pmContextName = pmContext.DEFAULT_PM_CONTEXT_NAME;
55、0; / see if authentication is turned off Strin
56、g isAuthenticationEnabledText = filterConfig .getInitParameter("authentication
57、"); if (isAuthenticationEnabledText != null)
58、60; && ("disabled".equalsIgnoreCase(isAuthenticationEnabledText) &
59、#160; isAuthenticationEnabled = false; public void doFilter(ServletRequest servle
60、tRequest, ServletResponse servletResponse, FilterChain filterChain)
61、60; throws IOException, ServletException String actorId = null; &
62、#160; / see if we can get the authenticated swimlaneActorId if (servletRequest instanceof ServletRequest) &
63、#160; ServletRequest ServletRequest = ( ServletRequest) servletRequest;
64、 Principal userPrincipal = ServletRequest.getUserPrincipal(); if
65、(userPrincipal != null) actorId = userPrincipal.getName();
66、
67、0; pmContext pmContext = getpmConfiguration(servletRequest)
68、 .createpmContext(pmContextName); try
69、60; if (isAuthenticationEnabled) pmContext.setA
70、ctorId(actorId);
71、 filterChain.doFilter(servletRequest, servletResponse); finally &
72、#160; pmContext.close();
73、60; /* * 从spring获取pmConfiguration的bean加载方式 */ protected pmConfiguration getpmConfiguration( &
74、#160; ServletRequest servletRequest) WebApplicationContext webApplicationContext =
75、(WebApplicationContext) ( ServletRequest) servletRequest) .getSession()
76、; .getServletContext() &
77、#160; .getAttribute(
78、60; WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
79、; pmConfiguration pmConfiguration = (pmConfiguration) webApplicationContext
80、160; .getBean("pmConfiguration"); / 得到业务Bean(在这里是你需要注入的bean) System.out.println("-"); &
81、#160; System.out.println("pmconfiguration对象化=" + pmConfiguration.toString(); System.out.println("-");
82、60; return pmConfiguration; public void destroy() &
83、#160; 编写发布流程定义xml的人机页面与程序 1 JSP页面使用struts1.2,spring2.0,hibernate3.2框架。此为流程发布页面。 <% page contentType="text/html;charset=UTF-8"%> <html> <head> </head> <body> <form action="项目名/pmtest.do?method=deploy"
84、 name="formupload" method="post" enctype="multipart/form-data"> 请选择要发布的流程文件<input name="workflowfile" type="file" id="workflowfile" > <input type=&q
85、uot;submit" name="submit"> </form> </body> </html> 2 后台对应类 /* * 文件名: pmAction.java<br> * 版本: <br> * 描述: <br> * 所有: <br> * / <br> * 创建者: 沙振中 <br> * 创建日期: Dec 27, 2007 <br> * 修改者: <br> * 修改日期: <br&
86、gt; * 修改说明: <br> */ package .gresoft.security.web; import java.io.InputStream; import javax.servlet. . ServletRequest; import javax.servlet. . ServletResponse; import org.apache mons.beanutils.DynaBean; import org.apache mons.logging.Log; import org.apache mons.logging.LogFactory; import
87、 org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.upload.FormFile; import org.pm.pmContext; import org.pm.graph.def.ProcessDefinition; import org.springmodules.workflow.pm31.pmTemplate; import
88、.gresoft mons.core.web.StrutsAction; public class pmAction extends StrutsAction private static Log log = LogFactory.getLog(pmAction.class); private pmTemplate pmTemplate; &
89、#160; public void setpmTemplate(pmTemplate pmTemplate) this.pmTemplate = pmTemplate; /*
90、; * 进入上传流程主页面 * param mapping * param form * param request * param response * return */ public ActionForward index(ActionMapping mapping, ActionForm form, ServletRequest request, ServletRe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 小学五年级数学下册《数字与信息:编码的奥秘》教学设计
- 初中九年级英语仁爱版Unit 2 Topic 3复习课教学设计
- 初中八年级物理《光的折射》创新教学设计(沪科版·安徽适用)
- 2026经济公考面试题及答案解析
- 2026溺水处理面试题及答案
- 2026人民服务面试题库及答案
- 学校招生报名录取流程
- 行政事业单位内控基本制度
- 孕妇吸氧注意事项
- 谋定天下:孙子兵法的现代商业战略智慧
- 人教PEP版(一起)(2024)一年级上册英语全册教案(单元整体教学设计)
- 舞蹈基础知识考试题库150题(含答案)
- 《电力行业企业培训师能力标准与评价规范》
- 铁工电〔2023〕54号国铁集团关于印发《普速铁路工务安全规则》的通知
- 安全生产应急预案管理办法
- 小升初奥数思维训练100题(附解析)
- 锂硫电池市场调研报告
- 《魔方》校本课程
- 2019-2021年山东省春季高考数学卷真题(含答案解析)
- 租赁合同终止协议官方版(5篇)
- YY/T 1853-2022超声骨组织手术设备刀具
评论
0/150
提交评论