Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
 * JBoss, Home of Professional Open Source
 * Copyright 2006, 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.jboss.embedded;
This listener takes in the init parameter "jboss.embedded.resources" which is a comma delimited list of ServletContext resources that you want deployed within the WAR file. i.e. "/WEB-INF/lib/mybeans.jar" When the WAR is initialized, those referenced resources will be deployed. When the WAR is destroyed, those referenced resources are undeployed from the embedded kernel.

Author(s):
Bill Burke
Version:
$Revision: 44597 $
   private DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
   public void contextInitialized(ServletContextEvent servletContextEvent)
   {
      ServletContext servletContext = servletContextEvent.getServletContext();
      String resources = servletContext.getInitParameter("jboss.embedded.resources");
      if (resources == nullthrow new RuntimeException("You must specify a resources parameter to the ServletContextResourceScanner");
      StringTokenizer tokenizer = new StringTokenizer(resources",");
      while (tokenizer.hasMoreTokens())
      {
         String token = tokenizer.nextToken().trim();
         try
         {
            URL resource = servletContext.getResource(token);
            .add(resource);
         }
         catch (Exception e)
         {
            throw new RuntimeException("Unable to add servlet resource to deloyer: " + tokene);
         }
      }
      try
      {
         .process();
      }
      catch (DeploymentException e)
      {
         throw new RuntimeException("Failed to deploy servlet resources: " + resourcese);
      }
   }
   public void contextDestroyed(ServletContextEvent servletContextEvent)
   {
      try
      {
         .undeploy();
      }
      catch (DeploymentException e)
      {
         throw new RuntimeException(e);
      }
   }
New to GrepCode? Check out our FAQ X