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 2008/06/24 23:36:55 UTC
svn commit: r671354 -
/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Author: djencks
Date: Tue Jun 24 14:36:54 2008
New Revision: 671354
URL: http://svn.apache.org/viewvc?rev=671354&view=rev
Log:
GERONIMO-3971, GERONIMO-4139. Write out empty config-subst.properties file if its missing; improve (?) usage instructions
Modified:
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
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=671354&r1=671353&r2=671354&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 Tue Jun 24 14:36:54 2008
@@ -101,6 +101,14 @@
private Properties localConfigSubstitutions;
private String resolvedPropertiesFile;
private final GBeanInfoFactory infoFactory;
+ 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);
@@ -617,8 +625,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);
@@ -629,7 +637,7 @@
}
} catch (Exception e) {
log.error("Caught exception " + e
- + " trying to open properties file " + configSubstitutionsFile.getAbsolutePath());
+ + " trying to read properties file " + configSubstitutionsFile.getAbsolutePath());
}
}
}
@@ -641,21 +649,13 @@
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 {} trying to open properties file {}", e, configSubstitutionsFile.getAbsolutePath());
+ log.error("Caught exception {} trying to write properties file {}", e, configSubstitutionsFile.getAbsolutePath());
}
}
}
@@ -668,7 +668,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());
}
}
}