我使用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)