0

I have a cache with objects which were read from the database (regular beans).
When I return them I want to make them read only so users of the cache can't damage the cache objects.
I'm looking for an efficient way since objects can be requested thousands of times per second.
One solution is to wrap each object with a proxy object which disables all the set accessors (can be done with Java Assist) but I'm looking for a more lightweight solution. Another solution is to clone the object before returning it but it is even wrost than the proxy solution performance wise.

Tim
  • 153
  • 1
  • 7
Avner Levy
  • 6,601
  • 9
  • 53
  • 92

0 Answers0