Bug 266415 - Allow private context collection
Summary: Allow private context collection
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-26 20:33 EST by Ramnivas Laddad CLA
Modified: 2009-02-26 20:33 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.