} else { final io.undertow.servlet.api.ServletInfo jspServlet = new ServletInfo("jsp", JspServlet.class); jspServlet.setRequireWelcomeFileMapping(true);
@Override public WebDeploymentController addWebDeployment(final WebDeploymentBuilder webDeploymentBuilder) throws Exception { DeploymentInfo d = new DeploymentInfo(); d.setDeploymentName(webDeploymentBuilder.getContextRoot()); d.setContextPath(webDeploymentBuilder.getContextRoot()); d.setClassLoader(webDeploymentBuilder.getClassLoader()); d.setResourceManager(new PathResourceManager(webDeploymentBuilder.getDocumentRoot().toPath().toAbsolutePath(), 1024 * 1024)); d.setIgnoreFlush(false); for (ServletBuilder servlet : webDeploymentBuilder.getServlets()) { ServletInfo s; if (servlet.getServlet() == null) { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass()); } else { s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass(), new ImmediateInstanceFactory<>(servlet.getServlet())); } if (servlet.isForceInit()) { s.setLoadOnStartup(1); } s.addMappings(servlet.getUrlMappings()); for (Map.Entry<String, String> param : servlet.getInitParams().entrySet()) { s.addInitParam(param.getKey(), param.getValue()); } d.addServlet(s); } if (controlPoint != null) { d.addOuterHandlerChainWrapper(GlobalRequestControllerHandler.wrapper(controlPoint, webDeploymentBuilder.getAllowRequestPredicates())); } return new WebDeploymentControllerImpl(d); }
@Override protected void init(DeploymentInfo servletBuilder) { addFilterMappings(servletBuilder); AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); appContext.register(HelloController.class); appContext.register(SpringConfig.class); servletBuilder.addServlet(new ServletInfo("DispatcherServlet", DispatcherServlet.class, () -> new ImmediateInstanceHandle(new DispatcherServlet(appContext))).addMapping("/*")); }
s = new ServletInfo(servlet.getName(), JspServlet.class); s.addHandlerChainWrapper(JspFileHandler.jspFileHandlerWrapper(servlet.getJspFile())); } else { if (servlet.getServletClass() == null) { if(DEFAULT_SERVLET_NAME.equals(servlet.getName())) { s = new ServletInfo(servlet.getName(), DefaultServlet.class); } else { throw UndertowLogger.ROOT_LOGGER.servletClassNotDefined(servlet.getServletName()); if (creator != null) { InstanceFactory<Servlet> factory = createInstanceFactory(creator); s = new ServletInfo(servlet.getName(), servletClass, factory); } else { s = new ServletInfo(servlet.getName(), servletClass);
/** * Creates a new servlet description with the given name and class * * @param name The servlet name * @param servletClass The servlet class * @return A new servlet description */ public static ServletInfo servlet(final String name, final Class<? extends Servlet> servletClass) { return new ServletInfo(name, servletClass); }
/** * Creates a new servlet description with the given name and class * * @param name The servlet name * @param servletClass The servlet class * @return A new servlet description */ public static ServletInfo servlet(final String name, final Class<? extends Servlet> servletClass, final InstanceFactory<? extends Servlet> servlet) { return new ServletInfo(name, servletClass, servlet); }
static <T extends Servlet> ServletInfo servletInfo(final String name, final Class<T> servletClass, final GenericFactory<T> instanceFactory) { return instanceFactory == null ? new ServletInfo(name, servletClass) : new ServletInfo(name, servletClass, instanceFactory); }
protected DeploymentManager createPippoDeploymentManager() { DeploymentInfo info = Servlets.deployment(); info.setDeploymentName("Pippo"); info.setClassLoader(this.getClass().getClassLoader()); info.setContextPath(getSettings().getContextPath()); info.setIgnoreFlush(true); // inject application as context attribute info.addServletContextAttribute(PIPPO_APPLICATION, getApplication()); // add pippo filter addPippoFilter(info); // add initializers info.addListener(new ListenerInfo(PippoServletContextListener.class)); // add listeners listeners.forEach(listener -> info.addListener(new ListenerInfo(listener))); ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class); defaultServlet.addMapping("/"); MultipartConfigElement multipartConfig = createMultipartConfigElement(); defaultServlet.setMultipartConfig(multipartConfig); info.addServlets(defaultServlet); DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info); deploymentManager.deploy(); return deploymentManager; }
private ServletInfo getResteasyServlet() { final ServletInfo servletInfo = new ServletInfo("Resteasy", HttpServletDispatcher.class); servletInfo.addMapping("/*"); return servletInfo; }
public static ServletInfo createServlet(final String name, final String path) { ServletInfo servlet = new ServletInfo(name, JspServlet.class); servlet.addMapping(path); //if the JSP servlet is mapped to a path that ends in /* //we want to perform welcome file matches if the directory is requested servlet.setRequireWelcomeFileMapping(true); return servlet; }
public Builder registerWebjars(final boolean disableCache, final String... urlMappings) { ServletInfo servletInfo = new ServletInfo("WebjarsServlet", WebjarsServlet.class).setLoadOnStartup(2) .addMappings(urlMappings); if (disableCache) servletInfo = servletInfo.addInitParam("disableCache", Boolean.toString(disableCache)); context.addServlet(servletInfo); return this; }
private ServletInfo getDefaultFaviconServlet() { return new ServletInfo(StaticResourceServlet.class.getName() + '@' + FAVICON_PATH, StaticResourceServlet.class, GenericFactory.fromInstance( new StaticResourceServlet("/com/qwazr/webapps/favicon.ico", getMimeTypeMap()))). addMapping(FAVICON_PATH); }
private void registerJavascriptServlet(final String urlPath, final java.nio.file.Path controlerPath) { context.servlet(new ServletInfo(JavascriptServlet.class.getName() + '@' + urlPath, JavascriptServlet.class, GenericFactory.fromInstance( new JavascriptServlet(getScriptEngine(), libraryService, controlerPath))).addMapping( urlPath)); }
public Builder registerStaticServlet(final String urlPath, final java.nio.file.Path staticsPath) { final ServletInfo servletInfo = new ServletInfo(StaticFileServlet.class.getName() + '@' + urlPath, StaticFileServlet.class, GenericFactory.fromInstance( new StaticFileServlet(getMimeTypeMap(), staticsPath))).addMapping(urlPath); context.servlet(servletInfo); return this; }
public ServletContextBuilder jaxrs(final String name, final Class<? extends Application> applicationClass, final Consumer<ServletInfo> servletInfoHook) { final ServletInfo servletInfo = new ServletInfo(StringUtils.isEmpty(name) ? applicationClass.getName() : name, ServletContainer.class).addInitParam(ServletProperties.JAXRS_APPLICATION_CLASS, applicationClass.getName()); final ApplicationPath path = AnnotationsUtils.getFirstAnnotation(applicationClass, ApplicationPath.class); if (path != null) servletInfo.addMapping(path.value()); servletInfo.setAsyncSupported(true).setLoadOnStartup(1); addServlet(servletInfo, servletInfoHook); return this; }
public ServletContextBuilder jaxrs(final String name, final ApplicationBuilder applicationBuilder, final Consumer<ServletInfo> servletInfoHook) { final JaxRsServlet jaxRsServlet = new JaxRsServlet(applicationBuilder.build()); final ServletInfo servletInfo = new ServletInfo( StringUtils.isEmpty(name) ? applicationBuilder.getClass() + "@" + applicationBuilder.hashCode() : name, jaxRsServlet.getClass(), GenericFactory.fromInstance(jaxRsServlet)); if (applicationBuilder.applicationPaths != null) { servletInfo.addMappings(applicationBuilder.applicationPaths); applicationBuilder.forEachEndPoint(endPoints::add); } servletInfo.setAsyncSupported(true).setLoadOnStartup(1); return addServlet(servletInfo, servletInfoHook); }
public Builder registerStaticServlet(final String urlPath, final String resourcePath) { final ServletInfo servletInfo = new ServletInfo(StaticResourceServlet.class.getName() + '@' + urlPath, StaticResourceServlet.class, GenericFactory.fromInstance( new StaticResourceServlet('/' + StringUtils.replaceChars(resourcePath, '.', '/'), getMimeTypeMap()))).addMapping(urlPath); context.servlet(servletInfo); return this; }
@Override public ServletRegistration.Dynamic addServlet(final String servletName, final Servlet servlet) { ensureNotProgramaticListener(); ensureNotInitialized(); ensureServletNameNotNull(servletName); if (deploymentInfo.getServlets().containsKey(servletName)) { return null; } ServletInfo s = new ServletInfo(servletName, servlet.getClass(), new ImmediateInstanceFactory<>(servlet)); readServletAnnotations(s); deploymentInfo.addServlet(s); ServletHandler handler = deployment.getServlets().addServlet(s); return new ServletRegistrationImpl(s, handler.getManagedServlet(), deployment); }
private ServletContext buildServletContext(String contextName) throws ServletException { ServletContainer servletContainer = new ServletContainerImpl(); DeploymentInfo deploymentInfo = new DeploymentInfo(); deploymentInfo.setClassLoader(Thread.currentThread().getContextClassLoader()); deploymentInfo.setDeploymentName("cxf-undertow"); deploymentInfo.setContextPath(contextName); ServletInfo asyncServlet = new ServletInfo(ServletPathMatches.DEFAULT_SERVLET_NAME, CxfUndertowServlet.class); deploymentInfo.addServlet(asyncServlet); servletContainer.addDeployment(deploymentInfo); DeploymentManager deploymentManager = servletContainer.getDeployment(deploymentInfo.getDeploymentName()); deploymentManager.deploy(); deploymentManager.start(); return deploymentManager.getDeployment().getServletContext(); }
private ServletContext buildServletContext(String contextName) throws ServletException { ServletContainer servletContainer = new ServletContainerImpl(); DeploymentInfo deploymentInfo = new DeploymentInfo(); deploymentInfo.setClassLoader(Thread.currentThread().getContextClassLoader()); deploymentInfo.setDeploymentName("cxf-undertow"); deploymentInfo.setContextPath(contextName); ServletInfo asyncServlet = new ServletInfo(ServletPathMatches.DEFAULT_SERVLET_NAME, CxfUndertowServlet.class); deploymentInfo.addServlet(asyncServlet); servletContainer.addDeployment(deploymentInfo); DeploymentManager deploymentManager = servletContainer.getDeployment(deploymentInfo.getDeploymentName()); deploymentManager.deploy(); deploymentManager.start(); return deploymentManager.getDeployment().getServletContext(); }