package com.jiuqi.mobile.core.service.base.test;
import java.security.SecureClassLoader;
import com.jiuqi.mobile.core.service.base.DynamicRemoteStub;
public class DynamicClassLoader2 extends SecureClassLoader
{ // Static
static ThreadLocal currentClass = new ThreadLocal();
public static Class getCurrentClass()
{
return (Class) currentClass.get();
}
private ClassLoader cl;
// Constructors --------------------------------------------------
public DynamicClassLoader2(ClassLoader cl)
{
super(cl);
this.cl=cl;
}
// Public implementation -----------------------------------------
protected Class findClass(String name) throws ClassNotFoundException
{
// if (name.endsWith("_Stub")) {
name = name.substring(0, name.length() - 5);
// Get impl
Class cl = loadClass(name);
// Assume that it only implements one remote interface
currentClass.set(cl.getInterfaces()[0]);
return DynamicRemoteStub.class;
// } else {
//
//// return super.findClass(name);
// return cl.loadClass(name);
//
// }
}
}