Fine-grained ejb3 SFSB
ben.wang Feb 17, 2006 12:02 AM(I have written this initial spec a while ago and checked into cvs. Now, I am publishing it here to solicit further comments. If resource allocation is not an issue, we'd start the implementation starting March.)
Goal: To enable fine-grained replication in JBoss EJB3 SFSB state replication. Currently, we support ejb3 SFSB replication using JBossCache. E.g., a user can annotate her SFSB with @Clustered and it will be replicated automatically. But it is replicated in a whole-sale fashion.
User, however, will need to do isModified() API to have fine-grained control of the bean replication. By using TreeCacheAop (aka POJO Cache), there will be no need of user implementing isModified flag. POJO Cache will track the field replication automatically (if there is one).
There is another side benefit that the new fine-grained replication can support object relationship inside the SFSB fields.
Note that we will support fine-grained http replication officially in 4.0.4 release. So some of the enhancement there for JBossCache will carry over here, e.g., activateRegion to support ejb lifecycle (deploy/undeploy) and also marshalling for classloader scope.
Steps: Here are the main tasks needed.
1. There is an additional annotation @PojoCachable that declares this SFSB to be instrumented. We need this for aop to aspectize the SFSB.
2. (Optional?) Determine a consistent annotation flag, such as "FIELD" tag inside the clustering annotation, e.g., @Clustered(ReplType=FIELD) (with ReplType default being SESSION)
3. Requires JBossCache 1.3 that supports 1.5 JDK with annotation
4. Depending on whether "FIELD" is specified, we should do two different paths:
a) If set, pojo cache API is used (putObject and removeObject). We need to instrument the SFSB first either on the fly (based on PojoCacheable annotation), LoadTime mode, or it can be pre-compiled, CompileMode. Then, we need to do putObject and removeObject for pojo cache operation instead of regular ones. Maybe we should use different SessionContext that stores the SFSB. One for regular and the other for FieldBased, like we did with Session in Tomcat.
b) If not, regular cache API is used (e.g., pure, remove). Then replication is "SESSION" based. User will need to implement isModified for fine-grained control.
5. For fine-grained, it should mimic the implementation in http session, e.g., issues of marshalling, etc.
6. Use StatefuleReplicationInterceptor for batch tx control. The counter part of ClusteredValve in Tomcat.
7. Configuration. Should not change much. User will need to annotate by itself on the SFSB POJOs.
Issues: There are couple possible issues need to be resolved.
1. passivation. Currently Bill has another passivation layer on top of JBossCache. What is the impact?
2. SFSB lifecycle. This should be supported already with the latest JBossCache, e.g., activateRegion for deploy/undeploying