geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r671359 - /geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Date Tue, 24 Jun 2008 21:44:25 GMT
Author: djencks
Date: Tue Jun 24 14:44:25 2008
New Revision: 671359

URL: http://svn.apache.org/viewvc?rev=671359&view=rev
Log:
GERONIMO-3971, GERONIMO-4139.  Write out empty config-subst.properties file if its missing;
improve (?) usage instructions

Modified:
    geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=671359&r1=671358&r2=671359&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Tue Jun 24 14:44:25 2008
@@ -98,6 +98,14 @@
     private File configSubstitutionsFile;
     private Properties localConfigSubstitutions;
     private String resolvedPropertiesFile;
+    private static final byte[] INSTRUCTION = ("#Put variables and their substitution values
in this file: \n"
+            + "#they will be used when processing the corresponding config.xml. \n"
+            + "#Values in this file will be overridden by environment variables and system
properties \n"
+            + "#by prefixing the property name with 'org.apache.geronimo.config.substitution.'"
+            + "#For example an entry such as hostName=localhost \n"
+            + "#can be overridden by an environment variable or system property org.apache.geronimo.config.substitution.hostName=foo
\n"
+            + "#To run multiple instances of geronimo choose a portOffset such that none
of the ports conflict \n"
+            + "#Try PortOffset=10 \n").getBytes();
 
     public LocalAttributeManager(String configFile, String configSubstitutionsFileName, String
configSubstitutionsPrefix, boolean readOnly, ServerInfo serverInfo) {
         this.configFile = System.getProperty(CONFIG_FILE_PROPERTY, configFile);
@@ -605,8 +613,8 @@
         Properties properties = new Properties();
         if (configSubstitutionsFile != null) {
             if (!configSubstitutionsFile.exists()) {
-                log.warn("Could not find the config substitution file: "
-                        + configSubstitutionsFile.getAbsolutePath());
+                //write out empty file with instructions as a hint to users.
+                storeConfigSubstitutions(configSubstitutionsFile, properties);
             } else {
                 try {
                     FileInputStream in = new FileInputStream(configSubstitutionsFile);
@@ -617,7 +625,7 @@
                     }
                 } catch (Exception e) {
                     log.error("Caught exception " + e
-                            + " trying to open properties file " + configSubstitutionsFile.getAbsolutePath());
+                            + " trying to read properties file " + configSubstitutionsFile.getAbsolutePath());
                 }
             }
         }
@@ -629,22 +637,14 @@
             try {
                 FileOutputStream out = new FileOutputStream(configSubstitutionsFile);
                 try {
-                    String instruction = "#Put variables and their substitution values in
this file: \n"
-                            + "#they will be used when processing config.xml. \n"
-                            + "#Values in this file will be overridden by environment variables
and system properties: \n"
-                            + "#    hostName=localhost \n"
-                            + "#    httpPort=8080 \n"
-                            + "#    httpsPort=8443 \n"
-                            + "#To run multiple instances of geronimo choose a portOffset
such that none of the ports conflict \n"
-                            + "#Try PortOffset=10 \n";
-                    out.write(instruction.getBytes());                    
+                    out.write(INSTRUCTION);                    
                     properties.store(out, null);
                 } finally {
                     out.close();
                 }
             } catch (Exception e) {
                 log.error("Caught exception " + e
-                        + " trying to open properties file " + configSubstitutionsFile.getAbsolutePath());
+                        + " trying to write properties file " + configSubstitutionsFile.getAbsolutePath());
             }
         }
     }
@@ -657,7 +657,7 @@
                 if (((String) entry.getKey()).startsWith(prefix)) {
                     String key = ((String) entry.getKey()).substring(start);
                     if (!vars.containsKey(key)) {
-                        vars.put(key, (String) entry.getValue());
+                        vars.put(key, entry.getValue());
                     }
                 }
             }



Mime
View raw message