- 浏览: 81576 次
- 性别:
- 来自: 信阳
文章分类
- 全部博客 (47)
- 数据库 (2)
- web应用 (14)
- 杂 (3)
- java基础 (3)
- Lucene (6)
- junit (2)
- spring (0)
- solr (4)
- JMS (0)
- 持久层 (0)
- 模板解决方案 (4)
- 项目发布管理 (0)
- GIS (0)
- 运维知识 (1)
- 设计模式 (2)
- 线程 (2)
- java.util (0)
- Linux (0)
- JVM (0)
- HTML5 (1)
- 敏捷开发 (0)
- 压力测试 (1)
- 字节码操控框架 (0)
- Classworking (1)
- EJB (1)
- REST (7)
- Restlets (4)
- Groovy (1)
- Selenium (1)
- test (3)
- Jersey一 (0)
- 架构分析 (0)
- 研发管理 (1)
- JAAS (0)
- JSCoverage (1)
- EclEmma (1)
- 计划 (0)
- jQuery (0)
- javascript MVC (0)
最新评论
-
悬空90:
兄弟人才啊 。英文不好找了老半天
web容器一、jetty的学习(下载源码) -
liushicheng1:
我也找了半天 被你发现了 人才。
web容器一、jetty的学习(下载源码) -
gandilong:
不过,我想通过ant+freemarker+xml生成jav ...
java代码自动生成一(freemarker) -
xinyangwjb:
solr官网例子默认编码是UTF-8,你的项目是不是UTF-8 ...
solr学习三(测试类,含普通与ExtractingRequestHandler测试) -
wjx:
up.setParam设置的内容如果有中文的话会乱码,不知lz ...
solr学习三(测试类,含普通与ExtractingRequestHandler测试)
Restlets
Restlet项目为“建立REST概念与Java类之间的映射”提供了一个轻量级而全面的框架。它可用于实现任何种类的REST式系统,而不仅仅是REST式Web服务。
The Restlet framework
Restlet application are akin to servlet applications in that they reside in a container,but in practice they are quite different in two major ways,First,Restlets use no direct notion of HTTP or its stateful manifestations such as cookies or sessions ,per se.Second,the Restlet framework is extremely lightweight.As you'll see ,a fully functional RESTful application can be built with a handful of classes that extend from a few core Restlet base classes.Configuration and deployment leverage existing container models,so you simply update the customary web.xml file and deploy a standard Web archive(WAR)file.
Restlet应用类似于servlet应用,他们都处于一个容器中。但是在实际操作中,他们在俩大方面有很大的不同:
一、Restlets没有直接的HTTP概念,也没有他自身的状态表现如cookies和sessions。
二、Restlets框架非常轻量。如你所见,一个全功能的RESTful应用只需少数几个继承自Restlet基础类的类。配置部署现有集成模式,只需简单更新通常的web.xml文件和部署一个标桩WAR文件。
For the most part,the bulk of a RESTful application built with the Restlet framework requires the use of two base classes:Application and Resource.Logically speaking,an Application instance maps URIs to Resource instances.Resource instances do the work of handling the basic CRUD commands,which are,of course ,mapped to GET,POST,PUT,and DELETE.
大部分情况下,基于Restlet框架的RESTful应用需要俩继承类:Application和Resource。从逻辑上讲,一个应用实例映射URIs到Resource实例。Resource实例支持CRUD命令操作。
The race application
You create a starting point with the Restlet framework by extending from the framework's Application class.In this class,you define Resources that respond to URIs.This definition process is done with the framework's Router class.For example,if you have a URI such as order/order_id,you need to specify which object can handle these requests.This object is an instance of the framework's Resource type.You link objects with URIs by attaching them to a Router instance,as in Listing5:
创建一个继承自Application的出发点。这个类中定义响应URIs的Resources,即框架的Router类实现。例如:URI order/order_id,你需要指定哪个对象来处理这个请求。这个对象是框架Resource类型的实例。对象与URIs的关联通过附加到Router实例下来实现。
So in this example, the URI order/order_id is logically mapped to an Order class (which, in turn, extends Resource).
这个例子将Order类与URI order/order_id逻辑映射起来。
Acme Racing has the four logical RESTful URIs that you've already defined - four patterns that work with various aspects of races and runners:
* /race
* /race/race_id
* /race/race_id/runner
* /race/race_id/runner/runner_id
你为Acme Racing 已经定义了四个逻辑RESTful URIs ——四种模式为各方面races和runners服务。
The behavior of each URI(such as if it works with POST,DELETE,GET,and so on)is'not important at this point.The behavior of each Resource is the job of a Resource instance; however,the Application instance is used to map these URIs to (yet-to-be-defined)Resources via a Router instance,as shown in Listing6:
继承自Application的实例被用来映射URIs到Resources,通过一个Router实例,如上面的代码所示。
The base class,Application,is an abstract class.Extending classes must implement the createRoot() method.In this method, you can create a Router instance and attach Resources to URIs as i've done in List6.
Application是一个抽象类,他的子类必须实现createRoot方法,这个方法中,我们可以创建Router实例附加Resources到URIs上。
Race resources
Now that you've defined the Application instance to handle four different URI patterns,you must implement the four Resources.
Resource types in the Restlet framework are known as Restlets.They are the heart of any RESTful application developed with the Restlet framework.Unlike the Application type.the base Resource class is not abstract.It's more like a template with default behavior that you can override as needed.
现在你已经定义了四种URI模式在Application实例中。现在你必须再实现4个Resources。
Resource类型在Restlet框架中被称为Restlets。他们是Restlet框架下RESTful应用的核心。不同于Application类型,基础Resource类不是抽象的,他更想一个有默认方法的模板,你只需重写你需要的方法。
At a high level,Resource has four methods that require overriding.Not coincidentally,they map to the basic HTTP commands that are the touchstone of REST-GET,POST,PUT,DELETE.because the Resource class is nonabstract,the framework requires a paired method to be implemented for desired behavior to be invoked.For instance,if you want a particular resource to respond to DELETE requests,you would first implement the delete() method.Second, you also must implement the allowDelete() method and have this method return true(it defaults to false).By default,the corresponding PUT,POST,and DELETE allow methods return false,and the alllowGet() method return true.this means for read-only Resources,you need to override only one method(instead of two in the other three cases).You can alternatively call the setModifcation(true) in a Resource class and thus not have to override individual HTTP verb allow methods.
Resource类有四个方法需要被重写。这并非巧合。他们映射到HTTP的四种命令,是REST-GET,POST,PUT,DELETE的试金石。因为Resource类不是抽象的,REST框架需要一系列的方法去实现所期待的行为去被调用。例如,如果你想让一个指定的resource去响应一个DELETE请求,首先你要实现delete()方法,然后你必须实现allowDelete()方法并且使这个方法返回值为true。
默认情况下,相应的PUT,POST,and DELETE方法允许返回值为false,alllowGet()方法返回为ture。这意味着对于只读Resources,你只需重载一个方法(其它几种情况要俩方法)。你可以在一个resource类中选择性地访问setModifcation(true)方法,并且因此不必重写个体的HTTP动词方法。
For instance,the RacesResource is intended to respond to GET requests with XML document that describes the races in the system.Users can also create new races via this Resource type.Therefore,the RacesResource class overrides at least three methods from the Resource base class:
*getRepresentation()
*allowPost()
*post()
Remember, Resources instances, by default, are read-only. Hence the allowGet() method doesn't need to be overridden.
上面讲的都是原理性的东西,下面是具体开发实例:
http://www.lifeba.org/arch/restlet_develop_jax-rs_service_1.html
Restlet项目为“建立REST概念与Java类之间的映射”提供了一个轻量级而全面的框架。它可用于实现任何种类的REST式系统,而不仅仅是REST式Web服务。
The Restlet framework
Restlet application are akin to servlet applications in that they reside in a container,but in practice they are quite different in two major ways,First,Restlets use no direct notion of HTTP or its stateful manifestations such as cookies or sessions ,per se.Second,the Restlet framework is extremely lightweight.As you'll see ,a fully functional RESTful application can be built with a handful of classes that extend from a few core Restlet base classes.Configuration and deployment leverage existing container models,so you simply update the customary web.xml file and deploy a standard Web archive(WAR)file.
Restlet应用类似于servlet应用,他们都处于一个容器中。但是在实际操作中,他们在俩大方面有很大的不同:
一、Restlets没有直接的HTTP概念,也没有他自身的状态表现如cookies和sessions。
二、Restlets框架非常轻量。如你所见,一个全功能的RESTful应用只需少数几个继承自Restlet基础类的类。配置部署现有集成模式,只需简单更新通常的web.xml文件和部署一个标桩WAR文件。
For the most part,the bulk of a RESTful application built with the Restlet framework requires the use of two base classes:Application and Resource.Logically speaking,an Application instance maps URIs to Resource instances.Resource instances do the work of handling the basic CRUD commands,which are,of course ,mapped to GET,POST,PUT,and DELETE.
大部分情况下,基于Restlet框架的RESTful应用需要俩继承类:Application和Resource。从逻辑上讲,一个应用实例映射URIs到Resource实例。Resource实例支持CRUD命令操作。
The race application
You create a starting point with the Restlet framework by extending from the framework's Application class.In this class,you define Resources that respond to URIs.This definition process is done with the framework's Router class.For example,if you have a URI such as order/order_id,you need to specify which object can handle these requests.This object is an instance of the framework's Resource type.You link objects with URIs by attaching them to a Router instance,as in Listing5:
Router router = new Router(this.getContext()); router.attach("order/{order_id}", Order.class);
创建一个继承自Application的出发点。这个类中定义响应URIs的Resources,即框架的Router类实现。例如:URI order/order_id,你需要指定哪个对象来处理这个请求。这个对象是框架Resource类型的实例。对象与URIs的关联通过附加到Router实例下来实现。
So in this example, the URI order/order_id is logically mapped to an Order class (which, in turn, extends Resource).
这个例子将Order类与URI order/order_id逻辑映射起来。
Acme Racing has the four logical RESTful URIs that you've already defined - four patterns that work with various aspects of races and runners:
* /race
* /race/race_id
* /race/race_id/runner
* /race/race_id/runner/runner_id
你为Acme Racing 已经定义了四个逻辑RESTful URIs ——四种模式为各方面races和runners服务。
The behavior of each URI(such as if it works with POST,DELETE,GET,and so on)is'not important at this point.The behavior of each Resource is the job of a Resource instance; however,the Application instance is used to map these URIs to (yet-to-be-defined)Resources via a Router instance,as shown in Listing6:
public class ReceApplication extends Application{ public RaceApplication(Context context){ super(context); } public Restlet createRoot(){ Router router = new Router(this.getContext()); router.attach("/race",RacesResource.class); router.attach("/race/{race_id}",RaceResource.class); router.attach("/race/{race_id}/runner",RaceRunnersResource.class); router.attach("/race/{race_id}/runner/{runner_id}", RaceRunnerResource.class); return router; } }
继承自Application的实例被用来映射URIs到Resources,通过一个Router实例,如上面的代码所示。
The base class,Application,is an abstract class.Extending classes must implement the createRoot() method.In this method, you can create a Router instance and attach Resources to URIs as i've done in List6.
Application是一个抽象类,他的子类必须实现createRoot方法,这个方法中,我们可以创建Router实例附加Resources到URIs上。
Race resources
Now that you've defined the Application instance to handle four different URI patterns,you must implement the four Resources.
Resource types in the Restlet framework are known as Restlets.They are the heart of any RESTful application developed with the Restlet framework.Unlike the Application type.the base Resource class is not abstract.It's more like a template with default behavior that you can override as needed.
现在你已经定义了四种URI模式在Application实例中。现在你必须再实现4个Resources。
Resource类型在Restlet框架中被称为Restlets。他们是Restlet框架下RESTful应用的核心。不同于Application类型,基础Resource类不是抽象的,他更想一个有默认方法的模板,你只需重写你需要的方法。
At a high level,Resource has four methods that require overriding.Not coincidentally,they map to the basic HTTP commands that are the touchstone of REST-GET,POST,PUT,DELETE.because the Resource class is nonabstract,the framework requires a paired method to be implemented for desired behavior to be invoked.For instance,if you want a particular resource to respond to DELETE requests,you would first implement the delete() method.Second, you also must implement the allowDelete() method and have this method return true(it defaults to false).By default,the corresponding PUT,POST,and DELETE allow methods return false,and the alllowGet() method return true.this means for read-only Resources,you need to override only one method(instead of two in the other three cases).You can alternatively call the setModifcation(true) in a Resource class and thus not have to override individual HTTP verb allow methods.
Resource类有四个方法需要被重写。这并非巧合。他们映射到HTTP的四种命令,是REST-GET,POST,PUT,DELETE的试金石。因为Resource类不是抽象的,REST框架需要一系列的方法去实现所期待的行为去被调用。例如,如果你想让一个指定的resource去响应一个DELETE请求,首先你要实现delete()方法,然后你必须实现allowDelete()方法并且使这个方法返回值为true。
默认情况下,相应的PUT,POST,and DELETE方法允许返回值为false,alllowGet()方法返回为ture。这意味着对于只读Resources,你只需重载一个方法(其它几种情况要俩方法)。你可以在一个resource类中选择性地访问setModifcation(true)方法,并且因此不必重写个体的HTTP动词方法。
For instance,the RacesResource is intended to respond to GET requests with XML document that describes the races in the system.Users can also create new races via this Resource type.Therefore,the RacesResource class overrides at least three methods from the Resource base class:
*getRepresentation()
*allowPost()
*post()
Remember, Resources instances, by default, are read-only. Hence the allowGet() method doesn't need to be overridden.
上面讲的都是原理性的东西,下面是具体开发实例:
http://www.lifeba.org/arch/restlet_develop_jax-rs_service_1.html
发表评论
-
javascript异步事件分析
2013-05-22 14:25 0console.log( "a" ); ... -
javascript作用域链的灵活运用1
2013-05-21 19:58 819javascript比较出彩的运用之一:作用域链。 1、对于有 ... -
2012-2013总结之javascript
2013-05-02 14:54 0javascript能力的来源与基石是一本书:javascri ... -
Js闭包理解、运用
2012-11-08 14:12 888onClick: (function (){ ... -
URL转义及编码
2012-08-31 11:01 822js对文字进行编码涉及3个函数:escape,encodeUR ... -
JS的架构
2012-06-25 09:35 0js代码页也需要架构,他能使你的代码更加漂亮,益于维护,便于代 ... -
各种浏览器语言包、国际化如何配置
2012-04-18 15:36 2957如果web项目使用了国际化多语言包,切换浏览器语言包可以切换 ... -
RESTful初探之六(testing)
2012-04-12 17:04 992Building and testing the servic ... -
RESTful初探之五(The data layer)
2012-04-12 14:34 949原文:http://www.ibm.com/developer ... -
RESTful初探之五(Generating XML documents)
2012-04-12 13:57 910In the Formatting the resource, ... -
RESTful初探之三(Formating the resource)
2012-04-11 16:52 871Race URIs The RESTful API you b ... -
RESTful初探之二(Off to the races:Building a RESTful API)
2012-04-11 15:58 823Imagine an online application t ... -
RESTful初探之一(What is REST)
2012-04-11 11:32 959英文tutorial guide http://www.ibm ... -
关于java Web Project引包的问题
2012-02-14 17:03 1570这里要说的是Web Project如何合理引入jar包的问题。 ... -
web容器二、jetty的学习(主要接口)
2012-01-15 22:49 1065学习资料: 官方Wiki:http://docs.codeh ... -
web容器一、jetty的学习(下载源码)
2012-01-15 00:26 2389由于jetty是由java编写的web容器,因此,对web容器 ... -
servlet容器监听器与拦截器
2012-01-11 18:05 0二者都是在web.xml中加载,分别为: <listen ... -
http传参get与post的误区与总结
2012-01-11 10:18 2916众所周知的http请求有两种: get与post: 这两种请求 ... -
如何在struts2拦截器中获得request
2011-12-22 15:23 2020由struts2原理图可知道,interceptor发生在ac ...
相关推荐
Python Flask高级编程之RESTFul API前后端分离精讲第六章节Python Flask高级编程之RESTFul API前后端分离精讲第六章节Python Flask高级编程之RESTFul API前后端分离精讲第六章节Python Flask高级编程之RESTFul API...
Python Flask高级编程之RESTFul API前后端分离精讲第四章节Python Flask高级编程之RESTFul API前后端分离精讲第四章节Python Flask高级编程之RESTFul API前后端分离精讲第四章节Python Flask高级编程之RESTFul API...
Python Flask高级编程之RESTFul API前后端分离精讲Python Flask高级编程之RESTFul API前后端分离精讲Python Flask高级编程之RESTFul API前后端分离精讲Python Flask高级编程之RESTFul API前后端分离精讲Python Flask...
本示例是关于如何使用C#语言创建一个简单的RESTful服务端以及对应的RESTful客户端。以下是相关知识点的详细说明: 1. **RESTful原则**:REST(Representational State Transfer)的核心思想是资源(Resource)和...
Python Flask高级编程之RESTFul API前后端分离精讲第二章节Python Flask高级编程之RESTFul API前后端分离精讲第二章节Python Flask高级编程之RESTFul API前后端分离精讲第二章节Python Flask高级编程之RESTFul API...
在IT行业中,RESTful(Representational State Transfer)是一种软件架构风格,用于设计网络应用程序,尤其在Web服务领域广泛应用。C#作为.NET框架的主要编程语言,提供了丰富的工具和技术来实现RESTful服务。本篇...
Java Restful Web 源代码Java Restful Web 源代码Java Restful Web 源代码Java Restful Web 源代码Java Restful Web 源代码Java Restful Web 源代码Java Restful Web 源代码Java Restful Web 源代码Java Restful Web...
总结来说,谷歌浏览器RESTful请求插件是开发人员必备的工具之一,尤其对于需要频繁与Elasticsearch交互的项目。通过这个插件,用户可以方便地发起REST请求,测试和调试API,同时学习和理解RESTful架构风格。无论是在...
使用C#语言可以实现一个Rest风格的Web服务供外部调用,主要包括以下四点:定义service的契约、定义URL Routing、实现service、为服务编写宿主程序。例如,定义服务契约可以使用GET和POST方式访问,使用VS2015创建一...
RESTful API 使用 HTTP 协议定义了四种主要的操作:GET、POST、PUT 和 DELETE,分别对应于资源的获取、创建、更新和删除。 #### 构建 RESTful 风格的 API 构建 RESTful 风格的 API 时,通常会遵循以下几点建议: ...
### RESTful接口文档模板知识点解析 #### 一、RESTful接口概述 REST(Representational State Transfer)是一种网络应用程序的设计风格和开发方式,基于HTTP协议,可以使用XML或者JSON格式传输数据,一般用于...
"Java调用Restful API接口的方式" Java调用Restful API接口是Java开发中非常重要的一部分,了解Java调用Restful API接口的方式可以帮助开发者更好地理解和使用相关技术。本文将详细介绍Java调用Restful API接口的...
RESTful接口是一种遵循REST(Representational State Transfer,表述性状态转移)架构约束的Web服务设计风格,用于构建可扩展、高性能的互联网应用程序。REST强调通过HTTP协议中的动词(GET、POST、PUT、DELETE等)...
在开发RESTful接口时,我们需要遵循一定的设计规范来确保接口的一致性、可维护性和易用性。RESTful API(Representational State Transfer,也称为RESTful web服务)是一种提供互联网计算机系统间互操作性的方法。...
在Java开发中,HTTPClient和RESTful风格的接口被广泛用于实现文件的上传与下载功能。HTTPClient是一个强大的HTTP客户端库,而RESTful是一种轻量级的、基于HTTP协议的软件架构风格,常用于构建Web服务。在分布式系统...
Restful风格的请求使用“url+请求方式”表达一次请求目的,HTTP协议里有四个表达操作方式的动词: * GET:用于获取资源 * POST:用于新建资源 * PUT:用于更新资源 * DELETE:用于删除资源 例如: * /user/1 GET ...
本文将深入探讨如何在Spring MVC中实现RESTful风格的CRUD操作,这对初学者尤其有价值。 首先,了解REST(Representational State Transfer,表述性状态转移)是一种网络应用程序的设计风格和开发方式,基于HTTP协议...
### RESTful Java Web Services #### 一、RESTful Web服务概览 REST(Representational State Transfer)是一种软件架构风格,最初由Roy Fielding在他的博士论文中提出。它定义了一种简单且灵活的方法来创建分布式...
在RESTful.NET中,`restService`是核心概念之一,它代表了一个服务端的资源处理单元。通过定义RESTful接口,开发者可以构建出易于理解、可维护的API。RESTful服务通常由一组URI(统一资源标识符)组成,每个URI对应...