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/
相关文档:
1.File类为管理文件和目录提供了方法,其对象表示一个文件或者目录。它提供了若干方法对文件或文件夹进行操作。其中的list()方法和listFiles()方法可以起到定位特定文件的作用。
2.Object类,是所有Java类的祖先,若一个类声明时没有包含extends关键字,则其直接继承于Objetc类。其中有许多重要方法:
equals(),not ......
一般进度条使用是给用户一种友好提示,让用户感觉这个事情正在做,而不是系统没有反应了;
JProgressBar的代码文档大家可以参考JDK1.6,比如构造函数有哪些,常用的方法有哪些在此就不多叙述;
一般使用情况是,点击按钮是做一件事情,比如备份,进度条出现并增加进度表示正在进行或到什么程度,事情结束时,进度条显示满 ......
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 ......
用 Java 解密 C# 加密的数据(DES)
[原文地址:http://yidinghe.cnblogs.com/articles/449212.html]
今天碰上一件令我头大的事情。我们的系统要和一个外部系统进行通讯,传输方式是采用 DES 算法对消息进行加密,再用 BASE64 编码。不过对方系统是用 C# 写的。平台不一样,于是我和对面的老兄先测试一下加密解密。 ......
java接口实现
对初学者来说,接口不是很好理解。现将某高手的一篇文章贴出来,共大家分享!
我们来看一个类
class A {
private int a;
public int getA() {
return a;
}
}
这个类的属性是私有的,外界不能访问,而外界可以通过公有方法来访问这个类。我们说一个类的公有方
法就是这个类的对外接口。通常
......