Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Local? Remote? urgh  RSS feed

J Hartley
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all.
Many people have tried to help me(many thanks people), but im still unsure.
I have the client and server ( RMI )
I have a class called Data which may have to run on the client OR server, depending on user preference.
Initially i wanted to do the following "at the top of my code".......
--------------Fragment A
CommonDataInterface data
if ( user wants local mode ) {
data = LocalData(path of the file Db.db);
} else {
data = bind(the server,Remotedata);
data.lock etc etc
Yes its easy to do if you dont mind getting the local class involved with RMI, but i want the local class to be pure and clean of RMI.
I want to know if the folling method is ok....
Use the adaptor pattern to have a pure local class and a remote class which do not share an interface so i cant do it like in code fragment A.
So i do this instead...
------fragment B
At the start of the code i just call...
Multiplex("local", Object local_or_remote_ref)
Multiplex("remote", Object local_or_remote_ref)
public class Multiplex{
LocalClass local;
RemoteRMIInterace remote;
remoteBool boolean;
///the Constrcutor sets remoteBool and gives a ref to either local or remote
public void getRecordCount(int i){
if (remote == true) return remote.getRecordCount(i)
return local.getRecordCount(i)
all public methods.....

I hope you follow Its the last bit thats most important
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!