I wanna make a cache(read/write) in memory used by the EJBs. How can I do this ,can use the singleton or startup class. Once I have used the startup class to bind a hashmap to JNDI, but I found I just can read the value, can not modify the value in the EJB.
Once I have used the startup class to bind a hashmap to JNDI, but I found I just can read the value, can not modify the value in the EJB.
This sounds like you haven't tied your beans to your cache. Are they entity beans direcly tied to a DB? Caching dynamic data doesn't make sense. You will be introducing extra overhead by monitoring the data and propogating changes. Unless you have benchmarks showing that repetitively fetching data is a bottleneck, I'd be inclined to avoid caching.
In EJB, how can I access a global cache to read and write data, the cache can access by different ejb instances
Sorry that I have not got your question. You have already metioned some possible solutions. It sounds like that you have some troubles when you tested them. In theory they should work. Could you please post some detail information about the errors you got for the startup class binding a hashmap to the JNDI? Then I will have a better understanding on the context. By the way you may also use a stateless session bean to do it.
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth