9.1 Using the RFIService client class
RFIService is the client class used for Remote Function Invocation programming.
To create an instance of RFIService use the static getInstance method. This method requires a properties parameter. These properties control the communication characteristics of the host connection.
|
Example
Properties properties = new Properties () ;
properties.put ( "rfi.server", "http://your.own.url:port" ) ;
RFIService service = RFIService.getInstance ( properties ) ;
The RFIService has two methods to send and receive serialized objects.
The getObject method is used to receive a serialized response object from the host server using the specified service name.
Object getObject ( String service )
Object getObject ( RFIObject service ) ;
Example
Object object = service.getObject ( "EMPLOYEE-FETCH" ) ;
The putObject method sends a serialized object to the host server and receives a response object from this named service.
Object putObject ( String service, Object sendObject ) ;
Object putObject ( RFIObject sendObject ) ;
Example
Object object = service.putObject ( "EMPLOYEE-UPDATE", employee ) ;
If the response status from the host is not successful then an RFIException is thrown.
If the content type of the response is not "application/x-java-serialized-object" an RFIException is thrown.
If no content was returned a null object reference is returned, else the content is de-serialized and an object reference is returned.
The RFIObject interface has one method to return the service name.
This allows the sendObject to supply the name of the service and eliminates the need for the String service name parameter.
public interface RFIObject
{
public String getService () ;
}
The RFIException class has several methods to allow access to the response status and message.
|