/** Start the process, visiting each ServletContextListener bound in the injector or any parents */ public void accept(Visitor<T> visitor) { accept(injector, visitor); }
@Override protected void startUp() throws Exception { log.debug("Starting web server"); server.start(); }
@Override protected void shutDown() throws Exception { log.debug("Stopping web server"); server.stop(); } }
@Override protected void configureServlets() { install(new WebModule()); serve(endpoint).with(RpcServlet.class); } }
server = createServer(webConfig); final ServletContextHandler sch = createRootServletContextHandler(); eventListenerScanner.accept(new Visitor<EventListener>() { @Override public void visit(EventListener listener) { handlerScanner.accept(new Visitor<Handler>() { @Override public void visit(Handler handler) {
/** Recursive impl that walks up the parent injectors first */ private void accept(Injector inj, Visitor visitor) { if (inj == null) return; accept(inj.getParent(), visitor); for (final Binding<?> binding: inj.getBindings().values()) { final Type type = binding.getKey().getTypeLiteral().getType(); if (type instanceof Class && scanFor.isAssignableFrom((Class)type)) { //noinspection unchecked visitor.visit((T)binding.getProvider().get()); } } } }
/** * Overrideable method to create the initial jetty Server. We need to draw a lot more configuration parameters * into WebConfig, but for now this gives users a hook to satisfy their needs. Bind a subclass to WebConfig, * subclass this WebServer, and change behavior to whatever you want. */ protected Server createServer(WebConfig webConfig) { return new Server(webConfig.getPort()); }
@Override protected void configureServlets() { install(new WebModule()); // The order these operations (including the steps in the linker) are important ServiceLocator locator = BootstrapUtils.newServiceLocator(); install(new BootstrapModule(locator)); bind(HK2Linker.class).asEagerSingleton(); serve("/*").with(ServletContainer.class); }
@Override protected void configureServlets() { install(new WebModule()); install(new JaxrsModule()); // Binding this will cause it to be picked up by gwizard-web bind(GuiceResteasyBootstrapServletContextListener.class); // Make sure RESTEasy picks this up so we get our ObjectMapper from guice bind(ObjectMapperContextResolver.class); bind(HttpServletDispatcher.class).in(Singleton.class); if (path == null) { serve("/*").with(HttpServletDispatcher.class); } else { final Map<String, String> initParams = ImmutableMap.of("resteasy.servlet.mapping.prefix", path); serve(path + "/*").with(HttpServletDispatcher.class, initParams); } } }