Java Code Examples for org.apache.catalina.startup.Tomcat#setSilent()

The following examples show how to use org.apache.catalina.startup.Tomcat#setSilent() . 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: TomcatTestServer.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private TestServerBuilder(final int fixedPort) {
  initializeProperties();
  baseDir = getFileForDirProperty(TOMCAT_BASE_DIR);      
  if (!baseDir.exists() && !baseDir.mkdirs()) {
    throw new RuntimeException("Unable to create temporary test directory at {" + baseDir.getAbsolutePath() + "}");
  }
  resourceDir = getFileForDirProperty(PROJECT_RESOURCES_DIR);
  if(!resourceDir.exists()){
      throw new RuntimeException("Unable to load resources");
  }

  tomcat = new Tomcat();
  tomcat.setBaseDir(baseDir.getParentFile().getAbsolutePath());
  tomcat.setPort(fixedPort);
  tomcat.getHost().setAppBase(baseDir.getAbsolutePath());
  tomcat.getHost().setDeployOnStartup(true);
  tomcat.getConnector().setSecure(false);
  tomcat.setSilent(true);
  tomcat.addUser("odatajclient", "odatajclient");
  tomcat.addRole("odatajclient", "odatajclient");
}