• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confused about remote object

 
Andre Mermegas
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
heres how i understand things to work, im using rmi.
my RemoteData class is a wrapper around Data i believe
its called delegation pattern, for all public methods.

this establishes (1) RemoteData server instance.

here is how a client would get a reference to it.
I'm having a little problem understanding if every client
just gets a reference from rmi,how to make it so each client gets a new remote object,instead of just the reference?

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, by extending Remote you have a version for each user.
The object you bind into RMI extends UNICastObject, which only creates one instance in your RMI that every user that looks it up gets. (I am not positive that it is UNICastObject that makes only one version, but I mean that object in the registry is only one object) Meaning there is only one version. So maybe the object you bind in RMI, can have a method to return a different object that extends Remote, and there you pass back a separate object for each user.
Do a search on Connection Factory on this forum
Mark
 
Andre Mermegas
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, found what i needed.
I UNDERSTAND IT NOW!! =)
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Spritzler:

Do a search on Connection Factory on this forum
Mark

Be referring to this as a Connection Factory, are we saying that this is an example of the Factory pattern? I thought the factory pattern involved deferring to a factory class the decison of which concrete implementation of a common interface to create. In this case, there is no decision, we are just creating one kind of concrete class. Perhaps later on we might create another concrete implementation of Connection's remote interface, and then it would involve a decision. I named mine ConnectionServer to try and reflect what it is actually doing.
Any thoughts?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Factory instance is responsible to contain the logic to create and return an instance based on a name or invocation of its methods to return objects.
Currently there is only one type of Connection instance which corresponds to db.db. In the future, you can add another method to the ConnectionFactory to return say "Passenger" Connection instance corresponding to passenger.db.
I would stick to the suffix "Factory".
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, You think of a factory as an object that creates an instance of an object that might have many different implementations, and how the client calls the "Make" method, determins the type of objec that it creates. But a factory is also an object that creates instances of the same object to many clients. as is in this case.
Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic