This content has been marked as final.
Show 3 replies
-
1. Re: Another XML file for configuration.
abraao Dec 15, 2008 5:46 PM (in response to bautto)I use something like this. I have a XML Property file in my applications. I put this file in the JBOSS's conf directory. I load him using this code:
public class ConfigurationLoader { public static Configuration loadConfiguration(final String baseName) throws IOException { URL url = null; url = getResourceAsURL(baseName); final Properties properties = new Properties(); if (baseName.matches("((.)*)\\.xml")) { properties.loadFromXML(url.openStream()); } else if (baseName.matches("((.)*)\\.properties")) { properties.load(url.openStream()); } else { throw new UnsupportedOperationException("Tipo de arquivo não reconhecido!"); } return new Configuration(properties); } public static URL getResourceAsURL(final String resource) throws FileNotFoundException { final String stripped = resource.startsWith("/") ? resource.substring(1) : resource; URL url = null; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader != null) { url = classLoader.getResource(stripped); } if (url == null) { url = ConfigurationLoader.class.getResource(stripped); } if (url == null) { url = ConfigurationLoader.class.getClassLoader().getResource(stripped); } if (url == null) { throw new FileNotFoundException(resource + " not found."); } return url; } }
-
2. Re: Another XML file for configuration.
igorcicompuit Dec 15, 2008 6:41 PM (in response to bautto)hy Abraao,
How am I going to pass this collected settings to Seam for will complement the original component.xml file?
thanks
Igor Guimarães
-
3. Re: Another XML file for configuration.
abraao Dec 16, 2008 6:17 PM (in response to bautto)What do you really want to do?