技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统架构 --> Restlet框架解读-2

Restlet框架解读-2

浏览:2849次  出处信息

    1)代码结构

     Restlet目前有三个分子版本,1.1.X,2.0.X,2.1.X,2.1.X是开发主干,有很多新的特性在添加和修改,本文主要解读2.0.X这个版本,同时会涉及到1.1.X的部分内容。

     下载完restlet代码后,可以看到如下的目录结构

     /+ org.restlet.* (restlet API)

     + org.restlet.engine.* (restlet的一个默认实现)

     + org.restlet.example.*

     + org.restlet.ext.*

     + org.restlet.test.*

    restlet是一款高度插件式的框架,ext包下面主要是restlet的扩展插件。

     org.restlet下面主要是restlet的核心API和默认实现的引擎。

     2)核心包结果

     restlet是构建http协议之上的,按照http://roy.gbiv.com/pubs/dissertation/rest_arch_style.htm实现,所以在restlet的API中很多类名都是完全按照论文所提到的概念来设计。

     核心API主要分为以下一个包:

  • Base package
  • Data package
  • Representation package
  • Resource package
  • Routing package
  • Security package
  • Service package
  • Util package
  •     详细的API说明可以查看http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet.html

         目前对restlet框架的代码结构有了一个简单的认识后,我们来看看restlet到底做了哪些工作。

         restlet就是实现了HTTP协议下对一个URL资源的访问,所以restlet必然要实现HTTP协议,然后将请求路由到指定的处理类上,过程就这么简单,现在我们就来看看核心API,这里需要引入大师的文字:

         Uniform REST interface. “The central feature that distinguishes the REST

         * architectural style from other network-based styles is its emphasis on a

         * uniform interface between components. By applying the software engineering

         * principle of generality to the component interface, the overall system

         * architecture is simplified and the visibility of interactions is improved.

         * Implementations are decoupled from the services they provide, which

         * encourages independent evolvability.” Roy T. Fielding

        大概意思就是说明:REST架构区别与其他基于网络的软件架构最重要的特点就是REST强调组件之间接口统一。

         所以在restlet核心API中所有的类都继承org.restlet.Uniform这个接口。

        

    建议继续学习:

    1. Restlet框架解读-1    (阅读:3289)
    QQ技术交流群:445447336,欢迎加入!
    扫一扫订阅我的微信号:IT技术博客大学习
    © 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

    京ICP备15002552号-1