Example 3: Hello World with Callback Object

This document was not updated for the J2SE release. If you downloaded this document as part of the J2SE documentation bundle, check the Web site at http://java.sun.com/j2se/1.4/docs/guide/idl/jidlExample3.html for updates.

Client programs often react to changes or updates that occur in a server. For example, a client graph or spreadsheet program might need to be updated with each stock price update on a stock market server. The client has two options in this scenario: (1) periodically ask for the stock price via a method request on the stock server or (2) ask to be notified by the server whenever a price change occurs. The second option is referred to as a "callback".

Example 3 illustrates how a client program can pass a callback object to a server. The server then issues a method request on the callback object and thereby notifies the client.

Example 3 is identical to Example 1 except for the callback enhancements. This page only discusses the code necessary to these enhancements.


ALIGN=CENTER>Home