Version 16

    JBoss Cache 2.0.0 "Habanero" designs

     

    JDK baseline?

     

    There is a discussion around whether Habanero should use Java 5 as a baseline, and JBossRetro as a means to providing Java 1.4.x compatible builds.  See JBossCacheHabaneroJava1.4 for more details.

     

    Habanero will use Java 5 as it's baseline and make full use of Java 5 language and API features, particularly in place of Doug Lea's concurrent.jar, albeit with some caveats listed on the JBossRetroPitfalls page. 

     

    JGroups dependency

     

    In addition, Habanero will ship with and depend on JGroups 2.5, which too is baselined on Java 5.

     

    JSR-107 JCache compliant interfaces

     

    While sticking to a JSR is probably a good thing, for several reasons Habanero will not be JSR-107 compliant:

     

    • JSR-107 is incomplete and is still in flux

    • JSR-107 defines a flat, map-like cache.  JBoss Cache uses a tree-structured cache.

     

    As such, one of the goals of Habanero is to glean good design ideas off JSR-107 (such as cache factories, interfaces and listeners), follow close naming conventions, and perhaps once the JSR is complete, provide an interface to JBoss Cache that is JSR-107 compliant.

     

    See discussion on this subject.

     

    Preliminary interfaces

     

    Other discussions on the Cache and Node interfaces and Listeners and Cache Loaders have also been ongoing.  Here's one on the CacheFactory interface.

     

    In it's current state, we have a concept as follows:

     

     

    • This raises the Node object as a top-level construct in the cache.

    • The cache itself is a wrapper around the root node, providing some additional cache-wide operations.

    • All operations performed on the node are relative to the node.

    • Cache and Node interfaces are minimalist, providing basic cache functionality.

    • SPI interfaces are available to both cache and node, that allow access to some internals.

      • Intended to be used by plugin authors and people extending JBoss Cache

      • Not indended for use by applications directly.

    • New construction mechanism and lifecycle management by the CacheFactory

     

    Please see the latest Habanero javadocs, published here.  Lots of javadoc comments detail the operation of each method.

     

    Using the new interfaces

     

    Simple usage example:

     

    
       // create a factory
       CacheFactory factory = new CacheFactoryImpl();
    
       // create and start the cache
       Cache c = factory.createCache("META-INF/replSync-service.xml"); 
    
       // add a child node, and put some data in it
       c.addChild("/a/b/c").put("key", "value");
    
       // retrieve the child node from the cache
       Node abc = c.getChild("/a/b/c");
    
       // create a new child 
       Node n123 = c.addChild("/1/2/3");
    
       // move nodes around
       abc.move(n123);
       
       abc.getFqn(); // expecting "/1/2/3/a/b/c"
    
       // add a new child, relative to current node
       n123.addChild("/4/5/6").put("key2", "value2");
    
       c.getChild("/1/2/3/4/5/6").get("key2"); // should equal value2
    
       factory.stopCache(c);
    
    

     

    Implementing Habanero

     

    For Habanero, these new interfaces and APIs will be implemented as simple wrappers around the existing, proven TreeCache.  In a later release, possibly JBoss Cache 2.1.0, the internals of how the cache and tree is organised may change, but the interfaces and API defined here will be adhered to.