io.undertow.servlet.api.ServletContainer Java Examples
The following examples show how to use
io.undertow.servlet.api.ServletContainer.
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: TestMessagesReceivedInOrder.java From quarkus-http with Apache License 2.0 | 9 votes |
@BeforeClass public static void setup() throws ServletException { final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(TestMessagesReceivedInOrder.class.getClassLoader()) .setContextPath("/") .setResourceManager(new TestResourceLoader(TestMessagesReceivedInOrder.class)) .setClassIntrospecter(TestClassIntrospector.INSTANCE) .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo() .setDispatchToWorkerThread(true) .addEndpoint(EchoSocket.class) ) .setDeploymentName("servletContext.war"); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/", manager.start())); }
Example #2
Source File: ServletSessionTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { 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") .addListener(new ListenerInfo(SessionCookieConfigListener.class)) .addServlets(new ServletInfo("servlet", SessionServlet.class) .addMapping("/aa/b")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); try { pathHandler.addPrefixPath(builder.getContextPath(), manager.start()); } catch (ServletException e) { throw new RuntimeException(e); } DefaultServer.setRootHandler(pathHandler); }
Example #3
Source File: TransferTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlet( new ServletInfo("servlet", TXServlet.class) .addMapping("/") ); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #4
Source File: RedirectTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { 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( servlet("request", RequestPathServlet.class) .addMapping("/"), servlet("redirect", RedirectServlet.class) .addMapping("/redirect/*")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); try { pathHandler.addPrefixPath(builder.getContextPath(), manager.start()); } catch (ServletException e) { throw new RuntimeException(e); } DefaultServer.setRootHandler(pathHandler); }
Example #5
Source File: ParameterEchoTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo s = new ServletInfo("servlet", ParameterEchoServlet.class) .addMapping("/aaa"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(ParameterEchoTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlet(s); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #6
Source File: GetCookiesTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo s = new ServletInfo("servlet", ValidCookieEchoServlet.class) .addMapping("/aaa"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(GetCookiesTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlet(s); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #7
Source File: MockRequestTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo s = new ServletInfo("servlet", HelloServlet.class).addMapping("/aa"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(MockRequestTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlet(s); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); deployment = manager.getDeployment(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #8
Source File: ServletAndResourceWelcomeFileTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ServletPathMappingTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(ServletAndResourceWelcomeFileTestCase.class)) .addWelcomePages("doesnotexist.html", "index.html", "default"); builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class) .addMapping("*.html")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #9
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 #10
Source File: ServletContextListenerTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServletContainerInitializer(new ServletContainerInitializerInfo(TestSci.class, Collections.<Class<?>>emptySet())) .addServlet( new ServletInfo("servlet", MessageServlet.class) .addMapping("/aa") ) .addListener(new ListenerInfo(ServletContextTestListener.class)); manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #11
Source File: RealPathTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo realPathServlet = new ServletInfo("real path servlet", RealPathServlet.class) .addMapping("/path/*"); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(RealPathTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(RealPathTestCase.class)) .addServlets(realPathServlet); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #12
Source File: DefaultServletCachingTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException, IOException { tmpDir = Files.createTempDirectory(DIR_NAME); final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ServletPathMappingTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .setResourceManager(new CachingResourceManager(100, 10000, dataCache, new PathResourceManager(tmpDir, 10485760, false, false, false), METADATA_MAX_AGE)); builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class) .addMapping("/path/default")) .addFilter(Servlets.filter("message", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "FILTER_TEXT ")) .addFilterUrlMapping("message", "*.txt", DispatcherType.REQUEST); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #13
Source File: ContentTypeFilesTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ContentTypeFilesTestCase.class.getClassLoader()) .setContextPath("/app") .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(ContentTypeServlet.class)) .setDefaultServletConfig(new DefaultServletConfig(true)) .addMimeMapping(new MimeMapping("jnlp", "application/x-java-jnlp-file")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #14
Source File: SessionIdHandlingTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { 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(new ServletInfo("servlet", RequestedSessionIdServlet.class) .addMapping("/session")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); try { pathHandler.addPrefixPath(builder.getContextPath(), manager.start()); } catch (ServletException e) { throw new RuntimeException(e); } DefaultServer.setRootHandler(pathHandler); }
Example #15
Source File: ChangeSessionIdTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler path = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo s = new ServletInfo("servlet", ChangeSessionIdServlet.class) .addMapping("/aa"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addListener(new ListenerInfo(ChangeSessionIdListener.class)) .addServlet(s); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); path.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(path); }
Example #16
Source File: SimpleServletTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo s = new ServletInfo("servlet", MessageServlet.class) .addInitParam(MessageServlet.MESSAGE, HELLO_WORLD) .addMapping("/aa"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlet(s); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #17
Source File: ServletSessionListenerOrderingTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler path = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/listener") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("listener.war") .addListener(new ListenerInfo(FirstListener.class)) .addListener(new ListenerInfo(SecondListener.class)) .addServlet(new ServletInfo("message", EmptyServlet.class) .addMapping("/*")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); path.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(path); }
Example #18
Source File: EagerServletLifecycleTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@Test public void testServletLifecycle() throws Exception { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); FilterInfo f = new FilterInfo("filter", LifecycleFilter.class); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(EagerServletLifecycleTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .setEagerFilterInit(true) .addFilter(f) .addFilterUrlMapping("filter", "/aa", DispatcherType.REQUEST); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); Assert.assertTrue(LifecycleFilter.initCalled); }
Example #19
Source File: ServletSessionInvalidateWithListenerTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler path = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/listener") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("listener.war") .addListener(new ListenerInfo(SimpleSessionListener.class)) .addServlet(new ServletInfo("servlet", SessionServlet.class) .addMapping("/test")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); path.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(path); }
Example #20
Source File: GetResourceTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(GetResourceTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(GetResourceTestCase.class)); builder.addServlet(new ServletInfo("ReadFileServlet", ReadFileServlet.class) .addMapping("/file")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #21
Source File: ResponseWriterTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ResponseWriterTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .addServlet(Servlets.servlet("resp", ResponseWriterServlet.class) .addMapping("/resp")) .addServlet(Servlets.servlet("respLArget", LargeResponseWriterServlet.class) .addMapping("/large")); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #22
Source File: JsrWebSocketServerTest.java From quarkus-http with Apache License 2.0 | 6 votes |
private ServletContext deployServlet(final ServerWebSocketContainer deployment) throws ServletException { final DeploymentInfo builder; builder = new DeploymentInfo() .setClassLoader(getClass().getClassLoader()) .setContextPath("/") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("websocket.war") .addFilter(new FilterInfo("filter", JsrWebSocketFilter.class)) .addFilterUrlMapping("filter", "/*", DispatcherType.REQUEST) .addServletContextAttribute(javax.websocket.server.ServerContainer.class.getName(), deployment); final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); return manager.getDeployment().getServletContext(); }
Example #23
Source File: NestedListenerInvocationTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo a = new ServletInfo("asyncServlet", AsyncServlet.class) .setAsyncSupported(true) .addMapping("/async"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(NestedListenerInvocationTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .addServlets(a) .addListener(new ListenerInfo(SimpleRequestListener.class)); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #24
Source File: DefaultServletTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ServletPathMappingTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(DefaultServletTestCase.class)); builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class) .addMapping("/path/default")); builder.addServlet(new ServletInfo("default", DefaultServlet.class) .addInitParam("directory-listing", "true") .addMapping("/*")); //see UNDERTOW-458 builder.addFilter(new FilterInfo("date-header", GetDateFilter.class)); builder.addFilterUrlMapping("date-header", "/*", DispatcherType.REQUEST); builder.addFilter(new FilterInfo("Filter", HelloFilter.class)); builder.addFilterUrlMapping("Filter", "/filterpath/*", DispatcherType.REQUEST); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #25
Source File: WelcomeFileSecurityTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletIdentityManager identityManager = new ServletIdentityManager(); identityManager.addUser("user1", "password1", "role1"); DeploymentInfo builder = new DeploymentInfo() .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ServletPathMappingTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(WelcomeFileSecurityTestCase.class)) .addWelcomePages("doesnotexist.html", "index.html", "default") .setIdentityManager(identityManager) .setLoginConfig(new LoginConfig("BASIC", "Test Realm")) .addServlet( new ServletInfo("DefaultTestServlet", PathTestServlet.class) .setServletSecurityInfo( new ServletSecurityInfo() .addRoleAllowed("role1")) .addMapping("/path/default")) .addSecurityConstraint(new SecurityConstraint() .addRoleAllowed("role1") .addWebResourceCollection(new WebResourceCollection() .addUrlPattern("/index.html"))); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #26
Source File: CrossContextClassLoaderTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); ServletInfo s = new ServletInfo("includer", IncludeServlet.class) .addMapping("/a"); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(new TempClassLoader("IncluderClassLoader")) .setContextPath("/includer") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("includer.war") .addServlet(s); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); s = new ServletInfo("included", IncludedServlet.class) .addMapping("/a"); builder = new DeploymentInfo() .setClassLoader(new TempClassLoader("IncludedClassLoader")) .setContextPath("/included") .setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("included.war") .addServlet(s); manager = container.addDeployment(builder); manager.deploy(); root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler(root); }
Example #27
Source File: ServletContextImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public ServletContextImpl(final ServletContainer servletContainer, final Deployment deployment) { this.servletContainer = servletContainer; this.deployment = deployment; this.deploymentInfo = deployment.getDeploymentInfo(); sessionCookieConfig = new SessionCookieConfigImpl(this); sessionCookieConfig.setPath(deploymentInfo.getContextPath()); if (deploymentInfo.getServletContextAttributeBackingMap() == null) { this.attributes = new ConcurrentHashMap<>(); } else { this.attributes = deploymentInfo.getServletContextAttributeBackingMap(); } attributes.putAll(deployment.getDeploymentInfo().getServletContextAttributes()); this.contentTypeCache = new LRUCache<>(deployment.getDeploymentInfo().getContentTypeCacheSize(), -1, true); this.defaultSessionTimeout = deploymentInfo.getDefaultSessionTimeout() / 60; }
Example #28
Source File: Servlets.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns the default servlet container. For most embedded use * cases this will be sufficient. * * @return The default servlet container */ public static ServletContainer defaultContainer() { if (container != null) { return container; } synchronized (Servlets.class) { if (container != null) { return container; } return container = ServletContainer.Factory.newInstance(); } }
Example #29
Source File: DeploymentImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public DeploymentImpl(DeploymentManager deploymentManager, final DeploymentInfo deploymentInfo, ServletContainer servletContainer) { this.deploymentManager = deploymentManager; this.deploymentInfo = deploymentInfo; this.servletContainer = servletContainer; servletPaths = new ServletPathMatches(this); servlets = new ManagedServlets(this, servletPaths); filters = new ManagedFilters(this, servletPaths); }
Example #30
Source File: SuspendResumeTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo() .setClassLoader(TestMessagesReceivedInOrder.class.getClassLoader()) .setContextPath("/") .setResourceManager(new TestResourceLoader(TestMessagesReceivedInOrder.class)) .setClassIntrospecter(TestClassIntrospector.INSTANCE) .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo() .addListener(new WebSocketDeploymentInfo.ContainerReadyListener() { @Override public void ready(ServerWebSocketContainer c) { serverContainer = c; } }) .addEndpoint(SuspendResumeEndpoint.class) ) .setDeploymentName("servletContext.war"); DeploymentManager manager = container.addDeployment(builder); manager.deploy(); DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/", manager.start())); }