Bug 266415

Summary: Allow private context collection
Product: [Tools] AspectJ Reporter: Ramnivas Laddad <ramnivas>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ramnivas Laddad CLA 2009-02-26 20:33:37 EST
We should support marking certain context as private i.e. not exposed to advice or other pointcuts. See http://abc.comlab.ox.ac.uk/extensions for a syntax possibility.

A couple of use cases:

1. Conditional pointcut

pointcut largeWithdrawl() : private(balance) : execution(* Account.debit(float) && args(amount) && if(amount > LARGE_AMOUNT_THRESHOLD);

2. Computing the cache key
Consider a design approach similar to that specified in #266381, where the base aspect doesn't dictate the use of annotation-based pointcut. I will like the pointcut to simply expose the computed key

aspect AbstractCaching {
    public abstract pointcut cached(String key);

    after(String key) returning(Object cachedObject) : cached(key) {
       ... caching logic
    }
}

aspect AnnotationDrivenCaching extends AbstractCaching {
    pointcut cached(String key) :
        private(Cacheable cacheable) :
            execution(@Cacheable * *(..)) && @annotation(cacheable)
             && let(key = computeKey(cacheable.keyScript));
}

2. Transaction management

    Base aspect:
    public abstract pointcut transactional(TransactionAttribute ta);

    Annotation-based subaspect:
    pointcut transactional(TransactionAttribute ta)
       : private(Transactional tx) 
           : execution(@Transactional * *(..)) 
             && @annotation(tx) 
             && let(ta, computeTa(tx));

    Mapping based subaspect:
    pointcut transactional(TransactionAttribute ta)
       : execution(* ajia.service.*.*(..))
         && let(ta, computeTa(thisJoinPoint));

It seems that this feature should be implemented along with the let() pointcut in #266381. Most use case I see seems to need both.