假設我有一顆豆對話框,與高度和寬度屬性:在運行時應用動態屬性到Bean
public class DialogBox {
int x;
int y;
...
}
在我的applicationContext.xml我會定義屬性合理的默認值:
<bean id="dialogbox" class="DialogBox">
<property name="x" value="100"/>
<property name="y" value="100"/>
</bean>
我們有多個使用dialogBox bean的客戶端,每個客戶端都需要x和y的自定義值。一條路線,我們有討論是具有多個屬性文件,一個爲每一個客戶,並讓客戶端ID映射到正確的文件,例如客戶端123將映射到dialogbox_123.properties:當
在運行時dialogbox_123.properties:
x=200
y=400
然後bean被請求,Spring會查看客戶端是否存在自定義屬性文件,並使用這些屬性,否則使用默認值。我知道PropertyOverrideConfigurer,但AFAIK只有在上下文啓動時才起作用,因此不適用於我們的目的。春天有現成的設施來達到這個目的嗎?或者有人可以推薦另一種方法嗎?
另請參閱http://stackoverflow.com/questions/534030/reloading-refreshing-spring-configuration-file-without-restarting-the-servlet-co – Vadzim 2014-08-29 16:14:22