Chinaunix首页 | 论坛 | 博客
  • 博客访问: 382353
  • 博文数量: 80
  • 博客积分: 2682
  • 博客等级: 少校
  • 技术积分: 907
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-16 09:55
文章分类

全部博文(80)

文章存档

2012年(80)

分类: 系统运维

2012-12-12 15:51:17

/**  
 * 切面
 */
@Aspect        //  在切面类 前
public class TestAspectJ {
/**  
* 切入点
*/
    @Pointcut ("execution(* com.software.*.get*(..))")         // get 开头的方法   
private void anyOldTransfer(){}           // 不进入此方法
    
    
    /**  
*  通知
*/
      @AfterReturning("anyOldTransfer()")          //   anyOldTransfer()  名称对应 切入点
//    @Before("execution(* com.tfsoftware.*.*())")           //  第二种方式  直接  自己定义 如何切入
    public void test(){
     System.out.println("test()");
    }
}


application.xml
         
   

二 :配置方式
   
xmlns=""
xmlns:xsi=""
xmlns:aop=""
xsi:schemaLocation=" /spring-beans-2.0.xsd
/spring-aop-2.0.xsd">

                    通知类
 
    
    
       <aop:aspect  id="aspectDemo" ref="adviceDemo">
             <aop:pointcut  id="pointCutID" expression="execution(* com.tfsoftware.*.get*(..))"/>       切入点
             <aop:before method="test"  pointcut-ref="pointCutID"/>                               调用通知类方法名 test
            
      
    

阅读(533) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~