[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [equinox-dev] Wrapping a Bundle to create a classloader
|
Thanks Tom.
I've added a BundleProxyClassLoader recipe up on the
wiki.
-Simon
You should override loadClass and
getResource instead of the findClass and findResource methods from
ClassLoader.
This will prevent the
extra boot classloader lookup which the default ClassLoader implementation
does when the parent is null. Unfortunately the getResources (plural)
method is final (at least in JRE 1.4.2, I know sun was considering changing
this in the future). This means that you may get duplicate resources
because the boot classpath will get asked twice to load the resource you are
looking for. Once from Bundle.getResources and once from the default
implementation of ClassLoader.getResources.
Tom
"Kaegi, Simon"
<Simon.Kaegi@xxxxxxxxxx> Sent by: equinox-dev-bounces@xxxxxxxxxxx
06/07/2006 11:48 AM
Please respond
to Equinox development mailing list
<equinox-dev@xxxxxxxxxxx> |
|
To
| "Equinox development mailing
list" <equinox-dev@xxxxxxxxxxx>
|
cc
|
|
Subject
| [equinox-dev] Wrapping a Bundle
to create a classloader |
|
Hi,
I was about to craft my own implementation here,
but I figure this has probably been done many times before and bound to be
some subtle problems
Can anyone
point me at an example.
--
...or is it really as simple as:
import java.io.IOException;
import
java.net.URL;
import java.util.Enumeration;
import org.osgi.framework.Bundle;
public class
BundleProxyClassLoader extends ClassLoader {
private
Bundle bundle;
public BundleProxyClassLoader(Bundle bundle)
{
this.bundle = bundle;
}
public URL
findResource(String name) {
return
bundle.getResource(name);
}
public Enumeration findResources(String
name) throws IOException {
return
bundle.getResources(name);
}
public Class findClass(String
name) throws ClassNotFoundException {
return
bundle.loadClass(name);
}
}
-Simon
This message may
contain privileged and/or confidential information. If you have received
this e-mail in error or are not the intended recipient, you may not use, copy,
disseminate or distribute it; do not open any attachments, delete it
immediately from your system and notify the sender promptly by e-mail that you
have done so. Thank you. _______________________________________________
equinox-dev mailing
list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev