2013-04-10 09:45:00.0|分类: activiti|浏览量: 1696
activiti可以独立部署还可以嵌入项目,现在介绍怎么嵌入项目中。 步骤1:配置activiti的配置文件activiti.cfg.xml 步骤2:把activiti所依赖的jar拷到工程下面 步骤3:创建一个标准的ServletContextListener
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.apache.log4j.Logger; public class ActivitiServletContextListener implements ServletContextListener { private static final Logger logger = Logger.getLogger(ActivitiServletContextListener.class); @Override public void contextInitialized(ServletContextEvent event) { ProcessEngine processEngine =ProcessEngines.getDefaultProcessEngine(); if (processEngine == null) { logger.error("Could not start the Activiti Engine"); } } @Override public void contextDestroyed(ServletContextEvent event) { ProcessEngines.destroy(); } }步骤4:在web.xml中配置
<!-- activiti --> <listener> <listener-class>com.xxx.core.ActivitiServletContextListener</listener-class> </listener> 到这里就完成了,可以在项目中直接使用activiti工作引擎了。
|