有没有人能够在 SMX4 中的两个或多个捆绑包之间成功共享配置?我正在寻找的是这个:
- 有一个文件
$SMX_HOME/etc/myconfiguration.cfg - 让这个配置“可用”以通过 OSGi 配置管理使用 Spring dm 注入到我的包中,即
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
xmlns:ctx="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2.xsd">
<osgix:cm-properties id="cfg"
持久ID =“我的配置”>
<prop key="db.driverClassName">org.postgresql.Driver</prop>
<prop key="db.url">jdbc:postgresql://localhost/db</prop>
<prop key="db.username">某个用户</prop>
<prop key="db.password">一些密码</prop>
<prop key="amq.brokerURL">vm://default</prop>
</osgix:cm-properties>
<ctx:property-placeholder properties-ref="cfg" />
然后,我可以将这样的东西注入到我的 bean 中:
.
.
.
<bean id="activeMqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${amq.brokerURL}" />
</豆>
.
.
.
对于单个捆绑包,所有这些都只是桃子。我正在寻找一种方法来定义它一次,然后能够重用相同的配置文件作为一组包的属性。现在,我有多个包,每个包都有自己的配置实例(持久 id),因此,每个需要数据库连接、Java JMS 等的包都必须在每个文件中重复配置。
目前,我正在使用 Apache Servicemix 4,它使用 Apache Felix 作为 OSGi 容器。