Org.aspectj.lang.joinpoint-Chinese Brief API and Pointcut expression expressions

Source: Internet
Author: User

ASPECTJ uses the Org.aspectj.lang.JoinPoint interface to represent the target class connection point object, which, if it is a wrapping enhancement, uses Org.aspectj.lang.ProceedingJoinPoint to represent the connection point object, which is the sub-interface of the joinpoint. Any enhancement method can be accessed by declaring the first entry parameter as Joinpoint access to the connection point context. Let's take a look at the main methods of these two interfaces:
1) joinpoint
java.lang.object[] Getargs (): Gets the parameter list of the connection point method runtime;
signature getsignature (): Gets the method signature object of the connection point;
java.lang.object gettarget (): Gets the target object where the connection point resides;
java.lang.object getthis (): Gets the proxy object itself;
2) Proceedingjoinpoint
Proceedingjoinpoint inherits the Joinpoint Subinterface, which adds two methods for executing a connection point method:
java.lang.object proceed () throws Java.lang.Throwable: Performs the method at the connection point of the target object by reflection;
java.lang.object Proceed (java.lang.object[] args) throws Java.lang.Throwable: Performs the method at the target object connection point by reflection, but replaces the original entry with the new entry parameter.

Note: proceedingjoinpoint: Use this class to take processing logs and only handle surround notifications

<!--open an AOP interception function, Proxy-target-class: is used to control the injection of the implementation class or interface, the default is False indicates that only the interface can be injected, true: it is possible to use the class to inject-&LT;AOP: Aspectj-autoproxy proxy-target-class= "false"/> <aop:config> <!--Declare a slice---<aop:aspect id= "Testexcuteaspect" ref= "Testexcute" > <!--declare an outfit, when does the log processing--<!--declares a pointcut, expression: the first * means: wildcard, which indicates the return Back to any type, the second * means: wildcards, which represent any class under this package, the third * means: wildcards, which means that methods under this class can have 0 or more Parameter (..) : Represents all sub-packages under this package--<aop:pointcut expression= "Execution (* com.ckpt.logPackage .*.*(..))" Id= "Logtest"/> <aop:around method= "GetLog" pointcut-ref= "Logtest"/> </aop:aspect> </aop:config&gt

; <bean id= "Testexcute" class= "Com.ckpt.logPackage.TestExcute" scope= "prototype" ></bean> <bean id= "

Test "class=" Com.ckpt.Action.Test "scope=" prototype "> <property name=" test2 "ref=" Test2 "></property> </bean> <beanId= "Test2" class= "Com.ckpt.logPackage.Test2" scope= "prototype" ></bean>
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.