package web.aop; import org.aopalliance.aop.Advice; import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.ClassUtils; import web.service.BaseService; import java.lang.reflect.Method; /** * Created by reborn on 2017/8/3. */ @Component public class Advisor extends StaticMethodMatcherPointcutAdvisor { @Autowired public Advisor(Advice advice) { super(advice); } @Override public boolean matches(Method method, Class aClass) { return BaseService.class.isAssignableFrom(ClassUtils.getUserClass(aClass))&&method.getName().equals("save"); } }