在Spring AOP介绍中丢失了原始界面

这是我的Spring AOP配置。

      

 ApplicationContext context = new ClassPathXmlApplicationContext("myApp.xml"); Object myObject = context.getBean("myObject"); if (myObject instanceof OriginalClass) { System.out.println("This is OriginalClass"); } if(myObject instanceof IntroducedInterface) { System.out.println("This is IntroducedInterface"); } 

通过这个介绍,我能够调用IntroducedInterface中的方法。 但是,我无法访问OriginalClass的方法。 在上面的代码片段中,我从未打印出’This is OriginalClass’。

根据“简介”的定义,我理解实现新接口的代理将从OriginalClass扩展并使其’方法也可访问。

我在这里错过了什么吗? 有人可以解释一下原因吗?

PS:以下是Spring in Action(第3版)中描绘的图片。 调用者可以访问接口的“现有方法”和“引入方法”吗?

根据“简介”的定义,我理解实现新接口的代理将从OriginalClass扩展并使其’方法也可访问。

我不确定你从哪里得到那种印象。 默认情况下,所有Spring AOP都是在JDK动态代理上构建的,这只适用于接口。 代理一个具体的课是不可能的。 在Spring中支持使用CGLIB代理来代替类代理,但参考指南不鼓励使用CGLIB代理以支持对接口进行编程以减少耦合。