/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jbpm.pvm.internal.jobexecutor; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jbpm.api.Configuration; import org.jbpm.api.JbpmException; import org.jbpm.pvm.internal.env.EnvironmentFactory; import org.jbpm.pvm.internal.processengine.ProcessEngineImpl; /** * starts the job executor on init and closes the * jbpm configuration upon destroy. The closing of the * jbpm configuration will also shut down the job executor * thread pool. *
Name | *Description | *Type | *Default value | *
---|---|---|---|
jbpm.configuration.resource | *resource location of the jbpm.cfg.xml | *String | *jbpm.cfg.xml | *
Configuration example: *
* <web-app> * ... * <servlet > * <servlet-name>JobExecutorServlet</servlet-name> * <servlet-class>org.jbpm.job.executor.JobExecutorServlet</servlet-class> * <load-on-startup>1</load-on-startup> * </servlet> * <servlet-mapping > * <servlet-name>JobExecutorServlet</servlet-name> * <url-pattern>/jobexecutor</url-pattern> * </servlet-mapping> * ... * </web-app> ** * * @author Tom Baeyens */ public class JobExecutorServlet extends HttpServlet { private static final long serialVersionUID = 1L; JobExecutor jobExecutor; public void init() throws ServletException { String configurationResource = getInitParameter("jbpm.configuration.resource", "jbpm.cfg.xml"); EnvironmentFactory environmentFactory = (EnvironmentFactory) new Configuration().setResource(configurationResource).buildProcessEngine(); jobExecutor = environmentFactory.get(JobExecutor.class); if (jobExecutor==null) { throw new JbpmException("no job executor configured in resource "+configurationResource); } jobExecutor.start(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println(""); out.println(""); out.println("