Java Code Examples for org.apache.tomcat.util.scan.StandardJarScanner#setScanAllDirectories()

The following examples show how to use org.apache.tomcat.util.scan.StandardJarScanner#setScanAllDirectories() . 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: BootstrapHelper.java    From watcher with Apache License 2.0 6 votes vote down vote up
private void configTomcat(final Tomcat tomcat) throws ServletException {
	//设置tomcat工作目录,maven工程里面就放到target目录下,看起来爽点,注意,这行代码不要随便移动位置,不然你可以have a try。
	tomcat.setBaseDir("target");
	tomcat.setPort(port);
	Connector connector = new Connector("HTTP/1.1");
	connector.setPort(port);
	connector.setURIEncoding("utf-8");
	tomcat.setConnector(connector);
	tomcat.getService().addConnector(connector);
	String webappPath = getWebappsPath();
	System.out.println("webapp目录:" + webappPath);
	Context ctx = tomcat.addWebapp("/", webappPath);
	StandardJarScanner scanner = (StandardJarScanner) ctx.getJarScanner();
	if (!isServlet3Enable) {
		scanner.setScanAllDirectories(false);
		scanner.setScanClassPath(false);
	}
	tomcat.setSilent(true);
	System.setProperty("org.apache.catalina.SESSION_COOKIE_NAME", "JSESSIONID" + port);
}
 
Example 2
Source File: JFishTomcat.java    From onetwo with Apache License 2.0 5 votes vote down vote up
/****
 * 设置扫描目录,让实现了ServletContainerInitializer和WebApplicationInitializer接口而不在jar里面的类被扫描到
 */
public Context addWebapp(Host host, String url, String name, String path) {
	Context ctx = super.addWebapp(host, url, name, path);
	StandardJarScanner jarScanner = new StandardJarScanner();
	jarScanner.setScanAllDirectories(true);
	ctx.setJarScanner(jarScanner);
	return ctx;
}