Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] Need help with an advice

hello all,
 i have to modify an existing code to respect some new business rules..
Although i have access to the existing code, i prefer to implement this functionality wiht an aspect (i hate
those if..else etc that just clutter my code..)

i have following situation though (this is just an excerpt, i need to do similar functionality
further later in same method

public class MyBeanX {
    ....

     private void myMethod(String args) {

        Collection items = bean2.getItems(..)
     }
     .....
}


what i need to do is to replace that   Collection items = bean2.getItems() with a different call that does something else (but
 still return a collection)


i have thought to crete somethinglike this...

public aspect MyAspect {

pointcut myMethod() :
        execution (* com.BeanXmy.myMethod(..));
    
    pointcut retrieveCollection() :
        execution (* com.Bean2.getItems(..))
          && within(MyAspect);


    
    void around() : retrieveCollection() {
        System.err.println("There you go.. intercepted as we were expecting..");
    }



looking from cross-references in aspectJ,looks like  something is wrong since the around() advice does not intercept any methods...

can anyone tell me where my aspect code is wrong?

thanks and regards
 marco



Back to the top