In our first netlet example, Hello1Client, we used
a warrant to access a service. That netlet, and indeed any netlet,
uses the bindService() method to connect to such a service.
Now we know that any such service is accessed via another netlet.
That other netlet, the access point netlet, downloads and presents
facets (such as IHelloFacet) to the client netlet.
In our example the facet supplied a not-very-exciting hello message,
and it was unclear whether that message came directly from the access
point netlet or from a central server, and just retrieved by the access
point netlet. But in fact it didn't matter. The access point netlet
itself was not accessible to our client netlet--only its facet was.
And that's really the point about services: all the client deals with
is the service interface, IService, and everything else comes
from there. The access point netlet is irrelevant to the client because
it just deals with the service interface.
Nevertheless, that access point netlet is part of the service provided
(supplying a hello message). Writing a service involves, at the very
least, having an access point to supply the service. Here are some
example hello world services and how they might work:
- Hello world service 1. The access point sends a request back to a
central server to get the message and returns it to the client. The
central message server is clearly a single point of failure here.
- Hello world service 2. The access point downloads with a list of
available message servers and asks one of them for the message. Whenever
one message server dies the others create a new one. They update the
current list carried by all current access points and ensure that
future access points all start with this latest list.
- Hello world service 3. An extension of the previous example, but
here the service administrator can connect and change the message
whenever they wish. When they connect they get an access netlet, of
course, and it again connects to one of the message servers. When
they update the message on the one message server it percolates that
change to all the others. That way they are all kept up to date.
- Hello world service 4. The access point carries the message itself.
It doesn't need to worry about any message servers; they don't exist.
This service consists only of access points which don't communicate
with each other. The message cannot be updated on the fly.
Hello world service 3 might seem wildly ambitious, but in fact that's
just the kind of thing the Beatrix framework provides. If you've downloaded
the hello world warrant from the Jtrix.org site, you're using Hello
world service 2, which is only a small step away from it. It was
written with just seven classes within Beatrix. See Programming
with Jtrix: The Beatrix application framework6.1for more details.
However, the humbler Hello world service 4 is still a legitimate
Jtrix service. It's not as wild, but it's a good solid start. That's
what we'll write now.
Nik Silver
2002-03-09