Building RESTful Web Services with Java EE 8 - Mario-Leander Reimer - E-Book

Building RESTful Web Services with Java EE 8 E-Book

Mario-Leander Reimer

0,0
28,14 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Learn the fundamentals of Java EE 8 APIs to build effective web services




Key Features



  • Design modern and stylish web services with Java EE APIs

  • Secure your web services with JSON Web Tokens

  • Explore the advanced concepts of RESTful web services and the JAX-RS API



Book Description



Java Enterprise Edition is one of the leading application programming platforms for enterprise Java development. With Java EE 8 finally released and the first application servers now available, it is time to take a closer look at how to develop modern and lightweight web services with the latest API additions and improvements.






Building RESTful Web Services with Java EE 8 is a comprehensive guide that will show you how to develop state-of-the-art RESTful web services with the latest Java EE 8 APIs. You will begin with an overview of Java EE 8 and the latest API additions and improvements. You will then delve into the details of implementing synchronous RESTful web services and clients with JAX-RS. Next up, you will learn about the specifics of data binding and content marshalling using the JSON-B 1.0 and JSON-P 1.1 APIs.






This book also guides you in leveraging the power of asynchronous APIs on the server and client side, and you will learn to use server-sent events (SSEs) for push communication. The final section covers advanced web service topics such as validation, JWT security, and diagnosability.






By the end of this book, you will have implemented several working web services and have a thorough understanding of the Java EE 8 APIs required for lightweight web service development.




What you will learn



  • Dive into the latest Java EE 8 APIs relevant for developing web services

  • Use the new JSON-B APIs for easy data binding

  • Understand how JSON-P API can be used for flexible processing

  • Implement synchronous and asynchronous JAX-RS clients

  • Use server-sent events to implement server-side code

  • Secure Java EE 8 web services with JSON Web Tokens



Who this book is for



If you're a Java developer who wants to learn how to implement web services using the latest Java EE 8 APIs, this book is for you. Though no prior knowledge of Java EE 8 is required, experience with a previous Java EE version will be beneficial.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 103

Veröffentlichungsjahr: 2018

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Building RESTful Web Services with Java EE 8

 

 

 

 

Create modern RESTful web services with the Java EE 8 API

 

 

 

 

 

 

 

 

Mario-Leander Reimer

 

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Building RESTful Web Services with Java EE 8

Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Commissioning Editor: Richa TripathiAcquisition Editor: Denim PintoContent Development Editor: Priyanka SawantTechnical Editor: Romy DiasCopy Editor: Safis EditingProject Coordinator: Vaidehi SawantProofreader: Safis EditingIndexer: Mariammal ChettiyarGraphics:Jason MonteiroProduction Coordinator: Shantanu Zagade

First published: July 2018

Production reference: 1300718

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-78953-288-3

www.packtpub.com

 

mapt.io 

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

PacktPub.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

Contributors

About the author

Mario-Leander Reimer is a chief technologist for QAware GmbH. He is a senior Java developer with several years' experience in designing complex and large-scale system architectures. He continuously looks for innovations and ways to combine and apply state-of-the-art technology and open source software components to real-world customer projects. He studied computer science at Rosenheim and Staffordshire University and he teaches cloud computing as a part-time lecturer.

About the reviewer

Luca Stancapiano has been working in the IT industry since 2000. He specializes in Java EE and JBoss, and has collaborated with Apache, Alfresco, Atlassian, and eXo on several open source products. He lives in Italy and collaborates with leading consulting companies on the design and implementation of applications for both government and private companies. He brings projects such as WildFly, Alfresco ECM, Activiti, JGroups, Arquillian, eXo Portal, Solr, Infinispan, JBoss Portal, GateIn, Jira, and Confluence, and manages Vige, an open source community specializing in open government and smart cities. He is one of the authors of GateIn Cookbook, by Packt Publishing.

 

 

 

 

 

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Building RESTful Web Services with Java EE 8

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

Getting Started with Java EE 8

Technical requirements

Why is Java EE a good platform for microservices?

Java EE version history

Overview of Java EE 8

What's new in Java EE 8?

Getting started with Java EE 8 microservices

Containerizing Java EE 8 microservices

Summary

Building Synchronous Web Services and Clients

Implementing basic REST APIs with JAX-RS

Using sub-resources

Error handling in JAX-RS

Implementing web service clients with Java EE 8

Testing Java EE 8 web services

Jersey Test Framework

Test Containers

Summary

Content Marshalling with JSON-B and JSON-P

Introduction to content types and content negotiation

Easy data binding using JSON-B

Flexible JSON processing with JSON-P

Implementing hypermedia-driven REST APIs

Summary

Building Asynchronous Web Services

Benefits and usage scenarios of asynchronous processing

Basic idea

Goal

Implementing asynchronous web services

Using ManagedExecutorService and server-side callbacks

CompletionCallback

ConnectionCallback

Registering callbacks

CompletableFuture

Implementing asynchronous web service clients

Summary

Using Server-Sent Events (SSEs)

What are SSEs?

Implementing SSE on the server-side

Implementing SSE REST clients

Implementing and sending SSE broadcasts

Summary

Advanced REST APIs

Applying Design by Contract – adding validation

Using JSON Web Tokens for authentication

Diagnosability – logging, metrics, and tracing

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

Java Enterprise Edition is one of the leading application programming platforms for enterprise Java development. With Java EE 8 finally released and the first application servers being available, it is time to have a closer look at how to develop modern and lightweight web services with the latest API additions and improvements.

This book is a comprehensive guide that shows you how to develop state-of-the-art RESTful web services with the latest Java EE 8 APIs. We start by giving an overview of Java EE 8 and the latest API additions and improvements. Then, you will implement, build, and package your first working web service as a prototype for the remainder of the book. It delves into the details of implementing synchronous RESTful web services and clients with JAX-RS. Next up, you will learn about the specifics of data binding and content marshaling using the JSON-B 1.0 and JSON-P 1.1 APIs. You will then learn how to leverage the power of asynchronous APIs on both the server and client sides, and you will learn how to use Server-Sent Events (SSEs) for PUSH communications. The final chapter covers some advanced web service topics, such as validation, JWT security, and diagnosing web services.

By the end of this book, you will have a thorough understanding of the Java EE 8 APIs required for lightweight web service development. Also, you will have implemented several working web services to provide you with the required practical experience.

Who this book is for

This book is intended for Java developers who want to learn how to implement web services using the latest Java EE 8 APIs. No prior knowledge of Java EE 8 is required; experience with a previous Java EE version will, however, be beneficial.

What this book covers

Chapter 1, Getting Started with Java EE 8, gets you started with Java EE 8—we'll implement our first simple web service using Java EE 8 and the relevant APIs.

Chapter 2, Building Synchronous Web Services and Clients, dives deep into synchronous services—we'll be implementing synchronous web services, and also web service clients, using the relevant APIs.

Chapter 3, Content Marshaling with JSON-B and JSON-P, covers content marshaling—we'll be using JSON-B and JSON-P for marshaling our content.

Chapter 4, Building Asynchronous Web Services, explores asynchronous services—we'll be implementing asynchronous web services, and also a web service client, using the new reactive client APIs.

Chapter 5, Using Server-Sent Events (SSE), covers SSEs—we'll be implementing PUSH notifications using those services and events.

Chapter 6, Advanced REST APIs, gives you an overview of some more advanced REST APIs—we'll be implementing Design by Contract, we'll talk about JSON Web Token security, and we'll also add the ability to diagnose our web services.

To get the most out of this book

You need the following to get the most out of this book:

You need to have basic programming skills and some Java knowledge is required

You need a computer with a modern operating system, such as Windows 10, macOS, or Linux

You need a working Java 8 language installation; we'll be using Maven 3.5.x as our build tool

We'll be using Payara Server 5.x as our Java 8 application server

You need Docker for Windows, macOS, or Linux

You need an IDE with Java EE 8 support, such as IntelliJ IDEA 2017.3, and you will need a REST client, such as Postman or SoapUI

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

Log in or register at

www.packtpub.com

.

Select the

SUPPORT

tab.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR/7-Zip for Windows

Zipeg/iZip/UnRarX for Mac

7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Building-RESTful-Web-Services-with-Java-EE-8. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "In the preceding Dockerfile, we mentioned that we're using payara/server-full."

A block of code is set as follows:

<dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency>

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

@PUT @Path(

"/{isbn}"

) public Response update(@PathParam("isbn") String isbn, Book book) { if (!Objects.equals(isbn, book.getIsbn())) {

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

>docker build -t hello-javaee8:1.0 .

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Let's check our browser, you should see the "Hello World." message."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata