Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] point cut on:: Annotated field + new ArrayList()

Hi Ravi,

I believe that your problem is that the return type for your around advice is ArrayList, whereas it should be Object.

The reason is that since you are not specifying that the field being set must be of type List+, the pointcut can theoretically be applied to any field of any type.  Hence, the incompatible return type error.

Hope this helps,
--a

On Mon, Jun 22, 2009 at 10:58 AM, Ravi Chandra <ravi.eze@xxxxxxxxx> wrote:
Issue:
1. I have a variable defined with annotation
2, This variable is being assigned to an ArrayList

Now, i want to intercept this call and execute a logic by AOP. In the interception
1. I should be able to access the annotated value
2. Return a new object called MYLIst

The below mail therad is abt the same,
1. If i use set(* *List) then i cant access the annotation
2. If i use the below its (in eclipse) is throwing compilation errors

    pointcut listCut(LIST in) : set(@LIST* (*) * ) && @annotation(in);

    ArrayList around( LIST in) :listCut(in){
        System.out.println("**annotation " + thisJoinPoint + " ann:"
                + in.value());
        return new MyList();
    }

The java class i want to intercept::

    public static void main(String[] argv) {
        UserAttributes u = new UserAttributes();
        u.alias = new ArrayList();
    }

Any ideas where i am going wrong? Please help.


Back to the top