Version 7

    PojoCache 2.0 design

     

    This is the design page for the upcoming PojoCache 2.0 release. This release has significant refactoring on couple fronts:

     

    • New APIs. We have consolidated and renamed the PojoCache interface. It is much more compact and clean now.

     

    • Use underlying Cache implementation as delegate instead of inheritance (we use the Cache SPI for specific behavior). As a result, it is decoupled from the generic Cache operation. User still can obtain the underlying Cache API if needs to though.

     

    • New architecture with Aop-based interceptor stack. This enables different API to possilby have different interceptor stack for different behaviors. It also allows user of PojoCache to add customized interceptor. It is configurable from jboss-aop.xml.

     

    • Pojo-based event listener. Has a new interface, PojoEventListener that use can subscribe to listen for POJO event or field updates.

     

    • New internal object mapping that allows more canonical locking behavior, especially when there is multiple or cyclic object graph.

     

    • Supports only JDK5.0. Uses the JDK5.0 annotation only.

     

    APIs

     

    Attached is the class diagram for the new APIs in PojoCache 2.0:

     

     

    Code snippets

     

    Below is a sample code that illustrates how to use PojoCache 2.0.

     

       String configFile = "local-service.xml";
       PojoCache pc = PojoCacheFactory.createInstance(cofigFile);
    
       Person p = new Person();
       p.age = 21;
       ...
    
       String id = "joe";
       cache.attach(id, p); // Note that we don't associate formally with Fqn anymore.
    
       ...
      
       Person ap = cache.find(id);
    
       cache.detach(id);
    

     

    Interceptor stack

     

    This part is still moving since the on-going implementation. But currently the 3 major interceptor stack are:

     

    attach

     

       <stack name="Attach">
          <interceptor-ref name="Start"></interceptor-ref>
          <interceptor-ref name="CheckId"></interceptor-ref>
          <interceptor-ref name="MarshallNonSerializable"></interceptor-ref>
          <interceptor-ref name="Tx"></interceptor-ref>
          <interceptor-ref name="TxLock"></interceptor-ref>
          <interceptor-ref name="TxUndo"></interceptor-ref>
       </stack>
    

     

    detach

       <stack name="Detach">
          <interceptor-ref name="Start"></interceptor-ref>
          <interceptor-ref name="CheckId"></interceptor-ref>
          <interceptor-ref name="Tx"></interceptor-ref>
          <interceptor-ref name="TxLock"></interceptor-ref>
          <interceptor-ref name="TxUndo"></interceptor-ref>
       </stack>
    

     

    find

       <stack name="Find">
          <interceptor-ref name="Start"></interceptor-ref>
          <interceptor-ref name="CheckId"></interceptor-ref>
       </stack>