Java Dynamic Proxy
import java.lang.reflect.*;
public class A extends Thread {
public static void main(String[] args) throws Exception{
CC cc = new CC();
HH hh = new HH(cc);
II ii = (II) Proxy.newProxyInstance(HH.class.getClassLoader(),
new Class[]{II.class},
hh);
System.out.println ("" + ii.getClass().getName());
ii.test();
}
}
interface II {
void test();
}
class CC implements II {
public void test() {
System.out.println ("this is cc");
}
}
class HH implements InvocationHandler {
Object obj;
HH(Object obj) {
this.obj = obj;
}
public Object invoke(Object obj, Method m, Object[] args) throws Exception {
System.out.println ("start");
Object o = m.invoke(this.obj, args);
System.out.println ("end");
return o;
}
}
运行时加入 -Dsun.misc.ProxyGenerator.saveGeneratedFiles=true,可以得到proxy class。
参考:http://www.javablogging.com/what-is-java-dynamic-proxies-api/
相关文档:
项目中你不得不知的11个Java第三方类库
责任编辑:覃里作者:Javaeye 2009-11-02 来源:IT168网站
文本Tag: IT业界 Java Java开发工具
【IT168 评论】Java第三方library ecosystem是一个很广阔的范畴。不久前有人撰文:每个项目中,你必须知道的11个Java第三方类库。
单元测试
......
/*****************Animal.java begin ***********************/
public class Animal{
public void jj(){
}
public static void main(String args[]){
//编译时类型 //运行时类型
Animal anima ......
这里的说的java开发环境,以搭建eclipse3.2.1为主题.
1、安装好Ubuntu系统;安装的时候强烈建议连接上网,它会自动下载语言包,自动装上五笔,拼音,还有会默认把firefox浏览器设置为中文.
安装Ubuntu比windows系统一个比较爽地方就是安装可以一边上网浏览,还可以试用一下Ubuntu的功能。
2、配置Ubuntu环境: ......
1.基本概念的理解
绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:xyz est.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个URL绝对路径。
相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如:在
Servl ......
If the requested address is not a valid virtual memory address (it doesn't belong to any of
the memory segments of the executing process), the page cannot be validated, and
a segmentation fault is generated. This vectors control to another part of the kernel and
usually results in the pro ......