private void createWebAppContext() { contexts = new ContextHandlerCollection(); WebAppContext context; // Add web-app. Check to see if we're in development mode. If so, we don't // add the normal web-app location, but the web-app in the project directory. boolean developmentMode = Boolean.getBoolean("developmentMode"); if( developmentMode ) { System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode")); context = new WebAppContext(contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() + File.separator + "src" + File.separator + "web", "/"); } else { 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()); // 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"}); // Make sure the context initialization is done when in development mode if( developmentMode ) { context.addBean( new ServletContainerInitializersStarter( context ), true ); } }
private WebAppContext createDeployedApplicationInstance(File workDirectory, String deployedApplicationPath) { WebAppContext deployedApplication = new WebAppContext(); deployedApplication.setContextPath(this.getContextPath()); deployedApplication.setWar(deployedApplicationPath); deployedApplication.setAttribute("javax.servlet.context.tempdir", workDirectory.getAbsolutePath()); deployedApplication .setAttribute( "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$"); deployedApplication.setAttribute( "org.eclipse.jetty.containerInitializers", jspInitializers()); deployedApplication.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); deployedApplication.addBean(new ServletContainerInitializersStarter( deployedApplication), true); // webapp.setClassLoader(new URLClassLoader(new // URL[0],App.class.getClassLoader())); deployedApplication.addServlet(jspServletHolder(), "*.jsp"); return deployedApplication; }
static WebAppContext newWebAppContext() throws MalformedURLException { final WebAppContext handler = new WebAppContext(); handler.setContextPath("/"); handler.setBaseResource(Resource.newResource(webAppRoot())); handler.setClassLoader(new URLClassLoader( new URL[] { Resource.newResource(new File(webAppRoot(), "WEB-INF" + File.separatorChar + "lib" + File.separatorChar + "hello.jar")).getURI().toURL() }, JettyService.class.getClassLoader())); handler.addBean(new ServletContainerInitializersStarter(handler), true); handler.setAttribute( "org.eclipse.jetty.containerInitializers", Collections.singletonList(new ContainerInitializer(new JettyJasperInitializer(), null))); return handler; }
context.addBean(new JasperInitializer(context), true);
@Override public void configure(WebAppContext context) throws Exception { //add a bean to the context which will call the servletcontainerinitializers when appropriate JettyMockitoSpringContainerStarter starter = new JettyMockitoSpringContainerStarter(context, configuration.getMockTargetBeans(), configuration.getContextBeans(), configuration); context.addBean(starter, true); }
private void createWebAppContext() { WebAppContext context; // Add web-app. Check to see if we're in development mode. If so, we don't // add the normal web-app location, but the web-app in the project directory. boolean developmentMode = Boolean.getBoolean("developmentMode"); if( developmentMode ) { System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode")); context = new WebAppContext(contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() + File.separator + "src" + File.separator + "web", "/"); } else { 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()); // 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"}); // Make sure the context initialization is done when in development mode if( developmentMode ) { context.addBean( new ServletContainerInitializersStarter( context ), true ); } }
public void visitContainerInitializer (WebAppContext context, ContainerInitializer containerInitializer) { if (containerInitializer == null) return; //add the ContainerInitializer to the list of container initializers List<ContainerInitializer> containerInitializers = (List<ContainerInitializer>)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS); if (containerInitializers == null) { containerInitializers = new ArrayList<ContainerInitializer>(); context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, containerInitializers); } containerInitializers.add(containerInitializer); //Ensure a bean is set up on the context that will invoke the ContainerInitializers as the context starts ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER); if (starter == null) { starter = new ServletContainerInitializersStarter(context); context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter); context.addBean(starter, true); } }
/** * Sets up Jetty without any actual TCP port serving HTTP. */ @Override protected ServletContext createWebServer() throws Exception { QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10); server = new Server(queuedThreadPool); WebAppContext context = new WebAppContext(bootstrap.warDir.getPath(), contextPath); context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.getSecurityHandler().setLoginService(configureUserRealm()); context.setResourceBase(bootstrap.warDir.getPath()); server.start(); localPort = -1; setPluginManager(new PluginManagerImpl(context.getServletContext(), bootstrap.pluginsDir)); return context.getServletContext(); }
context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.setMimeTypes(MIME_TYPES);
context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.setMimeTypes(MIME_TYPES);
/** * Sets up Jetty without any actual TCP port serving HTTP. */ @Override protected ServletContext createWebServer() throws Exception { QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10); server = new Server(queuedThreadPool); WebAppContext context = new WebAppContext(bootstrap.warDir.getPath(), contextPath); context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.getSecurityHandler().setLoginService(configureUserRealm()); context.setResourceBase(bootstrap.warDir.getPath()); server.start(); localPort = -1; setPluginManager(new PluginManagerImpl(context.getServletContext(), bootstrap.pluginsDir)); return context.getServletContext(); }
initializers.add(initializer); context.setAttribute("org.eclipse.jetty.containerInitializers", initializers); context.addBean(sciStarter, true);
context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers()); context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); context.addBean(new ServletContainerInitializersStarter(context), true);
listener.setWebAppContext(context); context.setAttribute(CONTAINER_INITIALIZER_LISTENER, listener); context.addBean(listener, true);
starter = new ServletContainerInitializersStarter(context); context.setAttribute(CONTAINER_INITIALIZER_STARTER, starter); context.addBean(starter, true);
@Override public ContextHandler createContextHandler(final App app) throws Exception { final ContextHandler handler = super.createContextHandler(app); /* * Add an alias check that accepts double slashes in our resource paths. */ handler.addAliasCheck(new ApproveAbsolutePathAliases()); /* * Pulled from: http://bengreen.eu/fancyhtml/quickreference/jettyjsp9error.html * * Configure the application to support the compilation of JSP files. * We need a new class loader and some stuff so that Jetty can call the * onStartup() methods as required. */ if (handler instanceof WebAppContext) { WebAppContext context = (WebAppContext)handler; context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, jspInitializers()); context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); context.addBean(new ServletContainerInitializersStarter(context), true); } return handler; }
@Override public ContextHandler createContextHandler(final App app) throws Exception { final ContextHandler handler = super.createContextHandler(app); /* * Add an alias check that accepts double slashes in our resource paths. */ handler.addAliasCheck(new ApproveAbsolutePathAliases()); /* * Pulled from: http://bengreen.eu/fancyhtml/quickreference/jettyjsp9error.html * * Configure the application to support the compilation of JSP files. * We need a new class loader and some stuff so that Jetty can call the * onStartup() methods as required. */ if (handler instanceof WebAppContext) { WebAppContext context = (WebAppContext)handler; context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, jspInitializers()); context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); context.addBean(new ServletContainerInitializersStarter(context), true); } return handler; }
context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.setMimeTypes(MIME_TYPES);
context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.setMimeTypes(MIME_TYPES);
starter = new ServletContainerInitializersStarter(context); context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter); context.addBean(starter, true);