io.undertow.servlet.ServletExtension Java Examples
The following examples show how to use
io.undertow.servlet.ServletExtension.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebXmlContainer.java From thorntail with Apache License 2.0 | 6 votes |
/** * Add the default Thorntail {@code favicon.ico} handler. * * @return This archive. */ @SuppressWarnings("unchecked") default T addFaviconExceptionHandler() throws IOException { // Add FaviconServletExtension String path = "WEB-INF/classes/" + FaviconServletExtension.EXTENSION_NAME.replace('.', '/') + ".class"; byte[] generatedExtension; generatedExtension = FaviconFactory.createFaviconServletExtension(FaviconServletExtension.EXTENSION_NAME); add(new ByteArrayAsset(generatedExtension), path); // Add FaviconErrorHandler path = "WEB-INF/classes/" + FaviconServletExtension.HANDLER_NAME.replace('.', '/') + ".class"; byte[] generatedHandler; generatedHandler = FaviconFactory.createFaviconErrorHandler(FaviconServletExtension.HANDLER_NAME); add(new ByteArrayAsset(generatedHandler), path); // Add services entry for FaviconServletExtension this.addAsServiceProvider(ServletExtension.class.getName(), FaviconServletExtension.EXTENSION_NAME); return (T) this; }
Example #2
Source File: DeploymentUtils.java From quarkus-http with Apache License 2.0 | 6 votes |
/** * Sets up a simple servlet deployment with the provided servlets. * * This is just a convenience method for simple deployments * * @param servlets The servlets to add */ public static Deployment setupServlet(final ServletExtension servletExtension, final ServletInfo... servlets) { final PathHandler pathHandler = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlets(servlets); if(servletExtension != null) { builder.addServletExtension(servletExtension); } DeploymentManager manager = container.addDeployment(builder); manager.deploy(); try { pathHandler.addPrefixPath(builder.getContextPath(), manager.start()); } catch (ServletException e) { throw new RuntimeException(e); } DefaultServer.setRootHandler(pathHandler); return manager.getDeployment(); }
Example #3
Source File: ServletOutputStreamTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.setIgnoreFlush(false); } }, new ServletInfo(BLOCKING_SERVLET, BlockingOutputStreamServlet.class) .addMapping("/" + BLOCKING_SERVLET), new ServletInfo(ASYNC_SERVLET, AsyncOutputStreamServlet.class) .addMapping("/" + ASYNC_SERVLET) .setAsyncSupported(true), new ServletInfo(CONTENT_LENGTH_SERVLET, ContentLengthCloseFlushServlet.class) .addMapping("/" + CONTENT_LENGTH_SERVLET), new ServletInfo(RESET, ResetBufferServlet.class).addMapping("/" + RESET)); }
Example #4
Source File: ServletInputStreamRequestBufferingTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() { DeploymentUtils.setupServlet( new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { throw new RuntimeException("NYI"); //deploymentInfo.addInitialHandlerChainWrapper(new RequestBufferingHandler.Wrapper(1)); } }, new ServletInfo(BLOCKING_SERVLET, BlockingInputStreamServlet.class) .addMapping("/" + BLOCKING_SERVLET), new ServletInfo(ASYNC_SERVLET, AsyncInputStreamServlet.class) .addMapping("/" + ASYNC_SERVLET) .setAsyncSupported(true)); }
Example #5
Source File: FilterMappingTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
/** * Registers a servlet with two filters, one mapped by servlet name and one mapped by url pattern */ private void setupServlet() { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { servletContext .addFilter("MyFilter1", filterMappedByServletName) .addMappingForServletNames(null, false, SERVLET); servletContext .addFilter("MyFilter2", filterMappedByUrlPattern) .addMappingForUrlPatterns(null, false, "/"); } }, new ServletInfo(SERVLET, NullServlet.class) .addMapping("/" + SERVLET)); }
Example #6
Source File: RewriteTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.addOuterHandlerChainWrapper(new HandlerWrapper() { @Override public HttpHandler wrap(HttpHandler handler) { byte[] data = "RewriteRule /foo1 /bar1".getBytes(StandardCharsets.UTF_8); RewriteConfig config = RewriteConfigFactory.build(new ByteArrayInputStream(data)); return new RewriteHandler(config, handler); } }); } }, new ServletInfo("servlet", PathTestServlet.class) .addMapping("/")); }
Example #7
Source File: MultiPartTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.addListener(Servlets.listener(AddMultipartServetListener.class)); deploymentInfo.setExceptionHandler(LoggingExceptionHandler.builder().add(RuntimeException.class, "io.undertow", Logger.Level.DEBUG).build()); } }, servlet("mp0", MultiPartServlet.class) .addMapping("/0"), servlet("mp1", MultiPartServlet.class) .addMapping("/1") .setMultipartConfig(multipartConfig(null, 0, 0, 0)), servlet("mp2", MultiPartServlet.class) .addMapping("/2") .setMultipartConfig(multipartConfig(null, 0, 3, 0)), servlet("mp3", MultiPartServlet.class) .addMapping("/3") .setMultipartConfig(multipartConfig(null, 3, 0, 0))); }
Example #8
Source File: DefaultCharsetTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.setDefaultEncoding("UTF-8"); } }, servlet("servlet", DefaultCharsetServlet.class) .addMapping("/writer"), servlet("form", DefaultCharsetFormParserServlet.class) .addMapping("/form")); }
Example #9
Source File: SimpleAsyncTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.addErrorPages(new ErrorPage("/500", StatusCodes.INTERNAL_SERVER_ERROR)); } }, servlet("messageServlet", MessageServlet.class) .addInitParam(MessageServlet.MESSAGE, HELLO_WORLD) .setAsyncSupported(true) .addMapping("/message"), servlet("500", MessageServlet.class) .addInitParam(MessageServlet.MESSAGE, "500") .setAsyncSupported(true) .addMapping("/500"), servlet("asyncServlet", AsyncServlet.class) .addInitParam(MessageServlet.MESSAGE, HELLO_WORLD) .setAsyncSupported(true) .addMapping("/async"), servlet("asyncServlet2", AnotherAsyncServlet.class) .setAsyncSupported(true) .addMapping("/async2"), servlet("error", AsyncErrorServlet.class) .setAsyncSupported(true) .addMapping("/error"), servlet("dispatch", AsyncDispatchServlet.class) .setAsyncSupported(true) .addMapping("/dispatch"), servlet("doubleCompleteServlet", AsyncDoubleCompleteServlet.class) .setAsyncSupported(true) .addMapping("/double-complete")); }
Example #10
Source File: DefaultCharacterEncodingTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
private void setup(final String defaultEncoding) throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { if (defaultEncoding != null) { deploymentInfo.setDefaultEncoding(defaultEncoding); } } }, Servlets.servlet("servlet", DefaultCharacterEncodingServlet.class) .addMapping("/")); }
Example #11
Source File: ServletURLRewritingSessionTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.setServletSessionConfig(new ServletSessionConfig().setSessionTrackingModes(Collections.singleton(SessionTrackingMode.URL))); } }, Servlets.servlet(URLRewritingServlet.class).addMapping("/foo")); }
Example #12
Source File: ServletExtensionBuildItem.java From quarkus with Apache License 2.0 | 4 votes |
public ServletExtension getValue() { return value; }
Example #13
Source File: DeploymentInfo.java From quarkus-http with Apache License 2.0 | 4 votes |
public List<ServletExtension> getServletExtensions() { return servletExtensions; }
Example #14
Source File: ServletExtensionHolder.java From lams with GNU General Public License v2.0 | 4 votes |
public static List<ServletExtension> getServletExtensions() { return extensions; }
Example #15
Source File: Activator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void removedService(ServiceReference<ServletExtension> reference, ServletExtension service) { ServletExtensionHolder.getServletExtensions().remove(service); }
Example #16
Source File: Activator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void modifiedService(ServiceReference<ServletExtension> reference, ServletExtension service) { ServletExtensionHolder.getServletExtensions().add(service); }
Example #17
Source File: Activator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public ServletExtension addingService(ServiceReference<ServletExtension> reference) { return null; }
Example #18
Source File: Activator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void start(BundleContext context) throws Exception { tracker = new ServiceTracker<>(context, ServletExtension.class, this); tracker.open(); }
Example #19
Source File: DeploymentInfo.java From lams with GNU General Public License v2.0 | 4 votes |
public List<ServletExtension> getServletExtensions() { return servletExtensions; }
Example #20
Source File: UndertowDeploymentRecorder.java From quarkus with Apache License 2.0 | 4 votes |
public void addServletExtension(RuntimeValue<DeploymentInfo> deployment, ServletExtension extension) { deployment.getValue().addServletExtension(extension); }
Example #21
Source File: ServletExtensionBuildItem.java From quarkus with Apache License 2.0 | 4 votes |
public ServletExtensionBuildItem(ServletExtension value) { this.value = value; }
Example #22
Source File: Activator.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void start(BundleContext context) throws Exception { // Register the service in the OSGi registry. registration = context.registerService(ServletExtension.class, new Bootstrap(), null); }
Example #23
Source File: Activator.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void start(BundleContext context) throws Exception { tracker = new ServiceTracker<>(context, ServletExtension.class, this); tracker.open(); }
Example #24
Source File: Activator.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public ServletExtension addingService(ServiceReference<ServletExtension> reference) { return null; }
Example #25
Source File: Activator.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void modifiedService(ServiceReference<ServletExtension> reference, ServletExtension service) { ServletExtensionHolder.getServletExtensions().add(service); }
Example #26
Source File: Activator.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void removedService(ServiceReference<ServletExtension> reference, ServletExtension service) { ServletExtensionHolder.getServletExtensions().remove(service); }
Example #27
Source File: ServletExtensionHolder.java From quarkus-http with Apache License 2.0 | 4 votes |
public static List<ServletExtension> getServletExtensions() { return extensions; }
Example #28
Source File: DeploymentInfo.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Adds an additional servlet extension to the deployment. Servlet extensions are generally discovered * using META-INF/services entries, however this may not be practical in all environments. * @param servletExtension The servlet extension * @return this */ public DeploymentInfo addServletExtension(final ServletExtension servletExtension) { this.servletExtensions.add(servletExtension); return this; }
Example #29
Source File: DeploymentInfo.java From quarkus-http with Apache License 2.0 | 2 votes |
/** * Adds an additional servlet extension to the deployment. Servlet extensions are generally discovered * using META-INF/services entries, however this may not be practical in all environments. * @param servletExtension The servlet extension * @return this */ public DeploymentInfo addServletExtension(final ServletExtension servletExtension) { this.servletExtensions.add(servletExtension); return this; }