use of javax.servlet.ServletContext in project jetty.project by eclipse.
the class Invoker method init.
/* ------------------------------------------------------------ */
public void init() {
ServletContext config = getServletContext();
_contextHandler = ((ContextHandler.Context) config).getContextHandler();
Handler handler = _contextHandler.getHandler();
while (handler != null && !(handler instanceof ServletHandler) && (handler instanceof HandlerWrapper)) handler = ((HandlerWrapper) handler).getHandler();
_servletHandler = (ServletHandler) handler;
Enumeration<String> e = getInitParameterNames();
while (e.hasMoreElements()) {
String param = e.nextElement();
String value = getInitParameter(param);
String lvalue = value.toLowerCase(Locale.ENGLISH);
if ("nonContextServlets".equals(param)) {
_nonContextServlets = value.length() > 0 && lvalue.startsWith("t");
}
if ("verbose".equals(param)) {
_verbose = value.length() > 0 && lvalue.startsWith("t");
} else {
if (_parameters == null)
_parameters = new HashMap<String, String>();
_parameters.put(param, value);
}
}
}
use of javax.servlet.ServletContext in project jetty.project by eclipse.
the class StatisticsServlet method init.
public void init() throws ServletException {
ServletContext context = getServletContext();
ContextHandler.Context scontext = (ContextHandler.Context) context;
Server _server = scontext.getContextHandler().getServer();
Handler handler = _server.getChildHandlerByClass(StatisticsHandler.class);
if (handler != null) {
_statsHandler = (StatisticsHandler) handler;
} else {
LOG.warn("Statistics Handler not installed!");
return;
}
_memoryBean = ManagementFactory.getMemoryMXBean();
_connectors = _server.getConnectors();
if (getInitParameter("restrictToLocalhost") != null) {
_restrictToLocalhost = "true".equals(getInitParameter("restrictToLocalhost"));
}
}
use of javax.servlet.ServletContext in project jetty.project by eclipse.
the class QoSFilter method init.
public void init(FilterConfig filterConfig) {
int max_priority = __DEFAULT_MAX_PRIORITY;
if (filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM) != null)
max_priority = Integer.parseInt(filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM));
_queues = new Queue[max_priority + 1];
_listeners = new AsyncListener[_queues.length];
for (int p = 0; p < _queues.length; ++p) {
_queues[p] = new ConcurrentLinkedQueue<>();
_listeners[p] = new QoSAsyncListener(p);
}
int maxRequests = __DEFAULT_PASSES;
if (filterConfig.getInitParameter(MAX_REQUESTS_INIT_PARAM) != null)
maxRequests = Integer.parseInt(filterConfig.getInitParameter(MAX_REQUESTS_INIT_PARAM));
_passes = new Semaphore(maxRequests, true);
_maxRequests = maxRequests;
long wait = __DEFAULT_WAIT_MS;
if (filterConfig.getInitParameter(MAX_WAIT_INIT_PARAM) != null)
wait = Integer.parseInt(filterConfig.getInitParameter(MAX_WAIT_INIT_PARAM));
_waitMs = wait;
long suspend = __DEFAULT_TIMEOUT_MS;
if (filterConfig.getInitParameter(SUSPEND_INIT_PARAM) != null)
suspend = Integer.parseInt(filterConfig.getInitParameter(SUSPEND_INIT_PARAM));
_suspendMs = suspend;
ServletContext context = filterConfig.getServletContext();
if (context != null && Boolean.parseBoolean(filterConfig.getInitParameter(MANAGED_ATTR_INIT_PARAM)))
context.setAttribute(filterConfig.getFilterName(), this);
}
use of javax.servlet.ServletContext in project jetty.project by eclipse.
the class WebAppContextTest method testRealPathDoesNotExist.
@Test
public void testRealPathDoesNotExist() throws Exception {
Server server = new Server(0);
WebAppContext context = new WebAppContext(".", "/");
server.setHandler(context);
server.start();
ServletContext ctx = context.getServletContext();
assertNotNull(ctx.getRealPath("/doesnotexist"));
assertNotNull(ctx.getRealPath("/doesnotexist/"));
}
use of javax.servlet.ServletContext in project jetty.project by eclipse.
the class InfoServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
ServletContext context = config.getServletContext();
NativeWebSocketConfiguration configuration = (NativeWebSocketConfiguration) context.getAttribute(NativeWebSocketConfiguration.class.getName());
configuration.getFactory().getPolicy().setMaxTextMessageSize(10 * 1024 * 1024);
configuration.addMapping("/info/*", this);
}
Aggregations