开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜