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();
configProps.putAll(System.getProperties());
// search for configuration file
String configFileURL =
configProps.getProperty("felix.config.properties",
"file://./conf/config.properties");
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 " +
configFile.getCanonicalPath());
}
else {
is = url.openConnection().getInputStream();
System.out.println("Loading configuration from URL " + url);
}
Properties config = new Properties();
config.load(is);
for (Enumeration<?> e = config.propertyNames();
e.hasMoreElements(); ) {
String name = (String) e.nextElement();
configProps.setProperty(name,
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");
e.printStackTrace(System.err);
} finally {
try {
is.close();
} catch(Throwable e){}
}
This code simply tries to read a configuration file from the URL
specified in the system property felix.config.properties (with a default
value of file://./conf/config.properties) and puts its lines into the
configProps map.
Do you know if there is a better solutions for this problem?