Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈçºÎʹÓÃ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


Ïà¹ØÎĵµ£º

java°üµ¼Èë»úÖƵÄÑо¿

¡¡¡¡javaÖÐÓÐÁ½ÖÖ°üµÄµ¼Èë»úÖÆ£¬×ܽáÈçÏ£º
¡¡¡¡µ¥ÀàÐ͵¼Èë(single-type-import)£¬ÀýÈçimport java.io.File;
¡¡¡¡°´ÐèÀàÐ͵¼Èë(type-import-on-demand)£¬ÀýÈç import java.io.*;
¡¡¡¡¹ØÓÚÕâÁ½ÖÖµ¼ÈëÀàÐÍ´ó¼Ò¸÷ÓÐËù°®£¬ÖÚ˵·×ç¡¡£ÕâÀï·ÖÎöÒ»ÏÂÕâÁ½ÖÖµ¼ÈëÀàÐ͵ĴóÖ¹¤×÷Ô­Àí¹©´ó¼Ò²Î¿¼¡£
¡¡¡¡µ¥ÀàÐ͵¼Èë±È½ÏºÃÀí½â£¬½ö½öµ ......

һЩ³£¼ûJavaÒì³£¹éÀà(Ò»)

UnsupportedClassVersionError
¡¡¡¡²»Ö§³ÖµÄÀà°æ±¾´íÎó¡£µ±JavaÐéÄâ»úÊÔͼ´Ó¶Áȡij¸öÀàÎļþ£¬µ«ÊÇ·¢ÏÖ¸ÃÎļþµÄÖ÷¡¢´Î°æ±¾ºÅ²»±»µ±Ç°JavaÐéÄâ»úÖ§³ÖµÄʱºò£¬Å׳ö¸Ã´íÎó¡£
¡¡¡¡java.lang.VerifyError
¡¡¡¡ÑéÖ¤´íÎó¡£µ±ÑéÖ¤Æ÷¼ì²âµ½Ä³¸öÀàÎļþÖдæÔÚÄÚ²¿²»¼æÈÝ»òÕß°²È«ÎÊÌâʱÅ׳ö¸Ã´íÎó¡£
¡¡¡¡java.lang.VirtualMachineErr ......

java ÃæÊÔÌâ59µÀ£¨º¬²Î¿¼´ð°¸£©


Java
»ù´¡·½Ãæ
:
 
1
¡¢×÷ÓÃÓò
public,private,protected,
ÒÔ¼°²»Ð´Ê±µÄÇø±ð
´ð£º
Çø±ðÈçÏ£º
×÷ÓÃÓò
           
µ±Ç°Àà
       
ͬһ
package  
×ÓËïÀà
     &n ......

JAVA·´Éä»úÖÆ

JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬¶¼Äܹ»ÖªµÀÕâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨£»¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏ󣬶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£»ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆΪjavaÓïÑԵķ´Éä»úÖÆ¡£
package mypakage;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ