0

we are using the Jboss fuse 6.2 along with technical stack blueprint,camel ,activeMQ and Mybatis.

We need to know about how to configure the property files in OSGI , as per my knowledge we could configure .cfg files, but is there any simplest way to use like spring configuring the configuring.

In Our code we are reading from property files . using namespace ext:proeprtyplaceHolder giving that bean id and values we are giving . Help to provide is there any simplest way to read the property files

srikanth
  • 61
  • 6

1 Answers1

1

There is several ways to add configuration, because OSGi services can access configuration via ConfigurationAdmin service. The blueprint also can access property values over it. JBoss fuse using karaf, so you can use the following methods.

(There is some quotes from http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service)

Configuration with Blueprint

The integration with our bean class is mostly a simple bean definition where we define the title property and assign the placeholder which will be resolved using the config admin service. The only special thing is the init-method. This is used to give us the chance to react after all changes were made like in the pure OSGi example. For blueprint we do not need any maven dependencies as our Java Code is a pure Java bean. The blueprint context is simply activated by putting it in the OSGI-INF/blueprint directory and by having the blueprint extender loaded. As blueprint is always loaded in Karaf we do not need anything else.

<cm:property-placeholder persistent-id="ConfigApp" update-strategy="reload" >
    <cm:default-properties>
         <cm:property name="title" value="Default Title"/>
    </cm:default-properties>
</cm:property-placeholder>

<bean id="myApp" init-method="refresh">
    <property name="title" value="${title}"></property>
</bean>

After you can put a cfg file (which is a standard java property file) to karaf's etc or deploy directory with the name of of the given persistent-id which is MyApp in our example. (For example: /etc/ConfigApp.cfg)

title=Configured title