karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Leung" <tom.le...@netage.com.hk>
Subject RE: which API to edit .cfg in Karaf at runtime?
Date Sat, 08 Mar 2014 00:23:05 GMT
I think you want set up a configuration file.  Anytime, the user edit this
file, the value can be reflected in the application.

Why not using Blueprint placeholder and include a blueprint configuration
file as below:

<blueprint default-activation="eager"
           xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
           xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
 
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">

    <cm:property-placeholder persistent-id="your.sample.config"
update-strategy="reload" >
		<cm:default-properties>
			<cm:property name="property1" value="foo"/>
		</cm:default-properties>
	</cm:property-placeholder>
	   
	<bean class="sample.YourClassImpl " id="beanDao">
	    	    <property name=" property1" value="${ property1}"/>
    </bean>
</blueprint>


After the bundle has been started, you may create a cfg file named "
your.sample.config.cfg" under Karaf/etc folder.
This cfg file contains the property value as below:

property1=your_value

If the property value has been changed, the new property value will be
reloaded and reflected in the blueprint bean property.





-----Original Message-----
From: Brock Samson [mailto:brock.samson_@hotmail.com] 
Sent: Saturday, March 08, 2014 8:10 AM
To: user@karaf.apache.org
Subject: which API to edit .cfg in Karaf at runtime?

i have a bundle deployed in Karaf 3.2.1, which references a .cfg file in its
blueprint bundle-context.xml. i also have a javasript-based ui which allows
for such .cfg files to be edited at runtime. up to this point, i have been
using FileOutputStream("etc/my-bundle-PID.cfg") to perform the actual
editing. however, i am wondering if there is an official set of APIs to
accomplish such task.

thank you for your time!



--
View this message in context:
http://karaf.922171.n3.nabble.com/which-API-to-edit-cfg-in-Karaf-at-runtime-
tp4032135.html
Sent from the Karaf - User mailing list archive at Nabble.com.


Mime
View raw message