You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/06/22 08:58:03 UTC

svn commit: r787153 - in /geronimo/server/trunk: framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/ plugins/tomca...

Author: djencks
Date: Mon Jun 22 06:58:02 2009
New Revision: 787153

URL: http://svn.apache.org/viewvc?rev=787153&view=rev
Log:
GERONIMO-4684 Do property substitution and calculations in the tomcat server.xml

Modified:
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/TomcatServerGBeanTest.java
    geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/resources/tomcat-base/server.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Mon Jun 22 06:58:02 2009
@@ -251,6 +251,10 @@
         return serverOverride.getConfiguration(artifact) != null;
     }
 
+    public String substitute(String in) {
+        return expressionParser.parse(in);
+    }
+
     public void addConfigSubstitutions(Properties properties) {
         localConfigSubstitutions.putAll(properties);
         Map<String, Object> configSubstutions = loadAllConfigSubstitutions(localConfigSubstitutions, prefix);

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java Mon Jun 22 06:58:02 2009
@@ -41,4 +41,6 @@
     void addConfigSubstitutions(Properties properties);
 
     boolean isModuleInstalled(Artifact artifact);
+
+    String substitute(final String in);
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java Mon Jun 22 06:58:02 2009
@@ -127,7 +127,7 @@
 
         log.trace("Parsing input: {}", input);
 
-        StringBuffer buff = new StringBuffer();
+        StringBuilder buff = new StringBuilder();
 
         int cur = 0;
         int prefixLoc;

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java Mon Jun 22 06:58:02 2009
@@ -26,6 +26,9 @@
 import java.io.Reader;
 import java.io.StringReader;
 import java.util.Arrays;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
@@ -48,6 +51,7 @@
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.system.jmx.MBeanServerReference;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.system.configuration.PluginAttributeStore;
 import org.apache.geronimo.tomcat.model.ServerType;
 import org.apache.tomcat.util.modeler.Registry;
 import org.xml.sax.SAXException;
@@ -78,24 +82,34 @@
     public TomcatServerGBean(@ParamAttribute(name = "serverConfig")String serverConfig,
                              @ParamAttribute(name = "serverConfigLocation")String serverConfigLocation,
                              @ParamReference(name = "ServerInfo") ServerInfo serverInfo,
+                             @ParamReference(name = "AttributeManager", namingType = "AttributeStore") PluginAttributeStore attributeStore,
                              @ParamReference(name = "MBeanServerReference") MBeanServerReference mbeanServerReference,
                              @ParamSpecial(type= SpecialAttributeType.classLoader)ClassLoader classLoader) throws Exception {
         this.serverConfig = serverConfig;
         this.serverInfo = serverInfo;
         this.classLoader = classLoader;
 
-        Reader in;
-        if (serverConfig != null) {
-            in = new StringReader(serverConfig);
-        } else {
+        if(mbeanServerReference != null) {
+            Registry.setServer(mbeanServerReference.getMBeanServer());
+        }
+
+        if (serverConfig == null) {
             File loc = serverInfo.resolveServer(serverConfigLocation);
-            in = new FileReader(loc);
+            Reader in = new FileReader(loc);
+            StringBuilder b = new StringBuilder();
+            char[] buf = new char[1024];
+            int i;
+            while ((i = in.read(buf)) > 0) {
+                b.append(buf, 0, i);
+            }
+            serverConfig = b.toString();
         }
 
-        if(mbeanServerReference != null) {
-            Registry.setServer(mbeanServerReference.getMBeanServer());
+        if (attributeStore != null) {
+            serverConfig = attributeStore.substitute(serverConfig);
         }
-        
+        Reader in = new StringReader(serverConfig);
+
         try {
             ServerType serverType = loadServerType(in);            
             server = serverType.build(classLoader);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/TomcatServerGBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/TomcatServerGBeanTest.java?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/TomcatServerGBeanTest.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/TomcatServerGBeanTest.java Mon Jun 22 06:58:02 2009
@@ -56,7 +56,7 @@
     }
     public void testGBeanServer1() throws Exception {
         ServerInfo serverInfo = new BasicServerInfo(BASEDIR.getAbsolutePath());
-        TomcatServerGBean tomcatServerGBean = new TomcatServerGBean(null, SERVER_1, serverInfo, null, getClass().getClassLoader());
+        TomcatServerGBean tomcatServerGBean = new TomcatServerGBean(null, SERVER_1, serverInfo, null, null, getClass().getClassLoader());
         try {
             tomcatServerGBean.doStart();
         } finally {

Modified: geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml Mon Jun 22 06:58:02 2009
@@ -38,6 +38,9 @@
         <reference name="ServerInfo">
             <name>ServerInfo</name>
         </reference>
+        <reference name="AttributeManager">
+            <name>AttributeManager</name>
+        </reference>
         <reference name="MBeanServerReference">
             <name>MBeanServerReference</name>
         </reference>

Modified: geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/resources/tomcat-base/server.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/resources/tomcat-base/server.xml?rev=787153&r1=787152&r2=787153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/resources/tomcat-base/server.xml (original)
+++ geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/resources/tomcat-base/server.xml Mon Jun 22 06:58:02 2009
@@ -67,9 +67,11 @@
          APR (HTTP/AJP) Connector: /docs/apr.html
          Define a non-SSL HTTP/1.1 Connector on port 8080
     -->
-    <Connector port="8080" protocol="HTTP/1.1"
+    <Connector port="${HTTPPort + PortOffset}"
+               host="${ServerHostname}"
+               protocol="HTTP/1.1"
                connectionTimeout="20000"
-               redirectPort="8443" />
+               redirectPort="${HTTPSPort + PortOffset}" />
     <!-- A "Connector" using the shared thread pool-->
     <!--
     <Connector executor="tomcatThreadPool"
@@ -81,14 +83,21 @@
          This connector uses the JSSE configuration, when using APR, the
          connector should be using the OpenSSL style configuration
          described in the APR documentation -->
-    <!--
-    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
-               maxThreads="150" scheme="https" secure="true"
-               clientAuth="false" sslProtocol="TLS" />
-    -->
+    <Connector port="${HTTPSPort + PortOffset}"
+               host="${ServerHostname}"
+               protocol="HTTP/1.1"
+               SSLEnabled="true"
+               maxThreads="150"
+               scheme="https"
+               secure="true"
+               clientAuth="false"
+               sslProtocol="TLS" />
 
     <!-- Define an AJP 1.3 Connector on port 8009 -->
-    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
+    <Connector port="${AJPPort + PortOffset}"
+               host="${ServerHostname}"
+               protocol="AJP/1.3"
+               redirectPort="${HTTPSPort + PortOffset}" />
 
 
     <!-- An Engine represents the entry point (within Catalina) that processes