cerulean

          之前用axis2生成代碼的時候都沒有在意過,一路用default configuration下來。
          前一陣子發現以前的代碼在生成時選擇的data binding不是用默認的adb方式,而是用xmlbeans。
          google了一番不同數據綁定的區別,好像也沒什么結果,大意就是adb的最簡單,但是有局限性;xmlbeans支持的比較全面,但是用起來有點兒復雜。不過,我也沒有體會出來xmlbeans強大在哪里……只是知道生成的代碼更多了,調用起來更繞彎子而已。。。

          server端用xmlbeans生成,client端用adb生成,互通是沒有問題的。
          client端用xmlbeans生成時,需要把產生于resources里面的所有.class文件打成jar包加到client端的build path里,否則運行client加載類的時候就會報錯了,好詭異,太不友好了。
          類似這種錯誤:

          ClassNotFoundException : Cannot load SchemaTypeSystem. Unable to load class with name schemaorg_apache_xmlbeans.system.s68C41DB812F52C975439BA10FE4FEE54.TypeSystemHolder. Make sure the generated binary files are on the classpath.


          所幸是在官方網站上有說明:http://ws.apache.org/axis2/tools/1_2/CodegenToolReference.html
          posted @ 2009-12-30 15:59 cerulean 閱讀(694) | 評論 (0)編輯 收藏
          一個JNLP文件中的資源必須由同一個證書簽名
          當需要不同證書時,可以創建多個JNLP文件,并在主JNLP文件中引用之。

          遇到過的問題:找不到子JNLP文件中的資源
          解決方法:竟然把子JNLP文件放到比主JNLP文件所在目錄低一級就可以了?!
          posted @ 2009-11-20 15:13 cerulean 閱讀(483) | 評論 (0)編輯 收藏

           

          JLabel.setText("<html>auto new line</html>");
          JLabel.setText("<html>line<br>force new line</html>");

           

          posted @ 2009-10-29 11:43 cerulean 閱讀(3451) | 評論 (1)編輯 收藏
          費了半天勁,敢情Firefox在3.0版本后又支持彈出modal window啦
          window.showModalDialog


          posted @ 2009-09-22 15:59 cerulean 閱讀(344) | 評論 (0)編輯 收藏
          HttpClient.getHttpConnectionManager().getParams().setSoTimeout()
          HttpClient.getHttpConnectionManager().getParams().setConnectionTimeout()

          第一個針對連接建立后,但是沒有收到response的超時時間,測試時可將server simulator收到request后等一段時間后再回response。
          出錯信息:
          java.net.SocketTimeoutException: Read timed out

          第二個針對連接建立的超時時間,測試時可將目的IP地址設為不存在的IP地址。
          出錯信息:
          org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 8000 ms
                  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:154)
          默認值為0,如果不設置的話大概2分多鐘才會得到異常


          posted @ 2009-09-10 16:09 cerulean 閱讀(5181) | 評論 (1)編輯 收藏
          導入了某證書至truststore,建立SSL連接時遇到錯誤
          javax.net.ssl.SSLKeyException: RSA premaster secret error
          Caused by: java.security.InvalidKeyException: Illegal key size or default parameters

          在windows上雙擊查看該證書時發現Public Key是4096bit,查了一番后發現Java默認好像不能處理這么長的key,必須要按照JCE的一個Unlimited Strength Jurisdiction Policy
          http://java.sun.com/javase/downloads/index_jdk5.jsp里面就有下載,這樣貌似就可以處理這種強度比較高的了。


          posted @ 2009-09-08 17:24 cerulean 閱讀(2089) | 評論 (0)編輯 收藏
          打印數組的方法,小地方,卻老忘記,來自FindBugs的提示:
          The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array.

          Arrays提供一系列接收不同類型數組作為參數的toString方法

          String[] array = new String[]{"a","b","c"};
          System.out.println(Arrays.toString(array));

          posted @ 2009-08-17 15:17 cerulean 閱讀(1180) | 評論 (0)編輯 收藏
          FindBugs,http://findbugs.sourceforge.net/
          發現代碼中潛在bug的工具,有eclipse的插件,安裝后右鍵單擊java project name,點擊Find Bugs,切換到FindBugs得perspective可以看到結果,速度還比較快,比之前用過的一個(雖然已經記不得名字了)快一些~具體的效果還是要逐個分析。

          Bug categories:

          Correctness bug
          Probable bug - an apparent coding mistake resulting in code that was probably not what the developer intended. We strive for a low false positive rate.
          Bad Practice
          Violations of recommended and essential coding practice. Examples include hash code and equals problems, cloneable idiom, dropped exceptions, serializable problems, and misuse of finalize. We strive to make this analysis accurate, although some groups may not care about some of the bad practices.
          Dodgy
          Code that is confusing, anomalous, or written in a way that leads itself to errors. Examples include dead local stores, switch fall through, unconfirmed casts, and redundant null check of value known to be null. More false positives accepted. In previous versions of FindBugs, this category was known as Style.
          Multithreaded correctness
               Incorrect lazy initialization and update of static field
               Calls Thread.sleep() with a lock held: better to use wait(lock)
               Synchronization on interned String could deadlock: 最好不用字符串,以免重復
          Performance
               invokes inefficient new String() constructor
               concatenates strings using + in a loop: better to use append StringBuffer
               inner class usage


          posted @ 2009-08-14 16:04 cerulean 閱讀(993) | 評論 (0)編輯 收藏
          Server

          創建本地證書:

          keytool -genkey -alias testserver-keyalg RSA -keystore keystore

          其中alias自己起一個別名,keystore為證書庫的文件路徑

          還可以加上-keysize 1024、2048、4096等來指定公鑰的大小,由此導出的證書查看時可以看到公鑰的大小是與之一致的。keysize越大genkey時耗費時間越長。


          會要求鍵入一個密碼,為這個證書庫的訪問密碼

          會要求填寫一些信息,姓名、單位、地區之類

          最后要求鍵入一個密碼,為這條證書別名的密碼

          導出cert

          keytool -export -alias testserver-file testcert.cer -keystore keystore

          這里的別名和文件名同上一步


          Client

          直接導入cert

          Truststore文件中存儲的是作為client,信任那些server的證書。所以需要將server提供的證書導入進來(當然可以導入n個),client才能信任。

          keytool -import -alias testserver-file testcert.cer -keystore truststore

          導入時需要輸入密碼,該密碼應該是truststore文件的訪問密碼,密碼正確才能修改其信息。

          提示是否信任該證書信息,確認。

          查看證書信息:

          keytool –list –v –keystore truststore

          如果導入過多個,則可以看到多條entry

          刪除某一個證書entry,通過指定別名來刪:

          keytool -delete -alias testserver-keystore truststore


          上述是自簽名的證書,證書鏈的長度只為
          1

          真正商用時,需要找相關機構(例如verisign)認證通過才能成為有效的證書:

          生成證書簽名請求:

          keytool -certreq -keyalg RSA -alias testserver -file certreq.csr -keystore keystore

          之后能夠收到一個證書文件,證書鏈信息包含了該機構的一些信息,然后再導入。


          有兩種方法建立
          HTTPS連接,

          一種是,在java中可以設置相關的4個系統參數,指向相關的keystore,truststore,一旦設置,在運行時就不可改變了。除非一定要使用多個不同的證書庫文件,否則可以把多個不同證書都導入到同一個證書庫里,這樣,設置系統參數為唯一的值也夠用,而且也比較簡單一些。

          另一種是,自己繼承相關接口實現自己的證書管理器,這樣可以自定義相關行為,也可以load不同的證書庫。


          如果不設置
          password,就認為不檢查文件完整性,也能通過。如果設置了password,但是不正確,則會遇到密碼錯誤的異常;如果server證書沒有導入到client得信任列表里,則會遇到找不到可信證書的異常。

          posted @ 2009-07-16 17:27 cerulean 閱讀(578) | 評論 (0)編輯 收藏
          一個反編譯的好工具,600KB,簡單好使又免費,比之前用過的好~
          http://java.decompiler.free.fr/?q=jdgui
          posted @ 2009-06-24 13:45 cerulean 閱讀(300) | 評論 (0)編輯 收藏
          僅列出標題
          共6頁: 上一頁 1 2 3 4 5 6 下一頁 

          導航

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 东莞市| 成安县| 宜兰县| 永胜县| 比如县| 迭部县| 孟津县| 彭阳县| 肃宁县| 永春县| 丹巴县| 马龙县| 白玉县| 千阳县| 会东县| 宜良县| 育儿| 龙井市| 绥棱县| 景谷| 盘锦市| 垣曲县| 墨竹工卡县| 包头市| 原平市| 石阡县| 清水河县| 五家渠市| 安岳县| 宁安市| 白河县| 绥中县| 民县| 阿勒泰市| 鹤壁市| 华池县| 三河市| 宁晋县| 宝丰县| 万年县| 岚皋县|