/** * Creates a Jetty context handler that can be used to expose the cross-domain functionality as implemented by * {@link FlashCrossDomainServlet}. * * Note that an invocation of this method will not register the handler (and thus make the related functionality * available to the end user). Instead, the created handler is returned by this method, and will need to be * registered with the embedded Jetty webserver by the caller. * * @return A Jetty context handler (never null). */ protected Handler createCrossDomainHandler() { final ServletContextHandler context = new ServletContextHandler( null, "/crossdomain.xml", ServletContextHandler.SESSIONS ); // 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() ); // Generic configuration of the context. context.setAllowNullPathInfo( true ); // Add the functionality-providers. context.addServlet( new ServletHolder( new FlashCrossDomainServlet() ), "" ); return context; }
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 ); } }
initializers.add( new ContainerInitializer( new JasperInitializer(), null ) ); context.setAttribute( "org.eclipse.jetty.containerInitializers", initializers ); context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager() );
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; }
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 ); } }
/** * Creates a Jetty context handler that can be used to expose the cross-domain functionality as implemented by * {@link FlashCrossDomainServlet}. * * Note that an invocation of this method will not register the handler (and thus make the related functionality * available to the end user). Instead, the created handler is returned by this method, and will need to be * registered with the embedded Jetty webserver by the caller. * * @return A Jetty context handler (never null). */ protected Handler createCrossDomainHandler() { final ServletContextHandler context = new ServletContextHandler( null, "/crossdomain.xml", ServletContextHandler.SESSIONS ); // 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() ); // Generic configuration of the context. context.setAllowNullPathInfo( true ); // Add the functionality-providers. context.addServlet( new ServletHolder( new FlashCrossDomainServlet() ), "" ); return context; }
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
initializers.add( new ContainerInitializer( new JasperInitializer(), null ) ); context.setAttribute( "org.eclipse.jetty.containerInitializers", initializers ); context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager() );
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*taglibs.*\\.jar$"); context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers()); context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); context.addBean(new ServletContainerInitializersStarter(context), 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; }
@Override public void initialize() throws Exception { if (context == null) { throw new IllegalStateException(); } ClassLoader parent = context.getEnvironment().getClassLoader(); WebAppClassLoader webAppClassLoader = new WebAppClassLoader(parent, this); setClassLoader(webAppClassLoader); /* * 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. */ setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers()); setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); addBean(new ServletContainerInitializersStarter(this), true); if (!standalone) { CoreService rootService = context.getRootService(); WebService webService = AspectranWebService.create(getServletContext(), rootService); setAttribute(WebService.ROOT_WEB_SERVICE_ATTRIBUTE, webService); } }