Hi, I guess this must be a common problem we all will face sooner or later. In my project, we have a bunch of system wide parameters that are most time read only. The parameters are orginized into tables, say, we group
error codes into a table called "errorCodes" which has two columns:"errorMsg" and "errorCode".
Now my question is, should I use entity bean to represent this table? There are two problems here:
1. since most of the time, the entity bean will return a list of all the errorMsg & errorCodes. it need to have a findAll() method to return a Collection, then the clients will iterate through to get the info, I really don't think it is efficient.
2. we have about 8,9 such tables, I doubt it even make sense to model 8,9 entity beans for each, imagine the client will be mad every time he has to call jndi for a simple parameter.
I am wondering if I can just use stateless session bean, but then since we cannot use static field, how do i cache the data?
I also think about using stateless session bean to read all the entity beans modelled for each table. But that seems complex.
Can somebody share some light with me??
Thank you.
-
caching the system wide parameters in EJB (3 messages)
- Posted by: Di Zhao
- Posted on: August 31 2000 10:42 EDT
Threaded Messages (3)
- caching the system wide parameters in EJB by Uday Kumar on August 31 2000 18:13 EDT
- caching the system wide parameters in EJB by Di Zhao on August 31 2000 18:32 EDT
- caching the system wide parameters in EJB by Uday Kumar on September 01 2000 05:45 EDT
- caching the system wide parameters in EJB by Di Zhao on August 31 2000 18:32 EDT
-
caching the system wide parameters in EJB[ Go to top ]
- Posted by: Uday Kumar
- Posted on: August 31 2000 18:13 EDT
- in response to Di Zhao
hello Zhao,
When modelling the System wide parameters that would need to be used across all classes in the application it would be good to use a Properties Java class. It doesnt have to be modelled as an Entity bean since this is not a business entity. It would be correct to model this as a Helper class which provides the required information to the client classes. It can be made as a Singleton class and if you plan to use different sources ( like Databases and Files ) etc to instantiate it, then you can provide a Factory class to instantiate this Helper class. This way you can make it a static class and provide utility static methods for serving out the parameter information to the clients.
Thanks
-U -
caching the system wide parameters in EJB[ Go to top ]
- Posted by: Di Zhao
- Posted on: August 31 2000 18:32 EDT
- in response to Uday Kumar
Hi, Mr. Kumar, thank you very much for your comments. I also read about the usage of Singleton, but what is a Helper class? And how to use singleton in the context of EJB? Can you give some sample or direct me to some good readings?? Thanks again. -
caching the system wide parameters in EJB[ Go to top ]
- Posted by: Uday Kumar
- Posted on: September 01 2000 17:45 EDT
- in response to Di Zhao
hello Zhao,
By helper class I am referring to a normal Java class which is accessed from within another Bean. This has all the semantics of a traditional Java class. It can be declared as a static class and provided with a private constructor and an initialize method. I would suggest any good book on Patterns for information regarding Singleton.
Thanks
-u