`
san_yun
  • 浏览: 2600763 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

webx3的扩展点

阅读更多
以Template渲染服务为例子
  <!-- Template渲染服务。 -->
    <services:template xmlns="http://www.alibaba.com/schema/services/template/engines"
        searchExtensions="true">
        <velocity-engine templateEncoding="GBK" strictReference="false"
            path="/templates/${component}">
            <global-macros>
                <name>global/*.vm</name>
            </global-macros>
            <plugins>
                <vm-plugins:escape-support defaultEscape="html">
                    <vm-plugins:noescape>
                        <vm-plugins:if-matches pattern="^control\." />
                        <vm-plugins:if-matches pattern="^screen_placeholder" />
                        <vm-plugins:if-matches pattern="^stringEscapeUtil\.escape" />
                        <vm-plugins:if-matches pattern="^csrfToken\.(get)?hiddenField" />
                    </vm-plugins:noescape>
                </vm-plugins:escape-support>
            </plugins>
        </velocity-engine>
    </services:template>


services是root扩展点,template是对services的捐献,同时template的element也是扩展点,namespace:http://www.alibaba.com/schema/services/template/engines,详见template.xsd:

  <xsd:complexType name="TemplateServiceType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="template-mapping" type="TemplateServiceEngineMappingType"
                minOccurs="0" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation><![CDATA[
    将模板引擎和模板名后缀关联起来。
                    ]]></xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:any namespace="http://www.alibaba.com/schema/services/template/engines" />
        </xsd:choice>
        <xsd:attribute name="defaultExtension" type="xsd:string" />
        <xsd:attribute name="searchExtensions" type="springext:booleanOrPlaceholder" />
        <xsd:attribute name="searchLocalizedTemplates" type="springext:booleanOrPlaceholder" />
        <xsd:attribute name="cacheEnabled" type="springext:booleanOrPlaceholder" />
        <xsd:attributeGroup ref="springext:identifiedTypeAttributeSubset" />
    </xsd:complexType>

    <xsd:complexType name="TemplateServiceEngineMappingType">
        <xsd:attribute name="extension" type="xsd:string" use="required" />
        <xsd:attribute name="engine" type="xsd:string" use="required" />
    </xsd:complexType>



template的属性:searchExtensions等。
template的elements:global-macros, plugins。
global-macros是一个list sting
plugins又是一个扩展点.vm-plugins是其中的一种捐献。

对应的xsd描述:
<xsd:complexType name="VelocityTemplateEngineType">
        <xsd:complexContent>
            <xsd:extension base="beans:identifiedType">
                <xsd:all>
                    <xsd:element name="global-macros" type="VelocityGlobalMacrosType" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation><![CDATA[
    装载全局宏(相对于path路径),可使用通配符。
                            ]]></xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="plugins" type="VelocityPluginsType" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation><![CDATA[
    Velocity插件和事件处理器。
                            ]]></xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="advanced-properties" type="VelocityPropertiesType"
                        minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation><![CDATA[
    Velocity高级设置,参见velocity文档:
      (http://velocity.apache.org/engine/releases/velocity-1.6.2/developer-guide.html#Velocity_Configuration_Keys_and_Values)
    和默认配置文件:org/apache/velocity/runtime/defaults/velocity.properties。
                            ]]></xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:all>
                <xsd:attribute name="path" type="xsd:string" default="/templates" />
                <xsd:attribute name="templateEncoding" type="xsd:string" default="UTF-8" />
                <xsd:attribute name="cacheEnabled" type="springext:booleanOrPlaceholder"
                    default="true" />
                <xsd:attribute name="modificationCheckInterval"
                    type="springext:integerOrPlaceholder" default="2" />
                <xsd:attribute name="strictReference" type="springext:booleanOrPlaceholder"
                    default="true" />
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>



其中的
 <xsd:element name="global-macros" type="VelocityGlobalMacrosType" minOccurs="0">
 <xsd:element name="plugins" type="VelocityPluginsType" minOccurs="0">

定义了element的名字和类型的映射关系,下面是type的描述:
 <xsd:complexType name="VelocityGlobalMacrosType">
        <xsd:sequence>
            <xsd:element name="name" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="VelocityPluginsType">
        <xsd:sequence>
            <xsd:any
                namespace="http://www.alibaba.com/schema/services/template/engines/velocity/plugins"
                minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:complexType>

xsd:sequence表示list,xsd:any表示所有满足namespace="http://www.alibaba.com/schema/services/template/engines/velocity/plugins"都行。其实就是定义了一处扩展点。

二.VelocityEngineDefinitionParser类
再来看看VelocityEngineDefinitionParser如何来parser。
VelocityEngineDefinitionParser 继承了 AbstractSingleBeanDefinitionParser,但是要注意如果是顶级service要继承AbstractNamedBeanDefinitionParser,实现其getDefaultName方法。否则会抛出异常。
分享到:
评论
2 楼 san_yun 2011-09-26  
singleant 写道
楼主说得好!up!

谢谢支持,只不过是胡乱记录自己看的。
1 楼 singleant 2011-09-26  
楼主说得好!up!

相关推荐

    Webx3_Guide_Book.pdf 用户指南

    Webx3_Guide_Book 用户指南 2001年,阿里巴巴内部开始使用Java Servlet作为WEB服务器端的技术,以取代原先的 Apache HTTPD server和mod_perl的组合。 • 2002年,选择Jakarta Turbine作为WEB框架,并开始在此之上...

    webx3文档——web开发

    该文档为官方webx框架文档,对webx进行了全面的讲解,非常实用。

    webx3 PDF(阿里巴巴 前端web框架)

    webx3 PDF(阿里巴巴 前端web框架)

    webx3学习的demo,以及留言板的小例子

    根据webx3的官方网站,www.openwebx.org,找到“创建一个webx应用”,按照上面说的流程,就可以创建一个webx的项目。具体流程这里就不说了,官网上已经写得很清楚了。

    淘宝框架 Webx3资料

    阿里巴巴公司的开发框架webx3介绍 Webx3_Guide_Book.pdf

    Webx及框架简介

    Webx及框架简介 ppt 格式

    Webx3 Guide Book pdf

    Webx是一个在阿里巴巴集团内部广泛使用的,层次化、模块化的一个Web框架。...利用这些特性,Webx不仅能够用来开发高度可定制的Web应用(这是它的主要功能),也能够用来帮助你开发高度可扩展的非WEB的应用。

    webx总结 项目实践总结

    webx3 启动顺序,webx使用总结,webx表单提交(感觉你还是看webx文档 貌似更加好哦!那个表单提交写的很是详细)

    Webx3_Guide_Book.pdf

    Webx3_Guide_Book主要讲解webx框架的使用引导教程,方便您更好的使用Webx3

    Webx3.0小结

    webx3.0学习小结

    webx框架指南

    阿里开源框架webx的文档,想要学习webx或者维护webx的开发者可以下载

    webx2.7绿色安装

    WEBX是阿里巴巴的内部框架,“就是把页面与Service层之间的一些Servlet等公共的东西抽象出来,提供相应的服务以提高开发效率(《接口测试之Webx简介》—何晓峰 )”,可以看出,webx和传统的servlet-action模式的...

    创建简单的WEBX应用

    webx框架(淘宝框架),webx+spring+ibatis

    webx

    NULL 博文链接:https://xj84.iteye.com/blog/1850955

    淘宝WEBX框架详解

    WEBX框架详解,更好的了解Taobao的开发过程,对于新手更容易上手。

    paoding-webx3-solr-lucene

    paoding-webx3-solr-lucene

    WebX3 Guide Book学习指南

    Webx框架指南 Michael Zhou 出版日期 2010-11-13

    webx_guide

    快速使用 webx 开发web 应用 Webx框架指南 Michael Zhou

    Webx3日志系统的配置

    NULL 博文链接:https://trent-luo.iteye.com/blog/1071745

    Webx介绍_PDF

    淘宝开源Web开发框架Webx3.0介绍,内附宠物店程序作为例子详细解说webx框架的方方面面。

Global site tag (gtag.js) - Google Analytics