Home

Pointcuts

Pointcuts are a core concept in aspect-oriented programming. They define where advice should be applied by selecting a set of join points in a program’s execution.

Join points are well-defined moments during execution, such as method calls, method executions, field access, object

Pointcuts are expressed with designators that match patterns of join points. Common designators include execution and

Pointcuts can be combined using logical operators (and, or, not) to form more precise predicates, for example

Weaving integrates the aspect code with the base code. This can occur at compile time, load time,

Pointcuts are central to frameworks like AspectJ and Spring AOP. They enable powerful separation of concerns

construction,
or
exception
handling.
A
pointcut
is
a
predicate
that
matches
a
subset
of
these
join
points.
call
for
method
execution
and
calls,
get
and
set
for
field
access,
within
and
this
for
scoping,
target
for
the
object
on
which
a
join
point
operates,
and
args
for
the
types
of
arguments.
Annotations
and
wildcard
patterns
are
also
supported,
such
as
execution(*
com.example.service..*(..))
to
match
any
method
in
a
package,
or
@annotation(foo)
to
match
points
annotated
with
a
specific
annotation.
combining
patterns
or
excluding
certain
packages.
In
practice,
pointcuts
are
linked
to
advice
blocks
that
run
before,
after,
or
around
a
matched
join
point.
or
runtime,
depending
on
the
framework.
The
primary
goal
is
to
modularize
cross-cutting
concerns
such
as
logging,
security,
transactions,
and
performance
monitoring,
without
duplicating
code
across
modules.
but
can
increase
complexity,
so
clear
documentation
and
careful
design
are
important.