protected ContextHandlerCollection getContexts() { if (m_contexts == null) m_contexts = new ContextHandlerCollection(); return m_contexts; }
ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(contexts); servlet.addServletWithMapping("org.mortbay.jetty.servlet.DefaultServlet", URIUtil.SLASH); context.setHandler(servlet); contexts.addHandler(context); webapp.setResourceBase(args[2]); webapp.setContextPath(URIUtil.SLASH); contexts.addHandler(webapp);
public void setHandlers(Handler[] handlers) { _contextMap=null; super.setHandlers(handlers); if (isStarted()) mapContexts(); }
private void deploy(String filename) throws Exception { ContextHandler context=createContext(filename); Log.info("Deploy "+filename+" -> "+ context); _contexts.addHandler(context); _currentDeployments.put(filename,context); if (_contexts.isStarted()) context.start(); }
ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection(); contextHandlerCollection.addLifeCycleListener( listener ); contextHandlerCollection.mapContexts(); getServer().addHandler( contextHandlerCollection );
public static void main(String[] args) throws Exception { Server server = new Server(); Connector connector=new SelectChannelConnector(); connector.setPort(8080); server.setConnectors(new Connector[]{connector}); ContextHandler context0 = new ContextHandler(); context0.setContextPath("/zero"); Handler handler0=new HelloHandler(); context0.setHandler(handler0); ContextHandler context1 = new ContextHandler(); context1.setContextPath("/one"); Handler handler1=new HelloHandler(); context1.setHandler(handler1); ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.setHandlers(new Handler[]{context0,context1}); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()}); server.setHandler(handlers); server.start(); server.join(); }
/** Add a context handler. * @param contextPath The context path to add * @return * @throws IllegalAccessException * @throws InstantiationException */ public ContextHandler addContext(String contextPath,String resourceBase) { try { ContextHandler context = (ContextHandler)_contextClass.newInstance(); context.setContextPath(contextPath); context.setResourceBase(resourceBase); addHandler(context); return context; } catch (Exception e) { Log.warn(e); throw new Error(e); } }
protected void doStart() throws Exception { mapContexts(); super.doStart(); }
ContextHandlerCollection ctxHandler = new ContextHandlerCollection(); if ( !listeners.isEmpty() ) ctxHandler.addLifeCycleListener( listener ); ctxHandler.mapContexts(); getServer().addHandler( ctxHandler );
protected Context getContext() { if (getWebAppcontextPath() != null) { m_context = new WebAppContext( null,ConfigUtils .getInitialPropertyExpanded(getContextPath())); m_context.setResourceBase(getResourceBase()); getContexts().addHandler(m_context); getServer().setHandler(getContexts()); } else if (m_context == null) { getServer().setHandler(getContexts()); m_context = new Context(m_contexts, getContextPath(), Context.SESSIONS); if (getResourceBase() != null) { m_context.setResourceBase(getResourceBase()); } } return m_context; }
/** * @param contextPath The _contextPath to set. */ public void setContextPath(String contextPath) { if (contextPath!=null && contextPath.length()>1 && contextPath.endsWith("/")) throw new IllegalArgumentException("ends with /"); _contextPath = contextPath; if (getServer()!=null && (getServer().isStarting() || getServer().isStarted())) { Handler[] contextCollections = getServer().getChildHandlersByClass(ContextHandlerCollection.class); for (int h=0;contextCollections!=null&& h<contextCollections.length;h++) ((ContextHandlerCollection)contextCollections[h]).mapContexts(); } }
protected void createHttpServer() { final ContextHandlerCollection contexts; final ServletHolder servletHolder; final Context root; httpServer = new Server(port); contexts = new ContextHandlerCollection(); httpServer.setHandler(contexts); root = new Context(contexts, "/", Context.SESSIONS); servletHolder = new ServletHolder(new MainServlet()); servletHolder.setInitParameter("route_resolver", routeResolverClass().getName()); root.addServlet(servletHolder, "/*"); }
ContextHandlerCollection contexts = new ContextHandlerCollection(); webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml"); contexts.addHandler(webAppContext); webServer.setHandler(contexts);
public JavaNetReverseProxy(File cacheFolder) throws Exception { this.cacheFolder = cacheFolder; cacheFolder.mkdirs(); server = new Server(); ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(contexts); Context root = new Context(contexts, "/", Context.SESSIONS); root.addServlet(new ServletHolder(this), "/"); SocketConnector connector = new SocketConnector(); server.addConnector(connector); server.start(); localPort = connector.getLocalPort(); }
ContextHandlerCollection contexts = new ContextHandlerCollection(); webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml"); contexts.addHandler(webAppContext); webServer.setHandler(contexts);
public JavaNetReverseProxy(File cacheFolder) throws Exception { this.cacheFolder = cacheFolder; cacheFolder.mkdirs(); server = new Server(); ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(contexts); Context root = new Context(contexts, "/", Context.SESSIONS); root.addServlet(new ServletHolder(this), "/"); SocketConnector connector = new SocketConnector(); server.addConnector(connector); server.start(); localPort = connector.getLocalPort(); }
public static void main(String[] args) throws Exception { Server server = new Server(8080); ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(contexts); Context root = new Context(contexts,"/",Context.SESSIONS); root.addServlet(new ServletHolder(new HelloServlet("Ciao")), "/*"); Context other = new Context(contexts,"/other",Context.SESSIONS); other.addServlet("org.mortbay.jetty.example.ManyServletContexts$HelloServlet", "/*"); StatisticsHandler stats = new StatisticsHandler(); contexts.addHandler(stats); Context yetanother =new Context(stats,"/yo",Context.SESSIONS); yetanother.addServlet(new ServletHolder(new HelloServlet("YO!")), "/*"); server.start(); server.join(); }
public JavaNetReverseProxy(File cacheFolder) throws Exception { this.cacheFolder = cacheFolder; cacheFolder.mkdirs(); server = new Server(); ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(contexts); Context root = new Context(contexts, "/", Context.SESSIONS); root.addServlet(new ServletHolder(this), "/"); SocketConnector connector = new SocketConnector(); server.addConnector(connector); server.start(); localPort = connector.getLocalPort(); }
ContextHandlerCollection contexts = new ContextHandlerCollection(); RequestLog requestLog = HttpRequestLog.getRequestLog(name);
webServer.setThreadPool(threadPool); ContextHandlerCollection contexts = new ContextHandlerCollection(); RequestLog requestLog = HttpRequestLog.getRequestLog(name);