2010-10-22 187 views
2

我有一個註釋,不包括其他幾個註解,很像這樣一個位置:的Java:註解註釋(和值傳遞)

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

這意味着與@OsgiService註釋的所有類應自動也被標註爲@Component。哪些工作正常。

但是,現在我想添加另一個註釋,它的參數取決於isFactory參數@OsgiService

@Component // Spring Component 
@Scope(isFactory() ? "prototype" : "singleton") 
@Interface OsgiService { boolean isFactory() } 

哪一個不行。但是,作爲註釋的isFactory屬性需要是一個靜態值,難道不應該有這樣的東西嗎?

回答

3

我不認爲這是可能的。

您可以創建兩個註釋:@OsgiService@OsgiServiceFactory