@Override public void addLifeCycleListener(Listener listener) { delegate.addLifeCycleListener(listener); }
@Override public Handler getHandler() { final ServletContextHandler handler = new ServletContextHandler(); handler.addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarting(LifeCycle event) { handler.getServletContext().setExtendedListenerTypes(true); Iterable<ServletContainerInitializer> initializers = servletContainer.getInitializers(); for (ServletContainerInitializer servletContainerInitializer : initializers) { try { servletContainerInitializer.onStartup(Collections.<Class<?>>emptySet(), handler.getServletContext()); } catch (ServletException ex) { throw new RuntimeException(ex); } } handler.addServlet(DefaultServlet.class, "/"); handler.getServletContext().setExtendedListenerTypes(false); } }); return handler; }
handler.addServlet(NoneServlet.class, "/"); handler.setContextPath("/"); handler.addLifeCycleListener(new ShutDownListener(repo, gracefulShutdown)); server.setHandler(handler); server.dumpStdErr();
handler.addServlet(NoneServlet.class, "/"); handler.setContextPath("/"); handler.addLifeCycleListener(new ShutDownListener(repo, gracefulShutdown)); server.setHandler(handler); server.dumpStdErr();
protected ServletContextHandler createGraphAwareHandler(SessionManager sessionManager, ApplicationContext rootContext) { ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath(getContextPath(config)); context.getSessionHandler().setSessionManager(sessionManager); context.addLifeCycleListener(new JettyStartingListener(new WebAppInitializer(rootContext, getPackagesToScan(config)), context.getServletContext())); context.addFilter(new FilterHolder(txFilter), "/*", EnumSet.allOf(DispatcherType.class)); addDefaultFilters(context); return context; }
private Server setup() throws IOException, DeploymentException, ServletException { synchronized (this) { checkState(server == null, "Server already started."); } MatlabInstancePool pool = new MatlabInstancePool(MatlabInstancePoolConfiguration .builder() .withMaximalNumInstances(getOptions().getThreads()) .withInstanceConfig(MatlabInstanceConfiguration .builder() .withBaseDir(getOptions().getPath()) .hidden(getOptions().isHidden()) .build()) .build()); Server jetty = new Server(getOptions().getPort()); ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); handler.setContextPath("/"); jetty.setHandler(handler); handler.addLifeCycleListener(new MatlabInstancePoolDestroyer(pool)); ServerContainer sc = WebSocketServerContainerInitializer.configureContext(handler); sc.addEndpoint(ServerEndpointConfig.Builder.create(MatlabServerEndpoint.class, "/") .configurator(new MatlabServerEndpointConfigurator(pool)).build()); return jetty; }