use of org.eclipse.jetty.webapp.WebXmlConfiguration in project jetty.project by eclipse.
the class WSServer method createWebAppContext.
public WebAppContext createWebAppContext() throws MalformedURLException, IOException {
WebAppContext context = new WebAppContext();
context.setContextPath(this.contextPath);
context.setBaseResource(Resource.newResource(this.contextDir));
context.setAttribute("org.eclipse.jetty.websocket.jsr356", Boolean.TRUE);
// @formatter:off
context.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebXmlConfiguration(), new WebInfConfiguration(), new PlusConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new EnvConfiguration() });
return context;
}
use of org.eclipse.jetty.webapp.WebXmlConfiguration in project jetty.project by eclipse.
the class WSServer method createWebAppContext.
public WebAppContext createWebAppContext() throws MalformedURLException, IOException {
WebAppContext context = new WebAppContext();
context.setContextPath(this.contextPath);
context.setBaseResource(Resource.newResource(this.contextDir));
context.setAttribute("org.eclipse.jetty.websocket.jsr356", Boolean.TRUE);
// @formatter:off
context.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebXmlConfiguration(), new WebInfConfiguration(), new PlusConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new EnvConfiguration() });
return context;
}
use of org.eclipse.jetty.webapp.WebXmlConfiguration in project jersey by jersey.
the class JettyWebContainerFactory method create.
private static Server create(URI u, Class<? extends Servlet> c, Servlet servlet, Map<String, String> initParams, Map<String, String> contextInitParams) throws Exception {
if (u == null) {
throw new IllegalArgumentException("The URI must not be null");
}
String path = u.getPath();
if (path == null) {
throw new IllegalArgumentException("The URI path, of the URI " + u + ", must be non-null");
} else if (path.isEmpty()) {
throw new IllegalArgumentException("The URI path, of the URI " + u + ", must be present");
} else if (path.charAt(0) != '/') {
throw new IllegalArgumentException("The URI path, of the URI " + u + ". must start with a '/'");
}
path = String.format("/%s", UriComponent.decodePath(u.getPath(), true).get(1).toString());
WebAppContext context = new WebAppContext();
context.setDisplayName("JettyContext");
context.setContextPath(path);
context.setConfigurations(new Configuration[] { new WebXmlConfiguration() });
ServletHolder holder;
if (c != null) {
holder = context.addServlet(c, "/*");
} else {
holder = new ServletHolder(servlet);
context.addServlet(holder, "/*");
}
if (contextInitParams != null) {
for (Map.Entry<String, String> e : contextInitParams.entrySet()) {
context.setInitParameter(e.getKey(), e.getValue());
}
}
if (initParams != null) {
holder.setInitParameters(initParams);
}
Server server = JettyHttpContainerFactory.createServer(u, false);
server.setHandler(context);
server.start();
return server;
}
Aggregations