隨筆:25 文章:1 評(píng)論:66 引用:0
          BlogJava 首頁(yè) 發(fā)新隨筆
          發(fā)新文章 聯(lián)系 聚合管理

          2006年5月26日

          Sorry, I have already moved to JavaEye and Fanfou, please update if you have questions.
          posted @ 2009-05-09 22:13 steeven 閱讀(237) | 評(píng)論 (0)編輯 收藏
           
          最近讓新來(lái)的實(shí)習(xí)生寫訂餐機(jī)器人,羽毛球活動(dòng)預(yù)定機(jī)器人,兩個(gè)人寫了幾個(gè)星期,看得我心急火燎。現(xiàn)在的研究生啊。。。。

          自己拿來(lái)skype4java看了一下,感覺(jué)很好用。里面提供了一個(gè)application機(jī)制,類似socket,又強(qiáng)于socket。為什么說(shuō)強(qiáng)呢?因?yàn)槭腔趕kype, 穿透防火墻啦。
          windows自帶的遠(yuǎn)程桌面很好用,在速度上,比以前基于位圖傳送的netmeeting/pcanywhere之類的都要強(qiáng)。
          linux下面的遠(yuǎn)程桌面做的比較好的是nx系列。但是這些遠(yuǎn)程桌面的致命問(wèn)題就是網(wǎng)關(guān)、防火墻問(wèn)題。
          就是說(shuō)你要在家訪問(wèn)公司電腦,基本上要在防火墻上鑿洞,或者借助于vpn,softether之類的東東。

          skype的application利用skype自身的通訊機(jī)制,屏蔽了這些問(wèn)題,當(dāng)然,你的應(yīng)用也必須依賴skype了。

          java做遠(yuǎn)程桌面要能截屏、控制鼠標(biāo)鍵盤,所幸有java.awt.Robot, 原來(lái)這個(gè)東西是為了做自動(dòng)化測(cè)試,剛好。
          剩下就是穿數(shù)據(jù)的問(wèn)題。屏幕圖片,如果是bmp,比較碩大,即使是上網(wǎng)等文本界面,壓縮下來(lái)也要幾十k, 如果網(wǎng)絡(luò)帶寬不夠的話,比如公司有幾個(gè)下載愛(ài)好者,會(huì)比較慘。所以呢,決定傳差異,緩存前面的屏幕,看看如果差別不大,就只傳變化的部分。這樣數(shù)據(jù)量就比較小。但是呢,壓縮圖片的時(shí)候就不能采用有損壓縮啦,否則屏幕會(huì)變得越來(lái)越怪異。。。

          比較遺憾的是沒(méi)能象windows自帶的rdp那樣攔截繪圖操作,在點(diǎn)陣圖的方案上效率還是比較低的。希望有高手指點(diǎn)!

          skype4java是個(gè)日本人寫的,幾個(gè)聽了我介紹的朋友都有這疑問(wèn):日本人寫的?
          呵呵,如果你能寫出更好的,咱就不用它。那個(gè)日本作者還不錯(cuò),上班比較忙,還是答應(yīng)抽空f(shuō)ix幾個(gè)bug,感謝中~

          體驗(yàn)一下吧:skypeRDP
          posted @ 2006-12-06 20:18 steeven 閱讀(2612) | 評(píng)論 (6)編輯 收藏
           

          適用版本GWT 1.0.21。
          由于目前google web toolkit還沒(méi)有正式release, 所以問(wèn)題多多。記錄一下碰到的問(wèn)題:

          1. Shell調(diào)試模式和實(shí)際編譯結(jié)果有差異。
          shell中報(bào)告的異常在運(yùn)行中只是一些凌亂的腳本錯(cuò)誤,或者干脆沒(méi)有響應(yīng)。
          shell中通過(guò)的程序在實(shí)際運(yùn)行時(shí)還會(huì)有錯(cuò)誤。
          2. 避免錯(cuò)誤的方法是捕獲異常,
          在onModuleLoad方法中try catch
          或者GWT.setUnCaughtExceptionHandler()//全局異常捕獲
          3. LOG, 利用GWT.log(). shell模式下會(huì)輸出到控制臺(tái)。
          4. 遠(yuǎn)程調(diào)用屬于異步。同步遠(yuǎn)程調(diào)用可以自己包裝ClientCallback,在一個(gè)結(jié)束后調(diào)用另外一個(gè).
          5. RPC調(diào)用中Set傳遞有bug, 暫時(shí)用List
          6. Eclipse直接運(yùn)行Compiler/Shell, 加入gwt-dev-windows.jar。
          main: com.google.gwt.dev.GWTCompiler/GWTShell
          arguments: -out ${project_loc}\WebContent real/Index.html
          classpath->UserEnties->advanced->add folder->選擇項(xiàng)目的src目錄,要在第一位。
          7. Tomcat5問(wèn)題多多, 用tomcat4.
          8. gwt-user中非法包含javax.servlet, tomcat認(rèn)為其無(wú)效。直接放到tomcat/common/lib中。或者在jar中去掉。
          9. Exception.getStackTrace() 在Shell模式下有效, GWT.isScript()可以判斷
          10. 靜態(tài)中文在html中亂碼,要在html header中加入<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

          posted @ 2006-07-14 18:10 steeven 閱讀(2952) | 評(píng)論 (6)編輯 收藏
           
          開發(fā)設(shè)計(jì)兩個(gè)類:
          雞,構(gòu)造的時(shí)候要帶入蛋.
          蛋,構(gòu)造的時(shí)候要帶入雞.

          編譯沒(méi)問(wèn)題,初始化數(shù)據(jù)的時(shí)候問(wèn)題出來(lái)了.
          new 雞(new 蛋(???)) //蛋是誰(shuí)下的?
          作為一個(gè)正統(tǒng)的進(jìn)化論學(xué)生,解決如下:構(gòu)造原始雞類,雞開始是不下蛋的,把雞的構(gòu)造函數(shù)改成空的,這時(shí)候初始化一條原始雞的數(shù)據(jù)沒(méi)問(wèn)題.然后進(jìn)化出來(lái)蛋,雞下的,類不用改,把蛋的數(shù)據(jù)初始化好.這時(shí)候雞進(jìn)化,由蛋孵出來(lái),構(gòu)造方法要帶蛋進(jìn)來(lái),初始化一只新雞,刪除原始雞數(shù)據(jù).

          OK,問(wèn)題解決了嗎?這樣程序每次初始化數(shù)據(jù)的時(shí)候要改造雞類,好像不大容易啊....

          那上帝造物學(xué)說(shuō)怎樣解決問(wèn)題呢?:
          雞1 = new 雞(null);
          蛋1 = new 蛋(null);
          雞1.set蛋(蛋1);
          蛋1.set雞(雞1);
          save(雞1,蛋1);
          雞和蛋同時(shí)出來(lái)了.上帝造物法勝利

          是不是我的類設(shè)計(jì)有問(wèn)題,怎么會(huì)碰到雞生蛋蛋孵雞這種郁悶的問(wèn)題呢?
          posted @ 2006-07-02 20:28 steeven 閱讀(1461) | 評(píng)論 (2)編輯 收藏
           

          db4o目前還沒(méi)有unique index/primary key機(jī)制。(5.4)

          ???? public ? static ? void ?main(String[]?args)? {
          ????????ObjectContainer?db?
          = ?Db4o.openFile( " test.yap " );
          ????????db.set(
          new ?User( " abc " , 234 ));
          ????????db.set(
          new ?User( " abc " , 234 ));
          ????????ObjectSet
          < User > ?list? = ?db.query(User. class );
          ????????System.out.println(list);
          ????????db.close();?
          // halt?without?this?line?in?5.2
          ????}

          上面的例子會(huì)存儲(chǔ)兩個(gè)同樣的User對(duì)象。
          僅有的ID是一個(gè)存儲(chǔ)文件中的ID, 經(jīng)過(guò)碎片整理之后會(huì)發(fā)生變化,顯然不適用。
          要實(shí)現(xiàn)一個(gè)auto_increament的主鍵恐怕要自行實(shí)現(xiàn)。或者用已有的UUID實(shí)現(xiàn)。

          可能db4o太年輕的關(guān)系,目前還沒(méi)有支援這些功能。建議用@Annotation來(lái)實(shí)現(xiàn)。并且控制存儲(chǔ)。
          @ID
          @Unique
          @Index
          在EJB3里面已經(jīng)有現(xiàn)成的定義可以參考。
          posted @ 2006-06-19 18:15 steeven 閱讀(920) | 評(píng)論 (0)編輯 收藏
           
          原來(lái)說(shuō)是xaml只是隨著下一個(gè)版本的windows放出,后來(lái)改編到winfx里面,最近聽說(shuō)作為.net3.0出現(xiàn).這樣的直接后果就是這個(gè)b/s+c/s通吃的UI框架不但要寄生在新版windows里面,也要被用來(lái)在xp上攻城略地.

          微軟這回蓄勢(shì)待發(fā)xaml有多強(qiáng)大呢?3d(感覺(jué)不夠純粹)/強(qiáng)大的數(shù)據(jù)綁定/動(dòng)畫/多媒體支持...
          這里可怕的不僅僅是框架,還有配套的GUI開發(fā)工具.有趣的是Interactive Designer據(jù)說(shuō)就是用wpf開發(fā)的.
          xaml只是個(gè)xml描述文件,里面可以包含代碼,編譯成UI界面.所有的界面內(nèi)容也可以由程序動(dòng)態(tài)運(yùn)行.
          這樣未來(lái)運(yùn)行在browser里面的UI不是復(fù)雜的ajax,是和后臺(tái)一致的托管代碼.

          Java怎樣應(yīng)對(duì)呢?Java+Flash? 開發(fā)bs都困難重重.除非Flash能放棄as,直接同java結(jié)合,或者兩個(gè)公司合作開發(fā)一個(gè)新框架.這個(gè)新框架應(yīng)該是什么樣子呢?完全的3D視角,時(shí)間軸控制...重演c#后來(lái)居上的歷史.

          Java在Sun的手里一直半死不活,真希望能趕快被google并購(gòu),或者sun主動(dòng)把java捐贈(zèng)出來(lái).

          如果沒(méi)有"意外",在wpf正式發(fā)行以后,桌面應(yīng)用將逐步過(guò)渡到wpf開發(fā).HTML由于其跨平臺(tái),可能會(huì)平分秋色.

          面對(duì)wpf,如何反抗?java.net是太監(jiān),在.net陣營(yíng)里面連二奶都不算,等于投降.
          利用xaml? xaml被編譯加載,其執(zhí)行框架還是.net,機(jī)會(huì)似乎不大.在瀏覽器上可能會(huì)有類似lasszlo的組合.

          作為Java愛(ài)好者,祈禱奇跡發(fā)生吧,還好在Java世界中奇跡是家常便飯 :)
          posted @ 2006-06-18 22:57 steeven 閱讀(2459) | 評(píng)論 (3)編輯 收藏
           

          一般Apply按鈕應(yīng)該在用戶有輸入時(shí)有效,輸入沒(méi)有變化時(shí)無(wú)效。
          為了達(dá)到這個(gè)效果,一般界面上每個(gè)輸入控件要監(jiān)聽,并且和以前的值做比較,實(shí)現(xiàn)起來(lái)相當(dāng)麻煩。

          因?yàn)槲覀円延械慕缑媸腔跀?shù)據(jù)綁定,綁定到一個(gè)克隆的對(duì)象上。這樣判斷有沒(méi)有變化就很簡(jiǎn)單,updateInput之后,比較兩個(gè)對(duì)象是否一致即可。

          什么時(shí)候去判斷呢?在用戶輸入之后:捕捉鍵盤、鼠標(biāo)事件。

          攔截鍵盤鼠標(biāo)事件目前找到兩種方法:
          1. Toolkit.getDefaultToolkit().addAWTEventListener(listener,eventMask);
          這個(gè)方法注冊(cè)全局的監(jiān)聽機(jī)制,無(wú)論哪個(gè)窗口。里面注冊(cè)為weakHashmap,應(yīng)該不用考慮垃圾回收問(wèn)題。因?yàn)槭侨值模唤ㄗh采用。
          2. 攔截每個(gè)component自己的事件。
          正常來(lái)說(shuō),如果在textbox里面打字,事件不會(huì)交給window處理。enableInputMethods(true)可以幫忙。
          enable以后調(diào)用getInputContext(),取得InputContext處理。
          注意,InputContext的dispatchEvent(AWTEvent)會(huì)接到各種消息,感興趣的getID()有以下三個(gè):
          ???MouseEvent.MOUSE_CLICKED
          ???MouseEvent.MOUSE_WHEEL
          ???KeyEvent.KEY_TYPED

          posted @ 2006-06-13 16:52 steeven 閱讀(1634) | 評(píng)論 (2)編輯 收藏
           
          上海這方面活動(dòng)比較少,難得逮到一個(gè),跑去湊個(gè)熱鬧。天不作美,下班前一場(chǎng)大雨,讓參加的人少了很多。

          零星記了一些筆記,對(duì)我這個(gè)ajax門外漢來(lái)說(shuō)收獲還是很大。主講是ajaxcn.org的兩位高手。robbin的Rubby講座因?yàn)闀r(shí)間關(guān)系要改期。

          1. JS2的一些新特性:class/extend/interface/package/import/塊作用域/操作符函數(shù). 明年底會(huì)有browser開始支持。
          //干脆把java直接搬到browser里面算了。
          //以后是不是弄個(gè)標(biāo)準(zhǔn)接口允許加載不同語(yǔ)言的腳本引擎?大家就不用受js的鳥氣了。
          2. 推薦的ajax框架:Dojo/DWR/Prototype/GWT/YUI
          //排名有先后
          3. 新技術(shù):
          canvas 畫圖,已有多數(shù)瀏覽器支持。據(jù)說(shuō)有人用它實(shí)現(xiàn)了3D游戲
          SVG 基于xml的矢量圖。據(jù)說(shuō)和canvas都支持3d繪圖。
          E4X: xml的包裝, firefox支持
          4. 技術(shù)和需求水漲船高 //我們不會(huì)失業(yè)了
          5. HiJax:
          用傳統(tǒng)方式快速開發(fā)。在傳統(tǒng)網(wǎng)頁(yè)基礎(chǔ)上hack成ajax應(yīng)用。
          對(duì)禁用js的瀏覽器表現(xiàn)為傳統(tǒng)網(wǎng)頁(yè)。
          前期開發(fā)和后期改造獨(dú)立性很強(qiáng)。
          //后期要改造為完美的ajax,對(duì)server端要做些小的改動(dòng)來(lái)適應(yīng)。
          6. 推薦用FireFox調(diào)試AJAX, 插件三劍客:
          firebug/web develope tool/temper data分別用來(lái)調(diào)試腳本,觀察頁(yè)面dom,監(jiān)聽通信。
          //js調(diào)試的日子好過(guò)多了,但不要忘記總體效率。。。

          回來(lái)路上和一位tx聊起來(lái)ajax在企業(yè)中的地位好像不高,他對(duì)敏捷開發(fā)很有好感,對(duì)辦公室環(huán)境的要求很有趣。
          本次活動(dòng)的主要心得是:自助餐很好吃,以后有活動(dòng)還要去吃 :)
          posted @ 2006-06-07 23:44 steeven 閱讀(1327) | 評(píng)論 (4)編輯 收藏
           
          gwt的這些特性還是很有意思的,感覺(jué)比echo更貼近html, 比如說(shuō)尺寸等數(shù)據(jù),寫"20%"和"200px"都可以。echo則盡量封裝的象swing, 屏蔽掉html.

          anyway, 對(duì)于大多數(shù)邏輯都在客戶端的應(yīng)用,gwt可以大展身手。比如小游戲~

          guess number demo看這里:http://steeven.googlepages.com/MyApp.html
          完全在瀏覽器上運(yùn)行的玩意,沒(méi)有寫一句js,感覺(jué)還是很爽的~

          代碼如下:
          package?org.steeven.gwt.test.client;

          import?com.google.gwt.core.client.EntryPoint;
          import?com.google.gwt.user.client.Random;
          import?com.google.gwt.user.client.ui.Button;
          import?com.google.gwt.user.client.ui.ClickListener;
          import?com.google.gwt.user.client.ui.DialogBox;
          import?com.google.gwt.user.client.ui.Grid;
          import?com.google.gwt.user.client.ui.HasHorizontalAlignment;
          import?com.google.gwt.user.client.ui.RootPanel;
          import?com.google.gwt.user.client.ui.TextBox;
          import?com.google.gwt.user.client.ui.VerticalPanel;
          import?com.google.gwt.user.client.ui.Widget;

          /**
          ?*?
          @author?steeven@gmail.com
          ?
          */

          public?class?MyApp?implements?EntryPoint?{

          ????TextBox?txtCount?
          =?new?TextBox();

          ????
          private?Grid?pnlMain;

          ????
          private?Button[]?numbers?=?new?Button[100];

          ????
          private?int?target;

          ????
          private?int?count;

          ????
          private?DialogBox?box;

          ????
          private?Button?btnRetry;

          ????
          private?Button?btnClose;

          ????
          /**
          ?????*?This?is?the?entry?point?method.
          ?????
          */

          ????
          public?void?onModuleLoad()?{
          ????????VerticalPanel?pnlStatus?
          =?new?VerticalPanel();
          ????????pnlStatus.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
          ????????pnlStatus.setSpacing(
          20);

          ????????txtCount.setEnabled(
          false);
          ????????txtCount.setVisibleLength(
          10);
          ????????pnlStatus.add(txtCount);
          ????????btnRetry?
          =?new?Button();
          ????????btnRetry.setHTML(
          "<img?src=\"replay.gif\"/>?<u>R</u>etry");
          ????????btnRetry.setAccessKey(
          'r');
          ????????btnRetry.addClickListener(
          new?ClickListener()?{
          ????????????
          public?void?onClick(Widget?sender)?{
          ????????????????doInit();
          ????????????}

          ????????}
          );
          ????????pnlStatus.add(btnRetry);

          ????????Button?btnAbout?
          =?new?Button();
          ????????btnAbout.setHTML(
          "<img?src='about.gif'/>?<u>A</u>bout");
          ????????btnAbout.setAccessKey(
          'a');
          ????????btnAbout.addClickListener(
          new?ClickListener()?{
          ????????????
          public?void?onClick(Widget?sender)?{
          ????????????????doAbout();
          ????????????}

          ????????}
          );
          ????????pnlStatus.add(btnAbout);

          ????????RootPanel.get(
          "status").add(pnlStatus);

          ????????pnlMain?
          =?new?Grid(10,?10);
          ????????RootPanel.get(
          "main").add(pnlMain);

          ????????
          for?(int?i?=?0;?i?<?100;?i++)?{
          ????????????numbers[i]?
          =?new?Button();
          ????????????numbers[i].setText(i?
          +?"");
          ????????????numbers[i].addClickListener(
          new?ClickListener()?{
          ????????????????
          public?void?onClick(Widget?sender)?{
          ????????????????????doGuess(sender);
          ????????????????}

          ????????????}
          );
          ????????????pnlMain.setWidget(i?
          /?10,?i?%?10,?numbers[i]);
          ????????}


          ????????box?
          =?new?DialogBox();
          ????????box.setPopupPosition(
          400,?200);
          ????????btnClose?
          =?new?Button("<u>C</u>lose",?new?ClickListener()?{
          ????????????
          public?void?onClick(Widget?sender)?{
          ????????????????box.hide();
          ????????????????doInit();
          ????????????}

          ????????}
          );
          ????????btnClose.setAccessKey(
          'c');
          ????????box.add(btnClose);
          ????????doInit();
          ????}


          ????
          protected?void?doGuess(Widget?sender)?{
          ????????Button?btn?
          =?(Button)?sender;
          ????????btnRetry.setEnabled(
          true);
          ????????
          int?n?=?Integer.parseInt(btn.getText());
          ????????txtCount.setText(
          ""?+?(++count));
          ????????
          if?(n?==?target)?{
          ????????????numbers[n].setEnabled(
          false);
          ????????????btnClose.setFocus(
          true);
          ????????????box.clear();
          ????????????box
          ????????????????????.setHTML(
          "<center><img?src='win.gif'/><h1>YOU?WIN!!!</h1><br/><br/><br/>");
          ????????????box.add(btnClose);
          ????????????box.show();
          ????????}
          ?else?{
          ????????????
          if?(n?<?target)
          ????????????????
          for?(int?i?=?0;?i?<=?n;?i++)
          ????????????????????numbers[i].setEnabled(
          false);
          ????????????
          else
          ????????????????
          for?(int?i?=?n;?i?<?100;?i++)
          ????????????????????numbers[i].setEnabled(
          false);
          ????????}


          ????}


          ????
          protected?void?doAbout()?{
          ????????box.clear();
          ????????box
          ????????????????.setHTML(
          "<img?src='about.gif'/><h1>Guess?Number</h1><h3>Google?web?toolkit?test</h3>");
          ????????box.add(btnClose);
          ????????box.show();
          ????}


          ????
          private?void?doInit()?{
          ????????btnRetry.setEnabled(
          false);
          ????????target?
          =?Random.nextInt(99);
          ????????count?
          =?0;
          ????????txtCount.setText(
          "0");
          ????????
          for?(int?i?=?0;?i?<?100;?i++)?{
          ????????????numbers[i].setVisible(
          true);
          ????????????numbers[i].setEnabled(
          true);
          ????????}

          ????}


          }


          第一次玩gwt, 總共花了3個(gè)小時(shí),菜呀
          posted @ 2006-06-02 15:23 steeven 閱讀(1848) | 評(píng)論 (13)編輯 收藏
           

          前面轉(zhuǎn)貼Liebeck(echo的主要開發(fā)者,我的偶像)關(guān)于echo2和gwt的對(duì)比:http://www.aygfsteel.com/steeven/archive/2006/06/01/49379.html

          今天仔細(xì)做了一些筆記,并且加入了一些自己的想法,供選型者參考:

          綜合對(duì)比:
          1. 兩個(gè)都是非傳統(tǒng)的b/s框架,都是用AJAX來(lái)構(gòu)造動(dòng)態(tài)網(wǎng)站。編程過(guò)程都和SWT/Swing差不多。
          2. 區(qū)別在于一個(gè)運(yùn)行于客戶端,一個(gè)運(yùn)行于服務(wù)器

          3. gwt把代碼編譯為html+js, 目前只支持java1.4規(guī)范。echo沒(méi)這限制。
          4. gwt可以運(yùn)行于任何web server, echo則需要傳統(tǒng)的servlet容器。(意義不大,現(xiàn)在哪有靜態(tài)網(wǎng)站啊,后臺(tái)交互肯定還是需要的)
          5. echo2的客戶端引擎通過(guò)ajax提交用戶動(dòng)作,對(duì)用戶界面增量更新。
          ?
          性能:
          1. gwt的頁(yè)面logic都在瀏覽器上,所以很快。但是如果需要和中間層交互,就會(huì)碰到同樣的網(wǎng)絡(luò)問(wèn)題。
          2. echo2的代碼跑在server上,所以所有的交互都需要反饋給server。echo2在設(shè)計(jì)上盡量減少這種交互,比如客戶對(duì)文本的修改都是延遲發(fā)送到服務(wù)器,而服務(wù)器只發(fā)送頁(yè)面的變化部分到瀏覽器。
          3. gwt應(yīng)用被編譯成一個(gè)頁(yè)面,雖然應(yīng)用的復(fù)雜化,這個(gè)編譯結(jié)果也隨之變得可怕。。。(個(gè)人認(rèn)為隨著編譯器的發(fā)展,不同的頁(yè)面可以做到lazy load)
          4. echo的js模塊是lazy加載到瀏覽器的,界面上呈現(xiàn)哪些控件才去加載并且緩存對(duì)應(yīng)的js模塊。發(fā)送到客戶端的不是邏輯代碼,只有用戶狀態(tài)(個(gè)人認(rèn)為echo2現(xiàn)在過(guò)于lazy,導(dǎo)致初始化階段多次訪問(wèn)server加載一些基本的js模塊,應(yīng)該揉合到一起。另外,因?yàn)閑cho邏輯代碼在服務(wù)器上,相對(duì)來(lái)說(shuō)可以防止盜版)
          ?
          中間層和數(shù)據(jù)訪問(wèn):
          1. 如果要訪問(wèn)數(shù)據(jù),gwt還是要回到傳統(tǒng)的模式,通過(guò)rpc訪問(wèn)servlet。gwt提供把遠(yuǎn)程服務(wù)透明的包裝起來(lái),中間傳送pojo. 盡管包裝了,中間的安全和和校驗(yàn)還是必須要開發(fā)者考慮。
          2. echo支持SOA,但是不必須。大多數(shù)情況下安全不是問(wèn)題,因?yàn)閿?shù)據(jù)和邏輯都不會(huì)暴露到瀏覽器上。(以前給echo提過(guò)建議,瀏覽器用戶很可能去模擬一個(gè)被disabled按鈕提交,這種問(wèn)題現(xiàn)在無(wú)需考慮)
          ?
          運(yùn)行環(huán)境:
          1. gwt運(yùn)行在瀏覽器上,并非所有的java類都能編譯成js. gwt現(xiàn)在只支持java.lang/java.util下面的一個(gè)子集(版本?1.0.21):27 classes, 11 interfaces, and 18 exception(這讓人想起了j2me開發(fā)). 一些現(xiàn)有的類庫(kù)就別想了。
          ?
          調(diào)試:
          1. gwt調(diào)試需要一套和運(yùn)行時(shí)完全不同的環(huán)境:HOST模式,代碼作為真正的java在運(yùn)行。(個(gè)人認(rèn)為這里因?yàn)槭羌僯ava調(diào)試,比echo的web調(diào)試要稍微方便一些。做單元測(cè)試也更方便些,但不是對(duì)最終browser的測(cè)試)
          2. echo調(diào)試就是傳統(tǒng)的servlet調(diào)試。
          ?
          授權(quán):
          1. gwt的api是開源的,編譯器和host模式瀏覽器不公開。整體來(lái)說(shuō):free. (個(gè)人認(rèn)為,如果要擴(kuò)充gwt可能會(huì)遇到麻煩)
          2. echo2開源,mozilla public license. free(個(gè)人認(rèn)為:echostudio也free就好了。nextapp畢竟要生存)
          ?
          應(yīng)用:
          1. gwt可以嵌入傳統(tǒng)的靜態(tài)html, 也能作為一個(gè)完整應(yīng)用。做大應(yīng)用要考慮編譯后的重量、本地化、庫(kù)支持等問(wèn)題(關(guān)于18n, 可以在gwt支持論壇上搜索i18n,似乎已經(jīng)有方案)
          2. echo2成熟得可以適用各種應(yīng)用,但是不能作為靜態(tài)頁(yè)面的一部分使用。(有點(diǎn)吹牛,在大訪問(wèn)量下,服務(wù)器的壓力肯定不會(huì)小)
          ?
          ?
          ?
          個(gè)人結(jié)論:
          1. 開發(fā)方式都很優(yōu)秀,用純java開發(fā)b/s
          2. gwt可用于大型網(wǎng)站,把壓力轉(zhuǎn)嫁給客戶端。
          3. echo可用于快速開發(fā)復(fù)雜的企業(yè)應(yīng)用,把壓力丟給服務(wù)器(企業(yè)里面最清閑的就是前臺(tái)和服務(wù)器)

          兩個(gè)產(chǎn)品都很優(yōu)秀,GWT是2006年的IT颶風(fēng),波及后面幾年。M$的日子要難過(guò)了, GOOGLE的確是個(gè)令人頭痛的對(duì)手。

          然而,還有比gwt/echo2更美好的未來(lái)嗎?
          有!把他們的輸出變成flash,用java開發(fā)flash應(yīng)用。去年探索過(guò)一段時(shí)間,原型已經(jīng)出來(lái),因?yàn)閒lash開發(fā)調(diào)試太ugly, 沒(méi)有繼續(xù)下去。
          另外,微軟的WPF(AVALON)相當(dāng)值得關(guān)注。
          posted @ 2006-06-01 11:32 steeven 閱讀(1951) | 評(píng)論 (3)編輯 收藏
           

          Google Web Toolkit 雖然還是beta版本,和google的其他產(chǎn)品一樣,剛出生就注定不凡,也許將影響后面幾年的b/s開發(fā)。

          gwt利用了java開發(fā)的一切成熟條件,包括Unit test, refactor, IDE(eclipse...),傳統(tǒng)的b/s framework必將受到重創(chuàng),橫掃過(guò)后,JSF/ECHO等Server side framework可能幸存。如果哪天google加上serverside支持(從包命名上看是留有余地的)。。。雖然gwt目前還是小樣一個(gè),但是背后站的是重量級(jí)的google,強(qiáng)大的資源和數(shù)不完的銀子。。。。

          看到這玩意首先想到的是echo2, 客戶端技術(shù)都是ajax, 編碼都是java. 不同的是gwt發(fā)行時(shí)編譯成HTML+JS,Echo2則是完全的服務(wù)器端生成+更新。gwt跟server端交互依靠類似于ws的service把前后臺(tái)完全區(qū)分開。

          在echo的論壇里面已經(jīng)有人在討論這玩意了,并且八卦了一下gwt的前身似乎是Morfik的一部分(待證實(shí))
          從原理上,echo的開發(fā)者作出了對(duì)比,這個(gè)網(wǎng)站似乎被封鎖,這里轉(zhuǎn)貼一下:


          ===============================
          http://echotwo.blogspot.com/?作者tod liebeck

          Comparing the Google Web Toolkit to Echo2
          The Google Web Toolkit (GWT) is being compared to Echo2 quite frequently. Some of these comparisons have been fairly accurate, while others contain bits of misinformation. This article, written by the lead developer of Echo2, discusses the similarities and differences between these two frameworks.

          Overview

          The Google Web Toolkit and Echo2 definitely make for an interesting comparison. Both of these frameworks take a non-traditional approach toward web application development, even considering the latest crop of "AJAX-based frameworks" available today.

          The most obvious similarity between GWT and Echo2 is that they both enable the developer to create dynamic, AJAX-driven web user interfaces using only Java. In both projects, UIs are developed in a fashion similar to SWT or Swing: by assembling hierarchies of components and registering event handlers. Neither project requires the developer to work with HTML, JavaScript, or XML.

          The most obvious difference between GWT and Echo2 is that all of your GWT code is executed on the client, whereas your Echo2 code is executed on the server. There are advantages and disadvantages to both of these approaches, which will be highlighted throughout the article.

          GWT's defining attribute is the Java-to-JavaScript compiler. This compiler allows you to develop the web interface to your application in Java, then compile it to JavaScript. GWT limits the developer to a subset of the Java 1.4 libraries. GWT applications can be served by any web server, such as Apache, without the need for server-side processing.

          Echo2 applications are compiled to Java byte code and run on a Java server. Their Java code is executed by Echo2's "Web Application Container" layer, which sits atop a Java Servlet. On the web browser, the Echo2 "Client Engine" communicates user input to the Web Application Container via AJAX requests, with the server responding with directives to perform incremental updates to the state of the client web browser.

          User Interface Performance

          With GWT, all of your user interface code exists on the client browser. In operations that do not require server communication--that is, that do not require retrieving data from the middle tier--this configuration results in response times that are not dependent on the server. When data must be retrieved from the application's middle tier or business logic layer, the response time is subject to the same criteria as any other AJAX application, i.e., network latency, bandwidth, and server performance.

          Echo2 application code is run on the server, so for each user interaction that requires a call to the middle tier or immediate execution of the application's Java code, an AJAX connection is made to the server. Echo2 components are designed to minimize the client/server communication as much as is possible, limiting it to times when the server must be notified immediately of events. For example, simple events such as user input to a TextField component will not result in server contact. The server's response is the minimum set of instructions to incrementally update the client to reflect the new screen state.

          GWT applications are served to the client as a single HTML/JavaScript file, containing the entirety of the user interface. The size of this file will be proportional to the size of your user interface code and the toolkit libraries used by your application.

          Echo2 JavaScript modules are lazy-loaded to the client, and thereafter cached. A module will be retrieved when a component first appears on-screen that requires it. Application code is never sent to the client, only the state of the user interface.

          Middle Tier / Data Retrieval

          To access business data or perform a business process, a GWT user interface makes a remote procedure call (RPC) from the browser to a Servlet. GWT provides a mechanism to make the RPC invocation transparent to the developer, allowing the developer to build the application with "Plain Old Java Objects" (POJOs). However, any application that provides an RPC capability is a distributed application -- even when the RPC is accomplished transparently to the developer. Distributed applications in businesses and enterprises usually have security considerations and the remote objects serving the GWT clients must be designed with a focus on security to deflect attacks from imitated or hostile client applications.

          Echo2 applications support, but do not require, the use of distributed application logic or a Service Oriented Architecture (SOA). Alternatively, Echo2 applications can be built to run entirely within a single JVM instance, backed by a POJO-based middle tier. This allows Echo2 developers to build applications without the security concerns of distributed application logic -- and leverage the many strong frameworks built around POJO development such as the Spring Framework and Hibernate. Echo2 accomplishes this by keeping the state of a user's web interface on the server so that no remote objects need to be exposed.

          Run-time Environment

          GWT has some limitations due to the fact that applications are run on the client browser. First, GWT applications are limited to using a subset of the core Java class libraries, consisting of 27 classes, 11 interfaces, and 18 exception types found in the java.util and java.lang packages (as of GWT 1.0.21). This limitation prevents GWT applications from linking to most existing Java libraries. Additionally, all Java code must be compliant with the Java 1.4 specification; 1.5 is not supported. Localization-related portions of the Java API are not provided.

          Debugging

          GWT provides an alternate deployment environment for applications to facilitate debugging. The environment, called "Hosted Mode", allows a GWT application to be run as Java byte code in a local JVM, to which an IDE's debugger can be connected. In this mode, the application's user interface is displayed in a special web browser (a Mozilla/Firefox derivative).

          Echo2 applications may be debugged in the conventional manner, by connecting an IDE's debugger to a JVM running a Servlet container.

          Licensing

          The primary component of GWT, the Java-to-JavaScript cross-compiler, is proprietary, binary-only software. The Java API libraries are open source software, distributed under the Apache License. The API libraries have essentially no value without the proprietary compiler. The (non-critical) hosted-mode browser is also under the proprietary license. GWT is provided free of charge.

          Echo2 is open source software, licensed under the Mozilla Public License, and provided free of charge.

          Applicability

          GWT can be used as a means of creating AJAX components to embed in traditional web applications (or even in static web pages) as well as for creating complete application user interfaces. There are some issues to using it for the creation of large applications, where downloading an entire application to a client web browser in one shot would not be practical. The lack of localization and full Java API support also presents a problem for larger solutions.

          Echo2 is practical for creating web applications of any size. It is however not intended to scale downward to function as a platform for simply creating AJAX components in traditional web frameworks (or static web sites).

          More Information

          Google Web Toolkit:
          Home Page, Example Applications, Getting Started Guide, Developer Guide

          Echo2:
          Home Page, Example Applications, Tutorial
          posted by Tod Liebeck at 5:13 AM | 0 comments??

          ======================================
          畢竟gwt還是小baby, 以后怎么發(fā)展還難說(shuō),現(xiàn)在下結(jié)論太早。這兩天試用一下,有空從細(xì)節(jié)上對(duì)比一下。

          posted @ 2006-06-01 00:55 steeven 閱讀(609) | 評(píng)論 (0)編輯 收藏
           

          測(cè)試一下getResource(URI,boolean):

          ????????System.out.println(EcorePackage.eINSTANCE.eResource());? // 1
          ????????System.out.println(XMLTypePackage.eINSTANCE.eResource());? // 2

          ????????ResourceSet?rs?
          = ? new ?ResourceSetImpl();
          ????????rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
          ????????????????Resource.Factory.Registry.DEFAULT_EXTENSION,
          ????????????????
          new ?XMIResourceFactoryImpl());
          ????????String?uri?
          = ? " http://abc.eg/asdf " ;
          // ????????System.out.println(rs.createResource(URI.createURI(uri)));? // ?如果創(chuàng)建過(guò)臨時(shí)的,得到這個(gè)
          // ????????System.out.println(rs.createResource(URI.createURI(uri)));? // ?如果創(chuàng)建過(guò)多個(gè)臨時(shí)的,返回第一個(gè),這個(gè)忽略
          ????????rs.getPackageRegistry().put(uri,?EcorePackage.eINSTANCE);? // 得到結(jié)果同1,如果上面取消注釋,本地創(chuàng)建的優(yōu)先

          ????????System.out.println(rs.getResource(URI.createURI(uri),?
          false ));? // 同1


          createResource每次創(chuàng)建新的,getResource則是唯一實(shí)例的。

          每個(gè)生成的XxxPackage.eINSTANCE會(huì)自行創(chuàng)建自己的Resource。如果在插件中修改了EcorePackge.eInstance.eResource(),會(huì)不會(huì)天下大亂呢?

          ==================
          eclispe編輯器右邊的Mark Occurrence很方便,但是家里電腦上的這個(gè)黃色小標(biāo)記很不清楚。前幾天調(diào)整了老半天,修改配色方案,換顯示器驅(qū)動(dòng),調(diào)整顯示器對(duì)比度、亮度都收效不大。昨天偶然把XP的桌面風(fēng)格換回傳統(tǒng)模式,搞定了。

          ecore.ecore這個(gè)問(wèn)題很有意思,以前看過(guò)schema.xsd,就是自己定義自己。據(jù)說(shuō)JDK也是用java開發(fā)編譯出來(lái)的。。。
          先有雞還是現(xiàn)有蛋呢?

          posted @ 2006-05-26 10:22 steeven 閱讀(1026) | 評(píng)論 (1)編輯 收藏
           

          在RS中同一URI可以createResource多個(gè)Resource,List方式存放。還存在另外一種Map存放方式, getResource(URI,boolean loadOnDemand)就是通過(guò)這種方式存取,如果不存在的話創(chuàng)建。這兩個(gè)方法看起來(lái)有些沖突。似乎用于不同場(chǎng)合。

          再來(lái)看看怎樣通過(guò)URL存取EObject:
          RS整個(gè)相當(dāng)于一個(gè)DataBase, Resource相當(dāng)于表,存放的是EObject, 每個(gè)EObject可以看成對(duì)象或者XML。
          表用URI來(lái)區(qū)分,URI中的Segment用來(lái)定位EObject。URI的例子參見(jiàn)探索(1)
          getEObject(URL, boolean loadOnDemand)很簡(jiǎn)單,getResource找到對(duì)應(yīng)的Resource,在里面根據(jù)Segment查找,就是那個(gè)#///@xxx.n格式的東西,注意,還有ID方式。

          getPackageRegistry()用來(lái)返回RS的URL->Package注冊(cè)表,它也是個(gè)本地的注冊(cè)表,代理了全局的EPackage.Registry.INSTANCE。這個(gè)注冊(cè)表用于取得EPackage(類型信息)和EFactory(創(chuàng)建實(shí)例)


          Resource就不說(shuō)了,主要load,save, 一些具體子類,比如XmlResourceImpl可以直接使用,指定Encoding之類。

          看看ResourceSet對(duì)EMF了解了很多~

          posted @ 2006-05-26 01:23 steeven 閱讀(1101) | 評(píng)論 (0)編輯 收藏
           
          來(lái)看看ResourceSet.createResource(URI):Resource方法,從URI到Resource的過(guò)程如下:
          1. getResourceFactoryRegistry()
          ??public?Resource.Factory.Registry?getResourceFactoryRegistry()
          ??
          {
          ????
          if?(resourceFactoryRegistry?==?null)
          ????
          {//可以自行Set一個(gè)注冊(cè)表實(shí)現(xiàn),沒(méi)有的話用系統(tǒng)缺省注冊(cè)表
          ??????resourceFactoryRegistry?=
          ????????
          new?ResourceFactoryRegistryImpl()
          ????????
          {
          ??????????
          public?Resource.Factory?delegatedGetFactory(URI?uri)
          ??????????
          {
          ????????????
          return?Resource.Factory.Registry.INSTANCE.getFactory(uri);
          ??????????}

          ????????}
          ;?//代理系統(tǒng)注冊(cè)表,注意這個(gè)應(yīng)該是正宗的。
          ????}

          ????
          return?resourceFactoryRegistry;
          ??}

          所以自己new 出來(lái)的ResourceSet可以向注冊(cè)表中任意添加工廠實(shí)現(xiàn)。
          2. 調(diào)用注冊(cè)表的getFactory(URI), 實(shí)現(xiàn)如下:
          ?public?Resource.Factory?getFactory(URI?uri)
          ??
          {
          ????String?protocol?
          =?uri.scheme();
          ????Object?resourceFactory?
          =??protocolToFactoryMap.get(protocol);?//先根據(jù)protocol查找
          ????if?(resourceFactory?==?null)
          ????
          {
          ??????String?extension?
          =?uri.fileExtension();
          ??????resourceFactory?
          =?extensionToFactoryMap.get(extension);?//找不到再根據(jù)擴(kuò)展名查找
          ??????if?(resourceFactory?==?null)
          ??????
          {
          ????????resourceFactory?
          =?extensionToFactoryMap.get("*");?//嘗試查找缺省擴(kuò)展
          ????????if?(resourceFactory?==?null)
          ????????
          {
          ??????????resourceFactory?
          =?delegatedGetFactory(uri);?//自行實(shí)現(xiàn)可以擴(kuò)展此方法解析。
          ????????}

          ??????}

          ????}


          ????
          //Descriptor可以用于編程使用
          ????return?
          ??????resourceFactory?
          instanceof?Resource.Factory.Descriptor??
          ????????((Resource.Factory.Descriptor)resourceFactory).createFactory()?:
          ????????(Resource.Factory)resourceFactory;
          ??}

          查找一個(gè)工廠居然這么復(fù)雜!正因?yàn)檫@么復(fù)雜,才能支持platform/file/fttp等眾多千奇百怪的URI
          不同類型的工廠加工出不同類型的Resource, 才會(huì)輸出為XSD/XML/XMI/....

          如果直接操作系統(tǒng)注冊(cè)表要小心。EMF中定義了幾個(gè)擴(kuò)展點(diǎn),可以實(shí)現(xiàn)類似目的。
          已知的ResourceFactory實(shí)現(xiàn)有:XSD/ECore/EMOF/XML/XMI,XSD的輸出方法的介紹可以參考Eclipse Development using the Graphical Editing Framework and the Eclipse Modeling Framework電子書。



          posted @ 2006-05-26 00:02 steeven 閱讀(1132) | 評(píng)論 (0)編輯 收藏
          CALENDER
          <2006年5月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿(10)

          隨筆分類

          隨筆檔案

          文章檔案

          相冊(cè)

          我的鏈接

          搜索

          •  

          最新評(píng)論

          • 1.?re: 編程使用SDO[EMF兄弟篇]
          • 最近也在看這個(gè),有沒(méi)有好點(diǎn)的文章和代碼啊,有的話麻煩給些,謝謝,郵箱:
            huanggenping2002@163.com
          • --zebrahgp
          • 2.?re: SNMP親密接觸
          • 請(qǐng)問(wèn),我在接收Trap時(shí),同時(shí)有多個(gè)設(shè)備發(fā)送,在同一時(shí)間接收到的會(huì)有丟失的情況,怎么解決呢?snmp4j自帶的ThreadPool類有沒(méi)有在這方面起到多線程作用?
          • --analyser
          • 3.?re: 編程使用SDO[EMF兄弟篇]
          • 我也在研究soa,如果你有sdo方面的代碼,麻煩您給我一份作為參考,謝謝
            郵箱: litao5168@sohu.com 謝謝
          • --litao
          • 4.?re: 編程使用SDO[EMF兄弟篇]
          • 我也在研究soa,如果你有sdo方面的代碼,麻煩您給我一份作為參考,謝謝
          • --litao
          • 5.?re: 編程使用SDO[EMF兄弟篇]
          • 評(píng)論內(nèi)容較長(zhǎng),點(diǎn)擊標(biāo)題查看
          • --1984prince

          Powered By: 博客園
          模板提供滬江博客

          主站蜘蛛池模板: 吴旗县| 汉沽区| 钦州市| 郴州市| 通州区| 石屏县| 图木舒克市| 清镇市| 康马县| 叙永县| 泸州市| 同心县| 青河县| 习水县| 寿光市| 阳城县| 大同市| 定边县| 永福县| 怀宁县| 大兴区| 台州市| 霍城县| 临朐县| 大方县| 天台县| 西平县| 日喀则市| 耿马| 海盐县| 遂平县| 冷水江市| 镇巴县| 林西县| 龙江县| 南昌县| 鸡西市| 山西省| 陆良县| 泸定县| 大新县|