[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] Providing a callback to an OSGi bundle

Hi Devs,

I have faced with a use-case where a callback need to be passed to an OSGi bundle.

Scenario:

Bundle A exports package "x.y" and "a.b". These are the only packages it exports. The logic of this bundle is such that it can populate a callback, when some function is finished. Say this callback should implement interface "x.y.Foo". Required callbacks are written in a configuration file, and which will be located using OSGi infrastructure. 

There exist another bundle B, which has classes that implemented the interface "x.y.Foo" say "x.y.K.FooImpl1" and that bundle also contains the configuration file listing the QName of the impl classes. This bundle imports package "x.y".


When bundle A reads the configuration files from bundle B and tries to initiate the impl classes, bundle A would failed with class definition not found exception stating that it can't locate the implementation  "x.y.k.FooImpl1". This is obvious because bundle A does not import package "x.y.k".

Implementation to a callback can contain any package. Thus, bundle A needs to export this some way. Java itself provides callback mechanisms and implementations are done by the users.

Is there any way to solve prior problem. Is it possible me to say  in bundle A's MANIFEST.MF Export-Packaget : x.y, a.b, *; resolution:=optional. Is there a way to solve this callback issue using package admin.

My problem with callback would have been solved using OSGi services. Since I've to work with an existing code, OSGi service wouldn't be suffix.


Thank you!

Saminda


--
Saminda Abeyruwan

Senior Software Engineer
WSO2 Inc. - www.wso2.org