所以,我有 springDM 托管属性
<beans:beans xmlns="http://www.springframework.org/schema/osgi-compendium"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
<beans:bean id="configurationBean" class="com.eugene.PropertiesBean">
<osgix:managed-properties persistent-id="MyPid" update-strategy="container-managed"/>
<beans:property name="host" value="localhost"></beans:property>
<beans:property name="port" value="5698"></beans:property>
</beans:bean>
</beans:beans>
现在,这就是我要做的。将捆绑包部署到 Virgo,一切正常,默认属性(因为未部署 MyPid.properties)被注入到 bean 中。
在主机和端口都更改的地方部署 MyPid.properties,它们也都被重新注入。
那太棒了。但事情是这样的,我可以用一种方法告诉我 bean 已经改变了吗?属性已重新注入?类似于: XML 配置中的 afterPropertiesSet 或 init?因为现在拥有 afterPropertiesSet 或 init 仅在第一次注入属性时才有效,而不是第二次、第三次等等……这在某种程度上是合乎逻辑的。
我不知道(谷歌搜索)spring DM 是否提供这样的东西。
谢谢!尤金。