Search in sources :

Example 1 with WebXmlConfiguration

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;
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) WebInfConfiguration(org.eclipse.jetty.webapp.WebInfConfiguration) MetaInfConfiguration(org.eclipse.jetty.webapp.MetaInfConfiguration) PlusConfiguration(org.eclipse.jetty.plus.webapp.PlusConfiguration) FragmentConfiguration(org.eclipse.jetty.webapp.FragmentConfiguration) AnnotationConfiguration(org.eclipse.jetty.annotations.AnnotationConfiguration) EnvConfiguration(org.eclipse.jetty.plus.webapp.EnvConfiguration)

Example 2 with WebXmlConfiguration

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;
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) WebInfConfiguration(org.eclipse.jetty.webapp.WebInfConfiguration) MetaInfConfiguration(org.eclipse.jetty.webapp.MetaInfConfiguration) PlusConfiguration(org.eclipse.jetty.plus.webapp.PlusConfiguration) FragmentConfiguration(org.eclipse.jetty.webapp.FragmentConfiguration) AnnotationConfiguration(org.eclipse.jetty.annotations.AnnotationConfiguration) EnvConfiguration(org.eclipse.jetty.plus.webapp.EnvConfiguration)

Example 3 with WebXmlConfiguration

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;
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Map(java.util.Map)

Aggregations

WebAppContext (org.eclipse.jetty.webapp.WebAppContext)3 WebXmlConfiguration (org.eclipse.jetty.webapp.WebXmlConfiguration)3 AnnotationConfiguration (org.eclipse.jetty.annotations.AnnotationConfiguration)2 EnvConfiguration (org.eclipse.jetty.plus.webapp.EnvConfiguration)2 PlusConfiguration (org.eclipse.jetty.plus.webapp.PlusConfiguration)2 FragmentConfiguration (org.eclipse.jetty.webapp.FragmentConfiguration)2 MetaInfConfiguration (org.eclipse.jetty.webapp.MetaInfConfiguration)2 WebInfConfiguration (org.eclipse.jetty.webapp.WebInfConfiguration)2 Map (java.util.Map)1 Server (org.eclipse.jetty.server.Server)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1