Java Code Examples for org.apache.catalina.core.StandardContext#setJarScanner()
The following examples show how to use
org.apache.catalina.core.StandardContext#setJarScanner() .
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: SpringBootTomcatPlusIT.java From uavstack with Apache License 2.0 | 5 votes |
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); } }