Search in sources :

Example 1 with WebInfConfiguration

use of org.eclipse.jetty.webapp.WebInfConfiguration in project shiro by apache.

the class AbstractContainerIT method startContainer.

@BeforeClass
public static void startContainer() throws Exception {
    EmbeddedJettyConfiguration config = EmbeddedJettyConfiguration.builder().withWebapp(getWarDir()).build();
    jetty = new EmbeddedJetty(config) {

        /**
         * Overriding with contents of this pull request, to make fragment scanning work.
         * https://github.com/mjeanroy/junit-servers/pull/3
         */
        protected WebAppContext createdWebAppContext() throws Exception {
            final String path = configuration.getPath();
            final String webapp = configuration.getWebapp();
            final String classpath = configuration.getClasspath();
            WebAppContext ctx = new WebAppContext();
            ctx.setClassLoader(Thread.currentThread().getContextClassLoader());
            ctx.setContextPath(path);
            // Useful for WebXmlConfiguration
            ctx.setBaseResource(newResource(webapp));
            ctx.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(), new AnnotationConfiguration(), new JettyWebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration() });
            if (isNotBlank(classpath)) {
                // Fix to scan Spring WebApplicationInitializer
                // This will add compiled classes to jetty classpath
                // See: http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration
                // And more precisely: http://stackoverflow.com/a/18449506/1215828
                File classes = new File(classpath);
                FileResource containerResources = new FileResource(classes.toURI());
                ctx.getMetaData().addContainerResource(containerResources);
            }
            Server server = getDelegate();
            ctx.setParentLoaderPriority(true);
            ctx.setWar(webapp);
            ctx.setServer(server);
            // Add server context
            server.setHandler(ctx);
            return ctx;
        }
    };
    jetty.start();
    assertTrue(jetty.isStarted());
}
Also used : JettyWebXmlConfiguration(org.eclipse.jetty.webapp.JettyWebXmlConfiguration) WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) FragmentConfiguration(org.eclipse.jetty.webapp.FragmentConfiguration) JettyWebXmlConfiguration(org.eclipse.jetty.webapp.JettyWebXmlConfiguration) WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) Configuration(org.eclipse.jetty.webapp.Configuration) AnnotationConfiguration(org.eclipse.jetty.annotations.AnnotationConfiguration) WebInfConfiguration(org.eclipse.jetty.webapp.WebInfConfiguration) MetaInfConfiguration(org.eclipse.jetty.webapp.MetaInfConfiguration) EmbeddedJettyConfiguration(com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration) WebInfConfiguration(org.eclipse.jetty.webapp.WebInfConfiguration) Server(org.eclipse.jetty.server.Server) FileResource(org.eclipse.jetty.util.resource.FileResource) EmbeddedJettyConfiguration(com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JettyWebXmlConfiguration(org.eclipse.jetty.webapp.JettyWebXmlConfiguration) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) EmbeddedJetty(com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty) MetaInfConfiguration(org.eclipse.jetty.webapp.MetaInfConfiguration) FragmentConfiguration(org.eclipse.jetty.webapp.FragmentConfiguration) AnnotationConfiguration(org.eclipse.jetty.annotations.AnnotationConfiguration) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 2 with WebInfConfiguration

use of org.eclipse.jetty.webapp.WebInfConfiguration in project Openfire by igniterealtime.

the class AdminConsolePlugin method createWebAppContext.

private void createWebAppContext() {
    contexts = new ContextHandlerCollection();
    WebAppContext context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp", "/");
    // Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
    final List<ContainerInitializer> initializers = new ArrayList<>();
    initializers.add(new ContainerInitializer(new JasperInitializer(), null));
    context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
    context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    context.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebInfConfiguration(), new WebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new EnvConfiguration(), new PlusConfiguration(), new JettyWebXmlConfiguration() });
    final URL classes = getClass().getProtectionDomain().getCodeSource().getLocation();
    context.getMetaData().setWebInfClassesDirs(Collections.singletonList(Resource.newResource(classes)));
    // The index.html includes a redirect to the index.jsp and doesn't bypass
    // the context security when in development mode
    context.setWelcomeFiles(new String[] { "index.html" });
}
Also used : WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) JettyWebXmlConfiguration(org.eclipse.jetty.webapp.JettyWebXmlConfiguration) WebInfConfiguration(org.eclipse.jetty.webapp.WebInfConfiguration) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) InstanceManager(org.apache.tomcat.InstanceManager) PlusConfiguration(org.eclipse.jetty.plus.webapp.PlusConfiguration) ArrayList(java.util.ArrayList) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) JettyWebXmlConfiguration(org.eclipse.jetty.webapp.JettyWebXmlConfiguration) URL(java.net.URL) EnvConfiguration(org.eclipse.jetty.plus.webapp.EnvConfiguration) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) MetaInfConfiguration(org.eclipse.jetty.webapp.MetaInfConfiguration) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer) FragmentConfiguration(org.eclipse.jetty.webapp.FragmentConfiguration) AnnotationConfiguration(org.eclipse.jetty.annotations.AnnotationConfiguration) JasperInitializer(org.apache.jasper.servlet.JasperInitializer)

Example 3 with WebInfConfiguration

use of org.eclipse.jetty.webapp.WebInfConfiguration in project flow by vaadin.

the class RedeployLeakIT method setup.

public void setup(int port) throws Exception {
    server = new Server();
    try (ServerConnector connector = new ServerConnector(server)) {
        connector.setPort(port);
        server.setConnectors(new ServerConnector[] { connector });
    }
    File[] warDirs = new File("target").listFiles(file -> file.getName().matches("flow-test-memory-leaks-.*-SNAPSHOT"));
    String wardir = "target/" + warDirs[0].getName();
    context = new WebAppContext();
    context.setResourceBase(wardir);
    context.setContextPath("/");
    context.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebXmlConfiguration(), new WebInfConfiguration(), // new TagLibConfiguration(),
    new PlusConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new EnvConfiguration() });
    server.setHandler(context);
    server.start();
    testReference = new WeakReference<>(Class.forName(testClass, true, context.getClassLoader()));
    Assert.assertNotNull(testReference.get());
}
Also used : WebXmlConfiguration(org.eclipse.jetty.webapp.WebXmlConfiguration) Server(org.eclipse.jetty.server.Server) WebInfConfiguration(org.eclipse.jetty.webapp.WebInfConfiguration) PlusConfiguration(org.eclipse.jetty.plus.webapp.PlusConfiguration) EnvConfiguration(org.eclipse.jetty.plus.webapp.EnvConfiguration) ServerConnector(org.eclipse.jetty.server.ServerConnector) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) MetaInfConfiguration(org.eclipse.jetty.webapp.MetaInfConfiguration) FragmentConfiguration(org.eclipse.jetty.webapp.FragmentConfiguration) AnnotationConfiguration(org.eclipse.jetty.annotations.AnnotationConfiguration) File(java.io.File)

Example 4 with WebInfConfiguration

use of org.eclipse.jetty.webapp.WebInfConfiguration 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 5 with WebInfConfiguration

use of org.eclipse.jetty.webapp.WebInfConfiguration 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)

Aggregations

WebAppContext (org.eclipse.jetty.webapp.WebAppContext)7 WebInfConfiguration (org.eclipse.jetty.webapp.WebInfConfiguration)7 WebXmlConfiguration (org.eclipse.jetty.webapp.WebXmlConfiguration)7 AnnotationConfiguration (org.eclipse.jetty.annotations.AnnotationConfiguration)5 FragmentConfiguration (org.eclipse.jetty.webapp.FragmentConfiguration)5 MetaInfConfiguration (org.eclipse.jetty.webapp.MetaInfConfiguration)5 EnvConfiguration (org.eclipse.jetty.plus.webapp.EnvConfiguration)4 PlusConfiguration (org.eclipse.jetty.plus.webapp.PlusConfiguration)4 SystemPropertyServletConfiguration (io.joynr.integration.setup.SystemPropertyServletConfiguration)2 File (java.io.File)2 Server (org.eclipse.jetty.server.Server)2 JettyWebXmlConfiguration (org.eclipse.jetty.webapp.JettyWebXmlConfiguration)2 EmbeddedJetty (com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty)1 EmbeddedJettyConfiguration (com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 JasperInitializer (org.apache.jasper.servlet.JasperInitializer)1 InstanceManager (org.apache.tomcat.InstanceManager)1 SimpleInstanceManager (org.apache.tomcat.SimpleInstanceManager)1