q两天学习REST及其java实现框架Restlet.
兯状态传输(Representational state transferQ?z>RESTQ是设计Z命名资源而非消息的松耦合应用E序的一U风根{构? RESTful 应用E序的最困难的部分在于确定要公开哪些资源.个h认ؓ它跟DDD联系的很紧密Q特别是REST中的“资源”Q我个h理解它就是从领域模型中的模型而来的?br />我们先来看一下restlet core api吧:
Overview of a Restlet architecture
Here is a diagram illustrating how the API composes components, connectors, virtual host and applications. Applications are in turncomposed of resources.

用白说来讲就是:Application通过Router 某个URI与Resourcel定在一定,而一个componet可能含有多个Application,
q有Representation q个cd实也很重要?/z>Representation entityQ?/span>Restlet中全部的接受和返回对象都Representationcȝ子类?/span>
如在WEB APP中经帔R要从一个FORM中拿到其Representation(getWebRepresentation()
)或组装成一?/font>Representation
Form(Representation webForm)
,以便客户端与服务器进行交互。我们知道REST是以资源Z心的Q一个URI׃表了对这个资源的CURD操作。@Pathq个注解提明?/z>
哪个操作是由该资源的那个Ҏ来实现的?
@POST
@Path("add")
public String addStudent(Representation entity) {
}
...
@DELETE
@Path("delete/{id}")
public String deleteStudent(@PathParam("id") int id) {
int status = ResourceHelper.deleteStudent(id);
return String.valueOf(status);
}
representation package overriew:
Restlet 对表现层的技术支持也是通来representationq个cL实现的,representation
Restletq没有你Setvlet API那样有自已的JSP作表现的技术,它是通过这三种模板技术整合v来而已?/z> : XSLT, FreeMarker and Apache Velocity
The org.restlet.representation package contains common representation data elements. Here is a hierarchy diagram with the core Representation classes:
Overview Representation package

当然restlve只是提供了一个入口,到要对数据库进?z>CURD操作Ӟ基具体实现还是由JDBC{技术来实现.

]]>