File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Design" Watch "Design" New topic
Author

Design

John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
Hi, I am implemeting my solution using RMI and therefore I have gone down the road of having an Adapter class wrap my Data.java class.
Now my question is, my remote object simply has one method in it


instead of creating a new DataAdapter here I was thinking about changing my DBRemote class to just get a reference to an instance of a DataAdapter.
I woulle be concerned that if every time a DBRemote instance is created and then a DataAdapter is created locking the database would be impossible.
Although would the fact that my Lockmanager class in the server, which is only accessed by Data.java, is a static refernce resolve this issue?

By the way, every time I create a DataAdapter instance an instance of Data.java is also created.

what do you guys think?
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
has anyone any thoughts on this?
John.
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by John R Roberts:
Hi, I am implemeting my solution using RMI and therefore I have gone down the road of having an Adapter class wrap my Data.java class.
Now my question is, my remote object simply has one method in it


instead of creating a new DataAdapter here I was thinking about changing my DBRemote class to just get a reference to an instance of a DataAdapter.
I woulle be concerned that if every time a DBRemote instance is created and then a DataAdapter is created locking the database would be impossible.
Although would the fact that my Lockmanager class in the server, which is only accessed by Data.java, is a static refernce resolve this issue?

By the way, every time I create a DataAdapter instance an instance of Data.java is also created.

what do you guys think?

Why not just have you DataAdapter as the remote object? This way you simply register a single DataAdapter in the registry and all clients will use this class. Alternatively the exact same thing would be to just have a static DataAdapter instance variable in your current remote object and return this to clients.

If you go down the multiple DataAdapters route you will indeed need to make the lock manager static. However you will not be able to use your class on multiple database files (if there are multiple new tables in the future). I think that either approach is more than acceptable once justified in the doc.

Mark


SCJP<br />SCJD
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
The next question is if I use my DataAdapter class as my remote object can I use that same DataAdapter class when I access my database in non-networked mode.

Keep in mind that networking must be entirely bypassed in the non-networked mode.
and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely. No authentication is required for database access.

does this mean that if my DataAdapter is my remote object I can't use that class when operating in non-networked mode?

many thanks,
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by John R Roberts:
The next question is if I use my DataAdapter class as my remote object can I use that same DataAdapter class when I access my database in non-networked mode.

Keep in mind that networking must be entirely bypassed in the non-networked mode.
and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely. No authentication is required for database access.

does this mean that if my DataAdapter is my remote object I can't use that class when operating in non-networked mode?

many thanks,


I would suggest that you are missing one more class before your design is complete, you will need another class to act as your remote object.

This can have the same methods as your adapter (maybe have an interface for the adapter class) then another remote interface that extends your adapter interface class and the RMI remote interface. Your remote class would implement this remote interface. The remote class could delegate to a private instance of the orignal adapter class.

One thing you would have to consider is that the orignal methods in the Adapter interface must throw IOExceptions (so the remote interface methods can throw the subclass RemoteException).

Mark.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design