基于Schema的引入

 


     <aop:declare-parents
                types-matching="com.itany.service.IPersonService+"
                implement-interface="com.itany.service.IIntroduceService"
                default-impl="com.itany.service.impl.IIntroduceServiceImpl"/>

说明:

  • 配置在<aop:aspect>标签下</aop:aspect>
  • types-matching:匹配需要引入接口的目标对象表达式;
  • implement-interface:定义需要引入的接口;
  • default-impl和delegate-ref:定义引入接口的默认实现,二选一

实例:

        ApplicationContext act=new ClassPathXmlApplicationContext("beans.xml");
        IIntroduceService introduceService = (IIntroduceService) act.getBean("personService");
        introduceService.introduce("testintroduce");
        ((IPersonService) introduceService).save();

从理解上来讲,看认为这个配置实现了introduceService继承了personService

posted @ 2016-06-05 10:13  爱上咖啡的唐  阅读(141)  评论(0编辑  收藏  举报