Re: Design Advice (And Orion JNDI syntax) Needed
Have you considered placing the string in the database? tim. 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?
RE: Design Advice (And Orion JNDI syntax) Needed
Do these strings need to change dynamically without app redeployment? If it's just error messages and the like, why not use java.util.ResourceBundle? String msg = ResourceBundle.getBundle("mymessages").getString(MSG_KEY); You can store the resources in any format you like if you implement your own ResourceBundle subclass, or you can use a .properties file. If you pass in the cool Orion classloader I believe it will dynamically reload the data, too. Check the javadocs. Jeff -Original Message- From: Neal Kaiser [mailto:[EMAIL PROTECTED]] Sent: Monday, March 12, 2001 4:41 PM To: Orion-Interest Subject: Design Advice (And Orion JNDI syntax) Needed 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?
RE: Design Advice (And Orion JNDI syntax) Needed
Yeah but where should he cache it. this is mostly read only data by the sound of it. Where should he cache it so that he has access to it via ejbs and servlets? A stateless session bean can cache non conversational state right? Can't he use a singleton from within a stateless session bean for this? He can then access this information via his servlet and an ejb. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Tim Endres Sent: Monday, March 12, 2001 5:27 PM To: Orion-Interest Subject: Re: Design Advice (And Orion JNDI syntax) Needed Have you considered placing the string in the database? tim. 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?