Spring AOP的:@annotation(注释) [英] Spring AOP: @annotation(annotation)

查看:935
本文介绍了Spring AOP的:@annotation(注释)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我(当然)试图维持使用多种结构,我不知道那个好项目。在试图找出在Spring AOP的使用过程中,我碰到的方法来了以下注释:

I am (of course) trying to maintain a project using many constructs I don't know that well. In the course of attempting to figure out the AOP use within Spring, I came across methods with the following annotation:

@Around(值=@annotation(注释))

@Around(value = "@annotation(annotation)")

所以@Around意味着我们正在做的AOP的方法切入点的左右的版本,我理解这一点。我不知道什么其他部分的含义。 Spring文档给出了以下内容:

So @Around means we're doing the 'around' version of the method pointcut in AOP, I understand that. I don't know what the other part means. The Spring documentation gives the following:

@annotation - 限定匹配特定的连接点,其中的主题
  连接点(在Spring AOP的时候方法的执行)已定
  注释

@annotation - limits matching to join points where the subject of the join point (method being executed in Spring AOP) has the given annotation

我不知道这意味着什么 - 使用Spring AOP的执行方法听起来像建议的方法,但我不知道我(或Spring)如何找出哪些被建议的方法。这听起来好像是有给出注释的方法,但如果是这样,什么注释被赋予了?

I don't know what that means - "method being executed in Spring AOP" sounds like the advised method, but I don't know how I (or Spring) figure out which methods are being advised. It sounds like it is the methods that have "the given annotation", but if so, what annotation has been given?

由这个注释建议什么样的方法?而还有什么意思呢?

What methods are advised by this annotation? And what else does it mean?

推荐答案

如果你有以下的Spring bean:

if you have the following Spring Bean:

@Component
public class foo {

    @com.pkg.Bar      
    void fooMe() {
    }
}

那么以下建议:

@Around("@annotation(com.pkg.Bar)")

将调用各地 fooMe 拦截器(或 @Bar 注释其他Spring Bean的方法)

Will invoke the interceptor around fooMe (or any other Spring bean method annotated with @Bar)

@Transactional 注释是一个很好的例子。

The @Transactional annotation is a good example

这篇关于Spring AOP的:@annotation(注释)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆