Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Install bundles located in the provisioning repositories programmatically
Install bundles located in the provisioning repositories programmatically [message #696272] Wed, 13 July 2011 15:45 Go to next message
Marco Gerber is currently offline Marco GerberFriend
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 08:03 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
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 08: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 09:10 Go to previous messageGo to next message
Marco Gerber is currently offline Marco GerberFriend
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 Smile


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 09:21]

Report message to a moderator

Re: Install bundles located in the provisioning repositories programmatically [message #696555 is a reply to message #696548] Thu, 14 July 2011 09:33 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
You could use the Deployer mxbean to deploy (i.e. install and start) bundles and get the benefit of the deployer transformations etc. should you need those. For instance, if you are installing a Web Application Bundle, you'd definitely need to run it through the deployer.
Re: Install bundles located in the provisioning repositories programmatically [message #696560 is a reply to message #696555] Thu, 14 July 2011 09:52 Go to previous messageGo to next message
Marco Gerber is currently offline Marco GerberFriend
Messages: 10
Registered: May 2011
Junior Member
Thanks, I think this would be the most common way to solve such problem. I'll try it out.

Cheers,
Marco

[Updated on: Thu, 14 July 2011 09:53]

Report message to a moderator

Re: Install bundles located in the provisioning repositories programmatically [message #696564 is a reply to message #696560] Thu, 14 July 2011 10:04 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Ok, please would you let us know how you get on as others will probably want to do the same thing.
Re: Install bundles located in the provisioning repositories programmatically [message #696598 is a reply to message #696564] Thu, 14 July 2011 11:12 Go to previous messageGo to next message
Marco Gerber is currently offline Marco GerberFriend
Messages: 10
Registered: May 2011
Junior Member
Yes, but it may take some time.

Cheers,
Marco
Re: Install bundles located in the provisioning repositories programmatically [message #696642 is a reply to message #696598] Thu, 14 July 2011 13:25 Go to previous messageGo to next message
Marco Gerber is currently offline Marco GerberFriend
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 Smile

Cheers,
Marco
Re: Install bundles located in the provisioning repositories programmatically [message #709197 is a reply to message #696642] Wed, 03 August 2011 16:11 Go to previous message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Thanks for reporting back your success.

We have an issue in our backlog to implement those functions and they should be coming soon. We have also added a section to the Virgo FAQ about programmatic deployment.

Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Previous Topic:Virgo OSGi modules integration test
Next Topic:Virgo 3.0.0.RC2 available
Goto Forum:
  


Current Time: Fri Dec 19 15:56:37 GMT 2014

Powered by FUDForum. Page generated in 0.02674 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software