You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by anair <as...@yahoo.com> on 2013/05/29 20:40:34 UTC

Is there a way to listen to osgi:install event on karaf 2.2.9

Hello,

I have a requirement where we need to programmatically install all the
bundles in cache after it has been cleared. I was thinking of writing the
bundle symbolic name to a file, (any file) so that we can keep a track of
all the bundles installed by the user using the osgi:install command. We
plan to extend it to let the user install the bundle from the obr
repository. Since this goes to cache we do not know a way of doing this now.
So my question is, is it possible to achieve this in karaf 2.2.9? I think I
need to listen to some event that is being generated when a bundle gets
installed. Is this the right approach or am I in the wrong track?

Any pointers are greatly appreciated.

thanks,

Asha



--
View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-listen-to-osgi-install-event-on-karaf-2-2-9-tp4028878.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Is there a way to listen to osgi:install event on karaf 2.2.9

Posted by anair <as...@yahoo.com>.
Sorry, looks like I need to register the listener as well. I was not aware of
this step. I am thinking of creating an activator class where I can register
the listener. I hope this is the right approach. Lets see how it goes.

regards,

Asha



--
View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-listen-to-osgi-install-event-on-karaf-2-2-9-tp4028878p4028900.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Is there a way to listen to osgi:install event on karaf 2.2.9

Posted by anair <as...@yahoo.com>.
Hi Jean-Baptiste,

Thank you for your response. I tried this approach. I created a class to an
already existing service that implements SynchronousBundleListener and added
some log statements in the bundleChanged method. I then installed a bundle
using 'osgi:install'. I did not see the statements in my log. I then created
a class that implements ServiceListener and added the log statements in the
serviceChanged method. I then installed the same bundle using osgi:install.
This prints the statements. I am not sure what I am missing here or if it is
the right approach to being with.

Pardon my ignorance as I am a newbie to osgi and karaf.

regards,

Asha



--
View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-listen-to-osgi-install-event-on-karaf-2-2-9-tp4028878p4028899.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Is there a way to listen to osgi:install event on karaf 2.2.9

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Asha,

You can create a class that implements 
org.osgi.framework.SynchronousBundleListener (and register it as an OSGi 
service).

Like this, you will catch all events on bundle.

Regards
JB

On 05/29/2013 08:40 PM, anair wrote:
> Hello,
>
> I have a requirement where we need to programmatically install all the
> bundles in cache after it has been cleared. I was thinking of writing the
> bundle symbolic name to a file, (any file) so that we can keep a track of
> all the bundles installed by the user using the osgi:install command. We
> plan to extend it to let the user install the bundle from the obr
> repository. Since this goes to cache we do not know a way of doing this now.
> So my question is, is it possible to achieve this in karaf 2.2.9? I think I
> need to listen to some event that is being generated when a bundle gets
> installed. Is this the right approach or am I in the wrong track?
>
> Any pointers are greatly appreciated.
>
> thanks,
>
> Asha
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-listen-to-osgi-install-event-on-karaf-2-2-9-tp4028878.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

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