3. Writing a Service

Dare to be naïve.

—R. Buckminster Fuller

The MessageStream interface is designed to work for many purposes. We will now show you two example implementations of a message stream service. The first will be a FortuneStream subinterface that returns randomly selected “fortune cookie” messages. The second will provide a chat stream that records a history of a conversation among several speakers. First, though, we must talk about what it means to be a Jini service.

A service differs from a client in that a service registers a proxy object with a lookup service, thereby advertising its services—the interfaces and classes that make up its type. A client finds one or more services in a lookup service that it wants to use. Of course, ...

Get Jini™ Specifications, The, Second 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.