You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by David Bosschaert <da...@gmail.com> on 2014/10/10 21:59:24 UTC

Re: Custom Subsystem Content Deployer

I expanded my implementation a little to provide the start of
implementation that can handle ConfigAdmin configuration as part of
subsystem content through the ConfigAdminContentHandler here
https://github.com/bosschaert/aries/commit/645daeb2acfaf745973428977d8a199016b3d740

Note that my editor removed some trailing spaces in certain files,
sorry for the noise there. The besides the ConfigAdminContentHandler
another file to look at would be the ConfigAdminContentHandlerTest.

It's just a start, anyone any thoughts?

Best regards,

David

On 30 September 2014 16:15, David Bosschaert <da...@gmail.com> wrote:
> I've spiked an implementation for this here:
> https://github.com/bosschaert/aries/commit/ebd98ad79a7796aece81abc9a86381dafc45ba72
>
> It's currently just a proof-of-concept, but if anyone has any
> thoughts, let me know!
>
> David
>
> On 30 September 2014 08:53, David Bosschaert <da...@gmail.com> wrote:
>> Hi Tarun,
>>
>> Good point. I have created
>> https://issues.apache.org/jira/browse/ARIES-1252 for this.
>>
>> Best regards,
>>
>> David
>>
>> On 5 July 2014 01:15, Ramakrishna, Tarun <ta...@elankath.com> wrote:
>>> Hi,
>>>
>>> I would like to embed custom content (stuff that isn't bundles) in
>>> subsystems. Now, according to the OSGI spec, in the  Subsystem-Content
>>> header, a subsystem implementation can choose to support additional resource
>>> types apart from the standard osgi bundle/fragment, etc.
>>>
>>> I looked at the Aries Subsystem source code. It appears to have the concept
>>> of different types of installer for resources, but I couldn't figure out
>>> whether it is possible to register a custom installer for a custom resource.
>>>
>>> Basically, I would like to have custom content in .ESA archives and then
>>> register some deployer onto the aries subsystem so that my deployer can be
>>> called for such content. I am not sure whether that is possible or not
>>> currently.
>>>
>>> All help/advice appreciated,
>>> Thanks,
>>> Tarun

Re: Custom Subsystem Content Deployer

Posted by David Bosschaert <da...@gmail.com>.
Hi all,

I have implemented this now in
http://svn.apache.org/viewvc?view=revision&revision=1642910

It supports fully pluggable embedded content and comes with an
implementation that can handle this for Configuration Admin files.
I've put the details of how to use it on the commit message, and
copied them below too.

Hope this works for everyone...

David

ARIES-1252 Support custom content in subsystems/.esa files

Custom content in .esa files is handled via Whiteboard service handlers.
To add a handler for custom content, register a
org.apache.aries.subsystem.ContentHandler service. This service will
be called back for install/start/stop/uninstall actions to be
performed.

The service must be registered with the service property
  org.aries.subsystem.contenthandler.type
to declare the content type that it should handle. This allows to
register handlers for content types different than the default
osgi.bundle/osgi.fragment and osgi.subsystem.* ones.

For more details take a look at the
CustomContentHandlerTest.testCustomContentHandler() itest. This
creates an .esa file that contains a bundle and also a custom content
file called 'custom1.sausages'. The custom content is declared in the
Subsystem-Content header via the standard 'type' attribute. To link it
with a resource in the .esa also provide the embedded-resource
attribute, e.g.:
Subsystem-Content:
  customContent1;embedded-resource=custom1.sausages;type=foo.sausages

Using a proper resource type (rather than directly using the file name
extension) makes it possible to also provide this custom resource from
a repository if needed.

The CustomContentHandlerTest has a test content handler that is called
back with the content of the resource, its name, the current subsystem
and the coordination.
Providing the coordination allows the custom handler to define a
compensation in case the installation fails elsewhere, or fail the
installation itself.

In addition, this commit also provides support for handling
configuration files as custom content. Two different configuration
file types are supported. Plain properties files (which are limited to
string values) and the Felix ConfigAdmin config file format, which
supports other datatypes as values [1].

To embed a Felix config admin file for PID org.foo.Bar, use
felix.cm.config as the resource type as the following in the
Subsystem-Content header:
 org.foo.Bar;embedded-resource=org.foo.Bar.cfg;type=felix.cm.config

To embed a properties configuration file for PID com.blah.Blah declare
it with the osgi.config.properties type:
  Subsystem-Content:
com.blah.Blah;embedded-resource=com.blah.Blah.cfg;type=osgi.config.properties

The ConfigAdminPropsFileContentHandlerTest shows this in action.

[1] See the javadoc of
http://svn.apache.org/repos/asf/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java
for syntax.


On 17 October 2014 at 16:25, Ramakrishna, Tarun <ta...@elankath.com> wrote:
> HI David,
>
> My apologies, I only saw your replies very late now! ContentHandler looks
> good at a first read. I will test, play around and give some feedback next
> week.
>
> Thanks!
> Tarun
>
> On Sat, Oct 11, 2014 at 1:29 AM, David Bosschaert
> <da...@gmail.com> wrote:
>>
>> I expanded my implementation a little to provide the start of
>> implementation that can handle ConfigAdmin configuration as part of
>> subsystem content through the ConfigAdminContentHandler here
>>
>> https://github.com/bosschaert/aries/commit/645daeb2acfaf745973428977d8a199016b3d740
>>
>> Note that my editor removed some trailing spaces in certain files,
>> sorry for the noise there. The besides the ConfigAdminContentHandler
>> another file to look at would be the ConfigAdminContentHandlerTest.
>>
>> It's just a start, anyone any thoughts?
>>
>> Best regards,
>>
>> David
>>
>> On 30 September 2014 16:15, David Bosschaert <da...@gmail.com>
>> wrote:
>> > I've spiked an implementation for this here:
>> >
>> > https://github.com/bosschaert/aries/commit/ebd98ad79a7796aece81abc9a86381dafc45ba72
>> >
>> > It's currently just a proof-of-concept, but if anyone has any
>> > thoughts, let me know!
>> >
>> > David
>> >
>> > On 30 September 2014 08:53, David Bosschaert
>> > <da...@gmail.com> wrote:
>> >> Hi Tarun,
>> >>
>> >> Good point. I have created
>> >> https://issues.apache.org/jira/browse/ARIES-1252 for this.
>> >>
>> >> Best regards,
>> >>
>> >> David
>> >>
>> >> On 5 July 2014 01:15, Ramakrishna, Tarun <ta...@elankath.com> wrote:
>> >>> Hi,
>> >>>
>> >>> I would like to embed custom content (stuff that isn't bundles) in
>> >>> subsystems. Now, according to the OSGI spec, in the  Subsystem-Content
>> >>> header, a subsystem implementation can choose to support additional
>> >>> resource
>> >>> types apart from the standard osgi bundle/fragment, etc.
>> >>>
>> >>> I looked at the Aries Subsystem source code. It appears to have the
>> >>> concept
>> >>> of different types of installer for resources, but I couldn't figure
>> >>> out
>> >>> whether it is possible to register a custom installer for a custom
>> >>> resource.
>> >>>
>> >>> Basically, I would like to have custom content in .ESA archives and
>> >>> then
>> >>> register some deployer onto the aries subsystem so that my deployer
>> >>> can be
>> >>> called for such content. I am not sure whether that is possible or not
>> >>> currently.
>> >>>
>> >>> All help/advice appreciated,
>> >>> Thanks,
>> >>> Tarun
>
>

Re: Custom Subsystem Content Deployer

Posted by "Ramakrishna, Tarun" <ta...@elankath.com>.
HI David,

My apologies, I only saw your replies very late now! ContentHandler looks
good at a first read. I will test, play around and give some feedback next
week.

Thanks!
Tarun

On Sat, Oct 11, 2014 at 1:29 AM, David Bosschaert <
david.bosschaert@gmail.com> wrote:

> I expanded my implementation a little to provide the start of
> implementation that can handle ConfigAdmin configuration as part of
> subsystem content through the ConfigAdminContentHandler here
>
> https://github.com/bosschaert/aries/commit/645daeb2acfaf745973428977d8a199016b3d740
>
> Note that my editor removed some trailing spaces in certain files,
> sorry for the noise there. The besides the ConfigAdminContentHandler
> another file to look at would be the ConfigAdminContentHandlerTest.
>
> It's just a start, anyone any thoughts?
>
> Best regards,
>
> David
>
> On 30 September 2014 16:15, David Bosschaert <da...@gmail.com>
> wrote:
> > I've spiked an implementation for this here:
> >
> https://github.com/bosschaert/aries/commit/ebd98ad79a7796aece81abc9a86381dafc45ba72
> >
> > It's currently just a proof-of-concept, but if anyone has any
> > thoughts, let me know!
> >
> > David
> >
> > On 30 September 2014 08:53, David Bosschaert <da...@gmail.com>
> wrote:
> >> Hi Tarun,
> >>
> >> Good point. I have created
> >> https://issues.apache.org/jira/browse/ARIES-1252 for this.
> >>
> >> Best regards,
> >>
> >> David
> >>
> >> On 5 July 2014 01:15, Ramakrishna, Tarun <ta...@elankath.com> wrote:
> >>> Hi,
> >>>
> >>> I would like to embed custom content (stuff that isn't bundles) in
> >>> subsystems. Now, according to the OSGI spec, in the  Subsystem-Content
> >>> header, a subsystem implementation can choose to support additional
> resource
> >>> types apart from the standard osgi bundle/fragment, etc.
> >>>
> >>> I looked at the Aries Subsystem source code. It appears to have the
> concept
> >>> of different types of installer for resources, but I couldn't figure
> out
> >>> whether it is possible to register a custom installer for a custom
> resource.
> >>>
> >>> Basically, I would like to have custom content in .ESA archives and
> then
> >>> register some deployer onto the aries subsystem so that my deployer
> can be
> >>> called for such content. I am not sure whether that is possible or not
> >>> currently.
> >>>
> >>> All help/advice appreciated,
> >>> Thanks,
> >>> Tarun
>