@Produces public ServletDescriptor metricsServlet() { String[] uris = new String[]{metricsConfig.getBaseUri()}; WebInitParam[] params = null; return new ServletDescriptor("Metrics", uris, uris, 1, params, false, AdminServlet.class); }
@Override public ServletHolder apply(ServletDescriptor servletDescriptor) { ServletHolder servletHolder = servletHandler.newServletHolder(Source.EMBEDDED); servletHolder.setHeldClass(servletDescriptor.servletClass()); servletHolder.setName(servletDescriptor.name()); if(servletDescriptor.initParams() != null) { Arrays.stream(servletDescriptor.initParams()) .forEach(p -> servletHolder.setInitParameter(p.name(), p.value())); } for(String pattern : servletDescriptor.urlPatterns()) { servletHandler.addServletWithMapping(servletHolder, pattern); } return servletHolder; } }
@Override public ServletInfo apply(ServletDescriptor servletDescriptor) { ServletInfo servletInfo = Servlets.servlet(servletDescriptor.name(), servletDescriptor.servletClass()) .setAsyncSupported(servletDescriptor.asyncSupported()) .setLoadOnStartup(servletDescriptor.loadOnStartup()) .addMappings(servletDescriptor.urlPatterns()); if(servletDescriptor.initParams() != null) { for(WebInitParam param : servletDescriptor.initParams()) { servletInfo.addInitParam(param.name(), param.value()); } } return servletInfo; } }
String servletName = servletDescriptor.name(); Wrapper wrapper = Tomcat.addServlet(ctx, servletName, servletDescriptor.servletClass().getName()); if(servletDescriptor.initParams() != null) { Arrays.stream(servletDescriptor.initParams()) .forEach(p -> wrapper.addInitParameter(p.name(), p.value())); stream(servletDescriptor.urlPatterns()).forEach(s -> ctx.addServletMappingDecoded(s, servletName)); }); filterDescriptors.forEach(filterDescriptor -> {
@Override public ServletInfo apply(ServletDescriptor servletDescriptor) { ServletInfo servletInfo = Servlets.servlet(servletDescriptor.name(), servletDescriptor.servletClass()) .setAsyncSupported(servletDescriptor.asyncSupported()) .setLoadOnStartup(servletDescriptor.loadOnStartup()) .addMappings(servletDescriptor.urlPatterns()); if(servletDescriptor.initParams() != null) { for(WebInitParam param : servletDescriptor.initParams()) { servletInfo.addInitParam(param.name(), param.value()); } } return servletInfo; } }
@Produces @Dependent public ServletDescriptor cxfServlet(RestServerConfiguration restServerConfiguration) { String servletMapping = restServerConfiguration.getRestServletMapping(); List<WebInitParam> params = new ArrayList<>(); if(enableSseTransport) { params.add(new WebParam(CXFNonSpringJaxrsServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID)); } WebInitParam[] initParams = params.toArray(new WebInitParam[params.size()]); return new ServletDescriptor("CXF",null, new String[]{servletMapping},1, initParams,true,CXFCdiServlet.class); }
String servletName = servletDescriptor.name(); Wrapper wrapper = Tomcat.addServlet(ctx, servletName, servletDescriptor.servletClass().getName()); if(servletDescriptor.initParams() != null) { Arrays.stream(servletDescriptor.initParams()) .forEach(p -> wrapper.addInitParameter(p.name(), p.value())); stream(servletDescriptor.urlPatterns()).forEach(s -> ctx.addServletMappingDecoded(s, servletName)); }); filterDescriptors.forEach(filterDescriptor -> {
@Produces @Dependent public ServletDescriptor cxfServlet(RestServerConfiguration restServerConfiguration) { String servletMapping = restServerConfiguration.getRestServletMapping(); List<WebInitParam> params = new ArrayList<>(); if(enableSseTransport) { params.add(new WebParam(CXFNonSpringJaxrsServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID)); } WebInitParam[] initParams = params.toArray(new WebInitParam[params.size()]); return new ServletDescriptor("CXF",null, new String[]{servletMapping},1, initParams,true,CXFCdiServlet.class); }
@Produces public ServletDescriptor swaggerUIDispatcherServlet() { String name = SwaggerUIDispatcherServlet.class.getSimpleName(); String[] uris = new String[] { config.getSwaggerUIPath(), config.getSwaggerUIPath() + UI_MATCH_FORWARD }; WebInitParam[] params = null; return new ServletDescriptor(name, uris, uris, 1, params, false, SwaggerUIDispatcherServlet.class); }
@Produces public ServletDescriptor jerseyServlet() { String urlPattern = restServerConfiguration.getRestServletMapping(); if (!applicationInstance.isUnsatisfied() && !applicationInstance.isAmbiguous()) { ApplicationPath annotation = ClassUtils.getAnnotation(applicationInstance.get().getClass(), ApplicationPath.class); if(annotation != null) { String path = annotation.value(); urlPattern = path.endsWith("/") ? path + "*" : path + "/*"; } } return new ServletDescriptor(SERVLET_NAME, null, new String[] { urlPattern }, 1, null, true, ServletContainer.class); }
@Produces public ServletDescriptor resteasyServlet() { String path = restServerConfiguration.getRestServerUri(); if( !(applicationInstance.isUnsatisfied() || applicationInstance.isAmbiguous())) { ApplicationPath appPath = ClassUtils.getAnnotation(applicationInstance.get().getClass(), ApplicationPath.class); if(appPath != null) { path = appPath.value(); } } String pattern = path.endsWith("/") ? path + "*" : path + "/*"; WebInitParam param = new WebParam("resteasy.servlet.mapping.prefix", path); return new ServletDescriptor("ResteasyServlet",new String[]{pattern}, new String[]{pattern}, 1,new WebInitParam[]{param},true,HttpServlet30Dispatcher.class); } }
private void procesServlets() { Consumer<Class<? extends HttpServlet>> c = servlet -> { WebServlet webServlet = ClassUtils.getAnnotation(servlet, WebServlet.class); if(webServlet != null) { ServletDescriptor servletDescriptor = new ServletDescriptor(webServlet.name(), webServlet.value(), mapUrls(webServlet.urlPatterns()), webServlet.loadOnStartup(), webServlet.initParams(),webServlet.asyncSupported(),servlet); webServer.addServlet(servletDescriptor); } }; extension.processServlets(c); }
private void procesServlets() { Consumer<Class<? extends HttpServlet>> c = servlet -> { WebServlet webServlet = ClassUtils.getAnnotation(servlet, WebServlet.class); if(webServlet != null) { ServletDescriptor servletDescriptor = new ServletDescriptor(webServlet.name(), webServlet.value(), mapUrls(webServlet.urlPatterns()), webServlet.loadOnStartup(), webServlet.initParams(),webServlet.asyncSupported(),servlet); webServer.addServlet(servletDescriptor); } }; extension.processServlets(c); }