You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Cristiano Gavião <cv...@gmail.com> on 2011/04/26 00:03:24 UTC

Configuration Admin service example?

Hi,

I would like to use Configuration Admin Service with Declared Service. 
But I couldn't find yet a updated tutorial with a good example.

Someone knows any to point me?

thanks

Cristiano

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Configuration Admin service example?

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Cristiano,

I already used the config admin service and fileinstall from Karaf in an 
Eclipse RCP app it works quite well. At that time blueprint was not 
ready so we used spring dm then. It is a little more work than in karaf 
as you have to care about using all the right bundles yourself but it 
works. It would be interesting though if Karaf could even work in an 
Eclipse RCP app but I did not yet test that.

For testing I can recommend pax exam. I used it in the camel osgi 
integration tests. It is not ideal but I think it is the best tool at 
the moment.

Christian


Am 28.04.2011 21:06, schrieb Cristiano Gavião:
> Hi Christian,
>
> I researched more info and blueprint seams to be the best way to 
> follow because we could inject beans too. I made a small test with it 
> under Karaf and it works very well...
>
> We are implement a server side using karaf with felix but we can't use 
> karaf on client side because it is a RCP application. And the service 
> we want to dynamically configure should be injected on both sides.
> Now my concern is that eclipse doesn't have blueprint out of box. I 
> could see that exists two options today: Gemini and Aries. I will 
> investigate a little more.
>
> One question, what is the best way to implement automated test to 
> evaluate the blueprint + configuration behavior scenarios ? are you 
> using any tool?
>
> cheers and thanks
>
> Cristiano
>
> On 26/04/11 12:01, Christian Schneider wrote:
>> Hi Cristiano,
>>
>> I have most experience in spring dm. Currently spring is the most 
>> comprehensive solution. The problem with spring dm is that you need 
>> to import any package the your spring config defines into your 
>> bundle. This is far from ideal but it works.
>>
>> I have also some experience with blueprint (Apache Aries). I think it 
>> lacks some features but for the things it supports it works great. I 
>> think you should check if blueprint already does everything you need. 
>> If yes then it is the best option.
>>
>> Declarative servcies are not so usefull as they are limited to just 
>> services while blueprint and spring dm have bigger scope.
>>
>> For the container I propose you look at karaf + equinox if you need 
>> equinox. It should do all karaf + felix does. The good thing with 
>> karaf in general is that it provides great features for provisioning. 
>> So you can pull features and bundles from a maven repo. If you 
>> already use maven then this could be a killer feature.
>>
>> For blueprint you use the following to access the config admin service:
>>
>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>            xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>            
>> xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
>>            
>> xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
>>            default-activation="lazy">
>>
>> <cm:property-placeholder persistent-id="yourPropertyFileName" 
>> update-strategy="reload">
>> <cm:default-properties>
>> <cm:property name="sshPort" value="8101"/>
>> </cm:default-properties>
>> </cm:property-placeholder>
>>
>> </blueprint>
>>
>> Then you can access properties with ${propertyName}
>>
>> If you use karaf then the config admin service is provided with the 
>> help of the fileinstall service. This allows you to simply create a 
>> file "yourPropertyFileName.cfg" in the etc dir of karaf. This file is 
>> then read and made available as a config admin resource with the 
>> filename as id. Each property in the file is available in blueprint 
>> then. The example above is from the ssh module of karaf which itself 
>> uses blueprint.
>>
>> Btw. Have a look at the sources of Karaf to learn more blueprint :-)
>>
>> Christian
>>
>>
>> Am 26.04.2011 16:41, schrieb Cristiano Gavião:
>>> Hi Christian,
>>>
>>> Actually, I would like a way to dynamically setup my app service using
>>> Configuration admin service  and able its use on both equinox or
>>> felix/karaf.
>>>
>>> I could see that Declarative Services is out of box on equinox while 
>>> Karaf
>>> has Blueprint out of box.
>>>
>>> Now I'm investigating if would be better to install blueprint on 
>>> equinox or
>>> DS on karaf. Initially I'm studying the second option.
>>>
>>> any tip is welcomed?
>>>
>>> cheers
>>>
>>> Cristiano
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

-- 
----
http://www.liquid-reality.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Configuration Admin service example?

Posted by Cristiano Gavião <cv...@gmail.com>.
Hi Christian,

I researched more info and blueprint seams to be the best way to follow 
because we could inject beans too. I made a small test with it under 
Karaf and it works very well...

We are implement a server side using karaf with felix but we can't use 
karaf on client side because it is a RCP application. And the service we 
want to dynamically configure should be injected on both sides.
Now my concern is that eclipse doesn't have blueprint out of box. I 
could see that exists two options today: Gemini and Aries. I will 
investigate a little more.

One question, what is the best way to implement automated test to 
evaluate the blueprint + configuration behavior scenarios ? are you 
using any tool?

cheers and thanks

Cristiano

On 26/04/11 12:01, Christian Schneider wrote:
> Hi Cristiano,
>
> I have most experience in spring dm. Currently spring is the most 
> comprehensive solution. The problem with spring dm is that you need to 
> import any package the your spring config defines into your bundle. 
> This is far from ideal but it works.
>
> I have also some experience with blueprint (Apache Aries). I think it 
> lacks some features but for the things it supports it works great. I 
> think you should check if blueprint already does everything you need. 
> If yes then it is the best option.
>
> Declarative servcies are not so usefull as they are limited to just 
> services while blueprint and spring dm have bigger scope.
>
> For the container I propose you look at karaf + equinox if you need 
> equinox. It should do all karaf + felix does. The good thing with 
> karaf in general is that it provides great features for provisioning. 
> So you can pull features and bundles from a maven repo. If you already 
> use maven then this could be a killer feature.
>
> For blueprint you use the following to access the config admin service:
>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>            xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>            
> xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
>            
> xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
>            default-activation="lazy">
>
> <cm:property-placeholder persistent-id="yourPropertyFileName" 
> update-strategy="reload">
> <cm:default-properties>
> <cm:property name="sshPort" value="8101"/>
> </cm:default-properties>
> </cm:property-placeholder>
>
> </blueprint>
>
> Then you can access properties with ${propertyName}
>
> If you use karaf then the config admin service is provided with the 
> help of the fileinstall service. This allows you to simply create a 
> file "yourPropertyFileName.cfg" in the etc dir of karaf. This file is 
> then read and made available as a config admin resource with the 
> filename as id. Each property in the file is available in blueprint 
> then. The example above is from the ssh module of karaf which itself 
> uses blueprint.
>
> Btw. Have a look at the sources of Karaf to learn more blueprint :-)
>
> Christian
>
>
> Am 26.04.2011 16:41, schrieb Cristiano Gavião:
>> Hi Christian,
>>
>> Actually, I would like a way to dynamically setup my app service using
>> Configuration admin service  and able its use on both equinox or
>> felix/karaf.
>>
>> I could see that Declarative Services is out of box on equinox while 
>> Karaf
>> has Blueprint out of box.
>>
>> Now I'm investigating if would be better to install blueprint on 
>> equinox or
>> DS on karaf. Initially I'm studying the second option.
>>
>> any tip is welcomed?
>>
>> cheers
>>
>> Cristiano
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Configuration Admin service example?

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Cristiano,

I have most experience in spring dm. Currently spring is the most 
comprehensive solution. The problem with spring dm is that you need to 
import any package the your spring config defines into your bundle. This 
is far from ideal but it works.

I have also some experience with blueprint (Apache Aries). I think it 
lacks some features but for the things it supports it works great. I 
think you should check if blueprint already does everything you need. If 
yes then it is the best option.

Declarative servcies are not so usefull as they are limited to just 
services while blueprint and spring dm have bigger scope.

For the container I propose you look at karaf + equinox if you need 
equinox. It should do all karaf + felix does. The good thing with karaf 
in general is that it provides great features for provisioning. So you 
can pull features and bundles from a maven repo. If you already use 
maven then this could be a killer feature.

For blueprint you use the following to access the config admin service:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
            xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
            default-activation="lazy">

     <cm:property-placeholder persistent-id="yourPropertyFileName" update-strategy="reload">
         <cm:default-properties>
             <cm:property name="sshPort" value="8101"/>
         </cm:default-properties>
     </cm:property-placeholder>

</blueprint>

Then you can access properties with ${propertyName}

If you use karaf then the config admin service is provided with the help 
of the fileinstall service. This allows you to simply create a file 
"yourPropertyFileName.cfg" in the etc dir of karaf. This file is then 
read and made available as a config admin resource with the filename as 
id. Each property in the file is available in blueprint then. The 
example above is from the ssh module of karaf which itself uses blueprint.

Btw. Have a look at the sources of Karaf to learn more blueprint :-)

Christian


Am 26.04.2011 16:41, schrieb Cristiano Gavião:
> Hi Christian,
>
> Actually, I would like a way to dynamically setup my app service using
> Configuration admin service  and able its use on both equinox or
> felix/karaf.
>
> I could see that Declarative Services is out of box on equinox while Karaf
> has Blueprint out of box.
>
> Now I'm investigating if would be better to install blueprint on equinox or
> DS on karaf. Initially I'm studying the second option.
>
> any tip is welcomed?
>
> cheers
>
> Cristiano

-- 
----
http://www.liquid-reality.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Configuration Admin service example?

Posted by Cristiano Gavião <cv...@gmail.com>.
Hi Christian,

Actually, I would like a way to dynamically setup my app service using
Configuration admin service  and able its use on both equinox or
felix/karaf.

I could see that Declarative Services is out of box on equinox while Karaf
has Blueprint out of box.

Now I'm investigating if would be better to install blueprint on equinox or
DS on karaf. Initially I'm studying the second option.

any tip is welcomed?

cheers

Cristiano

2011/4/26 Christian Schneider <ch...@die-schneider.net>

> Hi Cristiano,
>
> the question is what framework should the example use. Should it be plain
> osgi, spring dm or blueprint?
>
> Christian
>
>
> Am 26.04.2011 00:03, schrieb Cristiano Gavião:
>
>> Hi,
>>
>> I would like to use Configuration Admin Service with Declared Service. But
>> I couldn't find yet a updated tutorial with a good example.
>>
>> Someone knows any to point me?
>>
>> thanks
>>
>> Cristiano
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>>
> --
> ----
> http://www.liquid-reality.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
"Tudo vale a pena se a alma não é pequena..."

Re: Configuration Admin service example?

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Cristiano,

the question is what framework should the example use. Should it be 
plain osgi, spring dm or blueprint?

Christian


Am 26.04.2011 00:03, schrieb Cristiano Gavião:
> Hi,
>
> I would like to use Configuration Admin Service with Declared Service. 
> But I couldn't find yet a updated tutorial with a good example.
>
> Someone knows any to point me?
>
> thanks
>
> Cristiano
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

-- 
----
http://www.liquid-reality.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Configuration Admin service example?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Apr 26, 2011 at 4:46 PM, Cristiano Gavião <cv...@gmail.com> wrote:
> ...I found maven-scr-plugin annotation very interesting and easy...
>
> Now I'm trying figuring out how I could inject properties from a config file
> on the service using DS...

The Felix file installer (
http://felix.apache.org/site/apache-felix-file-install.html ) does
this.

-Bertrand

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Configuration Admin service example?

Posted by Cristiano Gavião <cv...@gmail.com>.
Hi Bertrand,

I found maven-scr-plugin annotation very interesting and easy...

Now I'm trying figuring out how I could inject properties from a config file
on the service using DS...

thanks

Cristiano

2011/4/26 Bertrand Delacretaz <bd...@apache.org>

> Hi,
>
> On Tue, Apr 26, 2011 at 12:03 AM, Cristiano Gavião <cv...@gmail.com>
> wrote:
> > ....I would like to use Configuration Admin Service with Declared
> Service. But I
> > couldn't find yet a updated tutorial with a good example....
>
> If your goal is to create Declarative Services that have configuration
> parameters, the maven-scr-plugin [1] makes things very easy.
>
> See [2] for an example which uses a number of @Property annotations
> for configurable parameters.
>
> -Bertrand
>
> [1] http://felix.apache.org/site/apache-felix-maven-scr-plugin.html
>
> [2]
> http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
"Tudo vale a pena se a alma não é pequena..."

Re: Configuration Admin service example?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Apr 26, 2011 at 12:03 AM, Cristiano Gavião <cv...@gmail.com> wrote:
> ....I would like to use Configuration Admin Service with Declared Service. But I
> couldn't find yet a updated tutorial with a good example....

If your goal is to create Declarative Services that have configuration
parameters, the maven-scr-plugin [1] makes things very easy.

See [2] for an example which uses a number of @Property annotations
for configurable parameters.

-Bertrand

[1] http://felix.apache.org/site/apache-felix-maven-scr-plugin.html

[2] http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org