Rmi callback pdf




















A portion that performs WLE client application functions, such as initializing the JNDI context, using the context to establish connections, looking up initial references to objects, and using factories to create objects. A portion that creates the remote object implementation callback object and activates the callback object. As indicated in the figure, the following operations are executed:. A server gets an object reference from some source.

It could be a naming service or it could be passed in through a client, but not located in that client. Since the object reference is not located in a client connected to an ISH, the outgoing call cannot be made using the bidirectional method. The WLE server invokes on the object reference. The ISH determines which outgoing connection to use to send the request to the client. The client executes the method and sends the reply back to the ISH.

Use of callback objects in Java applets is limited due to Java applet security mechanisms. In practical use, being able to use a remote object as a parameter or a return value for a remotely invoked method is convenient for such things as updating the display of an applet in response to server-side events. For example, you could simply export the applet itself as a remote object that registers an interest in server-side events, and whose display changes in response to those events.

Writing source code for RMI applications that use client-side callbacks differs from standard RMI applications in that you have to include some additional code for a client interface. The remote client must implement the client interface. Also, the remote server object will now include objects received from the client and method invocations on those objects. Figure shows the structure of an RMI application that uses client callbacks. Figure shows pseudo-code to illustrate the client-server interaction in a callback scenario.

The following sections provide a code example of a simple application that illustrates RMI client callbacks. Listing shows the client interface. Listing shows the RMI client implementing the client interface. Implements the methods defined in the client interface, CallbackClientInf.

The sendObject method does a callback on the client object. The sendLong method does a callback on the client object. Hashtable; import java. RemoteException; import javax. Context; import javax. InitialContext; import javax. NamingException; import javax. Couldn't send client object to server" ; System. Listing shows the RMI remote interface, in which we declare the business methods:.

Listing shows the remote object implementation of the business methods in the RMI remote interface. Listing CallbackImpl. Create a directory where you want to build and run the example. The temperature monitor client registers with the temperature service Server.

When the temperature does change, a callback is made, notifying registered client references. Server application:. TemperatureServer interface's methods are implemented by the Server used by the client application Monitor to register or remove a listener and to get the current temperature.

TemperatureListener interface's method is implemented by the client application used used by the server application to notify the client when the temperature is changed. TemperatureServerImpl is the Server application implementation. Client Monitor application:.

Add the interfaces TemperatureServer and TemperatureListener. Start the Monitor Client application. The monitor displays the current temperature then each time the temperature is changed on the server, the new value is displayed in the monitor.

This is the link for the source code:. References :. Michael Reilly, David Reilly. Addison-Wesley Professional , Ian F.



0コメント

  • 1000 / 1000