/** * Creates a Jetty context handler that can be used to expose static files. * * 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, or null when the static content could not be accessed. */ protected Handler createStaticContentHandler() { final File spankDirectory = new File( JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" ); if ( spankDirectory.exists() ) { if ( spankDirectory.canRead() ) { final WebAppContext context = new WebAppContext( null, spankDirectory.getPath(), "/" ); context.setWelcomeFiles( new String[] { "index.html" } ); return context; } else { Log.warn( "Openfire cannot read the directory: " + spankDirectory ); } } return null; }
public void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive if (welcome != null && welcome.trim().length() > 0) context.setWelcomeFiles((String[])ArrayUtil.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
@Override public void deconfigure (WebAppContext context) throws Exception { context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }
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 static WebAppContext createWebAppContext(Builder b, AccessControlList adminsAcl, final String appDir) { WebAppContext ctx = new WebAppContext(); ctx.setDefaultsDescriptor(null); ServletHolder holder = new ServletHolder(new DefaultServlet()); Map<String, String> params = ImmutableMap. <String, String> builder() .put("acceptRanges", "true") .put("dirAllowed", "false") .put("gzip", "true") .put("useFileMappedBuffer", "true") .build(); holder.setInitParameters(params); ctx.setWelcomeFiles(new String[] {"index.html"}); ctx.addServlet(holder, "/"); ctx.setDisplayName(b.name); ctx.setContextPath("/"); ctx.setWar(appDir + "/" + b.name); String tempDirectory = b.conf.get(HTTP_TEMP_DIR_KEY); if (tempDirectory != null && !tempDirectory.isEmpty()) { ctx.setTempDirectory(new File(tempDirectory)); ctx.setAttribute("javax.servlet.context.tempdir", tempDirectory); } ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, b.conf); ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); addNoCacheFilter(ctx); return ctx; }
context.setWelcomeFiles(new String[0]);
/** * Creates a Jetty context handler that can be used to expose static files. * * 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, or null when the static content could not be accessed. */ protected Handler createStaticContentHandler() { final File spankDirectory = new File( JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" ); if ( spankDirectory.exists() ) { if ( spankDirectory.canRead() ) { final WebAppContext context = new WebAppContext( null, spankDirectory.getPath(), "/" ); context.setWelcomeFiles( new String[] { "index.html" } ); return context; } else { Log.warn( "Openfire cannot read the directory: " + spankDirectory ); } } return null; }
public void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive if (welcome != null && welcome.trim().length() > 0) context.setWelcomeFiles((String[])ArrayUtil.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
/** * @param context * @param node */ protected void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive if (welcome != null && welcome.trim().length() > 0) context.setWelcomeFiles((String[])LazyList.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
/** * @param context * @param node */ protected void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive if (welcome != null && welcome.trim().length() > 0) context.setWelcomeFiles((String[])LazyList.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
/** * @param context * @param node */ protected void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive if (welcome != null && welcome.trim().length() > 0) context.setWelcomeFiles((String[])LazyList.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
/** * @param context * @param node */ protected void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive context.setWelcomeFiles((String[])ArrayUtil.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
/** * @param context * @param node */ protected void addWelcomeFiles(WebAppContext context, XmlParser.Node node) { Iterator<XmlParser.Node> iter = node.iterator("welcome-file"); while (iter.hasNext()) { XmlParser.Node indexNode = (XmlParser.Node) iter.next(); String welcome = indexNode.toString(false, true); //Servlet Spec 3.0 p. 74 welcome files are additive context.setWelcomeFiles((String[])ArrayUtil.addToArray(context.getWelcomeFiles(),welcome,String.class)); } }
@Override public void deconfigure (WebAppContext context) throws Exception { context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }
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 ); } }
@Override public void deconfigure (WebAppContext context) throws Exception { ServletHandler _servletHandler = context.getServletHandler(); context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }
@Override public void deconfigure (WebAppContext context) throws Exception { ServletHandler _servletHandler = context.getServletHandler(); context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }
@Override public void deconfigure (WebAppContext context) throws Exception { ServletHandler _servletHandler = context.getServletHandler(); context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }
@Override public void deconfigure (WebAppContext context) throws Exception { // TODO preserve any configuration that pre-existed. ServletHandler _servletHandler = context.getServletHandler(); _servletHandler.setFilters(null); _servletHandler.setFilterMappings(null); _servletHandler.setServlets(null); _servletHandler.setServletMappings(null); context.setEventListeners(null); context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }
@Override public void deconfigure (WebAppContext context) throws Exception { // TODO preserve any configuration that pre-existed. ServletHandler _servletHandler = context.getServletHandler(); _servletHandler.setFilters(null); _servletHandler.setFilterMappings(null); _servletHandler.setServlets(null); _servletHandler.setServletMappings(null); context.setEventListeners(null); context.setWelcomeFiles(null); if (context.getErrorHandler() instanceof ErrorPageErrorHandler) ((ErrorPageErrorHandler) context.getErrorHandler()).setErrorPages(null); // TODO remove classpaths from classloader } }