Configure dynamic proxy with Annotation

Source: Internet
Author: User

/**
* Face-cutting class: The method to insert the methods in the current class to the target object
*
* @ Author ASUS
*
*/
@ Aspect
// Indicates the partition class.
Public class proxyobj {
//// @ Before indicates the pre-notification. Call this method before executing the target method.
/// * COM. Lovo. Service. *. * (..) indicates the path of the target method.
/// The first * indicates that the return type of the method is of any type.
/// Com. Lovo. Service is the package name com. Lovo. Service.... It is the specified package and the specified sub-package.
/// *. * Indicates all the methods of all classes in the package. S *. * indicates all the methods of the classes starting with S in the package.
//// (..) The parameters in this method are arbitrary parameters.
/// @ Before ("execution (* COM. Lovo. Service .*.*(..))")
/// Public void ready (){
//// System. Out. println ("to start ordering... ");
////}
/// @ Afterreturning ("execution (* COM. Lovo. Service .*.*(..))")
/// Public void end (){
/// System. Out. println ("invoice .. ");
////}
//// Surround Annotation
// @ Around ("execution (* COM. Lovo. Service .*.*(..))")
// Public object around (proceedingjoinpoint point ){
// System. Out. println ("Get money ");
// Try {
/// Execute the target method. This method returns the value after the target method is executed.
// Object value = point. Proceed ();
// System. Out. println ("Tea top ");
// Return value;
//} Catch (throwable e ){
/// Todo auto-generated Catch Block
// E. printstacktrace ();
//}
// Return NULL;
//}

@ Afterthrowing (value = "execution (* COM. Lovo. Service. *. * (..)", throwing = "er ")
Public void throwsmethod (joinpoint point, exception ER ){
// Obtain the target object
Object OBJ = point. gettarget ();
// Obtain the target object type
String classname = obj. getclass (). getname ();
// Obtain the target method name.
String methodname = point. getsignature (). getname ();
System. Out. println ("execution" + classname + "" + methodname + "method, throw" + Er. getmessage ());
}

}

Configure dynamic proxy with Annotation

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.