One problem that almost all the Distributed applications suffer from is the concept of Remoteness and lookup. One of the toughest problem in Software Engineering is to design a system with a single Interface. The Remoteness of an application should be hidden from the client application. How many components have we worked on where we need to do a "Lookup"? EJB, JMS, JINI and they all suffer from the javax.rmi.Remote interface. Even though powerful but these technologies expect not only the managed domain object be of type Remote but also to do the discovery to find them. The Remoteness is a behavior of the container not of the application. The Application should behave exactly the same way with or without a specific infrastructure. Of course I don't consider JVMs to be an infrastructure, some may disagree. Isn't Serializable interface enough to tell the container(?) that the application could be Remote?
EJB3.0 addressed this issue to some extent. At least the annotations remove the requirements to have some specific remote interfaces implemented. The EJB classes can then be used in a standalone applications too.
Even JavaSpaces suffer from the same problems. JavaSpace expects the Object to implement net.jini.core.entry.Entry interface. Of course the Space has to identify an Object type. But what else does the Entry interface contribute to?
- Its a Marker interface that extends Serializable. This architecture pretty much blocks users to make the Serialization any more efficient than what the default provided by the JVM is.
- The operations read and write on a Space works similar to the get () and put () operations on a Collection. take () is a little different but can be categorized as a specialized get (). The "Space" is made logically more close to a Collection. The use of a Space should be like a Map not a Collection. A space with houses, have defined addresses. Template based lookup is inefficient. It should have been a much better design if net.jini.space.JavaSpace had extended java.util.Map interface and read () and write () were renamed as get () and put () respectively.
- The third problem is the concept of Discovery or Finding the Space. Why? Why should the client application know that there is a Space out there that needs to be found? Isn't the discovery a role of the container and not of the end-client's?
- At last what does it take to migrate your existing application to a distributed environment? Not easy with JavaSpaces. That will require a lot of changes to your application. If JavaSpace extends Map then migrating could have been a trivial task as to just replacing your HashMap, TreeMaps etc with JavaSpace.
PS: Of course APIs can be built on top of JavaSpace to address these issues.