The following scenario:
I'm extending an admin tool for a system of small services compiled as runnable jars. These services use xml configurations in their classpath for a multitude of tasks.
I now want to extract configuration files like db configuration from the compiled jar files and add them dynamically to the classpath. Up until now you needed to recompile the whole suite if you wanted to change the settings for the database, which is all kinds of bad imho.
What I have tried:
java -Xbootclasspath/p:/path/db.xml java -jar Foo.jar
- this results in a java vm error
java -Xbootclasspath/p:/path/db.jar java -jar Foo.jar
- this doesn't seem to do anything, I've tried to find the xml file via the script below in the classpath, but I haven't been able to. The xml lies directly inside the jar (created with jar cvMf db.jar db.xml
)
The script I used:
ZipFile zf;
ZipFile zf;
try{
zf = new ZipFile("Foo.jar");
} catch(final ZipException e){
throw new Error(e);
} catch(final IOException e){
throw new Error(e);
}
final Enumeration e = zf.entries();
while(e.hasMoreElements()){
final ZipEntry ze = (ZipEntry) e.nextElement();
final String fileName = ze.getName();
final boolean accept = Pattern.compile(".*(xml)").matcher(fileName).matches();
if(accept){
log.debug(fileName);
}
}
I hope someone can help with this problem, I'm pretty clueless on what else I could try.