Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Capturing calls to annotated collections

Hi Andy,

thanks for the information, helps a lot not to dig any further in the
wrong direction. I followed your advice about capturing "this" and
"target" and it works pretty well with reflection and a
field/annotation-cache to speed up operations.

Thank you,
Maik

On Mon, Jul 25, 2011 at 17:33, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
> Hi Maik,
>
> Unfortunately you can't currently say that in AspectJ.  The best you
> could do is determine it yourself: advise the collection operations,
> and then in the advice check if the target of the call has the
> annotation.  Maybe use a cache of objects you know are/arent annotated
> to avoid ongoing reflection (getAnnotation) costs.
>
> cheers
> Andy
>
> On 22 July 2011 01:12, Maik Jablonski <maik.jablonski@xxxxxxxxx> wrote:
>> Hi,
>>
>> I'm currently working on a project which needs to advice collection
>> operations where the collections are marked via an annotation on field
>> level. Here's an example:
>>
>> public class Parent {
>>
>>        @Config(constraints="...")
>>        private List<Child> children = new ArrayList<Child>();
>>
>>        ...
>>
>>        public void addChild(Child child) {
>>                children.add(child);
>>        }
>> }
>>
>> I now want to create some kind of pointcut for #addChild() (or
>> children.add()) based on the @Config annotation for the collection
>> (and not on the naming of the methods in the parent-class). I can
>> create a get-pointcut for the "children"-field and also one for
>> calling all operations on collections in general, but I need something
>> which combines these two pointcuts: advice all operations on
>> collections which are annotated on field level.
>>
>> Is this possible at all? Or does someone has a good idea which might
>> as workaround?
>>
>> Cheers,
>> Maik
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top