This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Remote / Local Conncetion Inheritance  RSS feed

Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish to have the GUI/client, get a Connection object, based on its preference whether Remote or Local.
GUI/Client looks like this:

The rest of the GUI/client would not bother how this connection gets established. The idea is very similar to java.sql.Connection.
I could not get both local and remote connections to a single umberalla, because Remote interface and its implementation themselves extend UnicastRemoteObject and Remote respectively. And were not willing to get into a common hierarchy with the LocalConnection.
Can the above objective, similar to java.sql.Connection, be attained? If it cannot be attained, the client code would be cumbersome with 'if' statements doing the check of which connection was selected at the starting. Also, it would hinder scalability, for different ways of connection in future.
It would be nice if a common Connection object holds the DataServer instance and does all the database operations( add,delete,modify, find e.t.c.) and all its subclasses offering different ways of connctions to different clients(RMI client,Local client, Socket client ,corba client e.t.c )
Please tell me if my thinking is right and its feasibility.
Thanks in advance,
Mark Spritzler
Posts: 17309
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you just did it.
That is the code you will need to get back a Connection object. We called it DataAccess interface. And DataAccessRemote and DataAccessLocal both implement the interface, so that the client only deals with the DataAccess interface contract. And therefore the client does not care the actual class that is instantiated because it knows it will find the same methods of the interface in both.
DataAccess still extends Remote, which is fine.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!