我使用 Spring 3.1 和 APO(代理)。
提供用作 Pointcat 的注释。在这种情况下,Spring AOP 代理方法“getMergeMappingsAndCals”被标注为 CalendarMappingAnnotation
我的建议是 AfterReturning
方面:
@Component
@Aspect
public class MappingFilterAspect{
/**
*
* @param retVal
*/
@AfterReturning(
pointcut="@annotation(...annotation.CalendarMappingAnnotation)",
returning="retVal"
)
public void calendarMappingFilter(Object retVal) {
}
}
注解:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CalendarMappingAnnotation {
}
用法:
@Component
public class ApoiMappingManagerImpl implements ApoiMappingManager, ApplicationContextAware, Serializable {
...
@CalendarMappingAnnotation
public MergedMapAndCalsBeanCollection getMergeMappingsAndCals(){
...
}
}
配置:
<context:component-scan base-package="...aus.aspect" />
<aop:aspectj-autoproxy/>
堆栈跟踪:
java.lang.ClassCastException: $Proxy43 cannot be cast to ...mapping.cals.ApoiMappingManagerImpl
[JVM ...] at ...helpers.SaveFillRestCalsClientHelper.init(SaveFillRestCalsClientHelper.java:62)
[JVM ...] at ...DispatcherImpl.loadPlugin(DispatcherImpl.java:426)
[JVM ...] at ...dispatcher.DispatcherImpl.run(DispatcherImpl.java:181)
[JVM ...] at ...DispatcherImpl.complete(DispatcherImpl.java:319)
[JVM ...] at ...DispatcherImpl.process(DispatcherImpl.java:259)
[JVM ...] at ...RunnerImpl.run(RunnerImpl.java:88)
[JVM ...] at ...JvmLauncherSlave.main(JvmLauncherSlave.java:40)