Any better solution for system properties?


EJB design: Any better solution for system properties?

  1. Any better solution for system properties? (7 messages)

    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!

    Threaded Messages (7)

  2. 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(""), 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.

  3. Oh, yeah, singleton is a good choice.


    .....why am I forgot it?...

  4. once more[ Go to top ]

    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.

  5. once more[ Go to top ]

    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)
  6. once more[ Go to top ]

    That will be great if J2EE has such definition in specification.

  7. OS specific what?[ Go to top ]

    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.

  8. 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.