• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 構建支持Ajax的輕量級J2EE框架

    發表于:2008-01-29來源:作者:點擊數: 標簽:J2EE框架
    話說Buffalo是姓中的寫的,支持下國產! 來先頂一個。 Buffalo處理Ajax有多牛,嘿嘿 我還真沒有正兒八經的整過。慚愧啊,爭取在最近好好研究下吧。 Buffalo支持和Spring整合。嘿嘿 這也是一個亮點。亮的有些不自在。為啥?假如你用 Spring+Struts+Hibernate來
    話說Buffalo是姓中的寫的,支持下國產! 來先頂一個。
      Buffalo處理Ajax有多牛,嘿嘿 我還真沒有正兒八經的整過。慚愧啊,爭取在最近好好研究下吧。
      Buffalo支持和Spring整合。嘿嘿 這也是一個亮點。亮的有些不自在。為啥?假如你用  Spring+Struts+Hibernate來構建的輕量級J2EE框架,Spring和Struts整合有好幾種方式,有一種方式不要要論論了。
         <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
          <set-property property="contextConfigLocation" value="/WEB-  INF/applicationContext.xml,/WEB-INF/business-context.xml" />
        </plug-in>
        上面的代碼還熟悉吧。問題就在這了,Buffalo 支持Spring的是
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                 /WEB-INF/applicationContext.xml
            </param-value>
       </context-param>
       <servlet>
          <servlet-name>context</servlet-name>
          <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
       </servlet>
      上面的部分代碼是Buffalo支持Spring必須的。如果Spring和Struts整合用PlugIn方式,也就是Spring來管理Action(管理Action好壞先不說).Buffalo和Spring整合再在Web.xml配置SPring的東東,總感覺怪怪的。Buffalo獲取WebApplicationContext是通過  WebApplicationContextUtils.getWebApplicationContext(context);來獲取的。感覺浪費。。。。。。所以想讓Buffalo用Spring放在ServletContext里面的WebApplicationContext ?。–ontextLoaderPlugIn 實現把WebApplicationContext的實例放在了ServletContext中)。所以就在Buffalo中實現了一個BuffaloPlugIn。代碼如下:(寫的不規范,湊合看吧)
    。。。。
      /**
       *
       * @Descripted <B>Buffalo+Spring+Struts+Hibernate/B>
       *             <P></P>
       * @author meconsea
       * @Company 
       * @IM:   MSN: meconsea@hotmail.com
       *        QQ:  75147664
       *        E-mail: meconsea@163.com
       * @date 2006-11-16
       * @Version 1.0Beta
       */
      public class BuffaloPlugIn implements PlugIn {
           
              public static final Logger log = Logger.getLogger(BuffaloPlugIn.class);
           
              public static final String SERVLET_CONTEXT_PREFIX =   ContextLoaderPlugIn.class.getName() + ".CONTEXT.";
              public static final String BUFFALO_CONTEXT_PREFIX =   BuffaloPlugIn.class.getName()+".CONTEXT.";
           
            private ModuleConfig moduleConfig;
            private ActionServlet actionServlet;
            public void destroy() {
                    // TODO Auto-generated method stub

            }
           
            protected final String getModuleConfigPrefix(){
                    return this.moduleConfig.getPrefix();
            }
            protected final ActionServlet getActionServlet(){
                    return this.actionServlet;
            }
           
            public String getServletContextAttributeNameForBuffalo(){
                    return BUFFALO_CONTEXT_PREFIX;
            }
            public String getServletContextAttributeNameForSCP(){
                    return SERVLET_CONTEXT_PREFIX+getModuleConfigPrefix();
            }

            public void init(ActionServlet as, ModuleConfig mc)
                            throws ServletException {
                    // TODO Auto-generated method stub
                    log.info("BuffaloPlugIn init begin ......");
                    this.actionServlet = as;
                    this.moduleConfig = mc;
                    as.getServletContext().setAttribute  (getServletContextAttributeNameForBuffalo(),getServletContextAttributeNameForSCP());
                    log.info("init  end ");
              }
      }

      把Buffalo中的SpringFactory和SpringUtil的獲得WebApplicationContext的方式修改如下:
    在SpringUtil中增加方法:
      /**
             * 獲?。祝澹猓粒穑穑欤椋悖幔簦椋铮睿茫铮睿簦澹?BR>         * @param context
             * @return
             */
            public static WebApplicationContext getWebApplicationContext(ServletContext context){
                    WebApplicationContext wac = null;
                    log.info("獲取Wac begin......");
                   
                    if(context == null){
                            log.info("context is null  reutrn null");
                            return null;
                    }
                    String wacAttrName = (String)context.getAttribute(BuffaloPlugIn.BUFFALO_CONTEXT_PREFIX);
                    log.info("wacAttrName == "+wacAttrName);
                   
                    if(wacAttrName != null){
                            wac = (WebApplicationContext)context.getAttribute(wacAttrName);
                    }
                   
                    if(wac == null){
                            log.info("wac is null , obtain WebApplicationContext by   WebApplicationContextUtils again");
                            wac = WebApplicationContextUtils.getWebApplicationContext  (context);
                    }
                    return wac;
            }

      ....//
      WebApplicationContext appCtx = getWebApplicationContext  (context);//WebApplicationContextUtils.getWebApplicationContext(context);
      好了,修改完畢了。在Struts-config.xml中增加<plug-in   className=.net.buffalo.service.spring.BuffaloPlugIn" />就OK了。Web.xml中只配置
      <servlet>
                      <servlet-name>bfapp</servlet-name>
                      <servlet-class>net.buffalo.web.servlet.ApplicationServlet</servlet-class>
        </servlet>
      就完全支持SPring了。當然是建立在Spring+Struts構建了輕量級框架的基礎上的。哈哈 不知道我自己能不能看懂。就此擱筆! 閃?。。。?!給自己留的紀念。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>