[jbpm-commits] JBoss JBPM SVN: r2782 - in projects/jsf-console/trunk/console/src/main: webapp/WEB-INF and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Nov 6 14:50:22 EST 2008
Author: heiko.braun at jboss.com
Date: 2008-11-06 14:50:22 -0500 (Thu, 06 Nov 2008)
New Revision: 2782
Added:
projects/jsf-console/trunk/console/src/main/java/org/jbpm/web/BootstrapListener.java
Modified:
projects/jsf-console/trunk/console/src/main/webapp/WEB-INF/web.xml
Log:
Added bootstrap listener that forces initialization of the hibenrate sssions used by jbpm.
Added: projects/jsf-console/trunk/console/src/main/java/org/jbpm/web/BootstrapListener.java
===================================================================
--- projects/jsf-console/trunk/console/src/main/java/org/jbpm/web/BootstrapListener.java (rev 0)
+++ projects/jsf-console/trunk/console/src/main/java/org/jbpm/web/BootstrapListener.java 2008-11-06 19:50:22 UTC (rev 2782)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.web;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+
+/**
+ * Force initialization of the hibernate sessions in jbpm.
+ * This will create the DB tables on new installations.
+ * If that's not needed the listener can be removed.
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class BootstrapListener implements ServletContextListener
+{
+ private JbpmConfiguration jbpmConfiguration;
+ private static final Log log = LogFactory.getLog(BootstrapListener.class);
+
+ public void contextInitialized(ServletContextEvent servletContextEvent)
+ {
+ String jbpmCfgResource =
+ servletContextEvent.getServletContext()
+ .getInitParameter("jbpm.configuration.resource");
+ jbpmConfiguration = JbpmConfiguration.getInstance(jbpmCfgResource);
+
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ log.info("Bootstrap Hibernate session");
+ jbpmContext.getGraphSession();
+ }
+ catch (RuntimeException e)
+ {
+ jbpmContext.setRollbackOnly();
+
+ throw e;
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent servletContextEvent)
+ {
+
+ }
+}
Modified: projects/jsf-console/trunk/console/src/main/webapp/WEB-INF/web.xml
===================================================================
--- projects/jsf-console/trunk/console/src/main/webapp/WEB-INF/web.xml 2008-11-06 16:39:49 UTC (rev 2781)
+++ projects/jsf-console/trunk/console/src/main/webapp/WEB-INF/web.xml 2008-11-06 19:50:22 UTC (rev 2782)
@@ -4,6 +4,18 @@
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" >
+
+ <!--
+ * Force initialization of the hibernate sessions in jbpm.
+ * This will create the DB tables on new installations.
+ * If that's not needed the listener can be removed.
+ -->
+ <listener>
+ <listener-class>
+ org.jbpm.web.BootstrapListener
+ </listener-class>
+ </listener>
+
<servlet>
<description>Enable the JSF servlet. See faces-config.xml for Faces-specific configuration</description>
<servlet-name>Faces Servlet</servlet-name>
More information about the jbpm-commits
mailing list