• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic design for review

 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After a lot of discussion (big thanks to Michael, Nate, Eugene, Mark and all others) and reading thru this forum I have come up with this preliminary design. Please add your comments :-
I have plannned to use one interface and one factory on the client side:-
suncertify.db
1. Interface DataInterface extends Remote
2. Data class plus more given from sun.
suncertify.server
1. DataAccessRemote extends UnicastRemoteObject implements DataInterface, Serializable
2. startServer
It creates object of type DataAccessRemote and then binds the object instance to the remote registry.
At this time I dont see a need of factory on the server side as I am still not clear how to implement lock/unlock.
suncertify.client
1. DataAccessLocal implements DataInterface
2. DataAccessFactory returns DataInterface type object. DataAccessFactory has getConnectionType() method which return DataInterface type object. If local returns dataInterface = new DataAccessLocal("db.db") else returns
(DataInterface)Naming.lookup(..)
3. FBNFlightManager constructor takes DataInterface object from #2 above. This class has methods to book the flight, search the database, etc.
4. The object of type FBNFlightManager is passed to my GUIManager which creates the f/e GUI. Its used a few classes to accomplish the f/e job like FBNTablemodel, etc
5. startClient starts the client, creates DatInterface object using the DataAccessFactory and passes this to FBNFlightManager and creates a object of type GUIManager.
I still have to work on the design for the lock/unlock.
Please let me know as many deficiencies as you all can see and let me know if I am in the right direction. Also, if I have placed the classes under the right packages.
Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. DataAccessRemote does not need to implement Serializable.
2. DataAccessRemote is not the object that you want bound to the Registry. You want to bind a ConnectionFactory to the registry, that when the client looks it up, it calls a method on it called getConnection, which returns a DataAccess class, which in this case will be an instance of the DataAccessRemote.
There are a couple of other things, but I will leave that to the other guys, I don't seem to ahve as much time to answer here as I have had in the past. Work is now watching what I do on the internet.
Mark
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark for a good analytical reply. Can I get some more thoughts to this.
Thanks.
 
Sumesh Aravindan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DataAccessRemote is not the object that you want bound to the Registry. You want to bind a ConnectionFactory to the registry, that when the client looks it up, it calls a method on it called getConnection, which returns a DataAccess class, which in this case will be an instance of the DataAccessRemote.

I am a bit confused
What do you mean by "binding to registry"?
Does the connectionFactory reside on the client side or server side?
[ August 14, 2002: Message edited by: Mark Spritzler ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sumesh,
When you call Naming.rebind or Naming.bind. You pass in a String which is the name of the service which clients can use to locate that service and an object which implements Remote.

Hope this helps,
Michael Morris
 
Sumesh Aravindan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael !!!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the connectionFactory reside on the client side or server side?

It will be on the server side because it is only for remote mode. In local Mode you will not have a "Connection" object.
You will have a DataAccessFactory on the client. Don't get confused with these two.
Hope that helps.
Mark
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question here what object type will be returned by the DataAccessFactory on the client side. Is the object type same for both local and remote type connections.
Also does the ConnectionFactory class on the server side, has to extend UnicastRemoteObject? I think the DataAccessRemote also extends UnicastRemoteObject so in this case both of these classes have to extend UnicastRemoteObject?

Thanks.
[ August 14, 2002: Message edited by: Samual Harvey ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DataAccessFactory returns an instance of DataAccess which is the interface that both DataAccessLocal and DataAccessRemote implement.
Yes the both extend UnicastRemoteObject.
Mark
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing some problems as below:-
1. If I bind the ConnectionFactory to the rmi then I get this error:-
Exception starting Server :: Stub class not found: java.rmi.server.RemoteObject
_Stub; nested exception is:
java.lang.ClassNotFoundException: java/rmi/server/RemoteObject_Stub
But if I bind DataAccessRemote to rmi then no errors.
Mark you said I should bind the ConnectionFactory, so what I am doing worng here. My ConnectionFactory extends UnicastRemote but does not implement DataInterface, whereas DataAccessRemote extends UnicastRemoteObject and implement DataInterface. Do you I have to make the ConnectionFactory also implement the DataInterface. Any idea why I am unable to bind ConnectionFactory to the rmi.
2. If I use System.setSecurityManager(new RMISecurityManager()) in main server starting class I get some error and If I dont then no error.
3. Similarly I am unable to use setSecurityManager and LocateRgistry on the client side.
I have tried creating policy file, but to no help.
Please let me know what I am doing wrong.
Thanks,
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have an interface for your Connection guy? You will need this for the client to talk to it when you get it back out of Naming... just like you would be using your DataInterface or DataAccess for the object that you said was working for you.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2. You don't need an RMISecurityManager on the server, I would remove that, and it will work.

3. You really don't need security on the client side either. I myself had it there, but it is uneccesary. Some that have gotten perfect scores didn't have any security. And you do not need to locate the registry. The lookup is done via
No back to one, sorry but try this.
make a ConnectionFactory interface

then make your object that will bind into the registry, you can call it whatever you like, I myself called it as follows.

This is the same thing that Nate is talking about.
Good luck
Mark
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a little confused here. Are we saying that we need two interfaces. One called DataInterface which extends Remote and another ConnectionFactory that also extends Remote.
Mark, As you said before:-
DataAccessRemote is not the object that you want bound to the Registry. You want to bind a ConnectionFactory to the registry, that when the client looks it up, it calls a method on it called getConnection, which returns a DataAccess class, which in this case will be an instance of the DataAccessRemote.

So how would I link the two interface so that getCOnnection returns object of type DataInterface (i.e DataAccessRemote which implements DataInterface)?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

that is the method in the interface, in the implementation of that the actual class that you will instantiate will implement this function so that it returns an instance of DataAccessRemote which implements the DataAccess interface.
Hope that helps clear things up.
Both interfaces do er extend Remote.
Mark
[ August 15, 2002: Message edited by: Mark Spritzler ]
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I was trying a few combinations and I also tried this.
On client side I am doing:-

On the server side I do this:-

I can start the server without any error. But when I start the client I get this error message
while executing :-


Exception in thread "main" java.lang.AbstractMethodError
at suncertify.client.DataAccessFactory.getConnectionChoice(DataAccessFactory.j....
The statement connectionInterface = (ConnectionInterface)Naming.lookup("rmi://myServer:1099/FBNServer");
executes without any problem.
I dont know what wrong I am doing..Please tell me.
Thanks.
[ August 15, 2002: Message edited by: Samual Harvey ]
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK Never mind, I got it resolved. The problem was that after I changed the getConnection return type I did not generated the stub and skel files for the ConnectionFactory.
Thanks for all ur assistance.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done Samual. You get an A for this lesson. JK
Mark
 
Sumesh Aravindan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to clear this doubt.
If I am registering the ConnectionFactory to the rmi registry insted of the RemoteData, how do I start my server. ie, if I have a class called FlyByNightServer, what should this class instantiate? is it the ConnectionFactory or the RemoteData class.
Basically, my question is , where does the server start from?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sumesh,
The ConnectionFactory will be instantiated by your server and RemoteDatas will be instantiated by ConnectionFactory as client requests come in.
Hope this helps,
Michael Morris
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And your ConnectionFactory has a reference to a Data class.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic