Singleton on multiple JVMs using JNDI [closed]

那年仲夏 提交于 2019-12-14 03:25:24

问题


It is said that Singleton is always on per JVM basis, but somebody asked me to create a singleton instance throughout multiple JVMs. I have found a solution to create an object on one JVM, register it with the JNDI, and lookup that object on different JVMs.

Please share your insight on this.


回答1:


My insight is that it won't work.

Even if you lookup the singleton using JNDI and then use it, the singleton will effectively be created on the JVM you are using as well.

Only way is to just invoke methods on that singleton bean remotely. May be via something like RMI.



来源:https://stackoverflow.com/questions/16525798/singleton-on-multiple-jvms-using-jndi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!