This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remote & Local mode connection

 
SungChan Park
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear, all-members !
My package structure is as follows;
suncertify : 1. db ; Data.java,
DataInfo.java,
FieldInfo.java,
DatabaseException.java,
db.db
2. server ; DataServer.java(Interface),
Server.java,
ServerImpl.java
3. client ; DataClient.java(Interface),
DataClientGUI.java,
LocalDataClient.java,
RemoteClient.java
TableModel.java
To get a remote & local instance at GUI,
I intend to use following code snippet.
========================================
Data data;
if (local)
data = new LocalDataClient();
else
data = (ServerImpl) Name.lookup(bla bla)
========================================
Can anyone suggest a graceful way to implement it ?
Thanks in advance.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like it is a good implementation. If I had a suggestion to what you might be asking, I'd say put that code into a DataAccessFactory class, that the client main class calls with the necessay parameters.
Mark
 
SungChan Park
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Mark Spritzler.
It seems that a graceful way to get a instance.
I'll try in that way.
Thanks you very much !
 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
In the following code snippet.
========================================
Data data;
if (local)
data = new LocalDataClient();
else
data = (ServerImpl) Name.lookup(bla bla)
========================================
Does the rmi server not have to be up and running for the else to work ?
In other words what happens in the following secnario :-
The above client is in local mode and gets the local data connection.
Some other remote client can also connect because the server is up and running.
So would we not have two diffent connections to the database with their own Data objects and hence locking mechanism etc..
Please correct me if i am completely off beat here.
I did search the forum for this ,but still i am not very clear on this topic.
Thanks in advance.
Regards
Suchak Jani
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are in local mode, no other "Client" from somewhere else can use the db.db file, local or remote.
In local mode there is no server.
Mark
 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
In other words i would have three scripts.
1. Start Server Remote
2. Start Client Remote(depends on 1)
3. Start Client Local (independant)
Does the above look Ok.
Regards
Suchak Jani
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess now i can change my design.
Thanks Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic