changeset 954:7c0a72c7c2c9

Add a way to access "libs" dir in Configuration Reviewed-by: vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-January/005424.html
author Omair Majid <omajid@redhat.com>
date Wed, 06 Feb 2013 11:40:45 -0500
parents e20c9ca1571f
children 9a0cd2dcf73c
files common/core/src/main/java/com/redhat/thermostat/common/config/Configuration.java common/core/src/main/java/com/redhat/thermostat/common/ssl/SSLKeystoreConfiguration.java common/core/src/main/java/com/redhat/thermostat/common/utils/LoggingUtils.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java main/src/main/java/com/redhat/thermostat/main/impl/FrameworkProvider.java
diffstat 5 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/config/Configuration.java	Tue Feb 05 22:51:00 2013 -0500
+++ b/common/core/src/main/java/com/redhat/thermostat/common/config/Configuration.java	Wed Feb 06 11:40:45 2013 -0500
@@ -78,10 +78,14 @@
         return file;
     }
 
-    public String getLibRoot() {
+    public String getLibRoot() throws InvalidConfigurationException {
         return home + File.separator + "libs";
     }
 
+    public String getConfigurationDir() throws InvalidConfigurationException {
+        return home + File.separator + "etc";
+    }
+
     public File getStorageBaseDirectory() throws InvalidConfigurationException {
         String loc = getThermostatHome() + File.separatorChar + "storage";
         File file = new File(loc);
--- a/common/core/src/main/java/com/redhat/thermostat/common/ssl/SSLKeystoreConfiguration.java	Tue Feb 05 22:51:00 2013 -0500
+++ b/common/core/src/main/java/com/redhat/thermostat/common/ssl/SSLKeystoreConfiguration.java	Wed Feb 06 11:40:45 2013 -0500
@@ -158,9 +158,7 @@
     private static void loadClientProperties()
             throws InvalidConfigurationException {
         if (clientProps == null) {
-            File thermostatEtcDir = new File(new Configuration().getThermostatHome(),
-                    "etc");
-            File clientPropertiesFile = new File(thermostatEtcDir,
+            File clientPropertiesFile = new File(new Configuration().getConfigurationDir(),
                     "ssl.properties");
             initClientProperties(clientPropertiesFile);
         }
--- a/common/core/src/main/java/com/redhat/thermostat/common/utils/LoggingUtils.java	Tue Feb 05 22:51:00 2013 -0500
+++ b/common/core/src/main/java/com/redhat/thermostat/common/utils/LoggingUtils.java	Wed Feb 06 11:40:45 2013 -0500
@@ -119,8 +119,8 @@
     }
 
     public static void loadGlobalLoggingConfig() throws InvalidConfigurationException {
-        File thermostatEtcDir = new File(new Configuration().getThermostatHome(), "etc");
-        File loggingPropertiesFile = new File(thermostatEtcDir, "logging.properties");
+        File thermostatConfigurationDir = new File(new Configuration().getConfigurationDir());
+        File loggingPropertiesFile = new File(thermostatConfigurationDir, "logging.properties");
         loadConfig(loggingPropertiesFile);
     }
     
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java	Tue Feb 05 22:51:00 2013 -0500
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java	Wed Feb 06 11:40:45 2013 -0500
@@ -76,8 +76,7 @@
             Keyring keyring = (Keyring)context.getService(reference);
             Configuration config = bundleService.getConfiguration();
 
-            String commandsDir = config.getThermostatHome() + File.separator + "etc" +
-                    File.separator + "commands";
+            String commandsDir = config.getConfigurationDir() + File.separator + "commands";
             CommandInfoSource builtInCommandSource =
                     new BuiltInCommandInfoSource(commandsDir, config.getLibRoot());
             CommandInfoSource pluginCommandSource = new PluginCommandInfoSource(
--- a/main/src/main/java/com/redhat/thermostat/main/impl/FrameworkProvider.java	Tue Feb 05 22:51:00 2013 -0500
+++ b/main/src/main/java/com/redhat/thermostat/main/impl/FrameworkProvider.java	Wed Feb 06 11:40:45 2013 -0500
@@ -69,14 +69,14 @@
     private static final String PROPS_FILE = "/com/redhat/thermostat/main/impl/bootstrapbundles.properties";
     private static final String BUNDLELIST = "bundles";
 
+    private Configuration configuration;
     private boolean printOSGiInfo;
-    private String thermostatHome;
     // The framework cache location; Must not be shared between apps!
     private Path osgiCacheStorage;
 
     public FrameworkProvider(Configuration config) {
+        this.configuration = config;
         printOSGiInfo = config.getPrintOSGiInfo();
-        this.thermostatHome = config.getThermostatHome();
     }
 
     // This is our ticket into OSGi land. Unfortunately, we to use a bit of reflection here.
@@ -95,8 +95,7 @@
     }
 
     private String getOSGiPublicPackages() throws FileNotFoundException, IOException {
-        File thermostatEtc = new File(thermostatHome, "etc");
-        File osgiBundleDefinitions = new File(thermostatEtc, "osgi-export.properties");
+        File osgiBundleDefinitions = new File(configuration.getConfigurationDir(), "osgi-export.properties");
 
         Properties bundles = new Properties();
         bundles.load(new FileInputStream(osgiBundleDefinitions));
@@ -162,7 +161,7 @@
     }
 
     private Framework makeFramework() throws FileNotFoundException, IOException {
-        File osgiCacheDir = new File(thermostatHome, "osgi-cache");
+        File osgiCacheDir = new File(configuration.getThermostatHome(), "osgi-cache");
 
         // Create temporary directory which will be used as cache for OSGi bundles. See
         // http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/Constants.html#FRAMEWORK_STORAGE
@@ -254,7 +253,7 @@
     }
 
     private String actualLocation(String resourceName) {
-        return "file:" + thermostatHome + "/libs/" + resourceName.trim();
+        return new File(configuration.getLibRoot(), resourceName).toURI().toString();
     }
 }