Java EE 8 and Angular

Book description

Learn how to build high-performing enterprise applications using Java EE powered by Angular at the frontend

About This Book

  • Leverage Java EE 8 features to build robust back end for your enterprise applications
  • Use Angular to build a single page frontend and combine it with the Java EE backend
  • Practical guide filled with ample real-world examples

Who This Book Is For

This book is for Java EE developers who would like to build modern enterprise web applications using Angular. No prior knowledge of Angular is expected.

What You Will Learn

  • Write CDI-based code in Java EE 8 applications
  • Build an understanding of Microservices and what they mean in Java EE context
  • Use Docker to build and run a microservice application
  • Use configuration options to work effectively with JSON documents
  • Understand asynchronous task handling and writing REST API clients
  • Explore the fundamentals of TypeScript, which sets the foundation for working on Angular projects
  • Use Angular CLI to add and manage new features
  • Use JSON Web tokens to secure Angular applications against malicious attacks

In Detail

The demand for modern and high performing web enterprise applications is growing rapidly. No more is a basic HTML front-end 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 back ends while applying Angular on the front end. Your journey to building excellent 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 microservice using RESTful APIs running in docker containers. Taking advantage of Payara Micro capabilities, you will build an Issue Management System, which will have various features exposed as services using 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 i.e. 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 hands on guide to building Modern Web Applications.

Style and approach

This is a step-by-step tutorial that explains to building modern web enterprise applications.

Table of contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  2. What's in Java EE 8?
    1. Improvements in EE 8
    2. Overview of Java SE 8
      1. Lambdas, streams, and default methods
    3. CDI 2.0
    4. JSON Processing 1.1
      1. Working with JSON documents
      2. JSON Processing API
    5. JSON Binding 1.0
    6. JAXRS 2.1
    7. Servlet 4.0
      1. Server Push
    8. JSF 2.3
    9. Bean Validation 2.0
    10. Java EE Security API 1.0
    11. Summary
  3. The CDI Advantage Combined with JPA
    1. Introduction to context and dependency injection
    2. CDI programming model
      1. CDI for Java SE 8
      2. RequestContext Activation
      3. Enhancing events
        1. Asynchronous events
        2. Ordered events
      4. Annotation literals
    3. Java Persistence API (JPA)
      1. Entities
      2. Performing CRUD operations with entities
      3. Entity listeners
      4. Validations the entity
    4. Summary
  4. Understanding Microservices
    1. Traditional monoliths
      1. Need for delivering new features quicker
      2. Team size and dependency
    2. Multiple small units of work
      1. Smaller code base
      2. Coding practices
        1. Follow domain-driven design
        2. Document it
        3. Build for failure
        4. Infrastructure tooling as part of code
    3. Single responsibility
    4. The need for REST
    5. Scale only what needs to scale
    6. The bad parts, yes, there are a few
    7. Summary
  5. Building and Deploying Microservices
    1. Fat JAR
      1. Fat JAR approach
    2. Skinny WAR
    3. Examples using Payara Micro
      1. Building our services
      2. Running our services
    4. MicroProfile
      1. Java EE already has support
      2. WildFly Swarm
      3. Spring Cloud
    5. Docker containers
      1. Working with distributed teams
      2. Building custom images
      3. Running multiple containers
      4. Fat JAR or Skinny WAR with Docker
        1. The choice
    6. Summary
  6. Java EE Becomes JSON Friendly
    1. REST prefers JSON
    2. JSON, a first-class citizen
      1. JSON in databases
    3. No more third-party libraries
    4. JSON processing
      1. JSON-P 1.1
      2. JSON Pointer and JSON Patch
      3. JSON merge patch
      4. JSON Collectors
    5. JSON binding
      1. Similar to JAXB with default mappings
      2. Standardizes current solutions (Jackson, Gson, and so on)
      3. Mapping between classes and JSON
      4. Customisation APIs
    6. Few tips in practice
    7. Summary
  7. Power Your APIs with JAXRS and CDI
    1. Resources
      1. URI templates
      2. Matching requests to resource methods
    2. Providers
      1. Entity providers
      2. Exception mapping
    3. Client API
      1. Targets
      2. Reactive clients
    4. Filters and interceptors
    5. Validation
    6. Asynchronous processing
    7. Server-Sent Events
    8. WebSockets
    9. Context
    10. Swagger
      1. API
      2. Maven plugin
    11. Summary
  8. Putting It All Together with Payara
    1. Building an Issue Management System (IMS) backend
    2. Using Java EE 8 technologies
      1. Defining the data model
      2. Building microservices using REST
      3. Swagger documentation
      4. Using JPA for persistence
      5. Deploying on Payara
      6. Uber JAR and Skinny WARs
    3. Running multiple microservices in Docker
    4. Learning to use the new features of Payara Micro
    5. Extras
      1. CDI event bus
      2. Tips and tricks
    6. Summary
  9. Basic TypeScript
    1. Getting started with TypeScript
      1. Why use it?
      2. Features
      3. Visual Studio Code
        1. IntelliSense
        2. Debugging
        3. SCM support
        4. Terminal
      4. Hello World example
    2. Using variables, types, and functions
      1. Type inference
      2. Using const
      3. Using let
      4. Using functions
      5. Arrow functions
    3. Working with classes and interfaces
      1. Interface
      2. Classes
      3. Inheritance
    4. Working with arrays
    5. Summary
  10. Angular in a Nutshell
    1. Understanding Angular
      1. Anatomy of a component
        1. Components live and die
        2. Component in code
      2. Pipes
      3. Modules
      4. Bootstrapping process
    2. Angular 2 and beyond
      1. Angular CLI
        1. Project structure
        2. Rapid development
      2. Managing packages
        1. Dependencies
      3. Bootstrap dependency
    3. A better Hello World
      1. Modules
      2. Components
      3. Handling events
    4. Data binding
      1. One way
      2. Two way
    5. Services
    6. Routes
      1. routerLinkActive
    7. Building a project
      1. Setup and run sample
      2. Introduction to PrimeNG
    8. Summary
  11. Angular Forms
    1. Two approaches to forms
      1. Template-driven forms
      2. Reactive forms
    2. Understanding forms with an example
    3. Building custom forms with validations
    4. Checking the state of a form
    5. Forms with NgModel
    6. Reactive forms
      1. Setting up forms with FormBuilder
      2. Adding validations
      3. Creating a custom validator
      4. Grouping controls
      5. Setting and patching values
    7. Handling forms in Angular
    8. Gaining more control with reactive forms
    9. Summary
  12. Building a Real-World Application
    1. Building an Issue Management System frontend
    2. Setup
      1. Structuring the project
      2. Working independently of the backend
      3. Data models
    3. Securing the application
    4. Issue lists and details
      1. Rendering data with templates
      2. Injectable service
    5. Issue creation and updates
      1. Reactive forms
      2. Validation
    6. Issue comments
    7. Chatting on an issue
    8. Production-ready build
    9. Summary
  13. Connecting Angular to Java EE Microservices
    1. Integration with microservices
      1. Docker – focusing made easy
      2. Verifying the running services
    2. Cross Origin Resource Sharing (CORS)
    3. JSON communication
    4. Observables in Angular
      1. Dynamic updates using Observables
    5. Going to production
      1. Deploying on the cloud using AWS
        1. Launching the Amazon EC2 instance
        2. Installing Docker on Amazon EC2
      2. Docker release
    6. Summary
  14. Testing Java EE Services
    1. Testing strategies for microservices
      1. Understanding the testing pyramid
        1. Unit testing
        2. Integration testing
        3. End-End testing
      2. Microservice testing challenges
      3. Contract testing
      4. Balancing act of tests
    2. Testing in practice
      1. Integration testing with Arquillian
      2. Acceptance testing with Cucumber
        1. Feature file
        2. Step definitions
    3. Summary
  15. Securing the Application
    1. Securing the application
      1. JSON Web Tokens
        1. Token structure
        2. Generating the token
          1. IMS Security
        3. Verifying the token
        4. Consuming token in Angular
      2. Route Guards
      3. Exchanging tokens
        1. Injecting an authorization header
    2. Neither in Java EE nor MicroProfile
    3. General tips
    4. Summary
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Java EE 8 and Angular
  • Author(s): Prashant Padmanabhan
  • Release date: January 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788291200