What is the best way to get the version of a bundle

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What is the best way to get the version of a bundle

Pascal Rapicault-2
With Platform.getBundle officially removed, and PackageAdmin on its way
out, could someone indicate the API of choice (and recommended code
snippet) to use to get the version of a given bundle?


_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the best way to get the version of a bundle

Raymond Auge
Pascal, from which perspective would you like to get the bundle version?

From the Bundle itself:

org.osgi.framework.Version version = org.osgi.framework.Bundle.getVersion();

Through the resolver API (arguably a little trickier):

Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> results = org.osgi.service.resolver.Resolver.resolve(org.osgi.service.resolver.ResolveContext ctx);
Resource resource = results.keySet().iterator().next();
List<Capability> capabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
Map<String,Object> attributes = capabilities.get(0).getAttributes();
org.osgi.framework.Version version = (org.osgi.framework.Version)attributes.get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);

There are a number of convenience APIs as well, but as I said earlier it really depends from which perspective you are trying... from a running framework or from some external agent analyzing a set of bundles.

Sincerely,
- Ray


On Tue, Dec 13, 2016 at 9:45 PM, Pascal Rapicault <[hidden email]> wrote:
With Platform.getBundle officially removed, and PackageAdmin on its way out, could someone indicate the API of choice (and recommended code snippet) to use to get the version of a given bundle?


_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the best way to get the version of abundle

Thomas Watson
I think Pascal is asking how to find an installed bundle given a specific BSN and version (range?).  I suggest you take a look at the PackageAdminImpl for the getBundles method:

https://git.eclipse.org/c/equinox/rt.equinox.framework.git/tree/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java?h=R4_6_maintenance#n170

The FrameworkWiring.findProviders method is the way to discover capabilities of bundles in the framework, including the osgi.identity capability which holds the bundles BSN and version.

Tom





From:        Raymond Auge <[hidden email]>
To:        Equinox development mailing list <[hidden email]>
Date:        12/13/2016 10:16 PM
Subject:        Re: [equinox-dev] What is the best way to get the version of a        bundle
Sent by:        [hidden email]




Pascal, from which perspective would you like to get the bundle version?

From the Bundle itself:

org.osgi.framework.Version version = org.osgi.framework.Bundle.getVersion();

Through the resolver API (arguably a little trickier):

Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> results = org.osgi.service.resolver.Resolver.resolve(org.osgi.service.resolver.ResolveContext ctx);
Resource resource = results.keySet().iterator().next();

List<Capability> capabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
Map<String,Object> attributes = capabilities.get(0).getAttributes();
org.osgi.framework.Version version = (org.osgi.framework.Version)attributes.get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);

There are a number of convenience APIs as well, but as I said earlier it really depends from which perspective you are trying... from a running framework or from some external agent analyzing a set of bundles.

Sincerely,
- Ray


On Tue, Dec 13, 2016 at 9:45 PM, Pascal Rapicault <pascal@...> wrote:
With Platform.getBundle officially removed, and PackageAdmin on its way out, could someone indicate the API of choice (and recommended code snippet) to use to get the version of a given bundle?


_______________________________________________
equinox-dev mailing list

[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

https://dev.eclipse.org/mailman/listinfo/equinox-dev



--

Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev



_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the best way to get the version of a bundle

Thomas Watson
In reply to this post by Pascal Rapicault-2
I'll also state that in Equinox (and AFAIK in Felix) the PackageAdmin implementation is not going anywhere for the foreseeable future.

Tom





From:        Pascal Rapicault <[hidden email]>
To:        Equinox development mailing list <[hidden email]>
Date:        12/13/2016 08:46 PM
Subject:        [equinox-dev] What is the best way to get the version of a bundle
Sent by:        [hidden email]




With Platform.getBundle officially removed, and PackageAdmin on its way
out, could someone indicate the API of choice (and recommended code
snippet) to use to get the version of a given bundle?


_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev





_______________________________________________
equinox-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev
Loading...