Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Pointcut question to simply subaspects

You are right, Andy!

I haven't yet come across the need for type params on aspects, but now I have.  My design now takes another beautiful step toward simplicity!

Thanks for that gem!


On Mon, Oct 7, 2013 at 5:18 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
Wonder if there is a way with generics - have you tried it? (parameterized super aspect). Have the pointcut refer to generics in the supertype then fill it in in the subaspect?

In some ways this sounds like a variant of named type patterns, where something common across a set of pointcuts can be pulled out and defined as a single thing. Named signature patterns (if we had those) would get you some of the way but because you are using method and field joinpoints which have different signatures it wouldn't completely solve it.  Actually I'm convincing myself more and more that generics is the right answer. I just can't recall the extent to which type variables are allowed in pointcuts.

Andy


On 7 October 2013 22:56, Matthew Adams <matthew@xxxxxxxxxxxxxxx> wrote:
If I have a pointcut like the following:

public aspect TypeSpecificAspect {
  public pointcut accessingTarget():
    call(Person+.new(..)) || call(* Person+.*(..)) || get(* Person+.*) || set(* Person+.*);
}

I'd like to push the pointcut up into a superaspect so that all the subaspect would have to supply is the actual type _expression_ (in this case, Person).  Something like the following:

public aspect Super {
  public abstract pointcut theType();
  public pointcut accessingTarget(): /* demonstrating the point -- doesn't compile */
    call(thisType()+.new(..)) || call(* thisType()+.*(..)) || get(* thisType()+.*) || set(* thisType()+.*);
}
=====
public aspect Sub extends Super {
  public pointcut theType():  Person;
}

How can I achieve what I hope you understand I mean?

Thanks,
Matthew

_______________________________________________
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




--
mailto:matthew@xxxxxxxxxxxxxxx 
skype:matthewadams12
googletalk:matthew@xxxxxxxxxxxxxxx
http://matthewadams.me
http://www.linkedin.com/in/matthewadams

Back to the top