Your bundle (ClassManager) has a class loader managed by OSGi (its Bundle class loader). The bundle class loader can only find classes from packages you either import (with Import-Package or Require-Bundle) or are provided by your own bundle's content or attached fragments.
In order to do what you describe I think you would need to use PackageAdmin
to find the ExportedPackages for the class_name you are getting the info
for. Then you can use ExprotedPackage.getExportingBundle().loadClass
(class_name) to load the class and reflectively find its methods etc.
HTH.
Tom
From: "David Conde" <[email protected]>
To: "'Equinox development mailing list'" <[email protected]>
Date: 09/24/2009 05:12 AM
Subject: [equinox-dev] Bundle classes context problem
Hi, I have a bundle called ClassManager which get the classes which are
being installed in the framework and print their names.
The problem is that these classes are the name of another services classes
which have been registered in Equinox after my bundle ClassManager was
installed, so when a new bundle is installed, a method in ClassManager is
called which is the next one:
getMethodFromClass (String class_name) {
Class myclass = Class.forName (class_name);
}
Where class_name is the name of my new Service which has just been
installed.
The problem is that my bundle throws a ClassNotFoundException because of
class_name (which is the name of the Service.class that was registered) is
not in the ClassContext for ClassManager, and it is normal, because
ClassManager is a system bundle which can not know the name of the classes
which will be registered in Equinox.
I though it could be because of security permissions but I have tried
launching Equinox without security and I got the same Exception:
The full Exception is shown below:
java.lang.ClassNotFoundException:
es.citic.osgi.system.bundleManager.BundleManager
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal
(BundleLoader.java:481)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass
(BundleLoader.java:397)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass
(BundleLoader.java:385)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass
(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at es.citic.osgi.system.userManager.impl.RoleImpl$1.run
(RoleImpl.java:71)
at java.security.AccessController.doPrivileged(Native
Method)
at es.citic.osgi.system.userManager.impl.RoleImpl.<init>
(RoleImpl.java:53)
at es.citic.osgi.system.userManager.impl.UserImpl.getRoles
(UserImpl.java:461)
at testusermanager.Activator.start(Activator.java:112)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run
(BundleContextImpl.java:1009))
at java.security.AccessController.doPrivileged(Native
Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator
(BundleContextImpl.java:1003)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:984)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:346)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resume
(AbstractBundle.java:355):
at
org.eclipse.osgi.framework.internal.core.Framework.resumeBundle
(Framework.java:1074)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles
(StartLevelManager.java:616)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL
(StartLevelManager.java:508)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel
(StartLevelManager.java:299)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.launch
(StartLevelManager.java:247)
at
org.eclipse.osgi.framework.internal.core.SystemBundle.resume
(SystemBundle.java:201).
at
org.eclipse.osgi.framework.internal.core.Framework.launch
(Framework.java:644)
at org.eclipse.osgi.framework.internal.core.OSGi.launch
(OSGi.java:51)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup
(EclipseStarter.java:313)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:175)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main
(EclipseStarter.java:150)
Any idea?
How can I do that each bundle which I install include their class which are
exported in a package in the classpath of OSGI so that other bundles can
use them?
Thank you in advance
_______________________________________________
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
