org.jboss.resteasy.plugins.server.servlet.ServletBootstrap Maven / Gradle / Ivy
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;
}
}