aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: used RMI & Local same Time in local Side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply locked New topic
Author

NX: used RMI & Local same Time in local Side

guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
Sorry , i think the question is very old, but
I found and look a lot of topics in javaranch.
But i still unstand.
in my document :
Required Interface
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
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;
}
i think Sun says the class cannot be modi by myself.
someone say create a top abstract class and
two dbaccess ,one is local and other is a
remote;
can you give me a example? please help me!!!
Bob Reeves
Ranch Hand

Joined: May 01, 2003
Posts: 64
Hi Gy Gy:
I think that I have the same assignment as you (URLyBird). The way I interpretted SUN's directions in my class was:
Create a class, Data.java, that implements the DBAccess interface. This class must provide the basic data access functions. I surmise this class is possibly an "AUTOMATIC FAIL" if done improperly because SUN could well be running their test driver directly into it to evaluate your database design (i.e., locking).
Then create wrappers or callers for Data.java that handle the remote (RMI or sockets) feature. (My design has a DbServer class that is a Facade that wraps Data.java.)
Interestingly, the DBAccess interface doesn't follow SUN's documentation standards. I was conflicted whether it was OK to create a "clean" DBAccess interface file with proper javadoc, or just leave it ASIS.
Well, that's how I view the issue from Massachustts, other LAT/LONGs may differ ....
Tx
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
Then create wrappers or callers for Data.java that handle the remote (RMI or sockets) feature. (My design has a DbServer class that is a Facade that wraps Data.java.)
please give me a example ,I am not unstand
Bob Reeves
Ranch Hand

Joined: May 01, 2003
Posts: 64
Hi Gy Gy:
Simplified version:
class Data implements DBAccess {
public String [] readRecord(long recNo) {
...
}
}
class RemoteServer extends UnicastRemoteObject {
private Data myData = new Data();
public RecordModel readRecord(long recNo)
throws Remote {
String [] record = myData.recordRecord(recNo);
return new RecordModel(record);
}
...
}
So, RemoteServer is the remote rmi object, and passes its calls to Data. RecordModel is a great, programmer friendly enhancement. ) Seem OK?
Tx
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: used RMI & Local same Time in local Side