Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: hasmethod/hasfield pointcuts (was: AspectJ + Groovy?)

On Thu, 24 Feb 2005 13:11:32 -0800, Ron Bodkin <rbodkin@xxxxxxxxxxxxxx> wrote:
> (*) I don't think hasfield/hasmethod should be defined as pointcuts since it
> breaks orthogonality. Instead, these ought to be type patterns, just like
> Foo+ or annotation matching for type patterns.

Hi Ron,

Not sure I got what you meant from your comment, but I've implemented
the hasfield/hasmethod poincuts in AW and I have a very clear use case
for them.

I wanted to introduce a mixin in any class containing a method with a
certain annotation. This is the case for genesis (
https://genesis.dev.java.net , still using AW 1.1, going to migrate to
AW 2.0 next week ) CommandResolver interface and its default
implementation. The idea is any class that had a method annotated with
@Remotable/@Transactional had this interface introduced in order to
support two core genesis features, transparent remoting and
transactional support.

Why not requiring the classes to implement a marker interface or be
annotated at the class level? Well, it feels strange. If a class has
one or more methods containing one of these annotations, there is no
point in requiring it to follow yet another pattern just for the sake
of.

Besides that, this kind of pointcut is quite useful for situations
when you want to use AOP in existing classes without changing them.
Not always these classes inherit from the same class, implement a
common interface or are in the same package, but they may share some
properties, for example. I can see these pointcuts being useful for
dependency injection as well, requiring only POJOs to work.

Regards,
Michael Nascimento Santos
https://genesis.dev.java.net/


Back to the top