简体   繁体   中英

How to create configuration for Managed Service Factory with Karaf features?

I'm trying to create a simple configuration for Amdatu's MongoDB component. When I create a file named org.amdatu.mongo-kairos.cfg with following line inside dbName=kairos and put it into the deploy folder - everything works OK. However, when I'm trying to use config tag in features.xml nothing happens.

Part of my feature file, which uses configuration tag :

<feature name="persistency" version="0.0.1-SNAPSHOT" description="MongoDB Persistency">
    //(...)
    <config name="org.amdatu.mongo-kairos">
        dbName=kairos
    </config>
</feature>

As mentioned on the users mailing-list it's a known issue but can be worked around with using a configfile instead. With defining multiple configuration files the management service factory can also be used with a feature definition:

<feature name="persistence" version="1.0.0-SNAPSHOT" description="MongoDB Persistence">
    <configfile finalname="/etc/org.amdatu.mongo-kairos.cfg">
        mvn:groupId/persistency-config/version/cfg
    </configfile>
    <configfile finalname="/etc/org.amdatu.mongo-suez.cfg">
        mvn:groupId/artifactId/versionId/jar
    </configfile>
    //.. a list of bundles
</feature>

Moreover, using config files along with maven allows to version configurations along with the application:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <executions>
        <execution>
            <id>persistency-config</id>
            <phase>install</phase>
            <goals>
                <goal>install-file</goal>
            </goals>
            <configuration>
                <groupId>${project.groupId}</groupId>
                <artifactId>persistency-config</artifactId>
                <version>${project.version}</version>
                <packaging>cfg</packaging>
                <file>config/org.amdatu.mongo-kairos.cfg</file>
            </configuration>
        </execution>
    </executions>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM