• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client mode

 
Lucy Sommerman
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so now my server loads the DBdata into memory. Not sure whether to bind the DBAccess interface or the DB instance on the server side though. (using RMI). Clues?

Then, on the client side, unsure of how to let the GUI 'see' (i.e. perform operations upon) the server side DB.

//client side
DBAccess d = (DBAccess)Naming.lookup("Data");
My GUI currently operates on a Data instance d. So, unsure how, when in client mode to get it to work...I can't cast to a Data instance on the client side - (Data)d gives me java.lang.ClassCastException: Data_Stub. So I guess it has to work on the interface?

All clues appreciated...
 
Thomas Paul Bigbee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a multi-threaded socket server and a multi-threaded client, so I don't know if the below will do more harm than help, however, you did say any clues would be appreciated. I'm going to be rather vague, because, its always best to figure it out yourself.

I have public data objects corresponging to each, method in the interface implementation class(update, find, read, search...) I also have a class that wraps each of the interface implementation methods, said classes consist of an array of strings or and array of an array of strings, an exception, and getters and setters.

Example: serverMonitor.setServerMessage( new DataWrapper.DeteteWrapper(new DeleteObject(2))); (where 2 is the record number to delete)

When my Server GUI starts up it gets the port and db file and creates a connection to the the database.

The Client GUI starts up, gets a connection (new socket thread) from the server, spawns a new listener thread in the GUI.

When an action is performed on the Client, the client wakes up its thread with a Data Wrapper Object, the thread then sends the object to the server.

The server wakes up, figures out what kind of object this is, and takes the appropriate action upon the object it was sent.

The server sends the object (message) back to the Client, the client wakes up and takes the appropriate action.

Note: I use the same wrapper objects on my local data access, that way I can take care of exception handling the same way.

Anyway thats the two cents version, Tom
[ September 03, 2005: Message edited by: Thomas Paul Bigbee ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic