Hi,

I have the following managed-service-factory:

    <cm:managed-service-factory factory-pid="DataSource"
interface="javax.sql.DataSource">
        <service-properties>
            <entry key="osgi.jndi.service.name" value="${dbname}"/>
        </service-properties>
        <cm:managed-component
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value=""/>
            <property name="url" value=""/>
            <property name="username" value=""/>
            <property name="password" value=""/>
        </cm:managed-component>
    </cm:managed-service-factory>

Now I'd like to set ${dbname} to a value specified in a configuration file
so that every time I put a new config file into karaf/etc a new DataSource
service with a specific osgi.jndi.service.name is created.

I've tried using property-placeholder, however, this did not work. The only
method that currently works ist the following:

    <cm:managed-service-factory factory-pid="DataSource"
interface="javax.sql.DataSource">
        <service-properties>
            <cm:cm-properties persistent-id="DataSource"/>
        </service-properties>
        <cm:managed-component
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value=""/>
            <property name="url" value=""/>
            <property name="username" value=""/>
            <property name="password" value=""/>
        </cm:managed-component>
    </cm:managed-service-factory>

So using cm-properties inside the service-properties element. However, this
uses *all* properties defined in the config file for the service-properties,
which is not intended.

Is there some way to have a config file with several properties but only use
one of them as a service property for a managed service?



--
View this message in context: 
http://karaf.922171.n3.nabble.com/managed-service-factory-how-to-set-service-properties-from-config-file-tp4036836.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to