Join points occur as a program executes. Fields are set, methods are called,
exceptions are handled - these are all join points.  You define a pointcut
to choose which join points you are interested in.  A pointcut:

pointcut p(): set(int *);

will match upon all the join points where a field of type 'int' is being
set.

A pointcut is a language construct in an AspectJ program.  Named pointcuts
can be used

pointcut p(): set(int *);

before(): p() {
}

OR you can just use them inline in the advice signature:

before(): set(int *) {}

But you gain something in being able to name them - you can use a name that
will mean something in 6months time when you look back at the code and
wonder what on earth your complex pointcut was trying to match.  Named
pointcuts are also used in aspect libraries:

abstract aspect Tracing {
  abstract pointcut scope();

  before(): scope() { System.out.println("Entering "+thisJoinPoint);}
  after(): scope() { System.out.println("Exiting"+thisJoinPoint);}
}

aspect MyApplicationTracing extends Tracing {
  pointcut scope(): within(com.mycode..*);
}

Andy.



2008/12/10 Jason Weinstein <[EMAIL PROTECTED]>

>  Thanks Andy.
>
> So where does the joinpoint fit into the picture below?? Is a joinpoint the
> runtime location of a pointcut? Kind of like an instance of a class
> (joinpoint) vs. a class definition (pointcut)??
>
> Andy Clement wrote:
>
> Hi,
>
> 2008/12/9 Jason Weinstein <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>:
>
>
>  What are the correct names for these pieces
>
> Example
>
>   public pointcut NormalizedMessage_new() :
>       call(NormalizedMessage+.new(..));
>
>   Object around() :
>       NormalizedMessage_new() {
>       logEntering(thisJoinPoint);
>       return proceed();
>   }
>
> 1. (pointcut - this one i can do)
>   public pointcut NormalizedMessage_new() :
>
>
>
>  It is a named pointcut.  it has a pretty poor name though...  I'd
> prefer something like
> constructionOfNormalizedMessage() perhaps, something more readable.
> The ability to name the pointcuts is a powerful feature that helps you
> understand what the pointcut is trying to achieve - don't just
> translate the pointcut body directly into a name.
>
>
>
>  2.
>       call(NormalizedMessage+.new(..));
>
>
>  This is a kinded pointcut designator, the one named 'call' - which
> selects call join points.  Typically you would include a scoped
> pointcut designator, like within() or withincode() to limit where you
> are looking for the call join points, but it is not always required.
> You may also include some of the binding pointcut designators to
> expose context from the join point (you might use args() to exposed
> the arguments at the call).
>
>
>
>  3.
>   Object around() :
>       NormalizedMessage_new() {
>       logEntering(thisJoinPoint);
>       return proceed();
>   }
>
>
>  This is around advice.  If you had a better pointcut name the
> declaration may read a little more friendly:
>
> Object around(): constructionOfNormalizedMessage() {
>
> "around constructionOfNormalizedMessage"
>
>
>
>  4a.
>   Object around() : NormalizedMessage_new()
>
>
>  advice declaration/signature.
>
>
>
>  4b.
>       logEntering(thisJoinPoint);
>       return proceed();
>   }
>
>
>  advice body.  This around advice body uses a proceed to invoke the
> originally matched join point.
> _______________________________________________
> aspectj-users mailing [EMAIL 
> PROTECTED]://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to