Book Image

Java EE 8 and Angular

By : Prashant Padmanabhan
Book Image

Java EE 8 and Angular

By: Prashant Padmanabhan

Overview of this book

The demand for modern and high performing web enterprise applications is growing rapidly. No more is a basic HTML frontend enough to meet customer demands. This book will be your one-stop guide to build outstanding enterprise web applications with Java EE and Angular. It will teach you how to harness the power of Java EE to build sturdy backends while applying Angular on the frontend. Your journey to building modern web enterprise applications starts here! The book starts with a brief introduction to the fundamentals of Java EE and all the new APIs offered in the latest release. Armed with the knowledge of Java EE 8, you will go over what it's like to build an end-to-end application, configure database connection for JPA, and build scalable microservices using RESTful APIs running in Docker containers. Taking advantage of the Payara Micro capabilities, you will build an Issue Management System, which will have various features exposed as services using the Java EE backend. With a detailed coverage of Angular fundamentals, the book will expand the Issue Management System by building a modern single page application frontend. Moving forward, you will learn to fit both the pieces together, that is, the frontend Angular application with the backend Java EE microservices. As each unit in a microservice promotes high cohesion, you will learn different ways in which independent units can be tested efficiently. Finishing off with concepts on securing your enterprise applications, this book is a handson guide for building modern web applications.
Table of Contents (16 chapters)

WebSockets

As mentioned in Chapter 1, What's in Java EE 8?, while SSE is an HTTP-based standard for one-sided communication, WebSockets is a standard allowing for bidirectional communication between both client and server. WebSockets can be used in scenarios which require two-way communication, such as chat-based applications. WebSockets are published as endpoints using either a programmatic approach or an annotated one.

An endpoint would either extend the javax.websocket.Endpoint class for programmatic style or use the easier approach of using @ServerEndpoint annotation. An endpoint instance is created per connection:

@ServerEndpoint("/chat")
public class ChatEndpoint {
@OnMessage
public void onMessage(final Session session, String msg) {
try {
session.getBasicRemote().sendText(msg);
} catch (IOException e) { ... }
}
}

While this is a simple...