站内搜索: 请输入搜索关键词
当前页面: 图书首页 > Java InstantCode: Developing Applications Using Java NIO

Creating the Remote Interface - Java InstantCode: Developing Applications Using Java NIO

Team LiB
Previous Section Next Section

Creating the Remote Interface

To create the client-server application using RMI, you need to create a remote interface that declares the business logic of the application. The FileRemote.java file is a remote interface for the File Download application that defines the prototypes of the methods implemented by the FileRemoteImpl.java file.

Listing 3-1 shows the contents of the FileRemote.java file:

Listing 3-1: The FileRemote.java File
Start example
/* Imports java.rmi package classes. */
import java.rmi.Remote;
import java.rmi.RemoteException;
/* Imports java.util package classes. */
import java.util.Vector;
/*
Interface FileRemote - This interface declares the remote methods.
Methods:
downloadFile() - Downloads the file from a remote location.
displayList() - Displays the list of files stored in the server to the client.
*/
public interface FileRemote extends Remote 
{
   /* Declares downloadFile() method. */
   public byte[] downloadFile(String filename) throws RemoteException;
   /* Declares displayList() method. */
   public Vector displayList() throws RemoteException;
}
End example

Download this Listing.

In the above code:

  • The FileRemote interface defines the methods to perform various operations of the File Download application. These methods include displayList() and downloadFile().

  • The displayList() method displays the file list to the client machine.

  • The downloadFile() method downloads the selected file from the remote machine.


Team LiB
Previous Section Next Section