use of org.apache.catalina.Wrapper in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onDeployUAVApp.
public void onDeployUAVApp(Object... args) {
if (UAVServer.ServerVendor.SPRINGBOOT != UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR)) {
return;
}
Tomcat tomcat = (Tomcat) args[0];
String mofRoot = (String) args[1];
// add uavApp
StandardContext context = new StandardContext();
context.setName("com.creditease.uav");
context.setPath("/com.creditease.uav");
context.setDocBase(mofRoot + "/com.creditease.uav");
context.addLifecycleListener(new Tomcat.FixContextListener());
tomcat.getHost().addChild(context);
// add default servlet
Wrapper servlet = context.createWrapper();
servlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
servlet.setName("default");
context.addChild(servlet);
servlet.setOverridable(true);
context.addServletMapping("/", "default");
// init webapp classloader
context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
context.setDelegate(true);
// after tomcat8, skip jarscan
Object obj = ReflectionHelper.newInstance("org.apache.tomcat.util.scan.StandardJarScanner", Thread.currentThread().getContextClassLoader());
if (obj != null) {
ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllFiles", new Class<?>[] { Boolean.class }, new Object[] { false }, Thread.currentThread().getContextClassLoader());
ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanClassPath", new Class<?>[] { Boolean.class }, new Object[] { false }, Thread.currentThread().getContextClassLoader());
ReflectionHelper.invoke("org.apache.tomcat.util.scan.StandardJarScanner", obj, "setScanAllDirectories", new Class<?>[] { Boolean.class }, new Object[] { false }, Thread.currentThread().getContextClassLoader());
context.setJarScanner((JarScanner) obj);
}
}
use of org.apache.catalina.Wrapper in project cxf by apache.
the class AbstractTomcatServer method run.
protected void run() {
server = new Tomcat();
server.setPort(port);
try {
final File base = createTemporaryDirectory();
server.setBaseDir(base.getAbsolutePath());
if (resourcePath == null) {
final Context context = server.addContext("/", base.getAbsolutePath());
final Wrapper cxfServlet = Tomcat.addServlet(context, "cxfServlet", new CXFNonSpringJaxrsServlet());
cxfServlet.addInitParameter(CXFNonSpringJaxrsServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID);
cxfServlet.addInitParameter("jaxrs.serviceClasses", BookStore.class.getName());
cxfServlet.addInitParameter("jaxrs.providers", JacksonJsonProvider.class.getName());
cxfServlet.setAsyncSupported(true);
context.addServletMapping("/rest/*", "cxfServlet");
} else {
server.getHost().setAppBase(base.getAbsolutePath());
server.getHost().setAutoDeploy(true);
server.getHost().setDeployOnStartup(true);
server.addWebapp(contextPath, getClass().getResource(resourcePath).toURI().getPath().toString());
}
server.start();
} catch (final Exception ex) {
ex.printStackTrace();
fail(ex.getMessage());
}
}
use of org.apache.catalina.Wrapper in project nutzboot by nutzam.
the class TomcatStarter method addServlet.
private void addServlet(WebServletFace webServlet) {
log.debugf("[NutzBoot] add servlet name=%s pathSpec=%s", webServlet.getName(), webServlet.getPathSpec());
Wrapper servlet = tomcatContext.createWrapper();
servlet.setName(webServlet.getName());
servlet.setServletClass(webServlet.getServlet().getClass().getName());
servlet.setServlet(webServlet.getServlet());
for (Map.Entry<String, String> entry : webServlet.getInitParameters().entrySet()) {
servlet.addInitParameter(entry.getKey(), entry.getValue());
}
servlet.setOverridable(true);
this.tomcatContext.addChild(servlet);
addServletMapping(webServlet.getPathSpec(), webServlet.getName());
}
use of org.apache.catalina.Wrapper in project nutzboot by nutzam.
the class TomcatStarter method addDefaultServlet.
private void addDefaultServlet() {
Wrapper defaultServlet = this.tomcatContext.createWrapper();
defaultServlet.setName("default");
defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
defaultServlet.addInitParameter("debug", "0");
defaultServlet.addInitParameter("listings", "false");
defaultServlet.setLoadOnStartup(1);
defaultServlet.setOverridable(true);
this.tomcatContext.addChild(defaultServlet);
addServletMapping("/", "default");
}
use of org.apache.catalina.Wrapper in project microservice-starter-tomcat by ERS-HCL.
the class App method main.
public static void main(String[] args) throws LifecycleException {
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
Context ctx = tomcat.addContext("/", new File(".").getAbsolutePath());
Wrapper servletWrapper = Tomcat.addServlet(ctx, "rnd.web.service.rest.App", "org.glassfish.jersey.servlet.ServletContainer");
servletWrapper.addInitParameter("javax.ws.rs.Application", "rnd.web.service.rest.AppConfig");
ctx.addServletMappingDecoded("/*", "rnd.web.service.rest.App");
tomcat.start();
tomcat.getServer().await();
}
Aggregations