karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ɓukasz Dywicki <l...@code-house.org>
Subject RE: Placing properties files in the classpath
Date Thu, 09 Dec 2010 19:12:33 GMT
Hi,
You may use two solutions to do this - the osgix namespace in Spring or
blueprint-ext namespace. In both cases it's pretty similar:

...
    xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"

   <osgix:cm-properties id="cmProps" persistent-id="com.mycompany"> <!--
etc/com.mycompany.cfg -->
        <prop key="host">localhost</prop>
   </osgix:cm-properties>

   <ctx:property-placeholder properties-ref="cmProps" />

In blueprint:
...
	
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
	<cm:property-placeholder persistent-id="com.mycompany">
		<cm:default-properties>
			<cm:property name="host" value="localhost"/>
		</cm:default-properties>
	</cm:property-placeholder>

In case you choose blueprint and would use external variables (for example
system properties) you need additional thing:
...
	
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
	<ext:property-placeholder placeholder-prefix="$["
placeholder-suffix="]"/>

After that your configuration is accessible as in spring configuration in
${} braces, but System properties are accessible with $[] braces.

Working example you may find in our SVN tree:
http://svn.apache.org/repos/asf/karaf/trunk/management/src/main/resources/OS
GI-INF/blueprint/karaf-management.xml

Best regards,
Lukasz


-----Original Message-----
From: Mike Van [mailto:mvangeertruy@comcast.net] 
Sent: Thursday, December 09, 2010 6:47 PM
To: user@karaf.apache.org
Subject: Re: Placing properties files in the classpath


Gui,

Read part 116 of the OSGi Compendium, and it seems much too complex for what
I'm trying to do.  The goal is to have one location for all configuration
files and to have them available to bundles in Karaf.  I'm probably missing
what you're saying.  Is there an example you can point me to?

v/r,

Mike Van
-- 
View this message in context:
http://karaf.922171.n3.nabble.com/Placing-properties-files-in-the-classpath-
tp2054553p2058891.html
Sent from the Karaf - User mailing list archive at Nabble.com.


Mime
View raw message