Ïê½âJava»Øµ÷»úÖÆ (Callback) ½²½â+ʵÀý
JavaÖеĻص÷£¨callback£©ÊǺÜÖØÒªµÄÒ»¸ö¸ÅÄspringÕûºÏhibernate´óÁ¿Ê¹ÓÃÁËÕâÖÖ¼¼Êõ¡£
¾¿¾¹ÔõÑù²ÅÊǻص÷ÄØ£¿
ÕâÊÇÍøÉÏ×î¶à¼ûµ½µÄ˵Ã÷£º
1.class A,class B
2.class AʵÏÖ½Ó¿Úcallback
3.class BÓµÓÐÒ»¸ö²ÎÊýΪcallback½Ó¿ÚÀàÐ͵ĺ¯Êý
4.class AÔËÐÐʱµ÷ÓÃclass BÖеĺ¯Êý,ÒÔ×ÔÉí´«Èë²ÎÊý
5.class BÒÑÈ¡µÃA£¬¾Í¿ÉÒÔËæÊ±»Øµ÷AËùʵÏÖµÄcallback½Ó¿ÚÖеķ½·¨
ÏÂÃæÎÒ¾ÙÒ»¸öÀý×Ó£º
ÖйúµçÐÅ(ChinaTelecom)ÊÇÒÆ¶¯ÔËÓªÉÌÖ®Ò»£¬Ïë±Ø½üÁ½ÄêÂúÌì·ÉµÄ“ÌìÒí3G”´ó¼Ò¶¼ÖªµÀ°É¡£¿ÕÖÐÍø£¨KongNet£©ÊÇÄǸö×ÜÊǺ°“ÓÃÊÖ»ú¿´NBA”µÄ·þÎñÌṩÉÌ£¨ServiceProvider£¬¼ò³Æ“SP”£©¡£
ÒÆ¶¯ÔËÓªÉ̺ÍSPºÏ×÷²ÅÄÜΪÎÒÃǹã´óÒÆ¶¯Óû§Ìṩ¸÷ÖÖ·þÎñ¡£±ÈÈçÒôÀÖ£¬²ÊÁ壬ÊÖ»ú¿´NBAµÈµÈ¡£
ÕâÀïÓÐÒ»¸ö½Ó¿ÚServiceProvider£¬Ò²¾ÍÊÇCallback½Ó¿Ú£»
/**
* ÓëÖйúµçÐźÏ×÷µÄspʵÏִ˽ӿڼ´¿É
* Õâ¸ö¾ÍÊÇCallback½Ó¿Ú
* @author wanghe
*
*/
public interface ServiceProvider {
/**
* sp¿ÉÒÔ×Ô¶¨ÒåÌáʾ
*/
public void customHint();
}
Ò»¸öChinaTelecomÀ࣬¼´class B£»
/**
* ÖйúµçÐÅ
* @author wanghe
*
*/
public class ChinaTelecom {
private ServiceProvider sp;//callback½Ó¿Ú×÷ΪÊôÐÔ
public void setSp(ServiceProvider sp) {
this.sp = sp;
}
/**
* ³õʼ»¯
*/
public void init(){
System.out.println("Welcome, This is ChinaTelecom! ");
sp.customHint();//sp×Ô¶¨ÒåµÄ²Ù×÷
}
}
Ò»¸öKongNetÀ࣬¼´ class A
/**
* ·þÎñÌṩÉÌ(SP)--¿ÕÖÐÍø
* @author wanghe
*
*/
Ïà¹ØÎĵµ£º
×î½ü¿´µ½µÄһƪÎÄÕ£¬¾õµÃдµÄͦºÃ£¬¾Íת¹ýÀ´ÒÔ±ã×Ô¼ºÀ´¿´¡£
¿´µ½ÂÛ̳ÀïÓиöÌû×ÓÔÚÌÖÂ۽ӿںͳéÏóÀàµÄÇø±ðºÍ×÷Óã¬ÕâÆäʵҲÊǺܶàÃæÊÔ¹Ùϲ»¶ÎʵÄÎÊÌ⣬ÕâÀïÎÒ¾Í˵˵ÎÒµÄ×ܽᣬ˳±ã˵˵ÄÚ²¿ÀàµÄ×÷Ó㬵±ÊǸø¸ÕÈëÃÅ£¬»òÕßÏëѧϰjavaµÄͬѧÃÇÄܸüºÃµÄÀí½âËüÃǵÄÓ÷¨¡£
1.½Ó¿Ú(interface)£¬½Ó¿Ú±»ÓÃÀ´½¨Á¢ÀàÓëÀàÖ®¼ä¹ØÁªµÄ±ê× ......
¡¡1.Ê×ÏÈÊǹ¤¾ß±ÈÈçEclipseºÜ·½±ãÁË¡£
¡¡¡¡2.ÓÃwinrarÖ®ÀàµÄ¹¤¾ß£¬°Ñweb-infoĿ¼£¬¼°¸úËüͬ¼¶µÄËùÓÐĿ¼¼°Îļþ£¬´ò°ü³É zipÎļþ¾ÍÐÐÁË£¬È»ºó°ÑÀ©Õ¹Ãû¸Ä³Éwar!
¡¡¡¡3 JarÃüÁ
¡¡¡¡¼Ù¶¨ÓÐÒ»¸öWebÓ¦ÓãºC:\myHome
¡¡¡¡ myHome/WEB-INF/……
¡¡¡¡myHome/files/……
¡¡¡¡myHome/image/… ......
ºËÐÄÌáʾ£º±¾ÎÄÃèÊöÁËÔÚJ2meÖпª·¢Ö÷ҪʹÓõÄÍøÂçÁ¬½Ó·½·¨£¬·Ö±ðÏêϸ½éÉÜÁËʹÓÃhttpºÍsocketÁ½ÖÖ·½·¨¡£ HttpConnection Ê×ÏÈÎÒÃÇÏÈÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó°É£º Ö÷ÒªÓõ½µÄjava°ü£º javax.microedition.io.*; public String requestGET(String URLString,String URL) throws
±¾ÎÄÃèÊöÁËÔÚJ2meÖпª·¢Ö÷ҪʹÓõÄÍøÂçÁ¬½Ó·½·¨£¬ ......
Java iText ¶¯Ì¬ Éú³É PDF Îĵµ ±í¸ñ ÖÐÎÄÎÊÌâ
iTextÊÇÒ»¸ö¿ª·¢Ô´´úÂëµÄÏîÄ¿£¬Äã¿ÉÒÔʹÓÃiText·½±ãµÄʵÏÖPDFµÄÊä³ö¡£
Ò»¡¢iTextµÄÏÂÔØ£º
Äã¿ÉÒÔÔÚ http://www.lowagie.com/iText/ ²é¿´¹ØÓÚiTextµÄÏà¹ØÐÅÏ¢£¬°üÀ¨Ô´´úÂ룬Îĵµ..
1. itext-src-1.4 ......
Java¶ÁÎļþдÎļþ²Ù×÷
By Aillo on March 27, 2008 7:56 PM | 0 Comments | Previous | Next | EDIT
ÕâÀJavaµÄ¶ÁÎļþºÍдÎļþ¶¼ÊÇ»ùÓÚ×Ö·ûÁ÷µÄ£¬Ö÷ÒªÓõ½ÏÂÃæµÄ¼¸¸öÀࣺ
1¡¢FileReader----¶ÁÈ¡×Ö·ûÁ÷
2¡¢FileWriter----дÈë×Ö·ûÁ÷
3¡¢BufferedReader----»º³åÖ¸¶¨ÎļþµÄÊäÈë
¸ÃÀàµÄ·½·¨ÓУº
......