You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Christopher BROWN <br...@reflexe.fr> on 2013/06/21 08:48:29 UTC

Get version of package (not bundle) with OSGi

Hello,

Is there any correct way to get the version of a package with OSGi ?  I
didn't see anything on the Bundle or BundleContext other than the bundle
version.

When I create JAR files (without BND), I can add sections to the
MANIFEST.MF such as :

Name: org/osgi/service/log/
Implementation-Title: OSGi Log Service
Implementation-Vendor: MyVendorName
Specification-Title: OSGi Log Service
Specification-Vendor: OSGi Alliance
Specification-Version: 1.3.0

...which is available from
MyLogServiceImpl.class.getPackage().getSpecificationVersion() (which I can
then parse into an OSGi Version object).  Indeed, even the standard JDK
classes work this way.

For example, when I introspect the OSGi compendium (for example, here:
http://repo1.maven.org/maven2/org/osgi/org.osgi.compendium/4.2.0/ ), I'm
resorting to a fallback approach, seeking out the "packageinfo" file (a
text stub, containing "version 1.3" for example).

My use case isn't "production", it's for an application that can create new
"plugin" OSGi projects into an existing frameworks by selecting required
services and services to publish by introspecting a fixed set of bundles
(so that customers can extend the base functionality of our application).

Thanks,
Christopher

Re: Get version of package (not bundle) with OSGi

Posted by Christopher BROWN <br...@reflexe.fr>.
Hi,

That's what I was looking for (using PackageAdmin for the time being, not
upgraded to Felix 4.x yet, still using 3.2.2 for this project).

--
Christopher



On 21 June 2013 09:17, David Jencks <da...@yahoo.com> wrote:

> Well, in more recent specs it's still chapter 7 but Package Admin is
> deprecated and replaced by the bundle wiring api (which is a lot easier to
> use)
>
> david jencks
>
> On Jun 21, 2013, at 12:01 AM, Marcel Offermans <
> marcel.offermans@luminis.nl> wrote:
>
> > On Jun 21, 2013, at 8:48 , Christopher BROWN <br...@reflexe.fr> wrote:
> >
> >> Is there any correct way to get the version of a package with OSGi ?  I
> >> didn't see anything on the Bundle or BundleContext other than the bundle
> >> version.
> >
> > Take a look at Package Admin (chapter 7 in the core spec).
> >
> > Greetings, Marcel
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Get version of package (not bundle) with OSGi

Posted by David Jencks <da...@yahoo.com>.
Well, in more recent specs it's still chapter 7 but Package Admin is deprecated and replaced by the bundle wiring api (which is a lot easier to use)

david jencks

On Jun 21, 2013, at 12:01 AM, Marcel Offermans <ma...@luminis.nl> wrote:

> On Jun 21, 2013, at 8:48 , Christopher BROWN <br...@reflexe.fr> wrote:
> 
>> Is there any correct way to get the version of a package with OSGi ?  I
>> didn't see anything on the Bundle or BundleContext other than the bundle
>> version.
> 
> Take a look at Package Admin (chapter 7 in the core spec).
> 
> Greetings, Marcel
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Get version of package (not bundle) with OSGi

Posted by Marcel Offermans <ma...@luminis.nl>.
On Jun 21, 2013, at 8:48 , Christopher BROWN <br...@reflexe.fr> wrote:

> Is there any correct way to get the version of a package with OSGi ?  I
> didn't see anything on the Bundle or BundleContext other than the bundle
> version.

Take a look at Package Admin (chapter 7 in the core spec).

Greetings, Marcel