Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Annotations AspectJ questions

Hi all!

Another newbie question.  After scanning the docs, I'm a little confused
on the capabilities of annotations.  I'm trying to employ aspects as a
part of a broader project, some of whom's members are quite suspicious
of granting the ability to crosscut their code without they're explicit
knowledge embodied in their code.  Equally,  I've been required to use
the annotation style for my poincuts and advice as the result of the
build process issues around utilizing the aspectJ syntax directly. 

I've successfully used the  annotation style for the pointcuts and
advice declarations themselves, but I'm teetering on the brink of
understanding as to the use of annotations in the body of the code that
is to be cut.  Before I proceed down this road, I wanted to confirm that
one can concurrently employ annotations for both the advice declaration
as well as pointcut discrimination.  So given something that currently
looks like this:

class C {
    public void doIt() {...}
}

@Aspect class A {
    @Before("call(void C.doIt())") { ... }
}

Is there a prescription (at least by enforcing conventions) for being able to annotate Class C,such that: 

A) The developer of C will know that an aspect has been applied 
B) The developer of C will know (and by convention limit) the style of aspect applied 
C) The developer of A can not add a pointcut unbeknownst to the owner of C (without at least violating conventions)

thus if I had created a BeforeOnly & AfterOnly annotation: 
class C {
    @BeforeOnly @AfterOnly
    public void doIt() {...}
}

What would the syntax for the aspect look like?
@Aspect class A {
    @Before("???????") { ... }
}

Would there be a methodology to actually restrict the application of an @AfterReturning? 
I recognize that some of these notions might be outside the spirit of AOP/aspectJ, but having to deal with real world resistence to AOP is a part of the equation.

Thanks in advance for the 'advice'  ;-) !

=Ron=







Back to the top