import java.util.Properties;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.springframework.osgi.web.tomcat.internal.Activator;
/** Starts Catalina (hacked from Spring OSGi 1.0) */
public class CatalinaActivator extends Activator {
+ private final static Log log = LogFactory.getLog(CatalinaActivator.class);
+
private final static String ARGEO_OSGI_DATA_DIR = "argeo.osgi.data.dir";
/** System properties used to override Tomcat XML config URL */
public final static String ARGEO_SERVER_TOMCAT_CONFIG = "argeo.server.tomcat.config";
System.setProperty("catalina.base",
System.getProperty(ARGEO_OSGI_DATA_DIR) + "/tomcat");
+ // Make sure directories are created
+ File catalinaDir = new File(System.getProperty("catalina.home"));
+ if (!catalinaDir.exists()) {
+ catalinaDir.mkdirs();
+ if (log.isDebugEnabled())
+ log.debug("Created Tomcat directory " + catalinaDir);
+ }
+
// Call Spring starter
super.start(context);
}
import java.io.FileOutputStream;\r
import java.io.IOException;\r
import java.io.InputStream;\r
+import java.net.MalformedURLException;\r
import java.net.URL;\r
import java.net.URLConnection;\r
import java.net.URLStreamHandler;\r
throws Exception {\r
URL xmlConfiguration = null;\r
\r
- if (System.getProperty(CatalinaActivator.ARGEO_SERVER_TOMCAT_CONFIG) != null)\r
- xmlConfiguration = new URL(\r
- System.getProperty(CatalinaActivator.ARGEO_SERVER_TOMCAT_CONFIG));\r
- else\r
+ if (System.getProperty(CatalinaActivator.ARGEO_SERVER_TOMCAT_CONFIG) != null) {\r
+ String customConfig = System\r
+ .getProperty(CatalinaActivator.ARGEO_SERVER_TOMCAT_CONFIG);\r
+ try {\r
+ xmlConfiguration = new URL(customConfig);\r
+ } catch (MalformedURLException e) {\r
+ // within this bundle\r
+ // typically 'default-server-ssl.xml'\r
+ xmlConfiguration = bundle.getResource(customConfig);\r
+ }\r
+ } else {\r
// fragment\r
xmlConfiguration = bundle.getResource(XML_CONF_LOCATION);\r
+ }\r
\r
if (xmlConfiguration != null) {\r
log.info("Using custom XML configuration " + xmlConfiguration);\r
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<Server port="-1" shutdown="SHUTDOWN">
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <!-- <Listener className="org.apache.catalina.core.AprLifecycleListener"
+ SSLEngine="on" /> -->
+ <!-- Initialize Jasper prior to webapps are loaded. -->
+ <Listener className="org.apache.catalina.core.JasperListener" />
+ <!-- JMX -->
+ <!-- <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
+ /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
+ /> -->
+
+ <Service name="Catalina">
+ <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
+ maxThreads="150" minSpareThreads="4" />
+
+ <!-- HTTP -->
+ <Connector executor="tomcatThreadPool" port="${argeo.server.port.http}"
+ protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="${argeo.server.port.https}"
+ secure="${argeo.server.http.secure}" proxyName="${argeo.server.http.proxyName}"
+ proxyPort="${argeo.server.http.proxyPort}" />
+ <!-- HTTPS -->
+ <Connector port="${argeo.server.port.https}" protocol="HTTP/1.1"
+ SSLEnabled="true" scheme="https" secure="true" sslProtocol="TLS"
+ keystoreFile="${argeo.server.keystoreFile}" keystoreType="JKS"
+ keystorePass="${argeo.server.keystorePass}" truststoreFile="${argeo.server.truststoreFile}"
+ truststoreType="JKS" truststorePass="${argeo.server.truststorePass}"
+ clientAuth="${argeo.server.https.clientAuth}" />
+
+ <!-- AJP (for proxying with httpd) -->
+ <Connector port="${argeo.server.port.ajp}" protocol="AJP/1.3"
+ redirectPort="${argeo.server.port.https}" />
+
+ <Engine name="Catalina" defaultHost="localhost">
+ <Host name="localhost" appBase="webapps" unpackWARs="true"
+ autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"
+ workDir="work">
+ </Host>
+ </Engine>
+ </Service>
+</Server>
\ No newline at end of file