热点推荐:ASP.Net | ADO.Net | VB.Net | Web服务器 | Access | MSSQL | MySQL | Oracle | .Net控件 | Win 9x | Win 2000 | Win 2003 | DOS | Unix | 注册表 | 应用其它 | 安装调试 | 基本操作 | 使用技巧 | 系统优化 |故障处理 | 个性风格 | 病毒安全 | 专杀工具
您现在的位置: 中华IT技术网 >> Java >> J2EE >> 正文
全文
支持Ajax的轻量级J2EE框架之构建
作者:1024k    文章来源:本站原创    更新时间:2007-11-23

假如你用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(ContextLoaderPlugIn 实现把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;
&

[1] [2] 下一页

  • 上一篇文章:
  • 下一篇文章:
  • 相关文章
    最新更新
    编辑推荐
    热门图片
    频道大全
    文章阅读排行
    周排行
    月排行