我們有一些遺留代碼,我試圖找出一種清理方法。我想到的一種解決方案是,我可以根據給定的枚舉值注入自定義處理程序。我可以基於枚舉來限定注入嗎?我想這樣的東西也許(僞代碼)我可以根據Enum限定注射嗎?
@Service(MyEnum.MYVALUE, MyEnum.MYOTHERVALUE) // produces a handler given these enums
public class MyHandler { ... }
@Service(MyEnum.ANOTHERVALUE)
public class AnotherHandler {... }
// .... some mystical way of telling spring what my current enum context is so I can get the right handler
並不是真的暗示'@ Service'參數是一個枚舉,這就是爲什麼我說「僞代碼」,我不確定我要找的代碼是什麼 – xenoterracide 2015-01-16 02:42:48