ÈçºÎʹÓÃProxyģʽ¼°JavaÄÚ½¨µÄ¶¯Ì¬´úÀí»úÖÆ
1.Proxy
ģʽ
´úÀíģʽ֧³Ö½«Ä³Ð©²Ù×÷´Óʵ¼ÊµÄ¶ÔÏóÖзÖÀë³öÀ´£¬Í¨¹ýËüµÄ´úÀíÀàÌṩ´¦Àí¡£ÕâÑù±ãÓÚÐ޸ĺ͹ÜÀíÕâЩÌض¨µÄ²Ù×÷¡£
ÏÂÃæʾÀýÒ»¸ö´úÀíģʽµÄʵÏÖ¡£
<<interface>>Subject.java
package
com.zj.proxy;
public
interface
Subject {
void
operation1();
void
operation2(String arg);
}
ÏÖʵÀà
RealSubject.java
package
com.zj.proxy;
public
class
RealSubject
implements
Subject {
public
void
operation1() {
System.
out
.println(
"Realer do operation1"
);
}
public
void
operation2(String arg) {
System.
out
.println(
"Realer do operation2 with "
+ arg);
}
}
´úÀíÀà
ProxySubject.java
package
com.zj.proxy;
public
class
ProxySubject
implements
Subject {
private
Subject
proxied
;
//
±»´úÀí¶ÔÏó
public
ProxySubject(Subject
proxied) {
this
.
proxied
= proxied;
}
public
void
operation1() {
System.
out
.println(
"Proxyer do operation1"
);
proxied
.operation1();
}
public
void
operation2(String arg) {
System.
out
.println(
"Proxyer do operation2 with "
+ arg);
proxied
.operation2(arg);
}
}
²âÊÔÀà
SimpleProxyDemo.java
package
com.zj.proxy.client;
import
com.zj.proxy.Subject;
import
com.zj.proxy.RealSubject;
import
com.zj.proxy.ProxySubject;
public
class
SimpleProx
Ïà¹ØÎĵµ£º
Ò»¡¢Servlet¹ýÂËÆ÷µÄ¸ÅÄ
***************************************************************************************
Servlet¹ýÂËÆ÷ÊÇÔÚJava Servlet¹æ·¶2.3Öж¨ÒåµÄ£¬ËüÄܹ»¶ÔServletÈÝÆ÷µÄÇëÇóºÍÏìÓ¦¶ÔÏó½øÐмì²éºÍÐ޸ġ£¡¡¡¡¡¡
Servlet¹ýÂËÆ÷±¾Éí²¢²»²úÉúÇëÇóºÍÏìÓ¦¶ÔÏó£¬ËüÖ»ÄÜÌṩ¹ýÂË×÷Óá£Servlet¹ýÆÚÄÜ ......
ËãÊõÒì³£ÀࣺArithmeticExecption
¡¡¡¡¿ÕÖ¸ÕëÒì³£ÀࣺNullPointerException
¡¡¡¡ÀàÐÍÇ¿ÖÆת»»Òì³££ºClassCastException
¡¡¡¡Êý×鸺ϱêÒì³££ºNegativeArrayException
¡¡¡¡Êý×éϱêÔ½½çÒì³££ºArrayIndexOutOfBoundsException
¡¡¡¡Î¥±³°²È«ÔÔòÒì³££ºSecturityException
¡¡¡¡ÎļþÒѽáÊøÒì³££ºEOFException
¡¡¡¡ÎļþÎ´Õ ......
Ä¿Ç°ÍøÂçÉϹØÓÚ¶ÔÏóÐòÁл¯µÄÎÄÕ²»ÉÙ£¬µ«ÊÇÎÒ·¢ÏÖÏêϸÐðÊöÓ÷¨ºÍÔÀíµÄÎÄÕÂÌ«ÉÙ¡£±¾ÈË°Ñ×Ô¼º¾¹ý¾Ñé×ܽáºÍʵ¼ÊÔËÓÃÖеÄÌå»áд³ÉµÄѧϰ±Ê¼Ç¹±Ï׸ø´ó¼Ò¡£Ï£ÍûÄÜΪÕû¸öjavaÉçÇøµÄ·±ÈÙ×öÒ»µãÊÂÇé¡£
¡¡¡¡ÐòÁл¯µÄ¹ý³Ì¾ÍÊǶÔÏóдÈë×Ö½ÚÁ÷ºÍ´Ó×Ö½ÚÁ÷ÖжÁÈ¡¶ÔÏó¡£½«¶ÔÏó״̬ת»»³É×Ö½ÚÁ÷Ö®ºó£¬¿ÉÒÔÓÃjava.io°üÖеĸ÷ÖÖ×Ö½ÚÁ÷Àà½«Æ ......
1¡¢Java²ÉÓÃUnicode×Ö·û¼¯£¬Ôö¼ÓÁ˶ԷÇÀ¶¡ÓïϵµÄÖ§³Ö£¬Ò»¸öºº×Ö¿ÉÒÔÖ±½Ó×÷Ϊһ¸ö×Ö·û³£Á¿½øÐи³Öµ¶øÔÚC++ÖбØÐë×öΪ×Ö·û´®´¦Àí
char chTemp = 'ÎÒ';
System.out.println(chTemp);
Java×Ö·ûÊÇÒ»¸ö16ΪµÄÎÞ·ûºÅÕûÊý£¬C++ÖÐΪ8λ
2. Java±êʶ·û¿ÉÒÔÒÔÃÀÔª·û$¿ªÍ·£¬¿Éº¬ÓÐËùÓÐÊ®Áù½øÖÆÖµ´óÓÚ0xc0µ ......