0% found this document useful (0 votes)
59 views

RESTful Web Service Frameworks in Java

This is a peer reviewed document on RESTful web service frameworks in Java.

Uploaded by

anneusphotos
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

RESTful Web Service Frameworks in Java

This is a peer reviewed document on RESTful web service frameworks in Java.

Uploaded by

anneusphotos
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

RESTful Web Service Frameworks in Java

Hongjun Li
Informatization Office, Shanghai Lixin University of Commerce, Shanghai, 201620, China
e-mail: [email protected]

Abstract—In order to make the Web services, Web (4) intermediary components to reduce
applications in Java more powerful, flexible and user friendly, (5) intermediary components of reducing interaction
building unified Web applications is very significant. By latency, enforcing security, and encapsulating legacy
introducing a new style-Representational State Transfer, this systems
paper studied the goals and design principles of REST, the idea The components in the REST system must comply with
of REST and RESTful Web service design principles, RESTful the following constraint[1]:
style Web service, RESTful Web service frameworks in Java (1) identification of resources
and the ways to develop RESTful Web service. The RESTful (2) manipulation of resources through representations
Web Service frameworks in Java can effectively simplify the
(3) self-descriptive messages
Web development in many aspects.
(4) hypermedia as the engine of application state
Keywords-Rest; Restful Web Services; Restlet; RESTEasy; C. The Idea of REST
Struts 2
In the REST system, all the resources had the URI. Using
the GET, POST, DELETE and PUT as the general interface
I. REST AND THE RESTFUL WEB SERVICES of the resources, user visited the resources via them.
Developers must consider[4] each method’s expected
A. Introduction of REST semantics to decide which methods are suitable for each
REST stands for Representational State Transfer, which resource. GET, PUT, and DELETE, for example, must be
comes from Roy Fielding’s PhD dissertation [1] published in idempotent, and GET must be safe for clients to call
June of 2000.In this dissertation, he introduced the REST repeatedly because all it does is return a representation of a
architectural style, developed as an abstract model of the web resource. The PUT method lets a client replace a resource
architecture to guide the redesign and definition of the HTTP state with a new state, whereas clients use DELETE to
and URIs. The style describes the foundation of the World remove resources. Both obviously have side effects, but both
Wide Web. The technologies that make up this foundation are idempotent because calling them repeatedly has the same
include the Hypertext Transfer Protocol(HTTP), markup effect as calling them once. POST can be made to perform
languages such as HTML and XML, web-friendly formats virtually any action, but in RESTful systems, it’s normally
such as JSON, and Uniform Resource Identifier(URI). REST used to create or extend resources, and so it isn’t expected to
is an architectural style for networked applications, which be idempotent or free of side effects.
consists of several constraints to address separation of Not everyone agrees [4] that REST is easy, of course.
concerns, visibility, reliability, scalability, flexibility, One frequently mentioned issue is a lack of tools-
performance, and so on. The destination of REST is how to specifically, those that fit within the interactive development
determine a fine definitive Web program to drive forward. environments (IDEs) that many enterprise developers use to
Choosing a hyperlink on the Web page, the program could help them write and maintain their code. Given that IDEs are
make another Web page return to the user and run further. helpful only because they automate activities and approaches
For example, the client request the service of the train’s that developers have already manually proven to be worth
T106, the Web page in the return result included the link of automating, this “lack of tooling” argument is somewhat off
the serial number of bus run and timetable. When the client the mark. With the right language-specific patterns and
got the result, he could choose a link to determine the next idioms to follow, existing IDEs work just fine for RESTful
action. service development.
REST is not a protocol; it’s a style of the Web
architecture; abstraction and description to the design D. The RESTful Web Service Design Principles
principle of Web architecture. In other words, Web is the 1. Prerequisite gathering-similar to traditional software
instance of the REST system. REST described how to design requirement gathering practices.
and develop distributed system. 2. Resource identification-similar to OOD.
3. Resource representation definition.
B. The Goals and Design Principle of REST 4. URI definition-define the API, which consists of URIs
The goals[1] of REST are the followings: for clients and servers to exchange resources' representations.
(1) scalability of component interactions
(2) generality of interfaces
(3) independent deployment of components

Authorized licensed use limited to: Georgia Gwinnett College. Downloaded on November 15,2020 at 20:55:40 UTC from IEEE Xplore. Restrictions apply.
E. RESTful Style Web Services through the locate resources using the Uniform Resource
REST is a distributed software architecture that takes full Identifier (URI ) , use of resources for software agents and
use of Web features. It can reduce the complexity of system the interaction between the HTTP protocol, and using HTML,
development, provide scalability for the system. REST Web XML and other intermediaries for resources, and so can be
services are the resource-oriented services, you can use achieved.
normal simple operation to generate an action for the clear II. RESTFUL WEB SERVICE FRAMEWORKS IN JAVA
resources.
The followings are several key principles for RESTful A framework[5] is a piece of structural software. It tries
Web services: to make generalizations about the common tasks and
Defining the ID for all resources; workflow of a specific domain and then attempts to provide
Linking all the resources together; a platform upon which applications of that domain can be
Using standard methods; more quickly built. The framework does this primarily in
Resources to multiple statements; two ways. First, the framework tries to automate all the
Stateless communication; tedious tasks of the domain. Second, the framework tries to
If the developers can stick with the five principles in the introduce an elegant architectural solution to the common
design of the system applications, they will get a Web workflow of the domain in question. A web application
service architecture using high-quality system. framework in Java is a piece of structural software that
The first key principle of REST illustrates that, the ID of provides automation of common tasks of the domain as well
the resources in RESTful Web services (whether a single as a built-in architectural solution that can be easily inherited
resource, or a collection of resources; whether the virtual by applications implemented on the framework.
resources, or physical resources) can use a unified, unique Although creating Java web applications in the twenty-
concept URI to identity. first century without using a framework of some kind is
The second key principle of REST illustrates that, all the feasible. You need spending amount of hours on the project.
resources of the RESTful Web services, are available Perhaps it’s not a question of whether to use a framework or
through hyperlinks in the form of URI dynamically reference not, but of which framework offers the solutions you need.
in any case, in order to achieve the interconnection of With that in mind, it’s time to look at the frameworks for
network resources. RESTful Web services development in Java and see what
The third key principle of REST illustrates that, all of the kinds of modern conveniences they offers.
resources in RESTful Web services should be properly A. RESTEasy
achieved through HTTP, using a common, uniform and non-
specific HTTP interface. HTTP not only unique positioning Writing RESTful Web services in Java has been possible
of resources, but also indicates how to operate the resource. for years with the servlet API. In 2008, a new specification
Using the standard HTTP GET, PUT, POST, and DELETE for RESTful Web service in Java called JAX-RS(The Java
operations and other methods of resources can make the API for RESTful Web Services)[JSR 311]
client program and the Web services to the resources of (www.jcp.org/en/jsr/detail?id=311) was defined to simplify
mutual collaboration. RESTful Web service implementation. The specification
The fourth key principle of REST illustrates that, based on Metadata grammar of JDK 5 will be beneficial to
RESTful Web services can use HTTP to allow the data the standardization of RESTful Web service development.
processing and call the relationship between the separation of As JSR 311 shows, that situation is quickly improving. Red
operating characteristics, by providing resources to the Hat’s open source project-
multiple statements made between the client and server. The RESTEasy(http://www.jboss.org/resteasy) is a full
HTTP data can be applied to resources interaction. implementation of the JAX-RS specification.
The final key principle illustrates that, in order to RESTEasy[2] is not only a RESTful framework, but is
improve system scalability, RESTful Web services should be also JBoss's umbrella project that provides other frameworks
put into the resources required state, or saved on the client. to build RESTful web services. As part of the REST
This makes the change of Web server is not visible for the facilities, RESTEasy fully implements the JAX-RS
client. specification. The RESTEasy framework not only works
The followings are several features for RESTful Web within any Java Servlet container, but also offers extra
services: features that are not part of the JAX-RS requirements.
REST Web services, loosely coupled Web inherited JSR311 is a Java Community Process (JCP) specification
characteristics, by separating the user interface and data that provides a Java API for RESTful Web Services over the
storage of these two concerns, making the enjoyment of the HTTP protocol. RESTEasy is a portable implementation of
same data in different user terminals as possible. REST Web the JAX-RS specification that can run in any Servlet
services is still using a standardized interoperable and container, and integrates tightly with the JBoss Application
compatible with the traditional form of Web services Server to provide improved user experience in the JBoss
resources. Therefore, in the Web architecture of resources to Application Server environment. Where JAX-RS is a server-
determine, interaction with the resources and resources, that side only specification, RESTEasy brings JAX-RS functions
these three important concepts in REST Web services to the client side through the RESTEasy JAX-RS Client

Authorized licensed use limited to: Georgia Gwinnett College. Downloaded on November 15,2020 at 20:55:40 UTC from IEEE Xplore. Restrictions apply.
Framework, allowing you to map outgoing HTTP requests to C. Struts 2
remote servers with JAX-RS and interface proxies. The struts 2(http://struts.apache.org/2.x) framework is a
RESTEasy includes the JAX-RS implementation and a web development framework that is modelled after the
client framework to simplify the process of writing HTTP Model-View-Controller (MVC) architectural pattern[2]. This
clients, giving you the opportunity to define more than server framework is built on top of the Java Servlet specification
bindings. It is portable to any Tomcat or Application Server and works with any Java web server such as Tomcat or
that runs on Java Development Kit 5.0 or higher. The JBoss. Struts 2 is a full-featured web application framework
RESTEasy server implementation can be used with for the Java EE platform. Providing automatic form
Embedded JBoss for JUnit testing. RESTEasy integrates validation, Java objects domain population, and
easily with Enterprise JavaBeans (EJB) and the Spring internationalization of view renderings, it can make the web
Framework. application development easier.
B. Restlet Struts 2[5] is a second-generation web application
framework that implements the Model-View-Controller
Restlet is an open source Java web framework. It (MVC) design pattern. It is built from the ground up on best
provides[6] comprehensive capabilities to leverage REST, practices and proven, community-accepted design patterns.
the native architecture style of the Web, in your programs. One of the primary goals of the first Struts was incorporating
As an object-oriented framework, it provides an extensive set the MVC pattern from the desktop application world into a
of classes and routines that you can call or extend, saving web application framework.The resulting pattern is
you from writing a great deal of code you would otherwise occasionally called the Model 2 pattern. Struts 1 can claim
need to write, allowing you to focus instead on your domain responsibility for many of the better-designed web
requirements. It can open the doors of the Web in all its applications of the last 10 years. At some point, the Struts
forms, from the classic Web to the semantic Web, from web
community became aware of the limitations in the first
services to rich web clients and web sites, from the mobile framework. With such an active community, identifying the
Web to cloud computing. weak and inflexible points in the framework wasn’t hard to
The Restlet[3] project (http://www.restlet.org) provides a accomplish. Struts 2 takes advantage of the many lessons
lightweight but comprehensive framework for mapping learned to present a cleaner implementation of MVC. At the
REST concepts to Java classes. It can be used to implement same time, it introduces several new architectural features
any kind of RESTful system, not just RESTful web services, that make the framework cleaner and more flexible. These
and it’s proven a reliable piece of software since its inception new features include interceptors for layering cross-cutting
in 2005. The Restlet project was influenced by the other concerns away from action logic; annotation-based
major technologies for developing Web applications: the configuration to reduce or eliminate XML configuration; a
Servlet API, JSP(Java Server Pages), HttpURLConnection, powerful expression language, Object-Graph Navigation
and Struts. Language (OGNL), that transverses the entire framework;
The primary goal[3] of the project is to provide the same and a mini-MVC-based tag API that supports modifiable and
level of functionality while sticking closer to the goals of reusable UI components. At this point, it’s impossible to do
REST as expounded in the Fielding thesis. Another key goal more than name drop.
is to present a unified view of the Web, suitable for use in The core of a Struts 2 application is the action class. In
both client and server-side applications. The Restlet provides Struts 2 action classes are nothing more than Plain Old Java
REST support using its standalone application architecture Objects (POJOs) that are bound to the framework through
and a web container module that plugs into any Java web XML configuration and interface implementation. Any
container as a servlet extension. model object can become an action class, thus integrating
The Restlet Framework supports all those forms of Web, model and view logic easily using action classes.
in a simple and unified way. The Restlet Framework can The framework is extendable through plugins that are
expose and consume web resources.Restlet supports on the added to any web application using JAR libraries. The REST
client-side and the server-side, all the features of HTTP like plugin is one of these libraries and is now bundled with the
conditional methods, content negotiation, content ranges, and standard Struts 2 package.Struts 2 plugins are added to any
so on. web application using JAR libraries, so the framework is
The thought of Restlet is that the distinction between extendable.
HTTP client and HTTP server is architecturally unimportant.
A single piece of software should be able to act as web client, D. Grails
then as web server, without using two completely different Grails combined the open source technology in Java such
APIs. as Spring, Hibernate and SiteMesh. The Grails application
As with any web service, the web clients and servers can run in any J2EE server. Grails based on Groove dynamic
exchange representations through predefined URIs. In a language supported Web service development of REST and
Restlet solution, the web server directs requests to a Restlet SOAP. It adopted the exemplification coding by convention
layer (a Servlet). In the layer, a Restlet application delegates to reduce the requirement of configuration files and other
HTTP requests to these specific Restlet resources. template code. By doing so, REST Web service development
will become extraordinary briefness.

Authorized licensed use limited to: Georgia Gwinnett College. Downloaded on November 15,2020 at 20:55:40 UTC from IEEE Xplore. Restrictions apply.
E. Axis2 H. REST-art
Axis is the traditional Java Web service Framework, REST-art is an open-source (GPL) library helping
while Axis2 is the next edition of the Axis. Axis2 supported develop RESTful Web Services. It is designed to be simple
both SOAP and REST, adopted the combination of REST and tiny. It may replace huge SOAP frameworks in your
and Web service in WSDL2.0. By configuring Axis2, it developments. REST-art uses URIs, XML and REST/ HTTP
could be used as REST container to send and receive verbs (GET, POST, PUT, DELETE).
RESTful Web service request and response. This improved
the agility, security and credibility of Axis2. III. CONCLUSION
F. Certia4 This paper focused on how to use RESTful Web service
frameworks in Java to develop RESTful Web service,
Certia4 is a RESTful framework based on Servlet. It introduced the goals and design principles of REST, the idea
supported Web MVC mode, provided a set of JSP tab of REST and RESTful Web service design principles,
library. It can integrate SiteMesh and Spring framework. RESTful style Web service, the RESTful Web service
Certia4 may make use of the server side HTTP Session for frameworks in Java. With the market-wide acceptance of
the traditional Web applications. For the Web service REST, the RESTful Web service frameworks in Java have
applications, it would not use HTTP Session. become more acceptable. As for the retractility and concision
G. sqlREST of the REST, RESTful Web service will become more and
more important in Java Enterprise Applications development.
sqlREST is a Java EE and Java Web Application which
can be configured to use any JDBC database. Included in REFERENCES
sqlREST is a hsql database but it can be used with other
databases like MySQL, MS SQL Server or Oracle as well.
[1] R. T. Fielding, “Architectural Styles and the Design of Network-
sqlREST exposes relational databases as REST style Web based Software Architectures,” California, Irvine:University of
Service. Using HTTP and XML data can be queried, California, 2000
removed and altered. A Web Browser like Mozilla or MS [2] J. Sandoval, Restful Java Web Services . Packt Publishing, 2009.
Internet Explorer can be used to query. sqlREST was initially [3] L. Richardson and S. Ruby, RESTful Web Services .O’Reilly Media,
a project just for learning how to implement a Web Service 2007.
the RESTian way. [4] S.Vinoski, RESTful Web Services Development Checklist.
[5] D.Brown,C.M.Davis and S.Stanlick,Struts 2 in Action. Manning,2008
[6] D.Brown, C.M.Davis and S.Stanlick, Restlet in Action. Manning,
2011.

Authorized licensed use limited to: Georgia Gwinnett College. Downloaded on November 15,2020 at 20:55:40 UTC from IEEE Xplore. Restrictions apply.

You might also like