Refresh JIRA OSGi bundles - osgi

What's the proper way to refresh jira OSGi bundles?
Should I use Felix OSGi console on runtime (not available on my JIRA instance by default) ?

Refreshing from the Gogo shell is equivalent to the following code, which you can put into your own bundle:
context.getBundle(0).adapt(FrameworkWiring.class).refreshBundles(...)
So perhaps you can listen to the bundle events when new bundles are installed by JIRA UI, and call refresh using the above method.
The trick is to do the refresh only when JIRA has finished a series of installs/updates/removes. Only JIRA can really know when it is done, but perhaps you can do the refresh after waiting, say, 10 seconds after the last change.

Related

Does Apache Felix FileInstall works for dynamic configuration of an application?

I am trying to develop an application that can be configured by its users. I need the configuration to be done by installing/updating/stopping/uninstalling bundles. All this should be of course done dynamically during the run-time of the application.
I found a nice framework which is Apache Felix FileInstall that provides a directory in which it seems to add a bundle when you add the bundle file in the directory (update, and remove bundles similarly).
But I can see that this method does not work in my case. I need to have the bundles in the directory but to stop or even uninstall them by my application. And I want to install them when it is appropriate. This is how I am expecting the configuration of my application to be done.
Is what I am trying to achieve supported by Apache FileInstall? Am I making any wrong assumptions about this framework? What are other possible ways that would help me if Apache FileInstall is not enough? Thanks.
You don't need FileInstall for this, just use the OSGi APIs. You specifically mentioned installing, updating, stopping and uninstalling; these are supported with the following API calls respectively:
BundleContext.installBundle
Bundle.update
Bundle.stop
Bundle.uninstall
Incidentally these are exactly the same methods that are called by FileInstall to implements its directory-based bundle management.

unable to update bundle when update core whith karaf

I meet a big concern, I have several bundle.
As
bundlecore
bundleui
bundleaddoncore
bundleui needs bundlecore,
bundleaddoncore needs bundlecore
When I update bundlecore with karaf, I noticed that bundleui and bundleaddoncore still using the old version? I must restart Karaf? Is this normal? if so what is the right way to recharge the dependent bundle?
No, you don't need to restart Karaf this is typical for OSGi. The Other bundles still use the old services or reference the "old" classes. After a bundle update you need to refresh the depending bundles, only with this your bundles do get resolved again and therefore use the new bundle.
To do so you either call refresh or just refresh in the Karaf console.

How to autostart org.eclipse.gemini.blueprint.extender in a feature based eclipse rcp application?

I have an eclipse rcp application that uses gemini blueprint. It has two features and hence a feature based product. Some of our bundles depend on service that where created by the blueprint extender. But actually the blueprint extender is only resolved on startup and not activated. Today we work around this by executing code in bundle activators, that checks if the org.eclipse.gemini.blueprint.extender bundle was started and if not it gets started.
Adding the bundle to the .product with a start level of 3 and autoStart=true has no effect. I think this is because our product is feature based. Is this correct? What is the best way to autostart the extender?
You need to edit configuration/config.ini file and add the bundle you want started to the osgi.bundles property. For example:
osgi.bundles=<existing entries>, org.eclipse.gemini.blueprint.extender#3:start
Have you tried to set the start level to 0 and auto start to true?
There is a suggestion in this link.May be it can help you.

How to track osgi bundle failure information in Geronimo3

My team is using Geronimo 3 and osgi to develop applications. When our own osgi bundle or eba fails in Geronimo, I need to track the detailed failure information. Is there any API I can use to do this? Currently I could only do it by checking error stacktrace in geronimo log which is extremely not precise.
thanks,
Chandler
I added such a command to Karaf 3. It is called bundle:diag and shows the failure information for all bundles including blueprint and spring dm failures. As soon as Karaf 3 is released and geronimo switches to it you can use this. You can already try a karaf 3 snapshhot to see how it works.

Looking for code example to refresh a bundle during/right after the OSGi container loads

I am looking for a way to problematically refresh a bundle with a certain symbolic name after/during the OSGi container loads. Can someone please provide a code example?
I'm not sure why you'd want to do that, but registering a FrameworkListener that catches the STARTED event will allow you to find one when the framework startup is done.
In OSGi env, you can use ServiceTracker to track service status like register service, removing service.

Resources