<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    2007年5月9日

    搭建過程備注:
    1. 虛擬機軟件Vmware 8.0 Workstation,Windows 2008 Enterprise Server, Sql Server 2008 R2。
    2. 倆個節點平臺版本必須一致,都為企業版。
    3. 與構建Windows 2003群集不同,不能使用vmware的共享磁盤機制。Windows 2008集群對存儲要求很高,不支持SCSI硬盤做集群。
        本次使用starwind 5.4代替vmware的共享磁盤實現群集存儲。
    4. 搭建Windows集群需要3臺虛擬機:2個節點+1臺存儲。
    5. 搭建SqlServer 2008集群需要4替虛擬機:2個節點+1臺DC+1臺存儲。

    搭建順序:
    1. 安裝DC+DNS服務器。
    2. 安裝集群節點, 配置雙網卡,域登錄。
    3. 安裝群集磁盤服務器
    4. 在集群節點上配置iSCSI發起。
    5. 在集群節點上安裝“故障轉移群集”功能。
    6. 進行故障轉移群集驗證和創建。
    7. 至此,Windows集群環境安裝完畢。
    8. 在集群節點上按群集方式安裝SqlServer 2008。
    9. SqlServer 2008集群環境構建完畢。

    參考文檔:
    Windows Server 2008的故障轉移群集入門: http://os.51cto.com/art/201007/210286.htm
    windows server2008虛擬機+群集: http://wenku.baidu.com/view/5e5b2be8e009581b6bd9eb1a.html
    Windows2008+sqlserver2008集群安裝:http://wenku.baidu.com/view/601dc74d2b160b4e767fcf46.html

    posted @ 2012-06-21 09:23 bluoy 閱讀(3944) | 評論 (0)編輯 收藏

    神一樣的軟件,膜拜ing...
    連我這天生kernel iptable有缺陷的都能用。

    當前版本:2.04.
    還是個Open Source的,改天一定要好好觀摩一番的。

    posted @ 2011-09-28 15:55 bluoy 閱讀(313) | 評論 (0)編輯 收藏

    If you meet following errors below when you try to build your source code:

     

    Checking build tools versions...

    build/core/main.mk:72:

    ************************************************************

    build/core/main.mk:73: You are attempting to build on a 32-bit system.

    build/core/main.mk:74: Only 64-bit build environments are supported beyond froyo/2.2.

    build/core/main.mk:75:

    ************************************************************

    Don’t panic, just change the code:

    build/core/main.mk

    ifeq ($(BUILD_OS),linux)

    build_arch := $(shell uname -m) 

    ---ifneq (64,$(findstring 64,$(build_arch))) 

    +++ifneq (i686,$(findstring i686,$(build_arch)))

     

    and change the code in four mk files below from “+=-m64” to “+=-m32”


    external/clearsilver/cgi/Android.mk

    external/clearsilver/java-jni/Android.mk

    external/clearsilver/util/Android.mk

    external/clearsilver/cs/Android.mk


    LOCAL_CFLAGS += -m32

    LOCAL_LDFLAGS += -m32

    end.

    posted @ 2011-01-07 10:54 bluoy 閱讀(365) | 評論 (0)編輯 收藏

    I got this idea when i was surfing the web in search of a tool similar to the Nokia Pc Suite for my Linux

    This How-To  works with many NOKIA Mobile Phone, especially for Nokia 3230, 6670, 6680, 6682 e 7610, 6120, Sony Ericsson Z1010, LG U8110/8120.

    First of all, we have to grant access for Mobile Phone to “dialout” group.

    sudo gedit /etc/udev/rules.d/40-permissions.rules

    Now we have to add to the end of file:

    # NOKIA 6120
    BUS==”usb”, SYSFS{idVendor}==”0421″, SYSFS{idProduct}==”002f”, GROUP=”dialout”

    where 0421 and 002f could be different depending on your Mobile Phone.
    To check your idVendor and idProduct, we have to type on terminal

    lsusb
    Bus 003 Device 009: ID 0421:002f Nokia Mobile Phones

    Now, we have to reload udev permission file:

    sudo /etc/init.d/udev restart

    We have to add our username on group “dialout”

    gpasswd -a username dialout

    All basics configurations for USB Data Cable are completed. We can start installation of obexftp and obextool GUI. Obextool GUI is written for tk graphic library, so GUI not have a good design as GTK.

    sudo apt-get install openobex-apps libopenobex1 obexftp obextool

    If you want start obextool from terminal we have to type for the first time:

    export OBEXCMD=”obexftp -t /dev/ttyACM0 -u 1″
    obextool

    or, we can start it simply by typing:

    obextool –obexcmd “obexftp -t /dev/ttyACM0 -u 1″

    When we start Obextool we can see this error message:

    It seems, that your device does not support the memory status feature.
    Memory status will be disabled

    To solve this problem we have to set some values on obextool.cfg:

    sudo gedit /etc/obextool.cfg

    set ObexConfig(config,memstatus) 0
    set ObexConfig(config,filemove) 0

    Another error message that we can see is:

    FIle ‘/FileName/’ could not be uploaded to ‘E:/Path’!
    Please check your file permissions.

    To solve it:

    sudo gedit /etc/obextool.cfg

    set ObexConfig(config,dir_slash) 1

    Good Job! Now your Mobile Phone works well in Ubuntu Gutsy with ObexTool.
    If we want add it as Desktop Entry:

    sudo gedit /usr/share/applications/obextool.desktop

    [Desktop Entry]
    Encoding=UTF-8
    Version=1.0
    Type=Application
    Exec=/usr/bin/obextool –obexcmd “obexftp -t /dev/ttyACM0 -u 1″
    Icon=/usr/share/icons/gnome/scalable/devices/phone.svg
    Terminal=false
    Name=Obextool
    GenericName=
    Comment=Browser your Mobile Phone
    Categories=Application;Utility;

    So, you can find it in your Gnome Panel over: “Applications” -> “Accessories” -> Obextool

    posted @ 2009-04-23 16:30 bluoy 閱讀(381) | 評論 (0)編輯 收藏

    下面的例子實現把一個整數的各個位上的數字相加,通過這個例子我們再次理解 connect by.

    create or replace function f_digit_add(innum integer) return number
    is
    outnum integer;
    begin
    if innum<0 then
    return 0;
    end if;
    select sum(nm) into outnum from(
    select substr(innum,rownum,1) nm from dual connect by
    rownum<length(innum)
    );
    return outnum;
    end f_digit_add;
    /

    select f_digit_add(123456) from dual;

    posted @ 2009-04-01 17:02 bluoy 閱讀(831) | 評論 (1)編輯 收藏

    終于搞明白了困惑很久的問題,罪魁禍首還是jdk啊。天殺的。
    以下內容轉自網絡:

    測試環境:Win2K Pro日文版,SUN J2SDK 1.5.0-beta2

    經過測試,發現Shift_JIS和MS932編碼的全角波浪線(“~”)的編碼都是 0x8160(16進制,兩個字節,高位在前)。通過sun.io.ByteToCharMS932轉換后得到Unicode字符'\uFF5E',而通過sun.io.ByteToCharSJIS轉換后則得到Unicode字符'\u301C'。

    反之,Unicode字符'\uFF5E'通過sun.io.CharToByteMS932轉換后會得到MS932編碼的本地字符0x8160(16進制,兩個字節,高位在前),而Unicode字符'\u301C'通過 sun.io.CharToByteSJIS轉換后也會得到Shift_JIS編碼的本地字符0x8160(16進制,兩個字節,高位在前),兩者的轉換結果相同。

    結論:在WinNT/2K/XP上,MS932和Shift_JIS這兩種本地字符集完全相同,只是分別采用JDK的sun.io.ByteToCharMS932和sun.io.ByteToCharSJIS對個別特殊的本地字符進行轉換后所得到的 Unicode字符并不一樣。實際上,MS932就是WinNT/2K/XP上的Shift_JIS,只是與標準版的Shift_JIS字符集相比,MS932收錄了更多的字符,比如NEC和IBM對Shift_JIS的擴展(如日文中的“?????①..?...”等等);然而,JDK中的 ByteToCharSJIS及CharToByteSJIS卻使用了標準的Shift_JIS字符集,所以部分擴展字符在從byte轉換成char或是從char轉換成byte時會出現亂碼,這的確是JDK讓人非常迷惑的一處。

    參考資料1(日文):http://www.asahi-net.or.jp/~ez3k-msym/charsets/jis2ucs.htm

    posted @ 2009-02-03 16:52 bluoy 閱讀(1393) | 評論 (0)編輯 收藏

    1. 函數的overwrite實現時,函數參數類型必須嚴格一致。與overload不同,并不遵守參數優先匹配的原則。
    所以,不能用子類,或這接口的實現類來妄圖得到overwrite的目的。
    2. 使用反射手法時,getMethod()的調用,參數類型必須與要得到的函數類型嚴格一致。與overload不同,并不遵守參數優先匹配的原則。
    3內部類,要實例化時必須首先實例化包含類。可以理解為內部類只是包含類的數據成員
    4非public類,非javabean規范的Bean,內部類BeanUtil類無法進行操作,比如clone()等等。

    posted @ 2008-12-28 10:54 bluoy 閱讀(190) | 評論 (0)編輯 收藏

    雖然java沒有提供函數指針的操作,而是必須通過對象來曲線救國。
    不過延伸一下這個思路,其實也未必不是件好事。從某種意義上來說,整個java系統,或者對象系統,其實就是不計其數的鉤子組成的系統。因為,參數傳遞的過程中完全依賴著對象,一種行為和數據的結合體。這里,關鍵詞是參數傳遞和對象的行為,當然離不開多態。
            改變既有代碼的行為步驟:
            1. 派生參數類得到新的子類。
            2. 在子類中覆寫(overwrite)父類既有方法。
            3. 將子類的實例作為參數傳遞。
            這樣,就得到了改變父類行為的目的。
     對于既有框架自作主張的封裝,阻礙自己的目的的時候,這個做法往往能獨辟蹊徑。

    posted @ 2008-12-28 10:40 bluoy 閱讀(191) | 評論 (0)編輯 收藏

    Spring Framework 的理解以及可維護性是否得以改善的思考

    Spring的特性:
    1. 提供了一種管理對象的方法,可以把中間層對象有效地組織起來。一個完美的框架“黏合劑”。
    2. 采用了分層結構,可以增量引入到項目中。
    3. 有利于面向接口編程習慣的養成。
    4. 目的之一是為了寫出易于測試的代碼。
    5. 非侵入性,應用程序對Spring API的依賴可以減至最小限度。
    6. 一致的數據訪問介面。
    6. 一個輕量級的架構解決方案。

    對Spring的理解
    Spring致力于使用POJOs來構建應用程序。由框架提供應用程序的基礎設施,將只含有業務邏輯的POJOs作為組件來管理。從而在應用程序中形成兩條相對獨立發展的平行線,并且在各自的抽象層面上延長了各自的生命周期。

    Spring的工作基礎是Ioc。Ioc將創建對象的職責從應用程序代碼剝離到了框架中,通常2中注入方式:setter 和 ctor參數。
    每個Bean定義被當作一個POJO(通過類名和JavaBean的初始屬性或構造方法參數兩種方式定義的Bean)。
    Spring的核心在org.springframework.beans,更高抽象層面是BeanFactory. BeanFactory是一個非常輕量級的容器。

    關于可維護性的思考
    Spring之類的技術確實帶來了應用系統的可維護性的提高嗎?
    Ioc, AOP之類的技術,本質上都是將原本位于應用程序代碼中"硬編碼"邏輯,剝離出來放到了配置文件中(或者其他形式)。主流聲音都是認為提高了應用程序的可維護性。

    但如果從以下方面觀察,結合項目實際經驗,個人感覺這些技術的應用大大降低了應用程序的可維護性,尤其是面對一個陌生的系統,或者項目人員變動頻繁的時候。
    1. 中斷了應用程序的邏輯,使代碼變得不完整,不直觀。此時單從Source無法完全把握應用的所有行為。
    2. 將原本應該代碼化的邏輯配置化,增加了出錯的機會以及額外的負擔。
    3. 時光倒退,失去了IDE的支持。在目前IDE功能日益強大的時代,以往代碼重構等讓人頭痛的舉動越來越容易。而且IDE還提供了諸多強大的輔助功能,使得編程的門檻降低很多。通常來說,維護代碼要比維護配置文件,或者配置文件+代碼的混合體要容易的多。
    4. 調試階段不直觀,后期的bug對應階段,不容易判斷問題所在。
    5. 性能問題。雖說硬件性能日新月異,但是性能也是在不經意間一點一點地流失的。從匯編到高級語言,到面向對象,到虛擬機,一直處于這樣的發展趨勢。

    posted @ 2008-07-06 10:21 bluoy 閱讀(2011) | 評論 (3)編輯 收藏

    項目中組員偶然寫了一段垃圾的sql語句,不想卻誤打誤撞的發現了一個jdbc的bug,包括Oracle 10g附帶的版本。

    詳細描述可以參考如下代碼:
       public static void testSetTimestampBug() throws Exception{
            Calendar calendar = new GregorianCalendar();
            Date d = calendar.getTime();
            
            String sql = "select 1+1 from dual where ?-sysdate<1";         //error sql
            String sql1 = "select ?-sysdate from dual";                          //no error sql
            String sql2 = "select 1+1 from dual where ?-1<sysdate";       //no error sql
            PreparedStatement pst = cn.prepareStatement(sql);
            //pst.setDate(1, new java.sql.Date(d.getTime()));                 //no  error
            pst.setTimestamp(1, new java.sql.Timestamp(d.getTime()));   //bug!!!, throw SQLException: ORA-00932
        }
    三種sql的寫法中,第一種寫法在使用setTimestamp()時會出錯,其他倆種卻不會有問題。
    即正常調用PreparedStatement.setTimestamp()方法,遇到某些特殊寫法的sql語句卻會出錯。
    本例中,拋出如下例外:
    java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got INTERVAL.
    然而,如果使用setDate()方法,則一切正常,三種寫法都沒有問題。

    因為有這個問題,如果在持久層使用了其他的中間件,則這個問題可能變的更加隱蔽,比如iBatis中的處理是這樣的:
    java.util.Date ---> ibatis.DateTypeHandler----->PreparedStatement.setTimestamp() 
    java.sql.Date ---> ibatis.SqlDateTypeHandler----->PreparedStatement.setDate()
    如果不注意輸入參數類型的話,就會遇到上述問題。我就因此費了不少周折。
    對于iBatis的使用建議,保證入口參數類型始終為java.sql.Date即可。

    posted @ 2008-03-26 17:17 bluoy 閱讀(1791) | 評論 (0)編輯 收藏

    Web架構特性及REST架構風格(部分內容摘自網絡)

    良好的Web架構風格:
        1. 客戶/服務器模式:  實現了UI與數據的分離。
        2. 服務端無狀態性: 可見性,可靠性,可伸縮性等方面的改善。
         可見性-無狀態性使得服務器不必要維護海量的上下文(Context)。
         可靠性-無狀態性減少了服務器從局部錯誤中恢復的任務量。
         可伸縮性-無狀態性使得服務器可以很容易的釋放資源。
        3. 緩存: 減少服務端不必要的處理。
        4. 可伸縮性: 便于分布式和集群部署。
         上面的2,3點也是影響4的主要因素。而隨著系統用戶規模的指數上升,可伸縮性將變的至關重要。

    現在大多數應用程序都忽略或者違反了上述2, 3的風格。當然也肯定失去了4帶來的好處。
    比如Java Servlet中HttpSession的應用,使服務器端保存了客戶端的狀態。
    時下流行的動態頁面的做法也使得資源緩存變得困難或者不可能。
    這些都直接影響了應用的可伸縮性。

    改善現狀的思路是,把服務端的處理和狀態前移,由客戶端來實現。使服務端回歸到無狀態的特性。
    以采用ajax技術的應用系統為例:因為不需要完全刷新就可以與服務器進行交互,使得有狀態客戶機成為可用選擇。基于瀏覽器的應用程序代碼可以在必要時獲取新的服務器數據,并把這些數據織入當前頁面。
    將處理和狀態前移到每個客戶機上后,實現了無狀態的服務端;同時緩存服務器可以緩存ajax引擎(比如dojo, prototype etc.),以及狀態無關的數據。
    個人理解,多種瀏覽器的plug-in技術(Sun的applet, MS的ActiveX等等),都應該是這種思路的不同技術實現。

    經過以上分析整理,實際上已經涉及到了時下流行的一個概念-REST.

    REST(Representational State Transfer)來源于Dr. Roy Thomas Fielding,  <Architectural Styles and the Design of Network-based Software Architectures>
    當瀏覽器瀏覽訪問一個url資源時,返回的頁面即為該url資源的representation,這個representation給瀏覽器一個state,當
    瀏覽器訪問下一個url資源時,瀏覽器的state就transfer了。
    REST其本身只是為分布式超媒體系統(distributed hypermedia systems)設計的一種架構風格,而不是某個標準,框架。

    REST的設計準則
        1.網絡上的所有事物都被抽象為資源(resource);
        2.每個資源對應一個唯一的資源標識符(resource identifier);
        3.通過通用的連接器接口(generic connector interface)對資源進行操作;
        4.對資源的各種操作不會改變資源標識符;
        5.所有的操作都是無狀態的(stateless)。

    REST中的資源所指的不是數據,而是數據和表現形式的組合。
    REST是基于Http協議的,任何對資源的操作行為都是通過Http協議來實現。以往的Web開發大多數用的都是Http協議中的GET和POST方法,對其他方法很少使用,這實際上是因為對Http協議認識片面的理解造成的。Http不僅僅是一個簡單的運載數據的協議,而是一個具有豐富內涵的網絡軟件的協議。他不僅僅能對互聯網資源進行唯一定位,而且還能告訴我們如何對該資源進行操作。Http把對一個資源的操作限制在4個方法以內:GET, POST,PUT和DELETE,這正是對資源CRUD操作的實現。由于資源和URI是一一對應的,執行這些操作的時候URI是沒有變化的,這和以往的 Web開發有很大的區別。正由于這一點,極大的簡化了Web開發,也使得URI可以被設計成更為直觀的反映資源的結構,這種URI的設計被稱作 RESTful的URI。這位開發人員引入了一種新的思維方式:通過URL來設計系統結構。當然了,這種設計方式對一些特定情況也是不適用的,也就是說不是所有的URI都可以RESTful的。
    REST 之所以可以提高系統的可伸縮性,就是因為它要求所有的操作都是無狀態的。由于沒有了上下文(Context)的約束,做分布式和集群的時候就更為簡單,也可以讓系統更為有效的利用緩沖池(Pool)。并且由于服務器端不需要記錄客戶端的一系列訪問,也減少了服務器端的性能。

    posted @ 2008-03-24 16:35 bluoy 閱讀(394) | 評論 (0)編輯 收藏

           Java語言編程中更新XML文檔的四種方法。第一種方法是直接讀寫XML文件。第二種方法是使用Apache Crimson的XmlDocument類,這種方法極為簡單,使用方便,如果你選用Apache Crimson作為XML解析器,那么不妨使用這種方法,不過這種方法似乎效率不高(源于效率低下的Apache Crimson),另外,高版本的JAXP或者是Java XML Pack、JWSDP不直接支持Apache Crimson,亦即這種方法不通用。第三種方法是使用JAXP的XSLT引擎(Transformer類)來輸出XML文檔,這種方法也許是標準的方法 了,使用起來十分靈活,特別是可以自如控制輸出格式,我們推薦采用這種方法。第四種方法是第三種方法的變種,采用了Xalan XML Serializer,引入了串行化操作,對于大量文檔的修改/輸出有優越性,可惜的是要重復設置XSLT引擎的屬性和XML Serializer的輸出屬性,比較麻煩,而且依賴于Apache Xalan和Apache Xerces技術,通用性略顯不足。除此之外,實際上應用別的API(比如dom4j、JDOM、Castor、XML4J、Oracle XML Parser V2)也有很多辦法可以更新XML文檔。

    概念介紹
            Xerces/Crimson是XML解析器,Xalan是XSLT處理器,xml-apis.jar實際上是JAXP。
            Apache Crimson的前身是Sun Project X Parser, 至今Apache Crimson的很多代碼都是從X Parser中直接移植過來的。早期的JAXP是和X Parser捆綁在一起的。后來的 JAXP和Apache Crimson捆綁在一起,比如JAXP 1.1。最新的JAXP 1.2 EA(Early Access)改弦更張,采用性能更好的Apache Xalan和Apache Xerces分別作為XSLT處理器和XML解析器,不能直接支持Apache Crimson了。
            dom4j(dom4j.jar)是一個Java的XML API,類似于jdom,用來讀寫XML文件的。dom4j是一個非常非常優秀的Java XML API,具有性能優異、功能強大和極端易用使用的特點,同時它也是一個開放源代碼的軟件,可以在SourceForge上找到它。在IBM developerWorks上面可以找到一篇文章,對主流的Java XML API進行的性能、功能和易用性的評測,dom4j無論在那個方面都是非常出色的。

    posted @ 2008-03-19 10:27 bluoy 閱讀(1980) | 評論 (0)編輯 收藏

    .NET垃圾收集器的過去、現在和未來(一)

    Patrick Dussud介紹:
    Patrick Dussud在微軟工作了11年,曾經負責VBA、Jscript、MS Java等語言運行時的垃圾收集器(Garbage Collector)的設計,目前負責.NET CLR垃圾收集器的設計。他是.NET CLR的架構師,WinFX的首席架構師,Windows架構師組的成員。
    在微軟之前,Patrick是德州儀器(TI)Explorer工作站系統的主要設計人,Lucid公司Energize產品的首席架構師。

    關鍵內容摘要

    1. 微管理 / 內存的顯式管理 ---  手動內存管理(new/delete)
            你必須保證在釋放之前內存沒有被別人使用,如果你把內存給了別人,往往你就不確定應該何時釋放內存了。當你釋放了內存,不知道別人正在使用這塊內存時,就產生了程序崩潰的問題。所以,當你顯式進行“new”和“delete”時,內存管理是一個復雜的問題,并且,此時你的代碼不可組合。要么你必須確定對自己的內存有完全的控制,因此,要達到這種完全隔離的目的,你必須在將內存傳遞給別的模塊時進行完全拷貝,這樣,別的模塊就只對這個完全拷貝的內存負責。要么你就得在某個地方形成對整個內存池的統一的管理,這就是自動化內存管理,這就是垃圾收集器的工作。

    2. 對象終止器的調用時機由垃圾收集器決定,這些對象的析構函數被調用的先后順序是無法預先確定的。提出了“關鍵終止化對象”的概念。當有一系列對象需要終止化時,關鍵終止化對象最后被終止化,直到上層對象干完工作前。

    3.  工作機理: 垃圾收集器首先遍歷所有的棧和靜態變量,然后返回最初的樹集。然后遍歷樹集對程序能夠到達的每一個對象作標記。此時,我們就能逐個對象地檢查內存,發現它被標記了,好的,留下。沒有被標記?喔,我們有一個垃圾了。

    4.  垃圾收集器的絕大部分速度和效率都來源于對回收策略的調整。通過保持內存緊湊,形成緩存本地化,頁面本地化等等優勢,很可能其效率甚至高于傳統“new”和“delete” 操作,尤其是對于非常難以管理的服務器內存來說更是如此。

    posted @ 2008-03-13 21:26 bluoy 閱讀(347) | 評論 (0)編輯 收藏

    如下代碼:
    class A{
        public void foo(){print("aaaaa");}
    }

    class B extends A{
        public void foo(){print("bbbbb");}
    }

    如果想通過B的實例化變量來調用被override的父類的方法foo():

    B b = new B();

    在C++中(VC 6)可以兩種途徑;
    1.  ((A)b).foo();
    2.  A a = B();

    在java中類似做法則行不通,依然訪問的是子類方法。
    而且,在java中好像達不到這個目的。

    posted @ 2008-03-06 10:34 bluoy 閱讀(1064) | 評論 (3)編輯 收藏

    web常用的功能性測試方法

          
            1. 頁面鏈接檢查:每一個鏈接是否都有對應的頁面,并且頁面之間切換正確。

            2. 相關性檢查:刪除/增加一項會不會對其他項產生影響,如果產生影響,這些影響是否都正確。

            3. 檢查按鈕的功能是否正確:如update、cancel、delete、save等功能是否正確。

            4. 字符串長度檢查:輸入超出需求所說明的字符串長度的內容,看系統是否檢查字符串長度,會不會出錯。

            5. 字符類型檢查:在應該輸入指定類型的內容的地方輸入其他類型的內容(如在應該輸入整型的地方輸入其他字符類型),看系統是否檢查字符類型,會否報錯。

            6. 標點符號檢查:輸入內容包括各種標點符號,特別是空格、各種引號、回車鍵。看系統處理是否正確。

            7. 中文字符處理:在可以輸入中文的系統輸入中文,看會否出現亂碼或出錯。

            8. 檢查帶出信息的完整性:在查看信息和update信息時,查看所填寫的信息是不是全部帶出,帶出信息和添加的是否一致。

            9. 信息重復:在一些需要命名,且名字應該唯一的信息輸入重復的名字或ID,看系統有沒有處理,會否報錯,重名包括是否區分大小寫,以及在輸入內容的前后輸入空格,系統是否作出正確處理。

            10. 檢查刪除功能:在一些可以一次刪除多個信息的地方,不選擇任何信息,按”delete”,看系統如何處理,會否出錯;然后選擇一個和多個信息,進行刪除,看是否正確處理。

            11. 檢查添加和修改是否一致:檢查添加和修改信息的要求是否一致,例如添加要求必填的項,修改也應該必填;添加規定為整型的項,修改也必須為整型。

            12. 檢查修改重名:修改時把不能重名的項改為已存在的內容,看會否處理,報錯。同時,也要注意,會不會報和自己重名的錯。

            13. 重復提交表單:一條已經成功提交的紀錄,back后再提交,看看系統是否做了處理。

            14. 檢查多次使用back鍵的情況:在有back的地方,back,回到原來頁面,再back,重復多次,看會否出錯。

            15. search檢查:在有search功能的地方輸入系統存在和不存在的內容,看search結果是否正確。如果可以輸入多個search條件,可以同時添加合理和不合理的條件,看系統處理是否正確。

            16. 輸入信息位置:注意在光標停留的地方輸入信息時,光標和所輸入的信息會否跳到別的地方。

            17. 上傳下載文件檢查:上傳下載文件的功能是否實現,上傳文件是否能打開。對上傳文件的格式有何規定,系統是否有解釋信息,并檢查系統是否能夠做到。

            18. 必填項檢查:應該填寫的項沒有填寫時系統是否都做了處理,對必填項是否有提示信息,如在必填項前加* 

            19. 快捷鍵檢查:是否支持常用快捷鍵,如Ctrl+C Ctrl+V Backspace等,對一些不允許輸入信息的字段,如選人,選日期對快捷方式是否也做了限制。

            20. 回車鍵檢查:在輸入結束后直接按回車鍵,看系統處理如何,會否報錯。

    posted @ 2008-01-11 09:55 bluoy 閱讀(188) | 評論 (0)編輯 收藏

    調整完/usr的掛載點后,出現了一個奇怪的現象,原來正確的系統時鐘現在出故障了,提前了8個小時。
    鼓掌現象具體表現為:每次啟動系統,ubuntu會用BIOS的時間+8后作為系統時鐘,同時會把新的時間重新同步到BIOS中。所以每啟動一次,時間就會快進8小時。很是怪異。
    網上一通google才搞定。

    原因是因為/usr的掛載時間被滯后了,由于/etc/localtime(時區信息)是連接到/usr/share/zoneinfo/下的某個設定好的時區文件。在系統獲取時區信息時/usr尚未掛載,所以系統始終就錯了。

    修復辦法很簡單:
    1.  rm /etc/localtime(取消原來的符號連接)
    2. 把/usr/share/zoneinfo/下的某個設定好的時區文件copy到/etc/localtime.
    3. 重新啟動,故障消除。

    相關概念:
    UTC(Universal Time Coordinated)  = GMT  (Greenwich Mean Time)
    hwclock :   query and set the hardware clock (RTC)
    hwclock通過/etc/default/rcS的UTC(=yes/no)來認定BIOS時鐘是UTC還是localtime。

    參考文章:
    http://blog.chinaz.com/u1/5830/archives/2006/36628.shtml

    posted @ 2007-11-13 12:09 bluoy 閱讀(286) | 評論 (0)編輯 收藏

    昨天由于ubuntu的/分區空間緊張,決定把/usr掛載到別的分區。
    掛載步驟(root權限執行):
    1.   init  1  -- 切換到單用戶模式。
    2.   cp -ax /usr/*  /mnt/tmp  (tmp為新的/usr分區)。 -- 拷貝現在/usr下的內容到待切換的分區。
    3.   ls -l /dev/disk/by-uuid    -- 查看分區的UUID。
    4.   修改/etc/fstab中/usr的掛載方式,掛接到新的/usr分區。
    5.   mv /usr /usr.old   -- 重命名現有的/usr為/usr.old, 為第6步做準備,重啟動后可以刪除之。
    6.   mkdir /usr   -- 創建新的/usr掛載點,啟動時自動掛載/usr分區到此處。
    7.   restart

    posted @ 2007-11-13 11:49 bluoy 閱讀(5729) | 評論 (5)編輯 收藏

    /home 分區是最常移動的分區之一。某些時候,/home 中的全部空間都用完了,而且需要增加一個硬盤驅動器。另一些時候,/home 被設置為根分區的一部分,為了提高性能或便于備份,可能需要將它移動到別的地方。我會針對每種情況說明如何安全有效地移動 /home。

    please visit the address:
    http://www.ibm.com/developerworks/cn/linux/l-tip-prompt/tip05/index.html

    posted @ 2007-11-09 15:52 bluoy 閱讀(143) | 評論 (0)編輯 收藏

    網上常見的推薦是tora. 地址: http://sourceforge.net/projects/tora/
    但由于License關系,二進制版本剔除了對oracle的providor. 所以需要下載源碼自己編譯。
    感覺比較麻煩。

    最近又找到一個比較好的東東-- Aqua Data Studio。 (http://www.aquafold.com/index.html)
    而且也有免費版本。
    下載試用了一下,非常方便易用。
    推薦給有此需要者。

    posted @ 2007-11-07 11:49 bluoy 閱讀(2499) | 評論 (0)編輯 收藏

    如何臨時增加交換空間。

    1.產生一個64M的空文件

    #dd if=/dev/zero of=/swapfile bs=1024 count=65536

    2.初始化該文件為交換文件:

    mkswap /swapfile 65536

    sync

    3.激活這個交換文件:

    swapon /swapfile

    posted @ 2007-11-06 14:03 bluoy 閱讀(298) | 評論 (0)編輯 收藏

    The follow statement execute error using 9i driver(Oracle JDBC Driver version - 9.0.2.0.0).
    throw UncategorizedSQLException(Invalid Column Type Exception), 
    errorcode: 17004.
    Upgrade to Oracle JDBC Driver version - 10.2.0.1.0, it is OK.

    Example:

    ......
    PreparedStatement pst = cn.prepareStatement("select sysdate from dual where 1=?");
    pst.setNull(index,  java.sql.Types.NULL);   -------- throw exception!!
    ......




    posted @ 2007-10-09 19:39 bluoy 閱讀(907) | 評論 (0)編輯 收藏

    Using the JDBC 8i, 9iR1, Oracle's DATE datatype is mapped to the "java.sql.Timestamp" class. However, the new "ojdbc14.jar" driver maps DATE to "java.sql.Date", and "java.sql.Date" only holds a date (without a time), whereas "java.sql.Timestamp" holds both a date and a time.




    Subject: JDBC 920x Date/TimeStamp mapping
    Type: BULLETIN
    Status: UNDER_EDIT
    Content Type: TEXT/PLAIN
    Creation Date: 29-JUL-2003
    Last Revision Date: 04-OCT-2004


    PURPOSE
    -------
       Clarify the use of oracle.jdbc.V8Compatible property flag
     
    SCOPE & APPLICATION
    -------------------
    JDBC 920x Date/TimeStamp mapping is different from JDBC 8i, 9iR1.
    <TITLE FOR MAIN ARTICLE TEXT>
    -----------------------------
    Summary of  features afftected by oracle.jdbc.V8Compatible.
     
    As of 9.2.0.1.0 Oracle realigned its DATE type with the java.sql.Types.DATE type.
    Prior to this
    java.sql.DATE and  java.sql.TIMESTAMP were mapped to java.sql.Types.TIMESTAMP.
     
    This mapping change applies to JDBC default mapping (i.e when getObject() is
    used for Date column.
     
    example:
    select sysdate from dual;
    ...
    while (rset.next ())  {
    System.out.println("getObject for sysdate  : " +
    rset.getObject(1).getClass().getName());
    System.out.println("getDate for sysdate :" +
    rset.getDate(1).getClass().getName());
    System.out.println("getTimetamp for sysdate :" +
    rset.getTimestamp(1).getClass().getName());
    }
     
    Prior to 9201, this will return
    getObject for sysdate  : java.sql.Timestamp      <<<<
    getDate for sysdate :java.sql.Date
    getTimetamp for sysdate :java.sql.Timestamp
     
    As of 9201 onward the following will be returned
     
    getObject for sysdate  : java.sql.Date        <<<<<
    getDate for sysdate :java.sql.Date            >> no change
    getTimetamp for sysdate :java.sql.Timestamp   >> no change
     
     
     
    Note: java.sql.Date has no time portion whereas java.sql.Timestamp does.
     
     
    With this change in Datatype mapping, some application will fail and/or generate
    incorrect results when JDBC driver is upgraded from 8i/ 9iR1 to 920x JBDC driver.
    To maintain compatibility and keep applications working after upgrade, a compatibility flag was
    Provided.  Developers now have some options:
     
    1>
    Use oracle.jdbc.V8Compatible flag.
     
    JDBC Driver does not detect database version by default.
    To change the compatibility flag for handling TIMESTAMP datatypes,
    connection property 'oracle.jdbc.V8Compatible' can be set to
    'true' and the driver behaves as it behaved in 8i, 901x, 9200
    (with respect to TIMESTAMPs).
    By default the flag is set to 'false'. In OracleConnection constructor
    the driver obtains the server version and set the compatibility flag
    Appropriately.
     
    java.util.Properties prop = new java.util.Properties ();
    prop.put ("oracle.jdbc.V8Compatible", "true");
    prop.put ("user", "scott");
    prop.put ("password", "tiger");
    String url ="jdbc:oracle:thin:@host:port:sid";
    Connection conn = DriverManager.getConnection (url,prop);
     
     
     
    With JDBC 10.1.0.x, in instead of the connection property, the following system
    property can be useed
    java -Doracle.jdbc.V8Compatible=true .....
     
     
     
    Note: This flag is a client only flag that governs the Timestamp and Date mapping.
    It does not affect any Database feature.
     
     
     
    2> use set/getDate and set/getTimestamp   when dealing with Date and TimeStamp column datatype accordingly.
    9i server  supports both Date and Timestamp column types
     
    DATE is mapped to  java.sql.Date and TIMESTAMP is mapped to java.sql.Timestamp
     
    I> using setTimestamp
     
    PreparedStatement pstmt = conn.prepareStatement(
    "SELECT count(*) from  tstable where tscol between ? and ?");
    // tscol of type Timetamp (or it can be Date)
     
    String s = new String("2003-01-14 10:00:00.000000000");
    Timestamp ts1 = Timestamp.valueOf(s);
    pstmt.setTimestamp(1, ts1); // Timestamp
     
    String s2 = new String("2003-01-16 10:00:00.000000000");
    Timestamp ts2 = Timestamp.valueOf(s2);
    pstmt.setTimestamp(2, ts2); // Timestamp
    ...
     
     
    II>using setDate
     
    PreparedStatement pstmt = conn.prepareStatement(
    "SELECT count(*) from  tstable where datecol between ? and ?");
    // datecole of type Date
     
    /*
    pstmt.setDate(1,new java.sql.Date(System.currentTimeMillis()));
    pstmt.setDate(2,new java.sql.Date(System.currentTimeMillis()));
    */
     
    SimpleDateFormat start_dt_in1 = new SimpleDateFormat("2002-09-18 00:00:00");
    SimpleDateFormat start_dt_in2 = new SimpleDateFormat("2003-09-18 00:00:00");
    pstmt.setDate(1,start_dt_in1);
    pstmt.setDate(2,start_dt_in2);
     
     
     
    Summary of  features afftected by oracle.jdbc.V8Compatible.
     
    Is backward compatible (with oracle.jdbc.V8Compatible)?
    
     
     
    * Examples:
    ..
    The following will fail   when using JDBC 9iR1, 9iR2 connecting 817 server since the
    817 did not support Timestamp
     
     
    Connection conn = DriverManager.getConnection(url, "scott",  "tiger");
    // Prepare a statement to cleanup the emp table
    Statement  stmt = conn.createStatement();
    try {
    stmt.execute("delete from EMP where EMPNO = 1");
    } catch (SQLException e) {
    }
    try {
    stmt.execute("INSERT INTO EMP (EMPNO, ENAME, HIREDATE) VALUES (1, 
    'ALI', {ts '2003-04-14 14:19:24.94'})");
    } catch (SQLException e) {
    e.printStackTrace();
    }
     
    Error : Exception in thread "main" java.sql.SQLException: ORA-00904: invalid column name
     
    Solution you need
    1> fix for Bug 2640192 (included in 9204)
    2> oracle.jdbc.V8Compatible", "true"
     
     
     
    In earlier versions of JDBC drivers  SQL FUNCTION "TS" was mapped to "to_date" .   So, the query
     
    select {ts '2002-10-18 18:02:00'} from dual;
    was translated by JDBC to,
    select TO_DATE ('2002-10-18 18:02:00',  'YYYY-MM-DD HH24:MI:SS') from dual;
     
     
    With 9i Timestamp is supported in the database and also by 9203 JDBC Drivers.
    So the query
     
    select {ts '2002-10-18 18:02:00'} from dual;
     
    is now translated  by JDBC to
     
    select TO_TIMESTAMP('2002-10-18 18:02:00', 'YYYY-MM-DD HH24:MI:.SS.FF') from dual;
     
     
    Known issues:  There is some performances issue when set/getTimestamp
    Bug 3037615
    Bug 2770935
    These bugs are very likely duplicate.
     
     
    The following code will no longer work with 9203+ unless V8 flag is set to true
     
    Timestamp start_dt_in = Timestamp.valueOf("2002-09-18 00:00:00");
    Timestamp now_period_start_dt ;
    PreparedStatement stmt = null;
    ResultSet rs = null;
     
    System.out.println("start_dt_in="+  start_dt_in );
     
    try {
    stmt = conn.prepareStatement( "SELECT TRUNC(?) FROM DUAL" );
    stmt.setTimestamp( 1, start_dt_in );
    rs = (OracleResultSet) stmt.executeQuery();
    if ( rs.next() ) {
    now_period_start_dt = rs.getTimestamp( 1 );
    System.out.println("Curr Period Start="+  now_period_start_dt );
    }
     
     
    will generate
    Exception in thread "main" java.sql.SQLException:
    ORA-932: inconsistent datatypes
     
     
    Reason : trunc ( )  supports Date columns and does not support  Timestamp  (this is an RDBMS issue).
    So, you need to set the V8 flag to true
     
    Another bug that changed the Date/Timetamp mapping is  2428427 to comly with
    J2EE 1.3 CTS.  This was fixed in 9014 and it specific to classesdmx*.zip/jar
    (the *dms* jar filed mainly used by iAS/OC4J).  These *dms* jar files, by the
    default value for oracle.jdbc.J2EE13Compliant  is true.  in classes111.zip
    classes12.jar and ojdbc14.jar/zip the default is false.
     
    One can toggel this flag  true/false by
     
    java -Doracle.jdbc.J2EE13Compliant=true|false
     
     
    example of of sample runs:
     
    query used :"select sysdate from dual"
    classes12dms.jar used.
     
     
    Driver Version      Object Type
    ==============      ===========
    9.0.1.3.0         java.sql.Timestamp >> fix for 2428427 NOT included
    9.0.1.4.0         java.sql.Date   >> fix for 2428427 INCLUDED
    9.0.1.5.0         java.sql.Date   >> fix for 2428427 INCLUDE
     
    In JDBC 9014+ ,to keep older (9013) behavior  simply run the application with
     
     
    $java -Doracle.jdbc.J2EE13Compliant=false .....
     
     
    However please note that J2EE 1.3 CTS require that Date to mapped to
    java.sql.Date.
    

    posted @ 2007-10-09 19:16 bluoy 閱讀(1121) | 評論 (0)編輯 收藏

    我們知道,在Struts 1.0中,我們只能在web.xml中為ActionServlet指定一個配置文件,這對于我們這些網上的教學例子來說當然沒什么問題,但是在實際的應用開發過程中,可能會有些麻煩。因為許多開發人員都可能同時需要修改配置文件,但是配置文件只能同時被一個人修改,這樣肯定會造成一定程度上的資源爭奪,勢必會影響開發效率和引起開發人員的抱怨。

    在Struts 1.1中,為了解決這個并行開發的問題,提出了兩種解決方案:

    1. 多個配置文件的支持
    2. 模塊的支持

     

    支持多個配置文件,是指你能夠為ActionServlet同時指定多個xml配置文件,文件之間以逗號分隔,比如Struts提供的MailReader演示例子中就采用該種方法。

    
                <!-- Action Servlet Configuration -->
                <servlet>
                <servlet-name>action</servlet-name>
                <servlet-class>
                    org.apache.struts.action.ActionServlet
                </servlet-class> <init-param> <param-name>config</param-name> <param-value>
    /WEB-INF/struts-config.xml,
    /WEB-INF/struts-config-registration.xml
    </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>

    這種方法可以很好地解決修改沖突的問題,不同的開發人員可以在不同的配置文件中設置自己的Action、ActionForm等等(當然不是說每個開發人員都需要自己的配置文件,可以按照系統的功能模塊進行劃分)。但是,這里還是存在一個潛在的問題,就是可能不同的配置文件之間會產生沖突,因為在ActionServlet初始化的時候這幾個文件最終還是需要合并到一起的。比如,在struts-config.xml中配置了一個名為success的<forward>,而在struts-config-registration.xml中也配置了一個同樣的<forward>,那么執行起來就會產生沖突。

    為了徹底解決這種沖突,Struts 1.1中引進了模塊(Module)的概念。一個模塊就是一個獨立的子系統,你可以在其中進行任意所需的配置,同時又不必擔心和其它的配置文件產生沖突。因為前面我們講過,ActionServlet是將不同的模塊信息保存在不同的ModuleConfig對象中的。要使用模塊的功能,需要進行以下的準備工作:

    1、為每個模塊準備一個配置文件

    2、配置web.xml文件,通知控制器

    決定采用多個模塊以后,你需要將這些信息告訴控制器,這需要在web.xml文件進行配置。下面是一個典型的多模塊配置:

    
                <init-param>
                <param-name>config</param-name>
                <param-value>
                    /WEB-INF/struts-config.xml
                </param-value> </init-param> <init-param> <param-name>config/customer</param-name> <param-value>
                    /WEB-INF/struts-config-customer.xml
                </param-value> </init-param> <init-param> <param-name>config/order</param-name> <param-value>
                    /WEB-INF/struts-config-order.xml
                </param-value> </init-param>

    要配置多個模塊,你需要在原有的一個<init-param>(在Struts 1.1中將其對應的模塊稱為缺省模塊)的基礎之上,增加模塊對應的<init-param>。其中<param-name>表示為config/XXX的形式,其中XXX為對應的模塊名,<param-value>中還是指定模塊對應的配置文件。上面這個例子說明該應用有三個模塊,分別是缺省模塊、customer和order,它們分別對應不同的配置文件。

    3、準備各個模塊所需的ActionForm、Action和JSP等資源

    但是要注意的是,模塊的出現也同時帶來了一個問題,即如何在不同模塊間進行轉發?有兩種方法可以實現模塊間的轉發,一種就是在<forward>(全局或者本地)中定義,另外一種就是利用org.apache.struts.actions.SwitchAction。

    下面就是一個全局的例子:

    
                ...
                <struts-config>
                ...
                <global-forwards>
                <forward name="toModuleB"
                contextRelative="true"
                path="/moduleB/index.do"
                redirect="true"/>
                ...
                </global-forwards>
                ...
                </struts-config>
                

    可以看出,只需要在原有的path屬性前加上模塊名,同時將contextRelative屬性置為true即可。此外,你也可以在<action>中定義一個類似的本地<forward>。

    
                <action-mappings>
                <!-- Action mapping for profile form -->
                <action path="/login"
                type="com.ncu.test.LoginAction"
                name="loginForm"
                scope="request"
                input="tile.userLogin"
                validate="true">
                <forward name="success" contextRelative="true" path="/moduleA/login.do"/>
                </action>
                </action-mappings>
                

    如果你已經處在其他模塊,需要轉回到缺省模塊,那應該類似下面這樣定義,即模塊名為空。

    
                <forward name="success" contextRelative="true" path="/login.do"/>
                

    此外,你也可以使用org.apache.struts.actions.SwitchAction,例如:

    
                ...
                <action-mappings>
                <action path="/toModule"
                type="org.apache.struts.actions.SwitchAction"/>
                ...
                </action-mappings>
                ...
                

    posted @ 2007-08-17 16:25 bluoy 閱讀(191) | 評論 (0)編輯 收藏

    Oracle的systimestamp的精度與OS有關。例如:
    select systimestamp from dual;

    基于XP的輸出:07-07-03 16:07:10.328000 +08:00
    基于Solaris的輸出:07-07-03 16:09:18.328156 +08:00


    所以,如果DB中的表以timestamp類型的字段作唯一主鍵的話,在PC上就會藏有隱患:主鍵不唯一,因為精度降低了,頻繁的insert操作很有可能產生相同的主鍵。而在Solaris上這個可能性就很低了。

    這點在DB設計中還是需要加以考慮的。

    posted @ 2007-07-03 16:43 bluoy 閱讀(3276) | 評論 (1)編輯 收藏

    java.util.Arrays.asList的BUG

    jdk 1.4對java.util.Arrays.asList的定義,函數參數是Object[]。所以,在1.4中asList()并不支持基本類型的數組作參數。

    jdk 1.5中,java.util.Arrays.asList的定義,函數參數是Varargs, 采用了泛型實現。同時由于autoboxing的支持,使得可以支持對象數組以及基本類型數組。

    但在使用過程中發現jdk1.5中存在一個BUG。就是等參數為基本類型的數組時,函數的行為發生了變異:它不是把這個數組轉換為List,而是把這個數組整體作為返回List中的第一個元素,要取得轉換后的結果,得首先get(0)才行。

    到網上google了一下,Sun好像認為這并不是個問題。理由如下:
    Arrays.asList is now a vararg method, and the behavior is as intended:  asList(int[] ...)
    The Java generics implementation does not support non-reference type parameters.
    This is all standard Java 5.0 stuff.
    URL:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6353471

    雖然如此,但因此函數的行為就可能產生了歧義,對調用者還是會產生誤導的,我認為這終歸還應該是個問題的,如能解決是最好的了。

    posted @ 2007-07-03 14:55 bluoy 閱讀(890) | 評論 (0)編輯 收藏

    問題:同事不小心把項目DB中的一個表的數據delete all了。DB版本oracle 10g。
    網上簡單搜了一下,搞定。以下是過程:
    Oracle 10g開始,當我執行Drop Table時,Oracle也會把被刪除的表放到數據庫回收站(Database Recyclebin)里。這樣我們就可以用flashback table命令恢復被刪除的表,語法:
       Flashback table 表名 to before drop;

    開始恢復,執行以下命令:
    flashback table tmm2076 TO TIMESTAMP to_timestamp('2007-05-22
    12:00:00','yyyy-mm-dd hh24:mi:ss')
    彈出ORA-08189錯誤,需要執行以下命令先:
    alter table tmm2076 enable row movement

    這個命令的作用是,允許oracle修改分配給行的rowid。

    然后再flashback,數據被恢復完畢。

    posted @ 2007-05-22 16:30 bluoy 閱讀(4101) | 評論 (2)編輯 收藏

    There's a field introspector written by a Velocity user in the Wiki. You can configure velocity.properties to reference this. It require velocity version 1.4.

    PublicFieldUberspect.java
    -------------------------------------------------------------------------------------------------------------
    /*
    * Copyright 2003-2004 The Apache Software Foundation.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
    package org.apache.velocity.tools.generic.introspection;
    import java.lang.reflect.Array;
    import java.lang.reflect.Field;
    import org.apache.velocity.util.introspection.Info;
    import org.apache.velocity.util.introspection.UberspectImpl;
    import org.apache.velocity.util.introspection.VelPropertyGet;
    import org.apache.velocity.util.introspection.VelPropertySet;
    /**
    * Uberspect implementation that exposes public fields.
    * Also exposes the explicit "length" field of arrays.
    *
    * <p>To use, tell Velocity to use this class for introspection
    * by adding the following to your velocity.properties:<br />
    *
    * <code>
    * runtime.introspector.uberspect = org.apache.velocity.tools.generic.introspection.PublicFieldUberspect
    * </code>
    * </p>
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    public class PublicFieldUberspect extends UberspectImpl
    {
    /**
    * Default constructor.
    */
    public PublicFieldUberspect()
    {
    }
    /**
    * Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie).
    * <br />
    * Returns a special {@link VelPropertyGet} for the <code>length</code> property of arrays.
    * Otherwise tries the regular routine.  If a getter was not found,
    * returns a {@link VelPropertyGet} that gets from public fields.
    *
    * @param obj the object
    * @param identifier the name of the property
    * @param i a bunch of information.
    * @return a valid <code>VelPropertyGet</code>, if it was found.
    * @throws Exception failed to create a valid <code>VelPropertyGet</code>.
    */
    public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
    throws Exception
    {
    Class clazz = obj.getClass();
    boolean isArray = clazz.isArray();
    boolean isLength = identifier.equals("length");
    if (isArray && isLength)
    {
    return new ArrayLengthGetter();
    }
    VelPropertyGet getter = super.getPropertyGet(obj, identifier, i);
    // there is no clean way to see if super succeeded
    // @see http://issues.apache.org/bugzilla/show_bug.cgi?id=31742
    try
    {
    getter.getMethodName();
    return getter;
    }
    catch (NullPointerException notFound)
    {
    }
    Field field = obj.getClass().getField(identifier);
    if (field != null)
    {
    return new PublicFieldGetter(field);
    }
    return null;
    }
    /**
    * Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir").
    * <br />
    * First tries the regular routine.  If a setter was not found,
    * returns a {@link VelPropertySet} that sets to public fields.
    *
    * @param obj the object
    * @param identifier the name of the property
    * @param arg the value to set to the property
    * @param i a bunch of information.
    * @return a valid <code>VelPropertySet</code>, if it was found.
    * @throws Exception failed to create a valid <code>VelPropertySet</code>.
    */
    public VelPropertySet getPropertySet(Object obj, String identifier,
    Object arg, Info i) throws Exception
    {
    VelPropertySet setter = super.getPropertySet(obj, identifier, arg, i);
    if (setter != null)
    {
    return setter;
    }
    Field field = obj.getClass().getField(identifier);
    if (field != null)
    {
    return new PublicFieldSetter(field);
    }
    return null;
    }
    /**
    * Implementation of {@link VelPropertyGet} that gets from public fields.
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    protected class PublicFieldGetter implements VelPropertyGet
    {
    /** The <code>Field</code> object representing the property. */
    private Field field = null;
    /**
    * Constructor.
    *
    * @param field The <code>Field</code> object representing the property.
    */
    public PublicFieldGetter(Field field)
    {
    this.field = field;
    }
    /**
    * Returns the value of the public field.
    *
    * @param o the object
    * @return the value
    * @throws Exception failed to get the value from the object
    */
    public Object invoke(Object o) throws Exception
    {
    return this.field.get(o);
    }
    /**
    * This class is cacheable, so it returns <code>true</code>.
    *
    * @return <code>true</code>.
    */
    public boolean isCacheable()
    {
    return true;
    }
    /**
    * Returns <code>"public field getter"</code>, since there is no method.
    *
    * @return <code>"public field getter"</code>
    */
    public String getMethodName()
    {
    return "public field getter";
    }
    }
    /**
    * Implementation of {@link VelPropertyGet} that gets length from arrays.
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    protected class ArrayLengthGetter implements VelPropertyGet
    {
    /**
    * Constructor.
    */
    public ArrayLengthGetter()
    {
    }
    /**
    * Returns the length of the array.
    *
    * @param o the array
    * @return the length
    * @throws Exception failed to get the length from the array
    */
    public Object invoke(Object o) throws Exception
    {
    // Thanks to Eric Fixler for this refactor.
    return new Integer(Array.getLength(o));
    }
    /**
    * This class is cacheable, so it returns <code>true</code>.
    *
    * @return <code>true</code>.
    */
    public boolean isCacheable()
    {
    return true;
    }
    /**
    * Returns <code>"array length getter"</code>, since there is no method.
    *
    * @return <code>"array length getter"</code>
    */
    public String getMethodName()
    {
    return "array length getter";
    }
    }
    /**
    * Implementation of {@link VelPropertySet} that sets to public fields.
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    protected class PublicFieldSetter implements VelPropertySet
    {
    /** The <code>Field</code> object representing the property. */
    private Field field = null;
    /**
    * Constructor.
    *
    * @param field The <code>Field</code> object representing the property.
    */
    public PublicFieldSetter(Field field)
    {
    this.field = field;
    }
    /**
    * Sets the value to the public field.
    *
    * @param o the object
    * @param value the value to set
    * @return always <code>null</code>
    * @throws Exception failed to set the value to the object
    */
    public Object invoke(Object o, Object value) throws Exception
    {
    this.field.set(o, value);
    return null;
    }
    /**
    * This class is cacheable, so it returns <code>true</code>.
    *
    * @return <code>true</code>.
    */
    public boolean isCacheable()
    {
    return true;
    }
    /**
    * Returns <code>"public field setter"</code>, since there is no method.
    *
    * @return <code>"public field setter"</code>
    */
    public String getMethodName()
    {
    return "public field setter";
    }
    }
    }
    


    See
    http://wiki.apache.org/jakarta-velocity/PublicFieldUberspect

    posted @ 2007-05-18 10:10 bluoy 閱讀(273) | 評論 (0)編輯 收藏

    開發要求:
    為了便于維護,頁面端js中的錯誤信息要求不能硬編碼,要根據java端定義的Message對應的常量Key動態獲得。

    按照velocity常規做法,無法用VTL語言使用static類。調查了一下,原來velocity還是提供了變通了的實現方案的,官方論壇上還有就這一問題的爭論--“Add Support for Static Utility Classes”。

     
    基本上集中于兩種思路:static class wrapper 和 put class into context。
    前者就是作一個static class 的托管類,將托管類的實例放到context中。
    1.3.1版中對應實現為org.apache.velocity.app.FieldMethodizer。
    后者的想法是先把static類的Class放到context中,然后模版引擎在碰到Class對象時,優先在java.lang.Class中尋找對應的調用,然后再查找static class的調用。個人感覺這種思路比較好,用戶使用比較簡單直接,不需要額外的wrapper類。但官方好像更鐘情于前者。計劃在未來的1.6版中提供支持。

    附帶遇到的其他限制:
    1. velocity 1.3.1版不能正常處理jdk1.5中的可變參數(Varargs) 特性。可變參數(Varargs) 其實使用對應類型的數組來實現的。velocity會因為匹配不到對應的函數原型而調用失敗。其他版本未作驗證。
    2. velocity 1.3.1版不能正常處理jdk1.5中的enum特性。因為enum其實是按類來對待的。而velocity內部對類的處理是“取得所有的public的Methods”。所以類內部定義的enum類型的常量無法取到。這個處理請參見:org.apache.velocity.util.introspection.ClassMap。
    3. velocity只能調用類/對象的methods, 無法直接使用public的attributs。原因如2。同時可以參照
    Access to public member variable of a class

    posted @ 2007-05-17 14:52 bluoy 閱讀(2450) | 評論 (0)編輯 收藏

    下面這種現象在測試階段多次出DBoracle 10g。未作其他版本驗證

    test schema下共有12sequence.

    其中case_seq的定義為

    create sequence CASE_SEQ minvalue 1 maxvalue 99999999 start with 11531 increment by 1 cache 20;

     

    用程序出的LOG如下:

    -------------------------------------------------------------------------------------------------

    行號 出信息

    ......

    962 ('000000011531','000000000001','0','電話',to_date('2007/04/24

    15:38','yyyy/mm/dd hh24:mi'),

    ......

    2304 ('000000011532','000000000001','0','電話',to_date('2007/04/24

    15:44','yyyy/mm/dd hh24:mi'),

    ......

    6779 ('000000011551','000000000001','0','電話',to_date('2007/04/24

    15:58','yyyy/mm/dd hh24:mi'),

    ......

    --------------------------------------------------------------------------------------------------

     

    *1 取得sequence句如下:select lpad(case_seq.nextval,12,0) as case_id from dual

    *2 省略號代表其他操作,其中包含大量DB操作,包括1次其他sequence調用。但無

    case_seq調用。

     

    故障原因調查

    根據象初好像和sequence_cache_entries初始化參數有

    調查發現這個參數從Oracle 8.1.7后就被棄了。不知10g中是否對應參數?

     

    亦或是否有其他原因造成這種現象。尚待調查。

    posted @ 2007-05-09 17:10 bluoy 閱讀(391) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 久久精品免费全国观看国产| eeuss免费影院| 国产一卡二卡3卡四卡免费| 久久91亚洲精品中文字幕| 国产激情久久久久影院老熟女免费 | 中文字幕手机在线免费看电影 | 亚洲国产美女视频| 青青青免费国产在线视频小草| 亚洲网址在线观看| 无码av免费毛片一区二区| 亚洲第一区视频在线观看| 免费看污成人午夜网站| 亚洲人成人77777网站不卡| 无码人妻精品中文字幕免费东京热| 亚洲av无码成h人动漫无遮挡| 久久久久免费看黄a级试看 | 久久精品国产精品亚洲精品| 精品一卡2卡三卡4卡免费视频| 亚洲免费视频网站| 19禁啪啪无遮挡免费网站| 亚洲五月综合网色九月色| 成人免费视频国产| 免费人妻精品一区二区三区| 亚洲午夜国产精品无码| 丁香花在线视频观看免费| 亚洲色av性色在线观无码| 成人免费在线观看网站| 一级特黄a免费大片| 亚洲AV无一区二区三区久久| 国产一卡二卡四卡免费| 亚洲另类无码专区丝袜| 久久亚洲高清综合| 67194国产精品免费观看| 亚洲第一成年网站视频| 亚洲综合图色40p| 18国产精品白浆在线观看免费| 亚洲国产精品无码久久98 | 国产区在线免费观看| 久久亚洲精品成人无码网站| 午夜成年女人毛片免费观看| 久久国产乱子伦精品免费午夜|