All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.plugins.server.servlet.ServletBootstrap Maven / Gradle / Ivy

There is a newer version: 4.0.0.Beta5
Show newest version
package org.jboss.resteasy.plugins.server.servlet;

import org.jboss.resteasy.spi.ResteasyDeployment;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;

/**
 * @author Bill Burke
 * @version $Revision: 1 $
 */
public class ServletBootstrap extends ListenerBootstrap
{
   private ServletConfig config;

   public ServletBootstrap(final ServletConfig config)
   {
      super(config.getServletContext());
      this.config = config;
   }

   @Override
   public ResteasyDeployment createDeployment()
   {
      ResteasyDeployment deployment = super.createDeployment();
      deployment.getDefaultContextObjects().put(ServletConfig.class, config);
      deployment.getDefaultContextObjects().put(ServletContext.class, config.getServletContext());
      return deployment;
   }

   public String getParameter(String name)
   {
      String val = resteasyConfig.getValue(name);
      if (val == null) val = config.getInitParameter(name);
      if (val == null) val = super.getParameter(name);
      return val;
   }

   @Override
   public String getInitParameter(String name)
   {
      return config.getInitParameter(name);
   }

   @Override
   public Set getParameterNames()
   {
      Set set = getResteasyConfigParameterNames();
      if (set != null)
      {
         return set;
      }
      set = super.getServletContextNames();
      Enumeration en = config.getInitParameterNames();
      while (en.hasMoreElements()) set.add(en.nextElement());
      return set;
   }

   @Override
   public Set getInitParameterNames()
   {
      Set set = new HashSet();
      Enumeration en = config.getInitParameterNames();
      while (en.hasMoreElements()) set.add(en.nextElement());
      return set;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy