Question about the need for META INF/MANIFEST.MF data

View: New views
4 Messages — Rating Filter:   Alert me  

Question about the need for META INF/MANIFEST.MF data

by UseTheFork () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am a newbie to OSGi and I have managed to embed Felix in a standalone application. I have created a MyService API and a corresponding implementation. All these files are part of the same .jar.

I am using the book available at http://neilbartlett.name/blog/categories/osgibook/ and it mentions that some bundle data should be included in the META INF/MANIFEST.MF. In order to facilitate the work, it recommends using a tool called Bnd.

However, it does not explain the motivation for this. I guess that if you fetch a .jar from god-knows-where, having the OSGi framework search META INF/MANIFEST.MF for OSGi bundle 'configuration' makes sense.

But, if my service is in my .jar, is it really necessary to go through META INF/MANIFEST.MF? Can't I create create a simple BundleActivator to register my implemented service using the MyService API fully qualified name (since everything is visible from the class path)? One can assume that my service does not have dependency on other OSGi bundles or services. My service is typically one that you would start with felix.systembundle.activators.

Assuming the answer is yes, then how can I provide MyService's version for example? If MyService were to depend on other bundles, then how could I specify this without manipulating the META INF/MANIFEST.MF of my .jar? Is this possible?

Thanks !!!

JVerstry

Re: Question about the need for META INF/MANIFEST.MF data

by Richard S. Hall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am not sure I understand what you are asking, but you can provide
services from the outside to bundles on the inside of the framework;
this page (while a little out of date in the latter half) talks about that:

     
http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html

What it comes down to is this:

   1. Include the service interfaces on the class path.
   2. Configure the org.osgi.framework.system.packages.extra to export
      these packages from the system bundle.
   3. Instantiate the framework instance.
   4. Initialize (or start) the framework instance and use
      Framework.getBundleContent() to get the system bundle's context.
   5. Register your service using the system bundle context.

That's about it. Since your service is not a bundle, there is no way to
have a bundle version and whatnot associated with it, but you can add
versions to your service interface package when configuring the system
packages extra property.

-> richard

On 11/6/09 22:03, UseTheFork wrote:

> Hi,
>
> I am a newbie to OSGi and I have managed to embed Felix in a standalone
> application. I have created a MyService API and a corresponding
> implementation. All these files are part of the same .jar.
>
> I am using the book available at
> http://neilbartlett.name/blog/categories/osgibook/ and it mentions that some
> bundle data should be included in the META INF/MANIFEST.MF. In order to
> facilitate the work, it recommends using a tool called Bnd.
>
> However, it does not explain the motivation for this. I guess that if you
> fetch a .jar from god-knows-where, having the OSGi framework search META
> INF/MANIFEST.MF for OSGi bundle 'configuration' makes sense.
>
> But, if my service is in my .jar, is it really necessary to go through META
> INF/MANIFEST.MF? Can't I create create a simple BundleActivator to register
> my implemented service using the MyService API fully qualified name (since
> everything is visible from the class path)? One can assume that my service
> does not have dependency on other OSGi bundles or services. My service is
> typically one that you would start with felix.systembundle.activators.
>
> Assuming the answer is yes, then how can I provide MyService's version for
> example? If MyService were to depend on other bundles, then how could I
> specify this without manipulating the META INF/MANIFEST.MF of my .jar? Is
> this possible?
>
> Thanks !!
>
> JVerstry
>    

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


Re: Question about the need for META INF/MANIFEST.MF data

by oisin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> http://neilbartlett.name/blog/categories/osgibook/ and it mentions that some
> bundle data should be included in the META INF/MANIFEST.MF. In order to
> facilitate the work, it recommends using a tool called Bnd.
>
> However, it does not explain the motivation for this.

The motivation for this is that to be a compliant OSGi bundle, you must
have a MANIFEST.MF available for the OSGi framework to scan. So, if
you want to 'do OSGi', then you need a manifest.

> But, if my service is in my .jar, is it really necessary to go through META
> INF/MANIFEST.MF?

As Rich explained, you don't have to do this, but from a practical
standpoint, the cost of maintenance in avoiding the use of MANIFEST.MF
would be considerably greater than including that file in your bundle.

>... how can I provide MyService's version for
>example?

Without a manifest, you cannot.

>If MyService were to depend on other bundles, then how could I
>specify this without manipulating the META INF/MANIFEST.MF of my .jar? Is
>this possible?

No it's not possible in any practical sense - without the appropriate
manifest, your jar file is not a bundle and can't participate as on in
the OSGi container.

If you are going to adopt OSGi, you will have to learn to love the manifest :)

 --oh

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


Re: Question about the need for META INF/MANIFEST.MF data

by UseTheFork :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Many thanks for your answers. I know what to do next...

JVerstry