• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  •  
    Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic