Spring配置自動代理、注釈実現AOP

2170 ワード

appication Contect.xml設定

 
        
        
        
        
    
    
        
        
    
package net.xinqushi.aop;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect//  
@Component//new      
public class Log {
//         (myBefore)               ,      ,           
    @Before("execution(public boolean net.xinqushi.service.impl.UserServiceImpl.checkLogin(net.xinqushi.model.User))")
    public void myBefore(){
        System.out.println("    .........");
    }
//         (myAfter)               
    @AfterReturning("execution(public boolean net.xinqushi.service.impl.UserServiceImpl.checkLogin(net.xinqushi.model.User))")
    public void myAfter(){
        System.out.println("    .........");
    }
}