When a class can not be loaded, the o.a.f.framework.Felix class sends a
framework event with an ERROR level.
It can be very verbose in some cases: for example when using spring-osgi,
for each spring bean defined, spring tries to load a class names
XxxBeanInfo, where Xxx is the implemenation class name of the loaded spring
bean.
The piece of code is the loadBundleClass method, lines 1452 of the Felix
class:
protected Class loadBundleClass(FelixBundle bundle, String name) throws
ClassNotFoundException
{
Class clazz = bundle.getInfo().getCurrentModule().getClass(name);
if (clazz == null)
{
// Throw exception.
ClassNotFoundException ex = new ClassNotFoundException(name);
// The spec says we must fire a framework error.
fireFrameworkEvent(
FrameworkEvent.ERROR, bundle,
new BundleException(ex.getMessage()));
throw ex;
}
return clazz;
}
Given the comment, I've tried to find what the spec says. I think the
comment refers to the Bundle.loadClass methods. Quoting the spec:
If this bundle cannot be resolved, a Framework event of type Frame-
workEvent.ERROR is fired containing a BundleException with details of the
reason this bundle could not be resolved. This method must then throw a
ClassNotFoundException.
My understanding is that the framework event must be fired when the bundle
can not be *resolved*, not each time a class can not be found. I suppose
such a case could only happen if the bundle has been installed but not yet
resolved and someone is using the loadClass method. Can someone please
share thoughts on this ?
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/