Hello;

Problem: My application has many text strings (i.e. email messages, email
recipient addresses, canned messages, etc) that both my servlets and EJBs
need to access. It needs to be done in a way that these are not hardcoded
and can be accessed easily from servlets, ejbs, and possibly even standalone
applications.

My Solution: Have a MessageResources object that is created by a startup
servlet that contains all these strings. You can then use a
MessageResources.getValue(String) to get the desired string you want.  This
is all done, the startup servlet runs, reads in the XML file, and creates
the MessageResources.

My Problem: I now need a way to pass that MessageResource object into scope
so it is accessible by Servlets and EJBs (I'll worry about standalone
applications later).

However, I somehow need a way for the Stateless session bean to get this
MessageResource object.  I can't  do StartupServlet.getMR() because the EJBs
might be remote.

Is it possible to use JNDI and store an object? IF that is the case, then I
could do something like this in my stateless session bean:

public String getMessage(String key) {
  if (messageResources == null) {
     // lookup messageResources with JNDI
  }
}

How would I do this in OrionServer? I believe it is app server specific,
right?

Does anyone have any input? Is it the right way to do it?  This must be a
common problem (global variables needed). How is everyone else doing this?



Reply via email to