开发者

How can we ensure that there is a single instance of a class in a clustered environment

开发者 https://www.devze.com 2023-01-07 17:09 出处:网络
How can we ensure that there is a 开发者_JAVA百科single instance of a class in a clustered environment? The class is Serializable.You need to correctly implement readResolve method of your singleton c

How can we ensure that there is a 开发者_JAVA百科single instance of a class in a clustered environment? The class is Serializable.


You need to correctly implement readResolve method of your singleton class.

Preferably, I think terracotta would help.

This link has more help http://forums.terracotta.org/forums/posts/list/771.page


Use a container that provides application scoped singletons, e.g. Seam, Spring etc.


  1. Use container which provides you with this facility.
  2. If use of container is not a feasible option, then create a RemoteFactory which will provide you with instance of the class in context.
0

精彩评论

暂无评论...
验证码 换一张
取 消