李李的技術博客

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            13 隨筆 :: 0 文章 :: 61 評論 :: 0 Trackbacks

          2005年12月3日 #

          為了降低侵入性,更好的被引用,對bba96核心部分進行了大量重構,去除了冗贅的層次與不必要的接口,并借助jdk5.0范型進行了代碼精簡。發布了bba96 tiger beta2,這個版本已經是比較穩定的版本,具體的改動如下

          • 去除所有的接口依賴,可直接在任何項目中直接調用
          • service的兩層合并為一層且去除service層的接口,但DAO曾仍保留接口以備擴展更多的orm實現
          • 增加sql execute的方法
          • 增強源自view的直接查詢能力
          • 參數名由原來難看的oriNames, oriOperators, oriStringValues改為直觀的searchName, searchOperator, searchValue
          • 增加了對QueryParam的toString功能,可打出對應的sql,便于調試,參見com.bba96.tiger.util.QueryWebUtils的main函數

          下載頁面地址:https://bba96.dev.java.net/servlets/ProjectDocumentList?folderID=4149&expandFolder=4149&folderID=0

          如果你使用spring+hibernate,而又不喜歡hibernate criteria的麻煩,不妨嘗試一下bba96,你可以把主要精力放到業務方面。DefaultEntityManager提供了很多單層邏輯的便利方法給你使用,其中也包括執行hsql或者sql查詢/更新的方法,如果你要多層次邏輯的條件查詢可以自己組裝QueryObject,參見com.bba96.tiger.util.QueryWebUtils的main函數。bba96還提供給你在view層自由增加查詢的能力。

          tiger版本僅提供了dao/service部分,所以如果你希望在view 查詢的安全性方面得到加強,可參考bba96 2.0其中的webwork view部分,權限部分也沒有包含在tiger中,希望盡快把包括例子的權限部分遷移過來,但還需要一點時間,最近在忙一個CMS的產品,時間不夠用啊……

          SpringSide項目中webwork MVC部分應用到bba96 tiger對view部分的查詢,有興趣可以看看,這里也要推薦一下SpringSide,確實有很多很好的經驗在里面可以借鑒。

          posted @ 2006-06-10 19:16 李李 閱讀(1579) | 評論 (2)編輯 收藏

          bba96 CHANGELOG
          ==========================
          http://bba96.dev.java.net

          Changes in version 2.0 alpha3 (2006.4.3)
          *fix action query parameters bug -- [XXX:...]
          *fix distinct bug (discard Criteria.DISTINCT_ROOT_ENTITY)
          *some minor improvement

          Changes in version 2.0 alpha2.2 (2006.3.16)
          *update webwork's jar for fixing example bug in weblogic
          *remove all contentType setting in example

          Changes in version 2.0 alpha2.1 (2006.3.8)
          *fix example bug
          *update readme.txt

          Changes in version 2.0 alpha1 (2006.3.7)
          *webwork 2.2 support
          *hibernate 3.x support, then support native sql
          *fix some bug
          *add aop security module
          *add action query parameters validation
          *enhance action query parameters management
          *support more logic in action query
          *support multi orderby property


          Changes in version 1.0 (2005.09.23)
          *release first


          源碼下載(包含兩個快速開發的例子。)
          https://bba96.dev.java.net/servlets/ProjectDocumentList?folderID=4149&expandFolder=4149&folderID=0

          簡介參見http://www.aygfsteel.com/scorpio_leon/archive/2005/11/09/18878.aspx

          posted @ 2006-03-08 01:24 李李 閱讀(1045) | 評論 (0)編輯 收藏

          很容易找到getText實際的操作類是LocalizedTextUtil,方法public static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args, OgnlValueStack valueStack);

          java doc 如下

          Finds a localized text message for the given key, aTextName. Both the key and the message itself is evaluated as required. The following algorithm is used to find the requested message:

          1. Look for message in aClass' class hierarchy.
            1. Look for the message in a resource bundle for aClass
            2. If not found, look for the message in a resource bundle for any implemented interface
            3. If not found, traverse up the Class' hierarchy and repeat from the first sub-step
          2. If not found and aClass is a ModelDriven Action, then look for message in the model's class hierarchy (repeat sub-steps listed above).
          3. If not found, look for message in child property. This is determined by evaluating the message key as an OGNL expression. For example, if the key is user.address.state, then it will attempt to see if "user" can be resolved into an object. If so, repeat the entire process fromthe beginning with the object's class as aClass and "address.state" as the message key.
          4. If not found, look for the message in aClass' package hierarchy.
          5. If still not found, look for the message in the default resource bundles.
          6. Return defaultMessage

          主要就是查找resource bundle,下面說明一下
          1. 先查找該class(一般我們是在action調用,就是該action對應的class了)對應的properties文件,找不到再去找對應的接口,找不到再去從該class的繼承樹上去重復前面的步驟。
          2. 如果是ModelDriver,以上找不到再以model的class去重復1的步驟
          3.繼續找,如果key是符合ognl表達式還以ognl表達式去解析類,如果能找到類,還以以上的步驟去查找
          4. 還找不到,就從根據package以及package的繼承樹去找,這還包括了該class的繼承樹所有的class的package樹(這一步存在了太多的重復查找工作,因為很多package都是相同的)
          5 使用默認的resource bundle

          java.util.ResourceBundle雖然有cache,但是ww為了減少調用getResourceBundle方法,也維護了一個miss的hashset,找不到的bundle name就丟進去,那么每一次查找都同步了這個miss,如果很多次查找,開銷也是很大的。

          我就舉一個例子,就說第四步查找package樹好了

                  // nothing still? alright, search the package hierarchy now
                  for (Class clazz = aClass;
                       (clazz 
          != null&& !clazz.equals(Object.class);
                       clazz 
          = clazz.getSuperclass()) {

                      String basePackageName 
          = clazz.getName();
                      
          while (basePackageName.lastIndexOf('.'!= -1) {
                          basePackageName 
          = basePackageName.substring(0, basePackageName.lastIndexOf('.'));
                          String packageName 
          = basePackageName + ".package";
                          msg 
          = getMessage(packageName, locale, aTextName, valueStack, args);

                          
          if (msg != null) {
                              
          return msg;
                          }

                          
          if (indexedTextName != null) {
                              msg 
          = getMessage(packageName, locale, indexedTextName, valueStack, args);

                              
          if (msg != null) {
                                  
          return msg;
                              }
                          }
                      }
                  }

          假設你的action繼承樹是這樣
          com.bba96.core.webwork.actions.DefaultActionSupport
          com.xxxx.web.actions.XXXActionSupport
          com.xxxx.web.user.actions.UserAction
          com.xxxx.web.user.ViewUserAction
          且不說ww沒有判斷是否是com.opensymphony.xwork.ActionSupport或者ww的接口就停止,光是自己的繼承樹,就是4+3+3+3=13次,再加上往上的繼承樹以及對應的接口,com.opensymphony.xwork.ActionSupport以及Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable, ContinuableObject的接口,查找次數超過30次甚至更多,這里的每一次都有一個同步miss的過程,開銷相當大。

          如果你的key所在的resource bundle沒有對應到合適的class或package時,例如說放在了default bundle中,ww會浪費很多時間。這種情況下,我在沒有并發的時候測了一下,一次getText大概耗時40ms左右

          所以在實際應用我們應該避免這種情況出現,要不讓resource bundle一一對應class,要不就自己實現一個簡單的getText,其實要是ww的ActionSupport的textProvider允許改變就最好了。

          posted @ 2006-01-21 13:26 李李 閱讀(1628) | 評論 (0)編輯 收藏

             調試IIS+Tomcat,裝IIS的時候居然出現staxmem.dll不能復制,google了一下,居然很多人說要重裝才能解決,暈,又找到http://support.microsoft.com/?kbid=894351,根據上面說的,我是屬于method 2情況,但是沒有xp原盤,裝的時候就是sp2了,又倒……
            最后看到有人情況跟我的類似,就是用method 1的第一步 esentutl /p %windir%\security\database\secedit.sdb 就可以了%windir%那里應該寫你的xp安裝路徑,不用管什么警告,確認就對了,IIS安裝成功……開始配置。
          posted @ 2005-12-21 23:29 李李 閱讀(1991) | 評論 (3)編輯 收藏

          一個例子,原來的

          <interceptor-ref name="validation"/>
          <interceptor-ref name="workflow"/>

          可改寫為
          <interceptor-ref name="validation">
              <param name="excludeMethods">input,back,cancel</param>
          </interceptor-ref>
          <interceptor-ref name="workflow">
              <param name="excludeMethods">input,back,cancel</param>
          </interceptor-ref>

          那么,對于簡單的需驗證頁面,不需要再因為避免不必要的校驗而分兩個action。

          只有com.opensymphony.xwork.validator.ValidationInterceptor, com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor 定義并實現了這個excludeMethods,實現的也還是比較粗糙的,我們在做類似實現的時候可以參考一下,有必要也可以改進,擴展一下,例如增加includeMethods
              public void setExcludeMethods(String excludeMethods) {
                  
          this.excludeMethods = TextParseUtil.commaDelimitedStringToSet(excludeMethods);
              }

              
          public String intercept(ActionInvocation invocation) throws Exception {
                  
          if (excludeMethods.contains(invocation.getProxy().getMethod())) {
                      log.debug(
          "Skipping workflow. Method found in exclude list.");
                      
          return invocation.invoke();
                  }
                  
              }
          posted @ 2005-12-03 22:29 李李 閱讀(1527) | 評論 (2)編輯 收藏

          主站蜘蛛池模板: 黄梅县| 天全县| 虎林市| 普陀区| 巴林左旗| 柞水县| 海兴县| 新泰市| 内黄县| 新密市| 抚远县| 长白| 吴旗县| 汤阴县| 阳曲县| 红河县| 集贤县| 陇西县| 乐平市| 镇安县| 石狮市| 晴隆县| 兴城市| 青州市| 九龙县| 武邑县| 东丰县| 莱州市| 郑州市| 永川市| 遵义市| 平南县| 马尔康县| 龙川县| 高台县| 株洲市| 桂阳县| 临沂市| 多伦县| 清水县| 柘城县|