English 中文(简体)
如果 @Cacheble Spring AOP 应用在同一函数上, AspectJ 方面不会被截取
原标题:AspectJ aspect is not being intercepted if @Cacheble Spring AOP applied on the same function

我定义了两个方面 功能上 一个@control类。

一个是 @Cacheble (Ehcache Spring 批注, 使用 Spring AOP) 。

另一个是计算执行时间的周围建议。 这是 AspectJ 汇编时间的方面 。

When the method is called for the first time, both of the aspect is being executed. But, for all the subsequent call, only @Cacheble aspect is intercepted. Another advice (that computes execution time) is not being intercepted. Why is this not being intercepted? I ve set @Order for both aspects, but that doesn t help.

计算执行时间的第二个方面如下:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Order(value = 0)
public @interface MonitorPerformance {   
}

Dispathcher-servlet.xml has
<ehcache:annotation-driven create-missing-caches="true" cache-manager="ehCacheManager" order="1"/> Looking forward to your suggestions.

谢谢

问题回答

要执行的方方面面,您必须使用从容器中获取的方法来调用。是这种情况吗?

如果这是在弹簧 AOP 中编译时间 AspectJ 时, 它将无法在缓存结果上执行编译的方面。 编译分类的字节代码直接围绕方法被注入。 如果这是代理并返回, 而不使用方法( 也就是可以缓存的方法), 那么, 后一个方面自然不会被调用 。





相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签