标签:color pid opened before ofo art advice object repo
1.前置增强
public interface ISomeDAO { public void doSome(); } public class ISomeDAOImpl implements ISomeDAO { public void doSome() { System.out.println("国庆节"); } }
public interface ISomeService { public void doSome(); } public class ISomeServiceImpl implements ISomeService{ public ISomeDAO getDao() { return dao; } public void setDao(ISomeDAO dao) { this.dao = dao; } private ISomeDAO dao; public void doSome() { dao.doSome(); } }
public class MyBoforeAdvice implements MethodBeforeAdvice { public void before(Method method, Object[] objects, Object o) throws Throwable { System.out.println("日志记录"); } }
@Test public void test01(){ ApplicationContext context=new ClassPathXmlApplicationContext("applicationContextaop.xml"); ISomeService service = (ISomeService) context.getBean("someService"); service.doSome(); }
标签:color pid opened before ofo art advice object repo
原文地址:http://www.cnblogs.com/with-lj/p/7635282.html