`
xinyangwjb
  • 浏览: 82285 次
  • 性别: Icon_minigender_1
  • 来自: 信阳
社区版块
存档分类
最新评论

RESTful初探之五(The data layer)

 
阅读更多
原文:http://www.ibm.com/developerworks/java/tutorials/j-rest/section7.html
This section describes the existing domain objects that make the up data layer that your RESTful service will reuse.
这一章节主要讲数据层已存在的域对象如何在RESTful中重用

Domain objects
As you know from Off to the races: Building a RESTful API, Acme Racing invested in a data layer for a previous project and wants to reuse it for the new Web service.This,of course,makes your job even easier.In a nutshell,the data layer consists of three business objects:Race, Runner, and Result. They are effectively managed by Spring and Hibernate;however,these frameworks are hidden from you;you simply have a JAR file that works nicely(that is,lets you easily create new races,find existing runners,and so on).
之前那篇文章所讲的,Acme Racing 有一个之前有投资过一个数据层级的软件,并希望重用这些数据在新的Web服务中。当然,这使工作更加简单。简单的说,数据层级包含三大业务对象::Race, Runner, and Result. 他们被spring和hibernate有效的管理;但是这些框架对你是隐藏的;你只需一个jar包就能轻松搞定他们。

The business objects support a series of finder methods that make obtaining race and runner instances quite easy. Objects can be persisted,updated,and removed from the underlying database via save(), update(), and remove() methods, respectively.
业务对象提供了很多查询方法,使获得race和runner实例非常容易。对象可以被独立地保存,修改和删除通过save(), update(), and remove()。

For example,a Race object supports a series of finder methods and facilitates manipulating persisted data nicely.The Race object's API is straightforward,as shown in Listing10:                 

Collection<Race> findAll();
Race findById(long id);
Race findByName(String name);
void create(Race race);
void update(Race race);
void remove(Race race);

A Race instance has a number of properties,as shown in Listing11:
private long id;
private String name;
private Date date;
private double distance;
private Set<Runner> participants;
private Set<Result> results;
private String description;

All of Race's properties are available via getters and setters. What's more, collections of items (such as participants and results) support adding individual items. Therefore, the Race object has an addParticipant() method, shown in Listing 12:
public void addParticipant(final Runner participant) ;




分享到:
评论

相关推荐

    Pro ADO.NET Data Services: Working with RESTful Data

    Description: Pro ADO.NET Data Services: Working with RESTful Data is aimed at developers interested in taking advantage of the new REST–style data services that ADO.NET Data Services (formerly code–...

    Django restful web services the easiest way to build python

    ### Django RESTful Web Services: The Easiest Way to Build Python #### 一、概述与背景 本书主要聚焦于如何利用Python及其最受欢迎的Web框架Django来构建RESTful Web服务。随着互联网技术的发展,RESTful Web...

    Apress - Pro ADO.NET Data Services Working with RESTful Data

    本书聚焦于如何使用ADO.NET Data Services来处理RESTful数据,为读者提供了丰富的理论知识与实践指导。 ### 一、ADO.NET Data Services简介 ADO.NET Data Services是Microsoft推出的一种基于Web的数据访问技术,它...

    Python Flask高级编程之RESTFul API前后端分离精讲第七章节

    Python Flask高级编程之RESTFul API前后端分离精讲第六章节Python Flask高级编程之RESTFul API前后端分离精讲第六章节Python Flask高级编程之RESTFul API前后端分离精讲第六章节Python Flask高级编程之RESTFul API...

    Pro ADO.NET Data Services Working with RESTful Data

    《Pro ADO.NET Data Services Working with RESTful Data》是一本深入探讨如何利用 ADO.NET 技术栈中的数据服务来实现 RESTful 架构的书籍。本书由 John Shaw 和 Simon Evans 合著,并于2009年出版。该书主要面向...

    Python Flask高级编程之RESTFul API前后端分离精讲第五章节

    Python Flask高级编程之RESTFul API前后端分离精讲第五章节Python Flask高级编程之RESTFul API前后端分离精讲第五章节Python Flask高级编程之RESTFul API前后端分离精讲第五章节Python Flask高级编程之RESTFul API...

    restful restful所需要的jar包

    restful restful所需要的jar包 ========================================= Restlet, a RESTful Web framework for Java ========================================= http://www.restlet.org -------------------...

    Building.RESTful.Python.Web.Services.epub

    What You Will Learn Develop complex RESTful APIs from scratch with Python combined with and without data sources Choose the most appropriate (micro) framework based on the specific requirements of a ...

    vue 调用 RESTful风格接口操作

    在现代Web开发中,RESTful API已经成为服务端与前端交互的标准模式。Vue.js作为一个流行的前端框架,经常需要调用这些API来实现数据的获取、更新、创建和删除等操作。本篇文章将详细介绍如何在Vue项目中调用RESTful...

    Python Flask高级编程之RESTFul API前后端分离精讲第一讲解

    Python Flask高级编程之RESTFul API前后端分离精讲Python Flask高级编程之RESTFul API前后端分离精讲Python Flask高级编程之RESTFul API前后端分离精讲Python Flask高级编程之RESTFul API前后端分离精讲Python Flask...

    Spring Data REST简化RESTful开发.docx

    Spring Data REST 是基于 Spring Boot 和 Spring Data 项目构建 RESTful API 的强大工具,极大地简化了开发者的工作。在传统的 RESTful 开发中,我们需要手动编写控制器(Controller)来处理 HTTP 请求并映射到业务...

    Restful C# 服务端篇之实现RestFul Service开发(简单实用)

    在IT行业中,RESTful(Representational State Transfer)是一种软件架构风格,用于设计网络应用程序,尤其在Web服务领域广泛应用。C#作为.NET框架的主要编程语言,提供了丰富的工具和技术来实现RESTful服务。本篇...

    building restful web services with spring 5 2e

    Building RESTful Web Services with Spring 5 – Second Edition: Leverage the power of Spring 5.0, Java SE 9, and Spring Boot 2.0 Find out how to implement the REST architecture to build resilient ...

    Python Flask高级编程之RESTFul API前后端分离精讲第二章节

    Python Flask高级编程之RESTFul API前后端分离精讲第二章节Python Flask高级编程之RESTFul API前后端分离精讲第二章节Python Flask高级编程之RESTFul API前后端分离精讲第二章节Python Flask高级编程之RESTFul API...

    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 源代码Java Restful Web 源代码Java Restful Web...

    C# 一个简单的 Restful 服务端和 Restful 客户端 Demo

    本示例是关于如何使用C#语言创建一个简单的RESTful服务端以及对应的RESTful客户端。以下是相关知识点的详细说明: 1. **RESTful原则**:REST(Representational State Transfer)的核心思想是资源(Resource)和...

    谷歌浏览器restful请求插件

    总结来说,谷歌浏览器RESTful请求插件是开发人员必备的工具之一,尤其对于需要频繁与Elasticsearch交互的项目。通过这个插件,用户可以方便地发起REST请求,测试和调试API,同时学习和理解RESTful架构风格。无论是在...

    五六本关于restful开发的电子书

    RESTful开发是现代Web服务开发的核心技术之一,尤其在API设计中广泛应用。 1. RESTful原则: - 客户端-服务器架构:客户端与服务器之间无状态,每个请求包含所有必要的信息。 - 统一接口:包括资源识别(通过URI...

    restful接口文档模板

    ### RESTful接口文档模板知识点解析 #### 一、RESTful接口概述 REST(Representational State Transfer)是一种网络应用程序的设计风格和开发方式,基于HTTP协议,可以使用XML或者JSON格式传输数据,一般用于...

Global site tag (gtag.js) - Google Analytics