You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2013/04/05 04:43:26 UTC

svn commit: r1464814 - in /geronimo/server/branches/3.0/framework: configs/karaf-framework/src/main/distribution/text/etc/ configs/karaf-framework/src/main/filtered-resources/etc/ modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/client/ modul...

Author: gawor
Date: Fri Apr  5 02:43:26 2013
New Revision: 1464814

URL: http://svn.apache.org/r1464814
Log:
GERONIMO-6445: Configuration imports and add command-system.properties for tools

Added:
    geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties   (with props)
Modified:
    geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/filtered-resources/etc/command-config.properties
    geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/client/ClientCLI.java
    geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java
    geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/shutdown/ShutdownCLI.java
    geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
    geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Utils.java

Added: geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties?rev=1464814&view=auto
==============================================================================
--- geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties (added)
+++ geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties Fri Apr  5 02:43:26 2013
@@ -0,0 +1,29 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+################################################################################
+
+#
+# Overrides the properties defined in system.properties
+#
+
+${includes} = system.properties
+
+#
+# Configure whether META-INF/ resource lookup should also check wired bundles.
+#
+org.apache.xbean.osgi.bundle.util.BundleResourceHelper.searchWiredBundles=true

Propchange: geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/distribution/text/etc/command-system.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/filtered-resources/etc/command-config.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/filtered-resources/etc/command-config.properties?rev=1464814&r1=1464813&r2=1464814&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/filtered-resources/etc/command-config.properties (original)
+++ geronimo/server/branches/3.0/framework/configs/karaf-framework/src/main/filtered-resources/etc/command-config.properties Fri Apr  5 02:43:26 2013
@@ -21,6 +21,8 @@
 # Overrides the properties defined in config.properties
 #
 
+${includes} = config.properties
+
 # no need to install hotbundles/ scanner
 felix.fileinstall.dir    = ${karaf.base}/etc
 # no need to poll for changes

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/client/ClientCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/client/ClientCLI.java?rev=1464814&r1=1464813&r2=1464814&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/client/ClientCLI.java (original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/client/ClientCLI.java Fri Apr  5 02:43:26 2013
@@ -47,7 +47,8 @@ public class ClientCLI extends AbstractC
         Bootstrapper boot = super.createBootstrapper(parser);
         boot.setWaitForStop(false);
         boot.setUniqueInstance(true);
-        boot.setAdditionalConfigFile("command-config.properties");
+        boot.setConfigFile("command-config.properties");
+        boot.setSystemPropertiesFile("command-system.properties");
         boot.setStartBundles(Arrays.asList("org.apache.geronimo.framework/client-system//car"));
         boot.setLog4jConfigFile("var/log/client-log4j.properties");
         return boot;

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java?rev=1464814&r1=1464813&r2=1464814&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java (original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLI.java Fri Apr  5 02:43:26 2013
@@ -58,7 +58,8 @@ public class DeployerCLI extends Abstrac
         Bootstrapper boot = super.createBootstrapper(parser);
         boot.setWaitForStop(false);
         boot.setUniqueInstance(true);
-        boot.setAdditionalConfigFile("command-config.properties");
+        boot.setConfigFile("command-config.properties");
+        boot.setSystemPropertiesFile("command-system.properties");
         boot.setStartBundles(Arrays.asList("org.apache.geronimo.framework/online-deployer//car"));
         boot.setLog4jConfigFile("var/log/deployer-log4j.properties");
         return boot;

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/shutdown/ShutdownCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/shutdown/ShutdownCLI.java?rev=1464814&r1=1464813&r2=1464814&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/shutdown/ShutdownCLI.java (original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/shutdown/ShutdownCLI.java Fri Apr  5 02:43:26 2013
@@ -47,7 +47,8 @@ public class ShutdownCLI extends Abstrac
         Bootstrapper boot = super.createBootstrapper(parser);
         boot.setWaitForStop(false);
         boot.setUniqueInstance(true);
-        boot.setAdditionalConfigFile("command-config.properties");
+        boot.setConfigFile("command-config.properties");
+        boot.setSystemPropertiesFile("command-system.properties");
         boot.setStartBundles(Arrays.asList("org.apache.geronimo.framework/shutdown//car"));
         boot.setLog4jConfigFile("var/log/server-log4j.properties");
         return boot;

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java?rev=1464814&r1=1464813&r2=1464814&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java (original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java Fri Apr  5 02:43:26 2013
@@ -86,7 +86,7 @@ public class FrameworkLauncher {
     private String log4jFile;
     private String startupFile = STARTUP_PROPERTIES_FILE_NAME;
     private String configFile = CONFIG_PROPERTIES_FILE_NAME;
-    private String additionalConfigFile = null;
+    private String systemPropertiesFile = SYSTEM_PROPERTIES_FILE_NAME;
     private boolean cleanStorage = false;
 
     private ServerInfo serverInfo;
@@ -107,8 +107,8 @@ public class FrameworkLauncher {
         this.configFile = configFile;
     }
 
-    public void setAdditionalConfigFile(String additionalConfigFile) {
-        this.additionalConfigFile = additionalConfigFile;
+    public void setSystemPropertiesFile(String systemPropertiesFile) {
+        this.systemPropertiesFile = systemPropertiesFile;
     }
 
     public void setStartupFile(String startupFile) {
@@ -316,10 +316,10 @@ public class FrameworkLauncher {
      * arbitrary URL.
      * </p>
      */
-    protected static void loadSystemProperties(File baseDir) throws IOException {
-        File file = new File(new File(baseDir, "etc"), SYSTEM_PROPERTIES_FILE_NAME);
+    protected void loadSystemProperties(File baseDir) throws IOException {
+        File file = new File(new File(baseDir, "etc"), systemPropertiesFile);
         Properties props = Utils.loadPropertiesFile(file, false);
-
+        
         // Perform variable substitution on specified properties.
         for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
             String name = (String) e.nextElement();
@@ -332,15 +332,6 @@ public class FrameworkLauncher {
         File config = new File(new File(baseDir, "etc"), configFile);
         Properties configProps = Utils.loadPropertiesFile(config, false);
 
-        // Perform config props override
-        if (additionalConfigFile != null){
-            File additionalConfig = new File(new File(baseDir, "etc"), additionalConfigFile);
-            Properties additionalProps = Utils.loadPropertiesFile(additionalConfig, false);
-            for (Entry<Object, Object> entry : additionalProps.entrySet()) {
-                configProps.setProperty((String)entry.getKey(), (String)entry.getValue());
-            }
-        }
-
         // Perform variable substitution for system properties.
         for (Enumeration<?> e = configProps.propertyNames(); e.hasMoreElements();) {
             String name = (String) e.nextElement();

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Utils.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Utils.java?rev=1464814&r1=1464813&r2=1464814&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Utils.java (original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Utils.java Fri Apr  5 02:43:26 2013
@@ -29,11 +29,13 @@ import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.ConcurrentModificationException;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.StringTokenizer;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.zip.ZipFile;
@@ -152,7 +154,10 @@ public class Utils {
         }
         return rc;
     }
-
+    
+    private static final String INCLUDES_PROPERTY = "${includes}";
+    private static final String OPTIONALS_PROPERTY = "${optionals}";
+    
     public static Properties loadPropertiesFile(File file, boolean critical) throws IOException {
         // Read the properties file.
         Properties configProps = new Properties();
@@ -172,8 +177,84 @@ public class Utils {
                 try { is.close(); } catch (Exception e) {}
             }
         }
+        
+        loadIncludes(INCLUDES_PROPERTY, true, file, configProps);
+        loadIncludes(OPTIONALS_PROPERTY, false, file, configProps);
+        
         return configProps;
     }
+    
+    private static void loadIncludes(String propertyName, boolean mandatory, File file, Properties configProps) throws IOException {
+        String includes = configProps.getProperty(propertyName);
+        if (includes != null) {
+            StringTokenizer st = new StringTokenizer(includes, "\" ", true);
+            if (st.countTokens() > 0) {
+                String location;
+                do {
+                    location = nextLocation(st);
+                    if (location != null) {
+                        File newLocation = new File(location);
+                        if (!newLocation.isAbsolute()) {
+                            newLocation = new File(file.getParent(), location);
+                        }
+                        Properties props = loadPropertiesFile(newLocation, true);
+                        // included properties do NOT override current values
+                        for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
+                            String name = (String) e.nextElement();
+                            if (!configProps.containsKey(name)) {
+                                configProps.put(name, props.getProperty(name));
+                            }
+                        }
+                    }
+                } while (location != null);
+            }
+        }
+        configProps.remove(propertyName);
+    }
+    
+    private static String nextLocation(StringTokenizer st) {
+        String retVal = null;
+
+        if (st.countTokens() > 0) {
+            String tokenList = "\" ";
+            StringBuffer tokBuf = new StringBuffer(10);
+            String tok;
+            boolean inQuote = false;
+            boolean tokStarted = false;
+            boolean exit = false;
+            while ((st.hasMoreTokens()) && (!exit)) {
+                tok = st.nextToken(tokenList);
+                if (tok.equals("\"")) {
+                    inQuote = !inQuote;
+                    if (inQuote) {
+                        tokenList = "\"";
+                    } else {
+                        tokenList = "\" ";
+                    }
+
+                } else if (tok.equals(" ")) {
+                    if (tokStarted) {
+                        retVal = tokBuf.toString();
+                        tokStarted = false;
+                        tokBuf = new StringBuffer(10);
+                        exit = true;
+                    }
+                } else {
+                    tokStarted = true;
+                    tokBuf.append(tok.trim());
+                }
+            }
+
+            // Handle case where end of token stream and
+            // still got data
+            if ((!exit) && (tokStarted)) {
+                retVal = tokBuf.toString();
+            }
+        }
+
+        return retVal;
+    }
+  
 
     private static final String DELIM_START = "${";
     private static final String DELIM_STOP = "}";