Interface Taggable

All Known Implementing Classes:
TaggableObject

public interface Taggable

Objects of classes implementing this interface can hold arbitrary tags scoped by the object's Cache.

A tag is a keyword associated with an object stored in StateServer. You can associate tags with objects, remove tag associations from objects and test for the presence of a tag on an object by using the methods defined in object's TagHolder. Once a tag or set of tags have been associated with an object, the tags are stored as part of the object state.

To associate tags with objects stored in a Cache, the object's type must implement the Taggable interface. This interface requires an implementation which has a well-known property, tagHolder, which is used to store the tags associated with the object.

The set of strings used as tags on objects is scoped by the Cache in which the objects are stored. A tagged object binds itself to the cache when it is written to that cache. All tags assigned to the object prior to binding are saved in the global SOSS store and can be retrieved by reading that object from other clients. It is also possible to specify tag conditions in queries by using FilterFactory.hasAllTags(java.lang.String...) and FilterFactory.hasAnyTags(java.lang.String...).

Tagged objects returned by get and retrieve methods and queries are bound to the corresponding cache. It is possible to modify their tag sets and then do a cache update. However, to save an object into another cache, you should first cancel binding by clearing object's tags(TagHolder.clearTags()).

An implementation of Taggable should have a non-static initialised field of type TagHolder, a reference to which is returned by getTags(). This is necessary for saving tags in the cache. Operations with tags are performed by calling TagHolder methods.

An example of class, implementing Taggable:

 public class MyTaggable implements Taggable, Serializable {
    private TagHolder th = new TagHolder();
    public TagHolder getTags() {
          return th;
    }
    public MyTaggable(String tag) {
      th.addTags(tag);
    }
 }
 
If class hierarchy permits, instead of implementing Taggable it is more convenient to subclass TaggableObject. This class provides the getTags() implementation and wrappers for TagHolder methods.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.scaleout.client.messaging.messages.TagHolder
    Method used by Cache to store tags as SOSS attributes.
  • Method Details

    • getTags

      com.scaleout.client.messaging.messages.TagHolder getTags()
      Method used by Cache to store tags as SOSS attributes. It should return a reference to a TagHolder object associated with this class.
      Returns:
      a TagHolder