private static void configureHttpConnector(Tomcat tomcat, TomcatConfig tomcatConfig) { Connector connector = tomcat.getConnector(); connector.setProperty("server", "kicktipp"); connector.setPort(tomcatConfig.getPort()); connector.setRedirectPort(tomcatConfig.getSslPort()); addCompression(connector); }
public static Tomcat startServer(final TomcatConfig tomcatConfig) throws Exception { final Tomcat tomcat = new Tomcat(); Map<String, String> map = tomcatConfig.getProperties(); for (String key : map.keySet()) { System.setProperty(key, map.get(key)); } tomcat.setBaseDir("./target/tomcat"); tomcat.setSilent(true); // um zu verhindern dass sich die jmx namen mit www/info überschneiden tomcat.getEngine().setName(tomcatConfig.getName()); configureHttpConnector(tomcat, tomcatConfig); configureHttpsConnector(tomcat, tomcatConfig); // jndi wird gestartet, sonst bekommen wir eine hässliche Warnung, weil // wir in der HibernateConfig das Property // hibernate.session_factory_name setzen tomcat.enableNaming(); String absolutePath = new File(tomcatConfig.getPath()).getAbsolutePath(); Context context = tomcat.addWebapp("", absolutePath); VirtualWebappLoader virtualWebappLoader = new VirtualWebappLoader(); virtualWebappLoader.setVirtualClasspath("../jlot-web/target/classes"); context.setLoader(virtualWebappLoader); context.setUseHttpOnly(false); tomcat.getServer().addLifecycleListener(new TomcatStartupTimeLogger(tomcatConfig.getName())); tomcat.start(); new TomcatRunThread(tomcat).start(); return tomcat; }
private static void configureHttpsConnector(Tomcat tomcat, TomcatConfig tomcatConfig) { Connector connector = new Connector(); connector.setProperty("server", "jlot"); connector.setPort(tomcatConfig.getSslPort()); connector.setSecure(true); connector.setEnableLookups(false); connector.setScheme("https"); connector.setAttribute("SSLEnabled", true); File file = new File("../kicktipp.org.keystore"); String keystoreFile = file.getAbsolutePath(); connector.setAttribute("keystoreFile", keystoreFile); connector.setAttribute("keyAlias", "tomcat"); connector.setAttribute("keystorePass", "tomcat"); connector.setAttribute("clientAuth", "false"); connector.setAttribute("sslProtocol", "TLS"); addCompression(connector); tomcat.getService().addConnector(connector); }
@Override public boolean equals(Object obj) { TomcatConfig otherJettyConfig = (TomcatConfig) obj; return path.equals(otherJettyConfig.getPath()); }