felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jackson, Bruce" <bru...@qualcomm.com>
Subject Re: Classloading across bundles
Date Fri, 01 Aug 2008 14:57:08 GMT
Sorry, I don't think I made myself particularly clear:

I have a bundle "A" which exports a package containing a class (ObjectFactory.class) with
the method:

public static Object getObject(Class clazz);

This method creates a dynamic proxy object to be returned to the caller.
I have bundles B, C, and D which wish to make use of this class, and which will call it passing
an interface, for example:

Foo foo = (Foo) ObjectFactory.getObject(Foo.class);

However, ObjectFactory throws a ClassNotFoundException because Foo.class is not in the import
list for bundle A. Is there a way of allowing this?

On 01/08/2008 15:14, "Richard S. Hall" <heavy@ungoverned.org> wrote:

Jackson, Bruce wrote:
> Here's a question:
> I have a utility class in a bundle which will generate a dynamic proxy as a
> service to other bundles running inside Felix. Lets call this bundle "A".
> Is this possible in Felix/OSGi without having having to explicitly declare
> the import of the interface over which A will operate?

Well, you can get access to the interface class definition by calling
Bundle.loadClass() on bundle A without importing from A, so then you
should be able to use that to create the proxy, I would imagine.

-> richard

> Thanks
> Bruce

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message