This content has been marked as final.
Show 3 replies
-
1. Re: how can i store config file
jaikiran Sep 21, 2006 10:35 AM (in response to kiran25)Have a singleton utility class which will read the file once when it is instantiated. Invoke this singleton utility class from your EJB whenever you want the values for your properties
-
2. Re: how can i store config file
g_nagesh Sep 21, 2006 10:39 AM (in response to kiran25)Thanks, I am thinking of having a Config Mgr as singleton. But not sure where to put the logic of invoking this ConfigMgr (from ejbCreate or setSessionContext())
"jaikiran" wrote:
Have a singleton utility class which will read the file once when it is instantiated. Invoke this singleton utility class from your EJB whenever you want the values for your properties -
3. Re: how can i store config file
jaikiran Sep 21, 2006 10:53 AM (in response to kiran25)You need not write the code of instantiating the singleton in the ejbCreate or any other specific method. You can do something similar to:
MyEJB implements SessionBean { public void someMethod() { //do some logic ..... //at this point, i need the value for a property. So do the following ConfigMgr.getInstance().getPropertyValue("someProperty"); } } ConfigMgr { private static ConfigMgr configMgr; private Properties properties; private ConfigMgr() { //load the properties file properties = someCodeToLoadPropertiesFile(); } public synchronized static getInstance() { if (configMgr == null) { configMgr = new ConfigMgr(); } return configMgr; } }