?? 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 + -