aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: used RMI & Local in local Side 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 "NX: used RMI & Local in local Side" Watch "NX: used RMI & Local in local Side" New topic
Author

NX: used RMI & Local 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!!!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Hi Gy
I disagree with having Data an abstract class. Your instructions tell you that Data must implement the DBAccess interface. This doesnt sound abstract to me.
Once you have Data implemented, then you can look at how to connect to it in local or networked mode.
I am unsure of what your question was asking. Were you asking for help with the Data class? Or were you asking about the local / networked modes?
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
My question is about lcoal and Remote Mode
I think for some days about Design:
1) I create a class Data.java which implemts the DBAccess interface .
public class Data{
public readRecord(long recNo)
throws RecordNotFoundException{
//read record from the .db file
}
.....
}
2) i create a interface RemoteDBAccess.java
import java.rmi.*;
public interface RemoteDBAccess extends Remote{
public String [] readRecord(long recNo)
throws RecordNotFoundException,RemoteException;
....
}
I also create a class RemoteData.java
import java.rmi.*;
import java.rmi.server.*;
/**
*This is the implements from RemoteDBAccess used for Remote mode
*@date 2003-05-18
*@author Steven Gu
*/

public class RemoteData
extends UnicastRemoteObject
implements RemoteDBAccess{

public RemoteData () throws RemoteException{
super();
}
public String [] readRecord(long recNo)
throws
RecorNotFoundException ,
RemoteException{
//some codes :.....
}
}
can you tell me Am i right?
Thank you very much
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Hi Gy,
This looks like a very reasonable start to me.
Changing topic, is your name really Steven? If so, how do you feel about changing your name (here) to meet the JavaRanch registered names policy.
Regards, Andrew
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Andrew, How do you know his name is really Steven? That was a good pull.
Ok let me edit my post here now that I figured out how Andrew knew Gy's name is Steven.
So now Steven you just need to include your last name to be following the Naming Policy.
Mark
[ June 18, 2003: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Steven, you have a duplicate thread. There are two threads by you that are on the exact same topic. Which one do you want closed, because I can't figure out which one is more up to date, has your answer.
If you could do me a favor and pick which one of the two you want to keep, and then delete the other, I would greatly appreciate it.
Thanks
Mark
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
this topic is not ;
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

This thread appears to be the duplicate of this thread.
I am going to close the other thread.
Mark
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Steven, please review JavaRanch's Naming Policy, and change your name accordingly. To be more specific you have to add a last or family name.
Thanks,
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
amchi gelo
Ranch Hand

Joined: Jul 01, 2002
Posts: 75
So from what I understand, you end up running methods on different interfaces depending on whether its a local or network connection, right?
DBAccess for LOCAL and RemoteDBAccess for NETWORK, right?
Does this fit with the requirements?
Sanjay

Originally posted by Andrew Monkhouse:
Hi Gy,
This looks like a very reasonable start to me.
Changing topic, is your name really Steven? If so, how do you feel about changing your name (here) to meet the JavaRanch registered names policy.
Regards, Andrew


Sun Certified Web Component Developer 1.4<br />Sun Certified Java Developer 1.4<br />IBM Certified Associate Developer - WebSphere Studio, V5.0 (285)<br />IBM Certified Specialist - IBM WebSphere Application Server, Adv Single Server Edition for Multiplatforms, V4.0 (158)<br />IBM Certified Solutions Expert - IBM Websphere Studio V4.0 (487)<br />IBM Certified Specialist - IBM Visual Age for Java V4.0 (283)<br />Sun Certified Java Programmer 1.2
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Well actually different implementations of the interface. There is only one interface, but you will have two classes that implement it.
Does that help?
Mark
[ January 27, 2004: Message edited by: Mark Spritzler ]
amchi gelo
Ranch Hand

Joined: Jul 01, 2002
Posts: 75
I am a little confused now... isnt it more like two interfaces RemoteDBAccess and DBAccess which are similar but not exactly the same. And two different classes which implement them?
So when its in the Network mode, it runs RemoteDBAccess and not DBAccess methods...?
Originally posted by Mark Spritzler:
Well actually different implementations of the interface. There is only one interface, but you will have two classes that implement it.
Does that help?
Mark
[ January 27, 2004: Message edited by: Mark Spritzler ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: used RMI & Local in local Side