private static Server createServer(final String serverXml) { final Catalina catalina = new Catalina() { // skip few init we don't need *here* @Override protected void initDirs() { // no-op } @Override protected void initStreams() { // no-op } @Override protected void initNaming() { // no-op } }; catalina.setConfigFile(serverXml); catalina.load(); return catalina.getServer(); }
/** * @param catalina */ TomcatRuntimeImpl(Catalina catalina) { this.catalina = catalina; this.status = TomcatStatus.UNKNOWN; catalina.getServer().addLifecycleListener(new LifecycleListener() { @Override public void lifecycleEvent(LifecycleEvent event) { String type = event.getType().toUpperCase(); status = TomcatStatus.valueOf(type); if (Lifecycle.AFTER_START_EVENT.equals(event.getType()) || Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) { semaphore.release(); } } }); }
/** * Initialize Tomcat inner datasets. */ public void init () throws TomcatException { tomcatpath = configurationManager.getTomcatConfiguration ().getPath (); final String extractDirectory = tomcatpath; File extractDirectoryFile = new File (extractDirectory); LOGGER.info("Starting tomcat in " + extractDirectoryFile.getPath()); try { extract (extractDirectoryFile, extractDirectory); // create tomcat various paths new File (extractDirectory, "conf").mkdirs (); File cfg = new File (ClassLoader.getSystemResource ("server.xml").toURI ()); Files.copy (cfg, new File (extractDirectory, "conf/server.xml")); new File (extractDirectory, "logs").mkdirs (); new File (extractDirectory, "webapps").mkdirs (); new File (extractDirectory, "work").mkdirs (); File tmpDir = new File (extractDirectory, "temp"); tmpDir.mkdirs (); System.setProperty ("java.io.tmpdir", tmpDir.getAbsolutePath ()); System.setProperty ("catalina.base", extractDirectoryFile.getAbsolutePath ()); System.setProperty ("catalina.home", extractDirectoryFile.getAbsolutePath ()); cat = new Catalina (); } catch (Exception e) { throw new TomcatException ("Cannot initalize Tomcat environment.", e); } Runtime.getRuntime ().addShutdownHook (new TomcatShutdownHook ()); }
/** * Return the outer Catalina startup/shutdown component if present. */ @Override public Catalina getCatalina() { return catalina; }
/** * Set the outer Catalina startup/shutdown component if present. */ @Override public void setCatalina(Catalina catalina) { this.catalina = catalina; }
@Override public Catalina getCatalina() { return null; }
@Override public void setCatalina(Catalina catalina) { throw new UnsupportedOperationException("Catalina can't be changed at runtime"); }
/** * Return the outer Catalina startup/shutdown component if present. */ public Catalina getCatalina();
/** * Set the outer Catalina startup/shutdown component if present. */ public void setCatalina(Catalina catalina);