ÔÚJavaÖÐÀûÓÃcglibʵÏÖ´úÀí
ÔÚÉÏһƪÎÄÕ¡¶ÔÚJavaÖÐÀûÓö¯Ì¬´úÀíʵÏÖÊý¾Ý¿âÁ¬½ÓÓëÊÂÎñµÄ×Ô¶¯¹ÜÀí¡·½²ÊöÁËÈçºÎʹÓÃJava¶¯Ì¬´úÀí£¬µ«ÒªÇó±»´úÀí¶ÔÏóҪʵÏÖÒ»¸ö½Ó¿Ú£¬Èç¹û²»ÏëʵÏÖ½Ó¿ÚÔõô°ìÄØ£¿Ê¹ÓÿªÔ´µÄcglib¿ÉÒÔʵÏÖ¶ÔÒ»¸öÀà¶ÔÏóµÄ´úÀí£¬¶ø²»ÒªÇóʵÏÖ½Ó¿Ú¡£
cglib£¨Code Generation Library£©Äܹ»ÔÚ³ÌÐòÔËÐеÄʱºò¶¯Ì¬Éú³É½Ó¿ÚµÄʵÏÖÀàºÍ¼Ì³ÐÓÚij¸öÀàµÄ×ÓÀ࣬ËüÊÇÒÀÀµÓÚASMµÄ£¬¶øASM¿ÉÒÔÁé»îµÄ²Ù×÷×Ö½ÚÂë¡£ÔÚhttp://cglib.sourceforge.net/¿ÉÒÔÏÂÔØcglib.jar£¬±¾ÎÄÑ¡ÔñµÄÊÇcglib-nodep-2.2.jar£¬ÕâÊÇÒ»¸ö²»ÒÀÀµÆäËûjarµÄÎļþ¡£Èç¹ûÑ¡Ôñcglib-2.2.jar£¬»¹ÐèÒª¼ÓÈ뼸¸öÒÀÀµµÄjar°ü²ÅÐУ¬ÔÚhttp://cglib.sourceforge.net/dependencies.htmlÁгöÀ´ÁËËùÐèÒªµÄjarÎļþ¡£
ÔÚ¡¶ÔÚJavaÖÐÀûÓö¯Ì¬´úÀíʵÏÖÊý¾Ý¿âÁ¬½ÓÓëÊÂÎñµÄ×Ô¶¯¹ÜÀí¡·µÄ»ù´¡ÉÏ£¬ÎÒÃǼÌÐøÍêÉÆ¿ò¼Ü£¬Ê¹Ò»¸öûÓÐʵÏÖ½Ó¿ÚµÄÆÕͨÀàÒ²¿ÉÒÔÒÔ×¢½âµÄ·½Ê½À´×Ô¶¯¿ª´òÊý¾Ý¿âÁ¬½ÓºÍÊÂÎñ£¬µ±È»ÊÇͨ¹ýcglibÀ´ÊµÏֵġ£
Ê×ÏȽ¨Á¢·½·¨µÄÀ¹½ØÆ÷Àà¡£´úÂëÈçÏ£º
package demo.dynamicproxy;
import java.lang.reflect.Method;
import java.sql.Connection;
import demo.dynamicproxy.annotation.Transactional;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
public class CglibProxy implements MethodInterceptor {
private Object target;
private IDb db;
public CglibProxy(Object target) {
this.target = target;
this.db = (IDb) target;
}
@Override
public Object intercept(Object obj, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
 
Ïà¹ØÎĵµ£º
Ò».javaÀà
package com.java.test;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
public class JavaReadXml {
// Document¿ÉÒÔ¿´×÷ÊÇXMLÔÚÄÚ´æÖеÄÒ»¸ ......
×î½üѧϰÖÐ×ÜÊǸоõÍ£Ö¹²»Ç°ÁË£¬µ½´ïÒ»¸öÆ¿¾±£¬¾³£Ð´µ½Ò»¸öµØ·½»á¾õµÃÕâ¸ö¶«Î÷ѧ¹ýµ«Óв»ÊÇÄÇôµÄÇå³þ£¬Ò»ÖÖËƶ®·Ç¶®µÄ¸Ð¾õ£¬ËùÒÔ¾ö¶¨Õҵط½°ÑÿÌìËùѧϰµÄ»òÓÐÓõĶ«Î÷¼Ç¼ÏÂÀ´£¬½ñÌ쿪ʼÕâÀォÊÇÎҵļ¼Êõ¿â£¬ÎÒ»áÓëËùÓа®ºÃJAVAµÄÅóÓÑÒ»Æðѧϰ£¬Ò»Æð½ø²½¡£½ñÌìÊÇ¿ª²©µÚÒ»Ì죬ÕýºÃÔÚ¸´Ï°DAOÉè¼Æģʽ£¬¿´µ½Ò»Æ¬²»´íµÄ½²½â£ ......
1¡¢ClassÀàµÄ·ÃÎÊȨÏÞ£º
public£º¿ÉÒÔ¹©ËùÓеÄÀà·ÃÎÊ¡£
ĬÈÏ(°ü·ÃÎÊȨÏÞ)£ºÄ¬ÈÏ¿ÉÒÔ³ÆΪfriendlyµ«ÊÇ£¬javaÓïÑÔÖÐÊÇûÓÐfriendlyÕâ¸öÐÞÊηûµÄ£¬ÕâÑù³ÆºôÓ¦¸ÃÊÇÀ´Ô´ÓÚc++¡£Ä¬ÈϵķÃÎÊȨÏÞÊÇ°ü¼¶·ÃÎÊȨÏÞ¡£
¼´Èç¹ûдÁËÒ»¸öÀàûÓÐд·ÃÎÊȨÏÞÐÞÊηû£¬ÄÇô¾ÍÊÇĬÈϵķÃÎÊȨÏÞ£¬ ......
public static void main(String args[]) {
Comparator cmp = (RuleBasedCollator)java.text.Collator.getInstance(java.util.Locale.CHINA);
String[] array = {"ÕÅÈý", "ÀîËÄ", "ÍõÎå"};
Arrays.sort(array, cmp);
for(String str : array){
System.out.println(str);
}
} ......
¹ÖÒìÖ®Ò»£º
connect(SocketAddress endpoint):Õâ¸ö·½·¨£¬³¢ÊÔÁ¬½Óserver¶Ë£¬Èç¹ûÁ¬½Ó²»ÉÏ£¬¾ÍÅ׳öIOExceptionÒì³£¡£Èç¹ûÁ¬½Ó³É¹¦ÁË£¬¾Í¼ÌÐøÖ´ÐÐÏÂÒ»²½µÄ´úÂë¡£
¹ÖÒìÖ®¶þ£º
boolean isConnected() :Õâ¸ö·½·¨µÄ½á¹û½ö½ö´ú±íÕâ¸ösocketÔø¾³É¹¦Á¬½Óµ½ÁËserver£¬µ«²¢²»±íʾÏÖÔÚÕâ¸öʱ¿ÌËüºÍserverÈÔ±£³ÖÁ¬½Ó״̬¡£
ÓÐ ......