Aspectj learning notes (three)

xiaoxiao2021-03-05  22

Aspectj mainly has three places: Jionpoint Pointcut Advice

Below, the reflection starts from the point of PointCut and the relevant context:

ThisjoinPoint.getsignature (): thisjoi, npoint is a class defined by the AspectJ context: Access the incision environment, the result of the output is the method of connection point, such as String Test.getName ())

PointCut UNIQUELOG (String S): Call (String) && args (s); before (string s): unique (s) {system.out.println ("passed value =" s);}: You can access the parameters of the method in the main Java file, and the variables in 4 places must be consistent.

The following severings about accessing the context environment

Import org.aspectj.lang. *; import org.aspectj.lang.reflect. *;

Public aspect DVDaspect {PointCut Field (): Call (): before (): Field () {Object [] args = thisjoinpoint.getargs (); sourgocation sl = thisjoinpoint.getsourceLocation ();

System.out.println (thisjoinPoint.getkind ());

Class theclass = (class) sl.GetwithIntype (); system.out.println (theclass.tostring ());

For (int i = 0; i

Below is the cut surface in the class.

Public aspect arrayaspect {pointcut array (): set (public string array.test);

Before (): array () {system.out.println ("VALUES ARRAY CHANGED");}}

转载请注明原文地址:https://www.9cbs.com/read-37385.html

New Post(0)