By either registering your
ClientApp as a
CosEventListener, or by taking advantage of Rio's
Watchable interface, you can react to changes in watched data within the system. So, for example, when you add a category to the global list of categories, every client connected to the COS gets the updated category list via a remote event. These remote events cause changes to the client's local cache of categories, thus triggering a
PropertyChangeEvent that is heard by the local GUI elements.
Similarly, when you assign a task to one of your buddies, her task list will be updated by your client. That change will be transmitted to her client if she is connected to the COS. As these are RMI remote events, they cannot be relied upon to always succeed and are not used for mission-critical events; however, the damage done to a GUI by missing the occasional update here and there is not going to cause anyone to lose sleep. The client will get another event shortly, or will repoll the COS if it hasn't heard anything in a while. Either way, the changes get through eventually.
Ensemble systems are built upon the notion that all of their component parts will probably fail unexpectedly; this includes events. Your application is more than the sum of its parts, however; what is unreliable at the component level is seamless and reliable at the application level. When people criticize RMI events for their unreliability, they are making a classic "level error."
Jini-based ensemble applications are only really secure and simple on your local network right now, but Rio's JSP interface and Lincoln Tunnel, as well as Crudlet-style XML interfaces to COS, allow thin clients, Web pages, Flash movies, and so forth to connect to a COS system as if it were any other web service.
As Jini's Davis project (login required) matures, permitting secure, authenticated, ad-hoc, distributed networks, the patterns developed within the LAN become scalable to the global network.
You can download the TaskTracker Javadocs and a regular developer build of the TaskTracker from www.davesag.org. The build includes full time-stamped source code, from which the above examples are taken, as well as JavaDocs and an Ant build script. You will not be able to build it without COS, however, as it relies on several COS-specific APIs.
The COS Javadocs are online at cosproject.sourceforge.net. The COS source code is being prepared for release soon. Current plans are to separate out the API code from the implemetation code, much in the manner of Jini, before the source is released.
Dave Sag is a skilled Object Modeler and Software Designer, using Java as well as other programming environments.
Return to ONJava.com.