This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:[URLyBird]How can I use the flexible way to implement RMI data access? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:[URLyBird]How can I use the flexible way to implement RMI data access?" Watch "NX:[URLyBird]How can I use the flexible way to implement RMI data access?" New topic
Author

NX:[URLyBird]How can I use the flexible way to implement RMI data access?

Richard Jackson
Ranch Hand

Joined: Jun 25, 2003
Posts: 128
Hi,all,
In my instructions.html,there are the following statements:
package suncertify.db;
public interface DBAccess
{
// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] readRecord(long recNo)
throws RecordNotFoundException;
// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Deletes a record, making the record number and associated disk
// storage available for reuse.
// Throws SecurityException if the record is locked with a cookie
// other than lockCookie.
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);
// Creates a new record in the database (possibly reusing a
// deleted entry). Inserts the given data, and returns the record
// number of the new record.
public long createRecord(String [] data)
throws DuplicateKeyException;
// Locks a record so that it can only be updated or deleted by this client.
// Returned value is a cookie that must be used when the record is unlocked,
// updated, or deleted. If the specified record is already locked by a different
// client, the current thread gives up the CPU and consumes no CPU cycles until
// the record is unlocked.
public long lockRecord(long recNo)
throws RecordNotFoundException;
// Releases the lock on a record. Cookie must be the cookie
// returned when the record was locked; otherwise throws SecurityException.
public void unlock(long recNo, long cookie)
throws SecurityException;
}

-------------------------------------------------
So I have problems to this:
1)Whether or not ,I must extends the DBAccess interface and Remote interface at the same time when I write the remote interface?
2)In my remote interface,must I list all the required methods ?
3)What can I do if I'm asked for "must not require to install RMISecurityManager?
Thanks.
Regards,
Jackson
mrsgq@163.com


Regards, Richard
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Richard,
2)In my remote interface,must I list all the required methods ?

My personal belief is that having those methods available to the remote client makes for a more flexible system - the database server should rarely need modification, and can be easily adapted to provide access to other databases.
However I seem to be in the minority now With the new assignments, there does not seem to be a requirement to make all the methods available to the clients, so many people here seem to be developing a completely different interface which they provide to their clients. It seems that some of them are only providing find() and modify() methods in their RMI solution. This certainly can make life easier. I am just a grumpy person who doesnt like it
1)Whether or not ,I must extends the DBAccess interface and Remote interface at the same time when I write the remote interface?

I don't think you gain anything by extending the DBAccess interface in the interface that you write for RMI, even if you have all the same method names.
  • you still have to rewrite all the method signatures so that they can throw RemoteException
  • there is the danger that someone less knowledgable about RMI could expect that since your interface extends DBAccess then all the methods in DBAccess should be available remotely - this is not true.
    3)What can I do if I'm asked for "must not require to install RMISecurityManager?

    I think it would be better if you tried to write your RMI code, and if you come to a point where you cannot progress without installing a Security Manager, then come back and explain your issue, and people here will explain how to work around it.
    This requirement (and the one about not requiring a web server) was put in to stop people from getting too creative in their solutions: you should not need a security manager for this assignment. The requirement just stops people from putting one in because they wanted to experiment with the technology or because they had gone down a more complicated path in developing their solution.
    Regards, Andrew


  • The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: NX:[URLyBird]How can I use the flexible way to implement RMI data access?
     
    Similar Threads
    NX: used RMI & Local same Time in local Side
    NX: used RMI & Local in local Side
    URLyBird interface?
    Interface to Data
    DBAccess.java