|
Articles Index | Jini Index | Wireless Initiative TechnologyJini technology has become the hot topic for anyone interested in connecting a wide range of information devices to a network. When you plug any Jini technology-enabled device into a network, its services and resources are immediately available. Part of the reason is Jini technology's distributed event mechanisms. This article discusses methods of handling distributed events. An Introduction to Jini TechnologyJini technology provides simple mechanisms that enable devices to plug together to form an impromptu communitya community put together without any planning, installation, or human intervention. Each device provides services that other devices in the community may use. These devices provide their own interfaces, which ensures reliability and compatibility. The Java programming language is the key to making Jini technology work. Devices in a network employing Jini technology are tied together using Java Remote Method Invocation (RMI). By using the Java programming language, a Jini connection architecture is secure. The discovery and join protocols, as well as the lookup service, depend on the ability to move Java objects, including their code, between Java1 virtual machines (JVM). Jini technology not only defines a set of protocols for discovery, join, and lookup, but also a leasing and transaction mechanism to provide resilience in a dynamic networked environment. The underlying technology and services architecture is powerful enough to build a fully distributed system on a network of workstations. And the Jini connection infrastructure is small enough that a community of devices enabled by Jini connection software can be built out of the simplest devices. Moving Past the Delegation Event ModelEvents are the mechanism used for asynchronous communication in Jini systems, and as such are crucial to the effective use of the technology. It is both interesting and valuable to consider the nature of the distributed event mechanism, since such an investigation will reveal much of interest about both Jini technology and the appropriate use of RMI. Perhaps the most useful approach is to consider why the existing delegation event model is not used directly and then examine the way in which these shortcomings are addressed. There are several reasons why conventional events are not used:
Moving on to RemoteEventThese difficulties are all addressed in the distributed events system of Jini technology. First, and perhaps simplest, a single "universal" event listener interface/method pair is defined, that is: thenet.jini.core.event.RemoteEventListener interface.
This is a remote interface, indicating that RMI will be used to call the
The second and third problems, those of the potentially huge size of serialized
event objects in the pre-existing events and the unreliable network scenario,
have been handled by the elegant design of the
The
In fact, there is only one element in the
The second field is an identifier for the event. You have seen that it is
common for multiple event causes to be handled in the same listener method.
The The third field is a sequence number. This is used to give some indication of whether events have been delivered in the correct order and whether any have been missed or duplicated. In general, as events are issued, the sequence number they carry should be incremented monotonically (that is, counting 3, 4, 5, and so forth). Sometimes, if a server fails and recovers, it might not be possible to guarantee that the order is perfectly maintained. The minimum requirement is that an event is never issued with a sequence number less than the one last used. But, where possible, event-source implementations attempt to make more guarantees. The specification describes these various guarantee levels and their significance.
The fourth field is the handback, or registration, object. It is passed
to both the event registration and back to the listener in the form of a
It is useful to note that, in a distributed environment, another benefit accrues from using a single event class rather than defining new classes for each type of event that might occur. In such a system, there is no need to load a new class definition over the network when the first event of a new type is delivered. Control through LeasingThe final problem, how to abandon event registration when a listener fails, is handled using leasing. Leasing is one of the other core parts of the programming model of Jini technology. Briefly, a lease is a mechanism that provides API-level control over distributed garbage collection. In this context, providing a lease for the event registration provides, in a standard framework, a means of applying a timeout to that registration. If the lease holder (usually the event listener) keeps renewing the lease at suitable intervals, then the event source will maintain the registration. On the other hand, if the lease is allowed to time out or is cancelled explicitly by the lease holder, then the event source will recognize that a problem has occurred and will de-register the event listener automatically. These are just a few considerations for Jini technology developers today. Over time, the literature on this topic and many others will grow into a substantial resource for Jini developers. Good luck, and thank you for your early interest. Want to Learn More About Jini Technology?A new technical training seminar from Sun will provide you with the background needed to use Jini technology in real-world applications. Visit SunEd's registration page for more information.
Simon Roberts, senior course developer, joined Sun Educational Services in the UK four years ago and since then has been working with the Java programming language. He has taught and written training courses, co-authored two books, and leads the technical team responsible for the Sun Certified Programmer for the Java Platform and Sun Certified Developer for the Java Platform certification exams. Perviously, Simon spent twelve years as a software engineer, trainer, and course developer, concentrating on real-time control systems. Jon Byous is a freelance copywriter for high-tech markets, specializing in Java technology and the Internet.
_______ | ||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||