AspectJ程序化切入点和周围建议

时间:2018-11-12 10:42:26

标签: java spring frameworks aspectj spring-annotations

我在@Aspect注释类中包含以下代码部分:

@Pointcut("@within(org.springframework.transaction.annotation.Transactional) || @within(org.springframework.stereotype.Controller) || @within(org.granite.messaging.service.annotations.RemoteDestination)")
public void serviceMethod() {
}

@Around("serviceMethod()")
public Object aroundServiceInvocation(ProceedingJoinPoint joinPoint) throws Throwable {
    // my code goes here
}

我必须构建一个框架,在该框架中可以以编程方式添加各种注释(例如,在Pointcut中已在上面添加了Transactional和Controller),并确保所有注释均由相同的通知方法(在我的情况下为“ aroundServiceInvocation”方法)处理。

此框架将用于各种项目,因此我希望我可以做一些类似的方法(该方法将由子项目调用),该方法接收这样的注释类并基本上在(newAnnotationClass)中添加另一个“ ||”。到@Pointcut的值(默认情况下,上面会有@within注释)。

谢谢您的回答!

0 个答案:

没有答案
相关问题