Java:带注释的注释(和传递值)

时间:2010-10-22 08:20:47

标签: java spring annotations

我有一个注释,其中包含其他几个注释,就像这里的注释一样:

@Component // Spring Component
@Interface OsgiService { boolean isFactory() }

意味着所有使用@OsgiService注释的类都应自动注释为@Component。哪个工作正常。

现在,我想添加另一个注释,其参数取决于isFactory的{​​{1}}参数。

@OsgiService

哪个不起作用。但是,由于注释的@Component // Spring Component @Scope(isFactory() ? "prototype" : "singleton") @Interface OsgiService { boolean isFactory() } 属性需要是静态值,所以不应该有这样的东西吗?

1 个答案:

答案 0 :(得分:3)

我认为这不可能。

您可以创建两个注释:@OsgiService@OsgiServiceFactory