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

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资料

    它引入了XML Schema的概念,通过扩展点(Configuration Point)和捐献(Contribution)机制实现了对Spring配置文件的自动化处理,大大减轻了开发者的负担。 - **WebxFramework**:这部分主要介绍了Webx框架的初始化过程...

    Webx3_Guide_Book.rar_tapeov2_webx_webx 开源框架

    本指南将深入探讨Webx3框架的核心特性和使用方法,结合《Webx3_Guide_Book.pdf》的详细文档,我们将全面解析以下几个关键知识点: 1. **框架架构**:Webx3 的架构设计基于组件化思想,允许开发者灵活地选择和配置...

    Webx及框架简介

    7. **AOP(面向切面编程)**:Webx利用AOP实现横切关注点的解耦,如日志记录、事务管理等,让核心业务代码更专注于业务逻辑。 Webx框架的特性还包括: - **MVC架构**:Webx遵循经典的MVC设计模式,使代码结构清晰...

    webx3框架指南PDF教程附学习Demo

    2.2.2. 扩展点,Configuration Point ....................................................... 17 2.2.3. 捐献,Contribution ...................................................................... 17 ...

    webx框架指南

    SpringExt模块的原理非常丰富,涉及到了XML Schema的秘密,扩展点ConfigurationPoint的定义,捐献Contribution的概念以及组件和包的管理。SpringExt的引入大大增强了Spring框架的功能和灵活性。 WebxFramework部分...

    webx总结

    综合以上信息,Webx总结可能涵盖了以下几个关键知识点: 1. **Webx框架概述**:介绍Webx的基本架构、设计原则以及其在企业级应用中的优势。 2. **源码解析**:深入剖析Webx的核心组件,如Request Context,帮助...

    webx_guide

    提到使用Webx而不是其他框架的理由,关键点在于Webx的成熟可靠性和良好的开放性和扩展性。成熟可靠性意味着Webx已经经过了时间的考验,稳定且能够应对各种开发场景;开放和扩展性则是指Webx提供了灵活的接口供开发者...

    Webx3 Guide Book pdf

    - **SpringExtSchema**:扩展Spring的Schema,提供更高级别的配置选项,例如通过扩展点和贡献点机制。 ##### **2.2 SpringExt原理** - **XMLSchema中的秘密**:SpringExt通过定义自己的Schema来实现对Spring配置的...

    WebX入门指南示例程序

    通过结合提供的博客文章和代码,我们将深入探讨以下几个核心知识点: 1. **WebX框架概述**: WebX是一个组件化的MVC(Model-View-Controller)框架,它提供了丰富的功能,如数据持久化、事务管理、权限控制等。它...

    阿里巴巴J2EE Webx框架简介

    此外,Webx提供了丰富的扩展点和插件机制,允许开发者自定义行为,满足特定业务需求。 总的来说,阿里巴巴的Webx框架是一个强大且灵活的J2EE开发工具,它的模块化设计、Car组件化打包、URL管理和MVC架构,都极大地...

    WEBX3.0框架指南(PDF版)

    - **基础框架**:WEBX3.0的基础构建于Spring框架之上,通过提供一系列扩展点来实现高度定制化的开发。 - **层次化**:框架被划分为多个层次,每个层次负责不同的功能模块,这种设计使得开发者可以按需选择使用哪些...

    webx学习总结.pdf

    Webx框架的入口点是WebxControllerServlet,负责处理来自Web访问者的请求。框架的核心是ServicePipeline,它负责初始化和服务注入。在Web层,Form服务通过Form.xml进行配置,包含了表单信息、验证规则和错误处理...

    淘宝实习笔记--webx学习之旅

    3. **对象-关系映射(ORM)模式**:ORM技术将对象层次结构映射到关系型数据库结构。通过ORM,开发者可以专注于对象操作,而框架会自动处理SQL生成和执行。虽然ORM可能会带来额外的执行开销,但其优化潜力和减少的...

    阿里巴巴Web及框架简介

    3. **MVC架构**:Webx遵循经典的Model-View-Controller(模型-视图-控制器)架构,分离了业务逻辑、数据处理和用户界面,有利于团队协作和代码解耦。 4. **事务管理**:Webx提供了强大的事务管理机制,能够确保在...

    2-创建业务逻辑与数据库访问[归纳].pdf

    以下是相关知识点的详细说明: 1. **预备知识与环境设置**: 开始前,开发者需要确保已经安装了必要的软件,并且熟悉了基础的Web应用创建流程。这包括阅读《新人指南》以了解软件安装,以及阅读《创建简单的WEB...

Global site tag (gtag.js) - Google Analytics