Karaf 2.3.3 configuration files questions

2014-01-15 Thread simafengyun1984
Hi JB,
thank you very much for your quick answer to my questions

I have 3 questions about configuration files in karaf 2.3.3.
I have a bundle which includes a xml. The xml depend on 2 environment
variables, as below

*   list
value

classpath:${project.env}.ems.topic1.properties
/value
value

classpath:${project.env}.ems.topic2.properties
/value
/list*

I configured the 2 key-values in the system.properties file under the folder
etc. It works fine.

*But, I hope I can configure them to my own properties file, What should I
do?*


Actually I tried to configure the key-values in the custom.properties under
folder etc, it didn't work.
So what is use of the custom.properties?

*My last question is about the config commands. Actually there is a set of
config commands to add/delete/append/update configurations. I want to add a
new config file for my bundle, do you know how to bind the configuration
file to the specific bundle and how to get the values from the configuration
file in java class?*





--
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-2-3-3-configuration-files-questions-tp4031040.html
Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Karaf 2.3.3 configuration files questions

2014-01-15 Thread Jean-Baptiste Onofré

Hi,

if you take a look in etc/config.properties, you will see ${includes} 
which load jre.properties and custom.properties.
The purpose of custom.properties is to override the values in 
config.properties. config.properties is used by Karaf (in the Main) to 
load the OSGi framework.
system.properties is loaded by Karaf Main before config.properties. It 
loads the properties as system property (System.setProperty()). The 
properties are not directly used by the OSGi framework in anyway (it's 
exactly like in Felix using the system.properties file in the conf folder).


So, if you want to define system properties (like doing 
System.setProperty()), you have to use the etc/system.properties.


Regarding your own config, you can use ConfigAdmin via Spring or 
Blueprint (acting as a kind of property placeholder). So you can define 
your own config file in the etc folder (assuming it's a cfg properties 
file) and load automatically using Blueprint/Spring.
If you want to use your own format, you have to load and parse the file 
by yourself (for instance in the bundle Activator).


Regarding the config commands, it's the opposite: you don't associate 
a config to a bundle, but a bundle can use a config.


So creating a new config (using config:edit  config:update) creates 
the new cfg file, and it's up to the bundle to use this config.


Regards
JB

On 01/15/2014 10:25 AM, simafengyun1984 wrote:

Hi JB,
thank you very much for your quick answer to my questions

I have 3 questions about configuration files in karaf 2.3.3.
I have a bundle which includes a xml. The xml depend on 2 environment
variables, as below

*   list
value

classpath:${project.env}.ems.topic1.properties
/value
value

classpath:${project.env}.ems.topic2.properties
/value
/list*

I configured the 2 key-values in the system.properties file under the folder
etc. It works fine.

*But, I hope I can configure them to my own properties file, What should I
do?*


Actually I tried to configure the key-values in the custom.properties under
folder etc, it didn't work.
So what is use of the custom.properties?

*My last question is about the config commands. Actually there is a set of
config commands to add/delete/append/update configurations. I want to add a
new config file for my bundle, do you know how to bind the configuration
file to the specific bundle and how to get the values from the configuration
file in java class?*





--
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-2-3-3-configuration-files-questions-tp4031040.html
Sent from the Karaf - User mailing list archive at Nabble.com.



--
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com