aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/util/proxy
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2006-08-31 18:46:24 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2006-08-31 18:46:24 +0000
commitac5eb2dd048fa474e96f5f5786c6d482b674c051 (patch)
tree8bf7c20a7686efe8534f260323f28fa8e7b1fa35 /src/main/javassist/util/proxy
parent753e3f9ee02e946db80b9c87c582493ac5118f3c (diff)
downloadjavassist-ac5eb2dd048fa474e96f5f5786c6d482b674c051.tar.gz
javassist-ac5eb2dd048fa474e96f5f5786c6d482b674c051.zip
made ProxyFactory.getClassLoader() customizable.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@321 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/util/proxy')
-rw-r--r--src/main/javassist/util/proxy/ProxyFactory.java50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java
index fdd397ad..7fe72c77 100644
--- a/src/main/javassist/util/proxy/ProxyFactory.java
+++ b/src/main/javassist/util/proxy/ProxyFactory.java
@@ -143,6 +143,13 @@ public class ProxyFactory {
}
/**
+ * Obtains the super class set by <code>setSuperclass()</code>.
+ *
+ * @since 3.4
+ */
+ public Class getSuperclass() { return superClass; }
+
+ /**
* Sets the interfaces of a proxy class.
*/
public void setInterfaces(Class[] ifs) {
@@ -150,6 +157,13 @@ public class ProxyFactory {
}
/**
+ * Obtains the interfaces set by <code>setInterfaces</code>.
+ *
+ * @since 3.4
+ */
+ public Class[] getInterfaces() { return interfaces; }
+
+ /**
* Sets a filter that selects the methods that will be controlled by a handler.
*/
public void setFilter(MethodFilter mf) {
@@ -177,14 +191,48 @@ public class ProxyFactory {
return thisClass;
}
+ /**
+ * A provider of class loaders.
+ */
+ public static interface ClassLoaderProvider {
+ /**
+ * Returns a class loader.
+ *
+ * @param pf a proxy factory that is going to obtain a class loader.
+ */
+ public ClassLoader get(ProxyFactory pf);
+ }
+
+ /**
+ * A provider used by <code>createClass()</code> for obtaining
+ * a class loader.
+ * <code>get()</code> on this <code>ClassLoaderGetter</code> object
+ * is called to obtain a class loader.
+ *
+ * <p>The value of this field can be updated for changing the default
+ * implementation.
+ *
+ * @since 3.4
+ */
+ public static ClassLoaderProvider classLoaderProvider
+ = new ClassLoaderProvider() {
+ public ClassLoader get(ProxyFactory pf) {
+ return pf.getClassLoader0();
+ }
+ };
+
protected ClassLoader getClassLoader() {
+ return classLoaderProvider.get(this);
+ }
+
+ protected ClassLoader getClassLoader0() {
// return Thread.currentThread().getContextClassLoader();
ClassLoader loader = null;
if (superClass != null && !superClass.getName().equals("java.lang.Object"))
loader = superClass.getClassLoader();
else if (interfaces != null && interfaces.length > 0)
loader = interfaces[0].getClassLoader();
-
+
if (loader == null) {
loader = getClass().getClassLoader();
// In case javassist is in the endorsed dir