Wednesday, March 4, 2009

Using Custom Class Loaders In Spring Dm -OSGi

One has to be careful while using custom class loaders in any of the bundles.This is beacuse in the context of osgi each bundle will have a classloader whose parent will be the bootclassloader.
And the hierarchy of the classes searched will be delegated from child to the parent classloader. Hence when a class is not found in a bundle, the responsibility will be delegated to the parent classloader.
When we define a custom classloader as follows
CustomClassLoader = new CustomClassaloader() - > its parent is set to the boot classloader. Hence though its inside the bundle it canot see any classes inside the bundle .
The easy way to get away from this is to set the custom class laoders parent as the bundle classloader.Now any request to the classes in the custom class loader will be delegated to its parent that is the bundle classloader and the clases will be found.

No comments:

Free Domain Names @!