java¶¯Ì¬´úÀí
Java¶¯Ì¬´úÀíÀàλÓÚJava.lang.reflect°üÏ£¬Ò»°ãÖ÷ÒªÉæ¼°µ½ÒÔÏÂÁ½¸öÀࣺ
(1). Interface InvocationHandler£º¸Ã½Ó¿ÚÖнö¶¨ÒåÁËÒ»¸ö·½·¨Object£ºinvoke(Object obj,Method method, Object[] args)¡£ÔÚʵ¼ÊʹÓÃʱ£¬µÚÒ»¸ö²ÎÊýobjÒ»°ãÊÇÖ¸´úÀíÀ࣬methodÊDZ»´úÀíµÄ·½·¨£¬ÈçÉÏÀýÖеÄdothing()£¬argsΪ¸Ã·½·¨µÄ²ÎÊýÊý×é¡£ Õâ¸ö³éÏó·½·¨ÔÚ´úÀíÀàÖж¯Ì¬ÊµÏÖ¡£
(2).Proxy£º¸ÃÀ༴Ϊ¶¯Ì¬´úÀíÀ࣬×÷ÓÃÀàËÆÓÚÉÏÀýÖеÄProxySubject£¬ÆäÖÐÖ÷Òª°üº¬ÒÔÏÂÄÚÈÝ£º
Protected Proxy(InvocationHandler h)£º¹¹Ô캯Êý£¬¹À¼ÆÓÃÓÚ¸øÄÚ²¿µÄh¸³Öµ¡£
Static Class getProxyClass (ClassLoader loader, Class[] interfaces)£º»ñµÃÒ»¸ö´úÀíÀ࣬ÆäÖÐloaderÊÇÀà×°ÔØÆ÷£¬interfacesÊÇÕæʵÀàËùÓµÓеÄÈ«²¿½Ó¿ÚµÄÊý×é¡£
Static Object newProxyInstance(ClassLoader loader, Class[] interfaces, InvocationHandler h)£º·µ»Ø´úÀíÀàµÄÒ»¸öʵÀý£¬·µ»ØºóµÄ´úÀíÀà¿ÉÒÔµ±×÷±»´úÀíÀàʹÓÃ(¿ÉʹÓñ»´úÀíÀàµÄÔÚSubject½Ó¿ÚÖÐÉùÃ÷¹ýµÄ·½·¨)¡£
ËùνDynamic ProxyÊÇÕâÑùÒ»ÖÖclass£ºËüÊÇÔÚÔËÐÐʱÉú³ÉµÄclass£¬ÔÚÉú³ÉËüʱÄã±ØÐëÌṩһ×éinterface¸øËü£¬È»ºó¸Ãclass¾ÍÐû³ÆËüʵÏÖÁËÕâЩ interface¡£Ä㵱Ȼ¿ÉÒ԰ѸÃclassµÄʵÀýµ±×÷ÕâЩinterfaceÖеÄÈκÎÒ»¸öÀ´Óᣵ±È»À²£¬Õâ¸öDynamic ProxyÆäʵ¾ÍÊÇÒ»¸öProxy£¬Ëü²»»áÌæÄã×÷ʵÖÊÐԵŤ×÷£¬ÔÚÉú³ÉËüµÄʵÀýʱÄã±ØÐëÌṩһ¸öhandler£¬ÓÉËü½Ó¹Üʵ¼ÊµÄ¹¤×÷¡£
×îºóµ÷ÓÃÒµÎñ·½·¨sayHelloʱ£¬ÆäʵÊÇÈ¥µ÷ÓÃÁËLogerHandlerµÄinvoke·½·¨£¨¾ßÌåÔõôʵÏÖµÄÄÇʱÐéÄâ»ú×öµÄÊ£¬ÎÒÃDz»ÐèÒª¹ØÐÄ£©¡£ËùÒÔÒª×÷AOP»òÕß˵ÊÇ·½·¨À¹½Ø£¨ÕâÀïÊÇÊä³öÒ»¸öÈÕÖ¾£©Ó¦¸ÃÔÚinvoke·½·¨Àï×ö¡£ÄǾßÌåµ÷ÓÃÒµÎñÀࣨÕâÀïÊÇHelloImpl£©µÄÄĸö·½·¨ÄØ£¿invokeÀïµÄmethod²ÎÊý¾Í¸æËßinvoke¾ßÌåµ÷Óõķ½·¨ÁË¡£
ʵÀý£º
1¡¢¶¨Òå½Ó¿Ú
package com.beckham.proxy;
public interface Speek {
public void sayHello(String name) ;
}
2¡¢ÊµÏָýӿÚ
package com.beckham.proxy;
public class SpeekImp implements Speek {
public void sayHello(String name) {
System.out.println("hello :"+name);
}
}
3¡¢´úÀíÀà
package com.beckham.proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
//´úÀíÀà
public class LogProxy implements InvocationHandler {
private Object obje
Ïà¹ØÎĵµ£º
×÷Îı¾±à¼Æ÷µÄʱºò£¬³·Ïú(undo)¡¢»Ö¸´(redo)ÊDZز»¿ÉÉÙµÄÁ½¸ö¹¦ÄÜ¡£ÊµÏÖÕâ¸ö¹¦ÄÜ£¬ÒªÓõ½javax.swing.undo°üÖеÄUndoManagerÀà¡£
UndoManagerÀàÓÐÈçϳ£Ó÷½·¨£º
boolean canUndo() ——ÅжÏÄÜ·ñ½øÐг·Ïû²Ù×÷£¬¿ÉÒÔÔò·µ»Øtrue¡£
boolean canRedo() ——ÅжÏÄÜ·ñ½øÐлָ´²Ù×÷£¬¿ÉÒÔÔò·µ ......
Ŀ¼
¡¡¡¡Ç°ÑÔ
¡¡¡¡Ò». Java ÎĵµºÍ javadoc
¡¡¡¡¶þ. Îĵµ×¢Ê͵ĸñʽ
¡¡¡¡¡¡¡¡1. Îĵµ×¢Ê͵ĸñʽ»¯
¡¡¡¡¡¡¡¡2. Îĵµ×¢Ê͵ÄÈý²¿·Ö
¡¡¡¡Èý. ʹÓà javadoc ±ê¼Ç
¡¡¡¡¡¡¡¡1. @see µÄʹÓÃ
¡¡¡¡¡¡¡¡2. ʹÓà @author¡¢@version ˵Ã÷Àà
¡¡¡¡¡¡¡¡3. ʹÓà @param¡¢@return ºÍ @exception ˵Ã÷·½·¨
¡¡¡ ......
Compiling with the Java Compiler API
µ÷ÓÃJava±àÒëÆ÷API±àÒëJava
´ÓµÚÒ»Ì쿪ʼ,±ê×¼Javaƽ̨¾ÍȱÉÙÄܹ»±»µ÷ÓÃ,È¥²úÉúJava×Ö½ÚÂëµÄ±àÒëÆ÷½Ó¿Ú. ʹÓÃSunʵÏÖµÄƽ̨,Ò»¸öÓû§¿ÉÒÔͨ¹ý·Ç±ê×¼µÄ com.sun.tools.javac °üÖеÄMain class È¥±àÒëÄãµÄ´úÂë (Äã¿ÉÒÔÔÚlib×ÓĿ¼Ï嵀 tools.jar ÎļþÀïÕÒµ½Ëü). È»¶øÕâ¸ö° ......
ÄÇÌìÕý͵×ŲËͻȻ¾ÍÏëµ½ÁËΪºÎ²»×öÒ»¸öÅ©³¡ÄØ£¿
ÕýºÃ¸ÒÉϽá¿ÎÏîÄ¿¾ÍÒª¿ªÊ¼ÁË,ÀÏʦÓÖ´ß×ÅÕÒÏîÄ¿ÁË¡£
˵×ö¾Í×öÁË£¬
µ«´ÓÀ´Ã»ÓÐÉæ¼°¹ýÍøÒ³ÓÎÏ··½Ã棬Ȼºó·è¿ñ²é×ÊÁÏ£¬£¬ÊÕ»ñÈ´²»¶à£¬·¢ÏÖ×Ô¼ºÖªµÀ µÄÌ«ÉÙÁ˲»¾«flash£¬flexÒ²²»»á£¬¹â½çÃæ¾Í²»ºÃ°ì£¬
µ«ÊǼÈÈ»Ïëµ½ÕâÁË£¬²»»áÒ²ÒªÉÏÁË£¬£¬¹þ¡£
²»»áflashÁËÎÒ¾ÍÓÃcss+javascri ......
1. ÄãÐèÒª¾«Í¨ÃæÏò¶ÔÏó·ÖÎöÓëÉè¼Æ(OOA/OOD)¡¢É漰ģʽ(GOF£¬J2EEDP)ÒÔ¼°×ÛºÏģʽ¡£ÄãÓ¦¸ÃÁ˽âUML£¬ÓÈÆäÊÇclass¡¢object¡¢interactionÒÔ¼°statediagrams¡£
2. ÄãÐèҪѧϰJavaÓïÑԵĻù´¡ÖªÊ¶ÒÔ¼°ËüµÄºËÐÄÀà¿â(collections¡¢serialization¡¢streams¡¢networking¡¢multithreading¡¢reflection¡¢event¡¢handling¡¢NIO¡¢localiza ......