felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stijn de Witt <Stijn.deW...@planonsoftware.com>
Subject RE: questions about felix
Date Fri, 18 Oct 2013 08:44:23 GMT
>> i cannot cast a class that loaded from felix to a class that loaded from default class
loader, even two classes are the same.

Actually, the classes are not the same. This is weird, but Java defines the identity of a
class as the combination of the fully qualified classname + the classloader through which
the class is loaded. So classes from different classloaders are always treated as different.

Either move the stuff that needs the class to a bundle that imports the class (probably very
difficult) or do what Marcel suggested and make a common interface that is then exported as
a framework package.

-Stijn


-----Original Message-----
From: Marcel Offermans [mailto:marcel.offermans@luminis.nl] 
Sent: zondag 13 oktober 2013 23:56
To: users@felix.apache.org
Subject: Re: questions about felix

On Oct 13, 2013, at 22:54 PM, Peter Cheung <mcheung63@hotmail.com> wrote:

> Dear All   I have a standalone java app that embedded felix. I can start it, load bundle
and call the method from bundle (using reflection). 1) My first question is, using reflection
is not efficiency.  I imported the class from bundle to my host app, it popup "ClassCastException",
because i cannot cast a class that loaded from felix to a class that loaded from default class
loader, even two classes are the same. Any workaround?2) I am using maven, how to i add bundle
dependency to pom.xml?  pom.xml seems not searching the felix bundle repository. 

You cannot "see" classes that are loaded as part of bundles from your app. It does not help
to duplicate them either. The best option is to create an interface, add that to your application,
expose it as an exported package through the system bundle, and have the class in the bunde
import and implement this interface. That way the interface is shared between the app and
any bundle that imports it.

Hope that helps.

Greetings, Marcel


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


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


Mime
View raw message