[BACK]

Integrating JavaSpaces™ as an EAS4 Service

I have been using JavaSpaces™ Technology in conjunction with Lutris EAS4 for presentation services and I wanted to understand what was involved in integrating JavaSpaces as an EAS4 service and what benefits would result.

The following describes my experiences.

JavaSpaces Technology

JavaSpaces is a powerful Jini service from Sun Microsystems that facilitates building distributed applications. The JavaSpaces model provides persistent object exchange "spaces"in which remote Java processes can coordinate their actions and exchange data.

In order to use JavaSpaces, it is necessary to run the following:

  • a simple web server - to serve classes specified in RMI codebases.
  • a Jini Lookup service - to register and locate the JavaSpace. Jini doesn't use JNDI, but has its own location service.
  • a JavaSpaces instance.

Although these are all contained in the Jini Technology Starter Kit, the mechanism for starting and monitoring them is somewhat crude, compared to the sophistication provided by the Lutris Management Console (LMC). I have to manually start each of them using custom scripts, before I can use JavaSpaces from a Servet hosted within EAS4.

Ideally, I want to be able to start, stop and monitor the JavaSpace using the LMC, in the same way I that I can manage other EAS4 services. I thus consulted the EAS4 Services Developers Guide to find out what I needed to do.

JavaSpace as EAS4 Service

Reading the EAS4 Service Developers Guide you will quickly come across the terms Target Access Point (TAP) and Target and you need to decide which approach you will use to implement them. Since a JavaSpace behaves like a daemon (it has threads that need to be run until shutdown), it needs to be started by the TAP run() thread. It is possible to provide a Target that uses the Jini Lookup Service to locate a JavaSpace, but this does not seem appropriate, as JavaSpace clients expect to bind to JavaSpaces using the Jini Lookup Service and not JNDI.

I thus set out to implement a TAP that invokes the JavaSpace main() in its run() thread and a dummy Target that is not actually used. This should enable the JavaSpace to be started and stopped as an EAS4 service from the LMC, plus the ability to monitor any management information provided in the JavaSpace TAP MBean.

To get started I used the appwizard to create a service called "JavaSpaces". I then modified the TAP to override the run() method to invoke the JavaSpaces main() entry point. In the TAP MBean, I added a method to return the total number of objects in the space, using the JavaSpaceAdmin object which I obtained from the Jini Lookup Service. In the TAP shutdown() method, I called the destroy() method on the JavaSpaceAdmin object. I then modified the ant buildfile to include the appropriate JavaSpace JARs in my new service JAR and prepared to deploy.

I manually started the RMI codebase server and Lookup Service (I'll integrate these later, if all goes well). I then used LMC to deploy my new JavaSpaces service. It started cleanly and worked as expected. Just for fun, I used LMC to graph the number of object in the space over time, from the value exposed in the TAP MBean. Very impressive, yet amazlingly simple to implement.

Conclusion

Integrating a JavaSpace as an EAS4 service is simple, once you have decided which approach to follow. It can be started and stopped by simply deploying and undeploying the JavaSpace service and can thus be easily configured to start automatically when EAS4 is launched. Additional management information is very easy to add to the TAP MBean, and the LMC makes it very easy to monitor and/or graph such information.

References

JavaSpaces technology: http://java.sun.com/products/javaspaces/


Derek Baum is a Principal Consultant with Paremus, a Lutris Gold Bar Partner, in London, England. He can be reached at derek.baum@paremus.com. You can learn more about Paremus at www.paremus.com.

 

[TOP]
Legal Notices ---- Privacy Policy