📄 dynamicclassloader.java
字号:
/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package smartworld.server;
import java.net.URL;
import java.net.URLClassLoader;
import smartproxy.proxies.DynamicRemoteStub;
/**
* This is a special classloader that allows dynamic proxies to be used instead
* of generated stub classes.
*
* Load the remote object implementation class with this classloader to make it work.
*
* @author Rickard 謆erg (rickard@dreambean.com)
*/
public class DynamicClassLoader
extends URLClassLoader
{
// Static --------------------------------------------------------
static ThreadLocal currentClass = new ThreadLocal();
public static Class getCurrentClass()
{
return (Class)currentClass.get();
}
// Constructors --------------------------------------------------
public DynamicClassLoader(URL[] urls)
{
super(urls);
}
// 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);
currentClass.set(cl.getInterfaces()[0]); // Assume that it only implements one remote interface
return DynamicRemoteStub.class;
} else
{
return super.findClass(name);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -