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("完了,我死了");
}
}