Hi Saminda,

Am Donnerstag, den 17.04.2008, 14:56 +0530 schrieb Saminda Abeyruwan:
> 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".

When you read the configuration file, you know which bundle this
configuration file comes from, right ? (I assume you inspect the bundles
as they are started)

In this case, instead of just doing Class.forName() to load the classes
you could call Bundle.loadClass(String name) on the bundle which has the
configuration file and implementation class. This would then use the
class loader of the providing bundle and should be able to load the
class.

Hope this helps.

Regards
Felix

> 
> 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
> 
> 

Reply via email to