next up previous contents
Next: Future Improvements Up: The Basic Services Previous: The Basic Services

The HsObjectCreatorService

  One of the basic functions of Haystack is to dynamically create new HDM objects. This task is handled by the HsObjectCreatorService service. The interface for the HsObjectCreatorService is fairly straight-forward. One function, newObject(n) generates a new straw of type n (where n is a string of the fully qualified class name of the Straw, see section gif). The HsObjectCreatorService then uses the Java reflection API to dynamically load the class definition and instantiate the desired object. If the class for a certain straw does does not exist, or for some reason can not be created, a NoSuchStrawException is thrown. By using the fully qualified class name HsObjectCreatorService allows for the loading of objects not directly in the haystack.object package. This is valuable as it may be desirable to keep one Haystack installation on a machine intended for multiple users. However, as users may want to generate new object types, these will necessarily sit outside the haystack.object package.

HsObjectCreatorService also serves two other important functions. First, it will contact the HsCounter to get a unique ID for the new straw. Second, it will contact the HsPersistentObjectService to register the newly created object so that persistent storage is guaranteed when the HDM data is flushed to disk.





Copyright 1998, Eytan Adar (eytan@alum.mit.edu)