| Install bundles located in the provisioning repositories programmatically [message #696272] |
Wed, 13 July 2011 11:45  |
Marco Gerber Messages: 10 Registered: May 2011 |
Junior Member |
|
|
Hello everybody
I'm looking for a way to install bundles programmatically located in one of the provisioning repositories.
One solution I found is by using BundleContext.installBundle(location) (see [1]) where I have to set location with a file uri and an absolute path to the bundle's jar. Something like "file:/xxx/virgo/repository/usr/mybundle.jar".
Is there any other solution I can install bundles located within the provisioning repositories? Maybe to get their absolut paths on the filesystem or only something like a list of paths of bundles from the provisioning repositories or a list of input streams containing them? I'd like to avoid absolute paths as they may differ between different installations.
Regards,
Marco
[1] www.osgi.org/javadoc/r4v43/org/osgi/framework/BundleContext.html#installBundle%28java.lang.String%29
|
|
|
| Re: Install bundles located in the provisioning repositories programmatically [message #696525 is a reply to message #696272] |
Thu, 14 July 2011 04:03   |
Glyn Normington Messages: 1186 Registered: July 2009 |
Senior Member |
|
|
You can use a URL of the form "repository://type/name[/version]" to refer to an artifact in the provisioning repository. The square brackets indicate that the trailing "/version" is optional, in which case Virgo uses the highest version available, and are not part of the URL. In the case of a bundle, "type" is "bundle" and "name" is the bundle symbolic name (and if "version" is specified, it is the bundle version).
Please note that these installs will be done directly into the OSGi framework and will not benefit from any Virgo deployer support and that, in Virgo 3.0, bundles installed in this way will be installed in the same region as the BundleContext used to do the install.
Hope that helps!
[Updated on: Thu, 14 July 2011 04:05] Report message to a moderator
|
|
|
| Re: Install bundles located in the provisioning repositories programmatically [message #696548 is a reply to message #696525] |
Thu, 14 July 2011 05:10   |
Marco Gerber Messages: 10 Registered: May 2011 |
Junior Member |
|
|
Hi Glyn
Very cool, thanks!
Quote:
You can use a URL of the form "repository://type/name[/version]" to refer to an artifact in the provisioning repository
My problem with this approach is, that I don't have the symbolic names, but a pattern for all the bundles I'm interested in. Is there a way to get a list of symbolic names for all not yet installed bundles matching a pattern? It's not really a blocker, as I can use a config file to get the symbolic names from as a working alternative but the first would be the most beautiful way to go when using this approach 
Quote:
... in Virgo 3.0, bundles installed in this way will be installed in the same region as the BundleContext used to do the install.
This should be ok, as we manage such bundles from within a bundle installed and managed by virgo.
Quote:
Please note that these installs will be done directly into the OSGi framework and will not benefit from any Virgo deployer support...
Such as managing such bundles by a plan, right? However, the whole start/stop handling by using f.ex. the virgo web console still seems to be working. Or is there a way to let virgo install a bundle by using a virgo api in a way I don't have such limitations?
Thanks,
Marco
[Updated on: Thu, 14 July 2011 05:21] Report message to a moderator
|
|
|
|
|
|
|
| Re: Install bundles located in the provisioning repositories programmatically [message #696642 is a reply to message #696598] |
Thu, 14 July 2011 09:25   |
Marco Gerber Messages: 10 Registered: May 2011 |
Junior Member |
|
|
So, as a first try, I use the jconsole script provided with virgo 3.0.0.M05 to access the Deployer MXBean. Using install(p0) with:
repository:bundle/my.bundle.symbolic.name/0.0.1.BUILD-SNAPSHOT
the bundle passes over into state RESOLVED as expected. However, using start (p0) afterwards fails as it's deselected, and trying to use start(p0, p1, p2) with:
p0: bundle
p1: my.bundle.symbolic.name
p2: 0.0.1.BUILD-SNAPSHOT
fails with the following error:
Problem invoking start : java.lang.RuntimeException:java.lang.UnsupportedOperationException: Not yet implemented, use deploy instead of install and start.
Following the error message and using deploy(p0) with p0 set as follows instead of using install and start:
repository:bundle/my.bundle.symbolic.name/0.0.1.BUILD-SNAPSHOT
deploys the bundle where the resulting state is ACTIVE.
Same thing with stop/uninstall and undeploy.
The bad thing here is that I always have to use 'deploy' and 'undeploy' where I never reach RESOLVED -> ACTIVE in two single steps.
What's the reason for such limitations? It would be nice if I could manage the entire lifecycle over the deployer mxbean instead of getting and resolving the Bundle to do so; which, btw is a solution I can live with 
Cheers,
Marco
|
|
|
|
Powered by
FUDForum. Page generated in 0.02124 seconds