.addListeners(listenerInfos) .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME , new WebSocketDeploymentInfo()) .addServlets(servletInfos);
public static void main(String[] args) throws ServletException { MyServer myServer = new MyServer(8080, "0.0.0.0"); DeploymentInfo di = myServer.deployApplication("/rest", MyApplication.class) .setClassLoader(MyServer.class.getClassLoader()) .setContextPath("/myApp") .setDeploymentName("My Application") .addServlets(Servlets.servlet("helloServlet", org.viddu.poc.HelloServlet.class).addMapping("/hello")) .addListeners(Servlets.listener(org.jboss.weld.environment.servlet.Listener.class)); myServer.deploy(di); } }
.setClassLoader(Application.class.getClassLoader()) .setContextPath("/") .addListeners(listener(Listener.class)) .setResourceManager(new ClassPathResourceManager(Application.class.getClassLoader())) .addServlets(
.map( li -> li.getListenerClass().getName() ) .collect( Collectors.toList() ) ); into.addListeners( listeners );
deploymentInfo.addListeners(Servlets.listener(EnvironmentLoaderListener.class)); deploymentInfo.addFilter( Servlets.filter("shiro", JbootShiroFilter.class)) .addMapping(metricsConfig.getMappingUrl())); deploymentInfo.addListeners(Servlets.listener(JbootMetricServletContextListener.class)); deploymentInfo.addListeners(Servlets.listener(JbootHealthCheckServletContextListener.class)); deploymentInfo.addListeners(Servlets.listener(listenerClass));
protected DeploymentManager createFathomDeploymentManager() throws ServletException { DeploymentInfo info = Servlets.deployment(); info.setDeploymentName("Fathom"); info.setClassLoader(this.getClass().getClassLoader()); info.setContextPath(settings.getContextPath()); info.setIgnoreFlush(true); info.setDefaultEncoding("UTF-8"); FilterInfo guiceFilter = new FilterInfo("GuiceFilter", GuiceFilter.class); guiceFilter.setAsyncSupported(true); info.addFilterUrlMapping("GuiceFilter", "/*", DispatcherType.REQUEST); info.addFilters(guiceFilter); ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class); defaultServlet.setAsyncSupported(true); defaultServlet.addMapping("/"); ServletContextListener fathomListener = new ServletContextListener(settings); info.addListeners(new ListenerInfo(ServletContextListener.class, new ImmediateInstanceFactory<>(fathomListener))); MultipartConfigElement multipartConfig = new MultipartConfigElement(settings.getUploadFilesLocation(), settings.getUploadFilesMaxSize(), -1L, 0); defaultServlet.setMultipartConfig(multipartConfig); info.addServlets(defaultServlet); DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info); deploymentManager.deploy(); return deploymentManager; }