Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Singleton pattern

 
G.T. Reddy
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
The RMI server requires the instantiation of a single remote object to be passed to the Naming.rebind() method. Can this be considered a singleton pattern design?
please clarify me.
rgds,
Reddy
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really, though it's similar. But a singleton is all about making sure there's just one instance of a class on a single JVM. In a distributed environment it's more complex - we've got one instance of the implementing class, running on the server, and one instance of the stub class running on the client. Moreover neither of these necessarily unique. It's possible to create multiple implementation instances on the server easily enough. And if (for some reason) we wanted to bind a second instance to the registry using a different service name, then it would be possible for clients to retrieve a second separate stub class instance, using the second service name. (It's unlikely anyone would want or need to do this, but it's possible.) As such I would say this is not, strictly speaking, a singleton. But it is an example of controlled instance creation using a form of factory method, at least as far as the client is concerned.
 
G.T. Reddy
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks JIM.
rgds,
Reddy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic