Caching Objects in EJB in a static method
Hi,
I got a code in Stateless EJB, which create some objects and store their references in a staticHashTable, with some name.
public static final HashTable cache = new HashTable()
Now next time, it checks, if this name is present then it uses the object stored in the HashTable otherwise it cerates a new instance.
There is no difference in the application, even though i create this object every time, the only thing is the creation involves something which is time and memory consuming.
Now i think this is safe in multi threaded EJB server even in clustered environment. Please note that the object cached has no state, so i don't have any problem creating it twice for one user session.
What are your thoughts about it? Is there some other Caching Mecahnism for EJB?

