Hello everybody,
In EJB 2.0, we can get some environment propertise from ejb-jar. This is very useful for constant import. But I was noted that the above machnism is for a bean, not for entire application/system. Our application needs some important parameters to be initiated at starting time, it is better I can store those parameters out of code. The bean's environment property solution is not good for me, cause it work for specific bean, do you guys know how should I do this?
Thanks a lot!
Wallace
-
Any better solution for system properties? (7 messages)
- Posted by: Wallace Zou
- Posted on: June 09 2003 15:41 EDT
Threaded Messages (7)
- You need a Singleton Property file manager by SAF . on June 09 2003 16:31 EDT
- You need a Singleton Property file manager by Wallace Zou on June 09 2003 18:56 EDT
-
once more by Wallace Zou on June 10 2003 01:12 EDT
-
once more by Bhagvan K on June 10 2003 08:12 EDT
- once more by Wallace Zou on June 10 2003 10:16 EDT
- OS specific what? by SAF . on June 10 2003 11:05 EDT
- Put the property file in your classpath by John Pletka on June 10 2003 11:58 EDT
-
once more by Bhagvan K on June 10 2003 08:12 EDT
-
once more by Wallace Zou on June 10 2003 01:12 EDT
- You need a Singleton Property file manager by Wallace Zou on June 09 2003 18:56 EDT
-
You need a Singleton Property file manager[ Go to top ]
- Posted by: SAF .
- Posted on: June 09 2003 16:31 EDT
- in response to Wallace Zou
If you need a global manager for loading and initializing properties that will be available to all components in your ejb and web containers, then I would suggest using a simple property file. Create a singleton manager that loads the property file and stores it inside a static hashmap and makes it available to calling components via PropertyFileManager.getResource("myProperties.properties"), or something like that.
Since the property file manager is a singleton, all requests are centralized to a single class, preventing the property file from being loaded twice.
That's one suggestion.
Raffi -
You need a Singleton Property file manager[ Go to top ]
- Posted by: Wallace Zou
- Posted on: June 09 2003 18:56 EDT
- in response to SAF .
Oh, yeah, singleton is a good choice.
:->
.....why am I forgot it?...
Thanks,
Wallace -
once more[ Go to top ]
- Posted by: Wallace Zou
- Posted on: June 10 2003 01:12 EDT
- in response to Wallace Zou
I could use a singleton to load parameter at once system start, but I have to transfer a OS dependent parameter to this singleton (example, the config XML file name). If I migrate system from WIN to UNIX, I still have to modify code and compile to run. How to prevent modify code?
Thanks for your advice.
Wallace -
once more[ Go to top ]
- Posted by: Bhagvan K
- Posted on: June 10 2003 08:12 EDT
- in response to Wallace Zou
one way is to avoid the problem that you are explaining is to :
use a startup class to load the singleton ... pass the OS specific parameter through weblogic startxxxServer.xml as a parameter to the startup class...
I think startup class feature is available in weblogic and websphere (latest) -
once more[ Go to top ]
- Posted by: Wallace Zou
- Posted on: June 10 2003 10:16 EDT
- in response to Bhagvan K
That will be great if J2EE has such definition in specification.
Regards,
Wallace -
OS specific what?[ Go to top ]
- Posted by: SAF .
- Posted on: June 10 2003 11:05 EDT
- in response to Wallace Zou
What is specific to the OS? I use a singleton property file manager on both Windows and Solaris and I don't have to pass anything when switching environments. I would not use a startup class either to initialize the singleton, I would simply use a static initializer in the singleton class to perform any initialization. No need to complicate things when the class itself already provides a run-once start-up mechanism, hence the static initializer.
Raffi -
Put the property file in your classpath[ Go to top ]
- Posted by: John Pletka
- Posted on: June 10 2003 11:58 EDT
- in response to Wallace Zou
There is no need to have anything OS specific. Just put the property file in your classpath then use the ClassLoader.getResource() to look it up.