For the
Java Development assignment, I am required to write a remote interface. I understand basically what a remote interface is as the following example show:
//define a remote interface
public interface Intf extends Remote {
public
String meth() throws RemoteException;
}
//server to implements the remote interface
public class Server extends UnicastRemoteObject implements Intf {
public Server () throws RemoteException {
super();
}
//implementing the method
public String meth() throws RemoteException {
return �String�;
}
}
Query: What I am a bit puzzled is that the assignment required that the remote interface used all the public methods of the Data class. Is that correct that I have to create an instance of the Data class and then in the Server class, I refer to the methods found in the Data instance as shown below:
//remote interface
public interface DBI extends Remote{
public FieldInfo[] getFieldInfo() throws RemoteException;
public int getRecordCount() throws RemoteException;
//rest of Data class�s methods go here
}
//server class implementing the remote interface
public class Server extends UnicastRemoteObject implements DBI {
Data d;
public FieldInfo[] getFieldInfo(){
return d.getFieldInfo();
}
public int getRecordCount(){
return d.getRecordCount();
}
/*rest of implementing methods go here*/
}
Is that the correct approach that in the Server class, I create an instance of the Data class and then inside the implementing method, I refer to the Data class�s method. For example in the method getFieldInfo() in the Server class, I used the code below:
return d.getFieldInfo();
where d is the instance of the Data class.