Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Representational State Transfer (REST) is a simple yet powerful software architecture style that is meant for creating scalable web services. This book, RESTful Java web services, is a practical guide for developing RESTful web services using JAX-RS and Jersey extension APIs.

The book starts off with an introduction to RESTful web services and assumes that the reader has no prior knowledge of the RESTful architectural style. Each topic is explained with real-life use cases and code samples. This approach helps the reader in easily translating the theories into solutions for many kinds of real life use cases. In a nutshell, this is a practical guide on using JAX-RS and the Jersey framework extensions to build robust RESTful web services; it is not just about the theory of REST.

What this book covers

Chapter 1, Introducing the REST Architectural Style, covers the REST software architectural style and core architectural elements that form a RESTful system.

Chapter 2, Java APIs for JSON Processing, gives an overview of the JSON message format, and the popular tools and frameworks around JSON.

Chapter 3, Introducing the JAX-RS API, introduces JAX-RS APIs. This chapter will explain how to build RESTful web services with JAX-RS APIs.

Chapter 4, Advanced Features in the JAX-RS API, takes a deeper look into the advanced JAX-RS APIs, along with many real life use cases and code samples.

Chapter 5, Introducing the Jersey Framework Extensions, discusses some of the very useful Jersey framework extension APIs that are not yet a part of the JAX-RS standard.

Chapter 6, Securing RESTful Web Services, explores how to secure RESTful web services using the HTTP basic authentication and OAuth protocols.

Chapter 7, The Description and Discovery of RESTful Web Services, describes popular solutions that are available today for describing, producing, consuming, and visualizing RESTful web services.

Chapter 8, RESTful API Design Guidelines, discusses the best practices and design guidelines that developers will find useful while building RESTful web services. Learning the best practices will help you avoid common pitfalls that others might have faced before.

Appendix, Useful Features and Techniques, covers various useful features and techniques that we had deferred while discussing specific topics in this book. This section explores tools and techniques for building, testing, extending, and packaging JAX-RS web applications.

What you need for this book

The examples discussed in this book are built using the following software and tools:

  • The Java SE Development Kit 8, or newer versions

  • NetBeans IDE 8.0.2 (with the Java EE bundle), or newer versions

  • The Glassfish Server 4.1, or newer versions

  • Maven 3.2.3, or newer versions

  • The Oracle Database Express Edition 11g Release 2, or newer versions

  • The HR sample schema that comes with the Oracle database

  • The Oracle database JDBC driver (ojdbc7.jar or newer versions)

Detailed instructions for setting up all the required tools to run the examples used in this book are discussed in the Appendix, Useful Features and Techniques section of this book.

Who this book is for

This book is for Java developers who want to design and develop scalable and robust RESTful web services with the JAX-RS and Jersey APIs. Contents are structured by keeping an eye on real life use cases from the RESTful API world and their solutions. Although the JAX-RS API solves many of the common RESTful web service use cases, some solutions are yet to be standardized as JAX-RS APIs. Keeping this in mind, a chapter is dedicated in this book for discussing Jersey extension APIs, which takes you beyond JAX-RS. This book also discusses the best practices and design guidelines for your REST APIs. In a nutshell, you will find this book useful while dealing with many real life use cases, such as dynamic resource configuration, message broadcasting with the server-sent event, HATEOAS, and so on.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Assume that we want to delete the Sales department from the data storage."

A block of code is set as follows:

{"departmentId":10,
"departmentName":"IT",
"manager":"John Chen,
"links": [ {
    "rel": "employees",
    "href": "http://packtpub.com/resources/departments/IT/
    employees"
} ]"}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

@Path("departments")
@Produces(MediaType.APPLICATION_JSON)
public class DepartmentResource{
//Class implementation goes here...
}

Any command-line input or output is written as follows:

mvn install –DskipTests

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Select Local Domain and click on Next to continue the wizard."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Instructions for running examples are available in the README.md file present in the root folder of each project.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.