From: Marc P. <ma...@an...> - 2005-07-17 10:59:04
|
Lars George wrote: > Hi Keats, > >> I actually had a PropertyDirective years ago that did just what you >> are saying, but I've lost track of the code. (It never got committed >> to the core because nobody expressed interest.) There is some code in >> the core that parses expressions from the webmacro.properties file. I >> can point you to that if it is helpful. > > > Any pointer is helpful :) Personally, I would just write my own helper class: public class MyPropertiesHelper { private Properties props; public void load( Object filepath) { FileInputStream fis = ...; props.clear(); props.load( fis); } public Object get(Object key) { return props.getProperty(key.toString()); } public Object put(Object key, Object value) { return props.setProperty(key.toString(), value.toString()); } } An -new- instance of this can then be put into your context for every request, or you can wrap it in a contexttoolloader/factory so that you automatically get a new instance for every request. ...or you add a simple factory that you put into the context instead: public class MyPropertiesFactory { public MyPropertiesHelper newInstance(Object filename) { MyPropertiesHelper h = new MyPropertiesHelper(); h.load(filename); return h; } } Cheers -- Marc Palmer wj...@wa... Wangjammers - Java, J2ME and Web Consultants ~ http://www.wangjammers.org/ |