我有一个基类,有几个扩展它的派生类。 我想将我的Spring AOP Aspect仅限制为超类,以便仅为它创建AOP代理,而不是为派生类创建。
我尝试按如下方式定义切入点:
@Pointcut("execution(* com.blah.platform.persistence.generic.GenericDaoImpl.*(..))")
public void withinGenericDao() {}
其中GenericDaoImpl是超类。
我仍然可以看到代理也是为派生类生成的:
2011-11-24 18:00:28,616 ContainerBackgroundProcessor[StandardEngine[Catalina]] DEBUG [JdkDynamicAopProxy] Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.blah.admin.persistence.impl.CircuitDAOImpl@5c81cf46]
2011-11-24 18:00:28,638 ContainerBackgroundProcessor[StandardEngine[Catalina]] DEBUG [JdkDynamicAopProxy] Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.blah.admin.persistence.impl.CategoryDAOImpl@55eef3c1]
2011-11-24 18:00:28,645 ContainerBackgroundProcessor[StandardEngine[Catalina]] DEBUG [JdkDynamicAopProxy] Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.blah.admin.services.circuit.impl.CircuitsServiceImpl@d50112d]
2011-11-24 18:00:28,953 ContainerBackgroundProcessor[StandardEngine[Catalina]] DEBUG [JdkDynamicAopProxy] Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.blah.events.persistence.impl.EventsDAOImpl@4222023a]
2011-11-24 18:00:29,030 ContainerBackgroundProcessor[StandardEngine[Catalina]] DEBUG [JdkDynamicAopProxy] Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.blah.events.persistence.impl.PrototypesDAOImpl@d3bef50]
我认为只有当切入点定义如下时才会发生这种情况:
execution(public * com.mycompany.myservice.MyService+.*(..))
有什么想法吗?
答案 0 :(得分:1)
您可以将PointCut
定义从execution
更改为within
吗?我过去取得了成功。 (请注意,语法略有不同。有关详细信息,请参阅Spring AOP参考文档。)
e.g。 @PointCut("within(com.blah.platform.persistence.generic.GenericDaoImpl)")
答案 1 :(得分:0)
子类继承父类的公共方法和属性,包括注释。