incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giuseppe Miscione <>
Subject Felix initialization with configuration file
Date Tue, 15 Jan 2013 13:31:46 GMT
Hi all,
I needed to start the Felix environment with a customized profile (I 
needed the main bundle not to export javax.transaction.* packages), but 
looking at the method getConfigProps in 
org.apache.clerezza.platform.launcher.ClerezzaApp class there is no way 
to set the configuration properties needed by Felix to choose which 
packages should be exported.
To solve this problem I changed the first line of this method in this way:

Properties configProps = new Properties();

// search for configuration file
String configFileURL = 
InputStream is = null;
try {
     URL url = new URL(configFileURL);
     if("file".equals(url.getProtocol())) {
         File configFile = new File(configFileURL.substring(7));
         is = new FileInputStream(configFile);
         System.out.println("Loading configuration from file " + 
     else {
         is = url.openConnection().getInputStream();
         System.out.println("Loading configuration from URL " + url);
     Properties config = new Properties();
     for (Enumeration<?> e = config.propertyNames(); 
e.hasMoreElements(); ) {
         String name = (String) e.nextElement();
Util.substVars(config.getProperty(name), name, null, config));
} catch(FileNotFoundException e) {
     // Configuration file cannot be found, default configuration will 
be used
} catch(Exception e) {
     System.err.println("Configuration file \"" + configFileURL + "\" 
cannot be loaded, default configuration will be used");
} finally {
     try {
     } catch(Throwable e){}

This code simply tries to read a configuration file from the URL 
specified in the system property (with a default 
value of file://./conf/ and puts its lines into the 
configProps map.

Do you know if there is a better solutions for this problem?

View raw message