Summary

That's all there is to this netlet. All the work is done in the initialise() method, and the rest is absolutely minimal. Over the next few chapters we'll expand on those other methods in various ways.

But before we continue, you may be wondering ``Why is so much work happen in the initialise() method? Why not leave that method to perform very minimal initialisation and have something like a run() method in its own thread, executed by the node?'' There are several parts the answer.

First, initialise() could start one or more threads of its own and then return. There's no restriction here; we're completely free.

Second, this is just an example, and we're doing so much in initialise() just to keep it simple. The initialise() method is supposed to be just setup and nothing more.

Third, netlets tend to be event-driven. When initialise() returns the netlet remains alive waiting for a call into one of its other methods. If another netlet wants to bind a service we offer then bindService() will get called; if the node wants to look at the facets we offer it, it will call getFacets(); and so on. Even though initialise() returns the netlet is still alive.

An example of a simpler initialise() and an event-driven call to bindService() can be found in Chapter [*]. Threads are covered in great detail in Chapter [*].

Now on with the example.

Nik Silver 2002-03-09