How do you know the Bundle where the configuration file is and how do you read it from Bundle B? I assume you must be getting the Bundle object for B somehow and using Bundle.getEntry to find the configuration file. If that is the case you can just call Bundle.loadClass(String name) on the bundle that has the configuration file.
But we must be missing something from your scenario because you say you are
working with existing code that I assume knows nothing about OSGi,
otherwise you would use services like you said. For legacy code that needs
access to implementation class from other bundles that depend on it you can
use the eclipse buddy class loading mechanism. Adding the following header
to Bundle A's manifest will allow Bundle B (and any other bundle that
depends on A) to become a buddy to Bundle A.
Eclipse-BuddyPolicy: dependent
Tom
From: "Saminda Abeyruwan" <[EMAIL PROTECTED]>
To: [email protected]
Date: 04/17/2008 04:27 AM
Subject: [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 _______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev
<<inline: graycol.gif>>
<<inline: ecblank.gif>>
_______________________________________________ equinox-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/equinox-dev
