Pointcuts and aspect-oriented programming

How to use pointcuts in an aspect-oriented programming language to add functionality to an existing program?

As far as I understand, from this Wikipedia article - http://en.wikipedia.org/wiki/Pointcut

Streams are placed at a specific place in a piece of code, and when that point is reached, based on a pointcut estimate, more code can be executed at a specific point somewhere in the code, based on an estimate of the slice of the points. Is this the correct understanding?

If so, this will add functionality because the programmer can execute another piece of code based on this evaluation.

+3
source share
2 answers

, , . AspectJ:

class MyAspect
{
    @Around("execution(public * my.service.package.*(..))")
    public Object aroundAdvice(JoinPoint jp)
    {
       // start timer
       Object o = jp.proceed();
       // stop timer, etc.
       return o;
    }
}

"execute (public * my.service.package. * (..))" - pointcut: , ( ).

+2

Pointcut - , ( "" , , ) ( , , , ).

pointcut , , (, true/false ).

0

Source: https://habr.com/ru/post/1779075/


All Articles