org.mortbay.jetty.handler.ContextHandlerCollection Java Examples
The following examples show how to use
org.mortbay.jetty.handler.ContextHandlerCollection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Jetty6PluginServer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404 * if we hit the root and the webapp's context isn't at root. */ public void configureHandlers() throws Exception { this.defaultHandler = new DefaultHandler(); this.requestLogHandler = new RequestLogHandler(); if (this.requestLog != null) { this.requestLogHandler.setRequestLog(this.requestLog); } this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class); if (this.contexts == null) { this.contexts = new ContextHandlerCollection(); this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class); if (this.handlers == null) { this.handlers = new HandlerCollection(); this.server.setHandler(handlers); this.handlers.setHandlers(new Handler[]{this.contexts, this.defaultHandler, this.requestLogHandler}); } else { this.handlers.addHandler(this.contexts); } } }
Example #2
Source File: HttpServer.java From hadoop-gpu with Apache License 2.0 | 6 votes |
/** * Add default apps. * @param appDir The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("hadoop.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(DefaultServlet.class, "/"); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); defaultContexts.put(staticContext, true); }
Example #3
Source File: HttpServer.java From RDFS with Apache License 2.0 | 6 votes |
/** * Add default apps. * @param appDir The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("hadoop.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(DefaultServlet.class, "/"); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); defaultContexts.put(staticContext, true); }
Example #4
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8081 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); server.start(); server.join(); }
Example #5
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8080 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/xdocreport-webapp" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); // JSP Servlet + Context Context jsp_ctx = new Context( servlet_contexts, "/jsp", Context.SESSIONS ); jsp_ctx.addServlet( new ServletHolder( new org.apache.jasper.servlet.JspServlet() ), "*.jsp" ); server.start(); server.join(); }
Example #6
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8081 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); server.start(); server.join(); }
Example #7
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8081 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); server.start(); server.join(); }
Example #8
Source File: HttpServer.java From incubator-tajo with Apache License 2.0 | 6 votes |
/** * Add default apps. * * @param appDir * The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir, Configuration conf) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("tajo.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); //logContext.addServlet(AdminAuthorizedServlet.class, "/*"); logContext.setDisplayName("logs"); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); defaultContexts.put(staticContext, true); }
Example #9
Source File: HttpServer.java From tajo with Apache License 2.0 | 6 votes |
/** * Add default apps. * * @param appDir * The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir, Configuration conf) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("tajo.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); //logContext.addServlet(AdminAuthorizedServlet.class, "/*"); logContext.setDisplayName("logs"); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); defaultContexts.put(staticContext, true); }
Example #10
Source File: Jetty6PluginServer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
/** * Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404 * if we hit the root and the webapp's context isn't at root. */ public void configureHandlers() throws Exception { this.defaultHandler = new DefaultHandler(); this.requestLogHandler = new RequestLogHandler(); if (this.requestLog != null) { this.requestLogHandler.setRequestLog(this.requestLog); } this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class); if (this.contexts == null) { this.contexts = new ContextHandlerCollection(); this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class); if (this.handlers == null) { this.handlers = new HandlerCollection(); this.server.setHandler(handlers); this.handlers.setHandlers(new Handler[]{this.contexts, this.defaultHandler, this.requestLogHandler}); } else { this.handlers.addHandler(this.contexts); } } }
Example #11
Source File: Jetty6PluginServer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
/** * Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404 * if we hit the root and the webapp's context isn't at root. */ public void configureHandlers() throws Exception { this.defaultHandler = new DefaultHandler(); this.requestLogHandler = new RequestLogHandler(); if (this.requestLog != null) { this.requestLogHandler.setRequestLog(this.requestLog); } this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class); if (this.contexts == null) { this.contexts = new ContextHandlerCollection(); this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class); if (this.handlers == null) { this.handlers = new HandlerCollection(); this.server.setHandler(handlers); this.handlers.setHandlers(new Handler[]{this.contexts, this.defaultHandler, this.requestLogHandler}); } else { this.handlers.addHandler(this.contexts); } } }
Example #12
Source File: Jetty6PluginServer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404 * if we hit the root and the webapp's context isn't at root. */ public void configureHandlers() throws Exception { this.defaultHandler = new DefaultHandler(); this.requestLogHandler = new RequestLogHandler(); if (this.requestLog != null) { this.requestLogHandler.setRequestLog(this.requestLog); } this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class); if (this.contexts == null) { this.contexts = new ContextHandlerCollection(); this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class); if (this.handlers == null) { this.handlers = new HandlerCollection(); this.server.setHandler(handlers); this.handlers.setHandlers(new Handler[]{this.contexts, this.defaultHandler, this.requestLogHandler}); } else { this.handlers.addHandler(this.contexts); } } }
Example #13
Source File: HttpServer2.java From big-c with Apache License 2.0 | 5 votes |
/** * Add default apps. * @param appDir The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir, Configuration conf) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("hadoop.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); if (conf.getBoolean( CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES, CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) { @SuppressWarnings("unchecked") Map<String, String> params = logContext.getInitParams(); params.put( "org.mortbay.jetty.servlet.Default.aliases", "true"); } logContext.setDisplayName("logs"); setContextAttributes(logContext, conf); addNoCacheFilter(webAppContext); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); setContextAttributes(staticContext, conf); defaultContexts.put(staticContext, true); }
Example #14
Source File: HttpServer.java From big-c with Apache License 2.0 | 5 votes |
/** * Add default apps. * @param appDir The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir, Configuration conf) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("hadoop.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); if (conf.getBoolean( CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES, CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) { logContext.getInitParams().put( "org.mortbay.jetty.servlet.Default.aliases", "true"); } logContext.setDisplayName("logs"); setContextAttributes(logContext, conf); addNoCacheFilter(webAppContext); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); setContextAttributes(staticContext, conf); defaultContexts.put(staticContext, true); }
Example #15
Source File: HttpServer2.java From hadoop with Apache License 2.0 | 5 votes |
/** * Add default apps. * @param appDir The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir, Configuration conf) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("hadoop.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); if (conf.getBoolean( CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES, CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) { @SuppressWarnings("unchecked") Map<String, String> params = logContext.getInitParams(); params.put( "org.mortbay.jetty.servlet.Default.aliases", "true"); } logContext.setDisplayName("logs"); setContextAttributes(logContext, conf); addNoCacheFilter(webAppContext); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); setContextAttributes(staticContext, conf); defaultContexts.put(staticContext, true); }
Example #16
Source File: HttpServer.java From RDFS with Apache License 2.0 | 5 votes |
/** * Create a status server on the given port. * The jsp scripts are taken from src/webapps/<name>. * @param name The name of the server * @param port The port to use on the server * @param findPort whether the server should start at the given port and * increment by 1 until it finds a free port. * @param conf Configuration */ public HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf) throws IOException { webServer = new Server(); this.findPort = findPort; listener = createBaseListener(conf); listener.setHost(bindAddress); listener.setPort(port); webServer.addConnector(listener); int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1); // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the // default value (currently 254). QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool() : new QueuedThreadPool(maxThreads); webServer.setThreadPool(threadPool); final String appDir = getWebAppsPath(); ContextHandlerCollection contexts = new ContextHandlerCollection(); webServer.setHandler(contexts); webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); webAppContext.setWar(appDir + "/" + name); webAppContext.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); webServer.addHandler(webAppContext); addDefaultApps(contexts, appDir); addGlobalFilter("safety", QuotingInputFilter.class.getName(), null); final FilterInitializer[] initializers = getFilterInitializers(conf); if (initializers != null) { for(FilterInitializer c : initializers) { c.initFilter(this); } } addDefaultServlets(); }
Example #17
Source File: HttpServer.java From hadoop with Apache License 2.0 | 5 votes |
/** * Add default apps. * @param appDir The application directory * @throws IOException */ protected void addDefaultApps(ContextHandlerCollection parent, final String appDir, Configuration conf) throws IOException { // set up the context for "/logs/" if "hadoop.log.dir" property is defined. String logDir = System.getProperty("hadoop.log.dir"); if (logDir != null) { Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); if (conf.getBoolean( CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES, CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) { logContext.getInitParams().put( "org.mortbay.jetty.servlet.Default.aliases", "true"); } logContext.setDisplayName("logs"); setContextAttributes(logContext, conf); addNoCacheFilter(webAppContext); defaultContexts.put(logContext, true); } // set up the context for "/static/*" Context staticContext = new Context(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); setContextAttributes(staticContext, conf); defaultContexts.put(staticContext, true); }
Example #18
Source File: HttpServer.java From hadoop-gpu with Apache License 2.0 | 5 votes |
/** * Create a status server on the given port. * The jsp scripts are taken from src/webapps/<name>. * @param name The name of the server * @param port The port to use on the server * @param findPort whether the server should start at the given port and * increment by 1 until it finds a free port. * @param conf Configuration */ public HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf) throws IOException { webServer = new Server(); this.findPort = findPort; listener = createBaseListener(conf); listener.setHost(bindAddress); listener.setPort(port); webServer.addConnector(listener); webServer.setThreadPool(new QueuedThreadPool()); final String appDir = getWebAppsPath(); ContextHandlerCollection contexts = new ContextHandlerCollection(); webServer.setHandler(contexts); webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); webAppContext.setWar(appDir + "/" + name); webServer.addHandler(webAppContext); addDefaultApps(contexts, appDir); final FilterInitializer[] initializers = getFilterInitializers(conf); if (initializers != null) { for(FilterInitializer c : initializers) { c.initFilter(this); } } addDefaultServlets(); }
Example #19
Source File: HttpServer.java From tajo with Apache License 2.0 | 4 votes |
public HttpServer(String name, String bindAddress, int port, boolean findPort, Connector connector, Configuration conf, String[] pathSpecs) throws IOException { this.webServer = new Server(); this.findPort = findPort; if (connector == null) { listenerStartedExternally = false; listener = createBaseListener(conf); listener.setHost(bindAddress); listener.setPort(port); } else { listenerStartedExternally = true; listener = connector; } webServer.addConnector(listener); SessionIdManager sessionIdManager = new HashSessionIdManager(new Random(System.currentTimeMillis())); webServer.setSessionIdManager(sessionIdManager); int maxThreads = conf.getInt("tajo.http.maxthreads", -1); // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the // default value (currently 250). QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool() : new QueuedThreadPool(maxThreads); webServer.setThreadPool(threadPool); final String appDir = getWebAppsPath(name); ContextHandlerCollection contexts = new ContextHandlerCollection(); webAppContext = new WebAppContext(); webAppContext.setDisplayName(name); webAppContext.setContextPath("/"); webAppContext.setResourceBase(appDir + "/" + name); webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml"); contexts.addHandler(webAppContext); webServer.setHandler(contexts); addDefaultApps(contexts, appDir, conf); }
Example #20
Source File: HttpServer.java From incubator-tajo with Apache License 2.0 | 4 votes |
public HttpServer(String name, String bindAddress, int port, boolean findPort, Connector connector, Configuration conf, String[] pathSpecs) throws IOException { this.webServer = new Server(); this.findPort = findPort; if (connector == null) { listenerStartedExternally = false; listener = createBaseListener(conf); listener.setHost(bindAddress); listener.setPort(port); } else { listenerStartedExternally = true; listener = connector; } webServer.addConnector(listener); SessionIdManager sessionIdManager = new HashSessionIdManager(new Random(System.currentTimeMillis())); webServer.setSessionIdManager(sessionIdManager); int maxThreads = conf.getInt("tajo.http.maxthreads", -1); // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the // default value (currently 250). QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool() : new QueuedThreadPool(maxThreads); webServer.setThreadPool(threadPool); final String appDir = getWebAppsPath(name); ContextHandlerCollection contexts = new ContextHandlerCollection(); webAppContext = new WebAppContext(); webAppContext.setDisplayName(name); webAppContext.setContextPath("/"); webAppContext.setResourceBase(appDir + "/" + name); webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml"); contexts.addHandler(webAppContext); webServer.setHandler(contexts); addDefaultApps(contexts, appDir, conf); }