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?

[830 byte] By [Pawan_Shrivastavaa] at [2007-10-3 4:02:15]
# 1
hi pawan,Alternatively u can try in this site also http://archives.java.sun.comit is very usefulThanksMurali
muralijavaa at 2007-7-14 22:01:38 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...