Performing Callbacks

In most RMI applications, a client makes a call to a server object. In some cases, however, the server needs to make a call back to the client. For example, in a stock quote system, you might set up the server to call the client every time a stock price changes. A client registers with the server by invoking a remote method and passing a remote object reference to the server. From the client's standpoint, it's really passing a remote object, but RMI converts the remote object to a remote reference (that is, stub) when it sends the request to the server.

Figure 4.6 illustrates how the callback generally works.

Figure 4.6. With a callback architecture, the server can invoke methods on a client.

Listing 4.10 shows a simple ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.