summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/main
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2013-05-05 12:26:26 +0000
committerRobert Gemmell <robbie@apache.org>2013-05-05 12:26:26 +0000
commit47ad28774043573bf3a5f74b559d382ef2bf2d77 (patch)
treeb742f77a5770307f2b18283e48d59a1066c4f576 /qpid/java/broker/src/main
parent7c0210c854e0dfaaafae9a4cc75ae7ae70e7ecdc (diff)
downloadqpid-python-47ad28774043573bf3a5f74b559d382ef2bf2d77.tar.gz
QPID-4815: make BrokerOptions the primary source of the location for the logging configuration file
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1479309 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/main')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java34
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java36
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java2
3 files changed, 28 insertions, 44 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
index 25322c7a71..703162a609 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
@@ -109,7 +109,6 @@ public class Broker
private void startupImpl(final BrokerOptions options) throws Exception
{
- final String qpidHome = System.getProperty(BrokerProperties.PROPERTY_QPID_HOME);
String storeLocation = options.getConfigurationStoreLocation();
String storeType = options.getConfigurationStoreType();
@@ -119,8 +118,7 @@ public class Broker
//embedding the broker and want to configure it themselves.
if(!options.isSkipLoggingConfiguration())
{
- File logConfigFile = getConfigFile(options.getLogConfigFile(), BrokerOptions.DEFAULT_LOG_CONFIG_FILE, qpidHome, false);
- configureLogging(logConfigFile, options.getLogWatchFrequency());
+ configureLogging(new File(options.getLogConfigFileLocation()), options.getLogWatchFrequency());
}
BrokerConfigurationStoreCreator storeCreator = new BrokerConfigurationStoreCreator();
@@ -152,36 +150,6 @@ public class Broker
}
-
- private File getConfigFile(final String fileName,
- final String defaultFileName,
- final String qpidHome, boolean throwOnFileNotFound) throws InitException
- {
- File configFile = null;
- if (fileName != null)
- {
- configFile = new File(fileName);
- }
- else
- {
- configFile = new File(qpidHome, defaultFileName);
- }
-
- if (!configFile.exists() && throwOnFileNotFound)
- {
- String error = "File " + configFile + " could not be found. Check the file exists and is readable.";
-
- if (qpidHome == null)
- {
- error = error + "\nNote: " + BrokerProperties.PROPERTY_QPID_HOME + " is not set.";
- }
-
- throw new InitException(error, null);
- }
-
- return configFile;
- }
-
public static void parsePortList(Set<Integer> output, List<?> ports) throws InitException
{
if(ports != null)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
index ac6ee55c86..239726ba63 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
@@ -87,11 +87,6 @@ public class BrokerOptions
private boolean _overwriteConfigurationStore;
private Map<String, String> _configProperties = new HashMap<String,String>();
- public String getLogConfigFile()
- {
- return _logConfigFile;
- }
-
public String getManagementModePassword()
{
if(_managementModePassword == null)
@@ -107,11 +102,6 @@ public class BrokerOptions
_managementModePassword = managementModePassword;
}
- public void setLogConfigFile(final String logConfigFile)
- {
- _logConfigFile = logConfigFile;
- }
-
public int getLogWatchFrequency()
{
return _logWatchFrequency;
@@ -332,6 +322,32 @@ public class BrokerOptions
return Collections.unmodifiableMap(properties);
}
+ /**
+ * Get the broker logging configuration file location.
+ *
+ * If not previously explicitly set, defaults to {@value #DEFAULT_LOG_CONFIG_FILE} within the broker
+ * home directory if configured (gathered via config property {@link #QPID_HOME_DIR}) or the current
+ * JVM working directory if not.
+ *
+ * @return the previously set logging configuration file location, or the default location if none was set.
+ */
+ public String getLogConfigFileLocation()
+ {
+ if(_logConfigFile == null)
+ {
+ String homeDir = getHomeDir();
+
+ return new File(homeDir, DEFAULT_LOG_CONFIG_FILE).getAbsolutePath();
+ }
+
+ return _logConfigFile;
+ }
+
+ public void setLogConfigFileLocation(final String logConfigFile)
+ {
+ _logConfigFile = logConfigFile;
+ }
+
private String getWorkDir()
{
if(!_configProperties.containsKey(QPID_WORK_DIR))
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
index 03514939ec..66ef296a4b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
@@ -258,7 +258,7 @@ public class Main
String logConfig = _commandLine.getOptionValue(OPTION_LOG_CONFIG_FILE.getOpt());
if(logConfig != null)
{
- options.setLogConfigFile(logConfig);
+ options.setLogConfigFileLocation(logConfig);
}
boolean overwriteConfigurationStore = _commandLine.hasOption(OPTION_OVERWRITE_CONFIGURATION_STORE.getOpt());