@Override public ServletContext getContext(final String uripath) { DeploymentManager deploymentByPath = servletContainer.getDeploymentByPath(uripath); if (deploymentByPath == null) { return null; } return deploymentByPath.getDeployment().getServletContext(); }
protected void deployServlet(final DeploymentInfo deploymentInfo) { DeploymentManager manager = ServletContainer.Factory.newInstance().addDeployment(deploymentInfo); manager.deploy(); deployment = manager.getDeployment(); try { injectedHost.getValue().registerDeployment(deployment, manager.start()); } catch (ServletException e) { RTSLogger.ROOT_LOGGER.warn(e.getMessage(), e); deployment = null; } }
@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); }
@Override public void stop() throws Exception { host.getValue().unregisterDeployment(manager.getDeployment()); manager.stop(); }
@Override public void start() throws Exception { HttpHandler handler = manager.start(); host.getValue().registerDeployment(manager.getDeployment(), handler); }