Spring's Pointcut (example of a two-static pointcut)

Source: Internet
Author: User
Tags aop

Take Jdkregexpmethodpointcut as an example to show how to use a static pointcut using a complete example (see routine 4.3 for the complete engineering code). In engineering we define a people class and a slice, and link them to the spring XML configuration file. When the People object executes the method defined in our pointcut, the logerpeople will give the appropriate hints.

Create a new project aop_test4.3, add the Spring Development library, and create a new aop.test package.

Create the target class people, which has speak, Running, loving, died four member methods. The code is as follows:

Code

/**
*
*/
package aop.test;
/**
* @author zhangyong
*
*/
public class People{
  // 讲话
   public void speak() {
     System.out.println("Hello,我是People!");
   }
   // 跑步
   public void Running() {
     System.out.println("我在跑……跑…………逃……");
   }
   // 恋爱
   public void Loving() {
    System.out.println("我在和MM恋爱……别来打搅我!");
   }
  // 死亡  
   public void died() {
     System.out.println("完了,我死了");
   }
}

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.