문제

While I was going through the explanation of readResolve method , lot of references explain that this method will be useful to gurantee the singleton property when singleton class is deserialzied while object of that class is serialized and transferred over RMI .

Now my question is when RMI call takes place , Singleton class Object will be transported over different JVM (having different classloader) , so after deserialization we will have another instance of singleton class (in different JVM) . Am I right ?

So in the context of RMI calls , what is use of implementing readResolve method ?

도움이 되었습니까?

해결책

So that if you send it again, it resolves to the one that is already there. Which would probably be contrary to your intention. Don't confuse yourself by using singletons in RMI.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top