O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java EE 8 Application Development

Book Description

Develop Enterprise Java applications compliant with the latest version of the Java EE specification

About This Book

  • This book covers all of the major Java EE 8 APIs and includes new additions such as enhanced Security, JSON-B Processing, and more
  • Learn additional Java EE APIs, such as the Java API for Websocket and the Java Message Service (JMS)
  • Develop applications by taking advantage of the latest versions of CDI, Security, Servlets, and JSF and other Java EE specifications

Who This Book Is For

If you are a Java developer who wants to become proficient with Java EE 8, this book is ideal for you. You are expected to have some experience with Java and to have developed and deployed applications in the past, but you don't need any previous knowledge of Java EE.

What You Will Learn

  • Develop and deploy Java EE applications
  • Embrace the latest additions to the Contexts and Dependency Injection (CDI) specification to develop Java EE applications
  • Develop web-based applications by utilizing the latest version of JavaServer Faces, JSF 2.3.
  • Understand the steps needed to process JSON data with JSON-P and the new JSON-B Java EE API
  • Implement RESTful web services using the new JAX-RS 2.1 API, which also includes support for Server-Sent Events (SSE) and the new reactive client API

In Detail

Java EE is an Enterprise Java standard. Applications written to comply with the Java EE specification do not tie developers to a specific vendor; instead they can be deployed to any Java EE compliant application server. With this book, you’ll get all the tools and techniques you need to build robust and scalable applications in Java EE 8. This book covers all the major Java EE 8 APIs including JSF 2.3, Enterprise JavaBeans (EJB) 3.2, Contexts and Dependency Injection (CDI) 2.0, the Java API for WebSockets, JAX-RS 2.1, Servlet 4.0, and more.

The book begins by introducing you to Java EE 8 application development and goes on to cover all the major Java EE 8 APIs. It goes beyond the basics to develop Java EE applications that can be deployed to any Java EE 8 compliant application server.

It also introduces advanced topics such as JSON-P and JSON-B, the Java APIs for JSON processing, and the Java API for JSON binding. These topics dive deep, explaining how the two APIs (the Model API and the Streaming API) are used to process JSON data.

Moving on, we cover additional Java EE APIs, such as the Java API for Websocket and the Java Message Service (JMS), which allows loosely coupled, asynchronous communication. Further on, you’ll discover ways to secure Java EE applications by taking advantage of the new Java EE Security API.

Finally, you’ll learn more about the RESTful web service development using the latest JAX-RS 2.1 specification. You’ll also get to know techniques to develop cloud-ready microservices in Java EE.

Style and approach

The book takes a pragmatic approach, showing you various techniques to utilize new features of Java EE 8 specification. It is packed with clear, step-by-step instructions, practical examples, and straightforward explanations.

Downloading the example code for this book. 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 code file.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Errata
      3. Piracy
      4. Questions
  2. Introduction to Java EE
    1. Introduction to Java EE
      1. Java community process
      2. Java EE APIs
    2. One standard, multiple implementations
    3. Java EE, J2EE, and the Spring framework
    4. Summary
  3. JavaServer Faces
    1. Introducing JSF
      1. Facelets
      2. Optional faces-config.xml
      3. Standard resource locations
    2. Developing our first JSF application
      1. Facelets
      2. Project stages
      3. Validation
      4. Grouping components
      5. Form submission
      6. Named beans
        1. Named bean scopes
      7. Navigation
    3. Custom data validation
      1. Creating custom validators
      2. Validator methods
    4. Customizing JSF's default messages
      1. Customizing message styles
      2. Customizing message text
    5. Ajax-enabling JSF applications
    6. JSF HTML5 support
      1. HTML5-friendly markup
      2. Pass-through attributes
    7. JSF 2.2 Faces flows
    8. Injecting JSF artifacts
    9. JSF WebSocket support
    10. Additional JSF component libraries
    11. Summary
  4. Object Relational Mapping with the Java Persistence API
    1. The Customer database
    2. The Java Persistence API
      1. Entity relationships
        1. One-to-one relationships
        2. One-to-many relationships
        3. Many-to-many relationships
      2. Composite primary keys
      3. Java Persistence Query Language
      4. The Criteria API
        1. Updating data with the Criteria API
        2. Deleting data with the Criteria API
      5. Bean Validation support
    3. Final notes
    4. Summary
  5. Enterprise JavaBeans
    1. Session beans
      1. A simple session bean
      2. Implementing EJB client code
      3. A more realistic example
      4. Invoking session beans from web applications
      5. Singleton session beans
    2. Asynchronous method calls
    3. Message-driven beans
    4. Transactions in enterprise JavaBeans
      1. Container-managed transactions
      2. Bean-managed transactions
    5. Enterprise JavaBean life cycles
      1. Stateful session bean life cycle
      2. Stateless and singleton session bean life cycles
      3. Message-driven bean life cycle
    6. EJB timer service
      1. Calendar-based EJB timer expressions
    7. EJB security
      1. Client authentication
    8. Summary
  6. Contexts and Dependency Injection
    1. Named beans
    2. Dependency injection
    3. Qualifiers
    4. Named bean scopes
    5. CDI events
      1. Firing CDI events
      2. Handling CDI events
      3. Asynchronous events
      4. Event ordering
    6. Summary
  7. JSON Processing with JSON-P and JSON-B
    1. The JSON-P Model API
      1. Generating JSON data with the Model API
      2. Parsing JSON data with the Model API
    2. The JSON-P Streaming API
      1. Generating JSON data with the Streaming API
      2. Parsing JSON data with the Streaming API
    3. JSON pointer
    4. JSON Patch
    5. Populating Java objects from JSON with JSON-B
    6. Generating JSON strings from Java objects with JSON-B
    7. Summary
  8. WebSocket
    1. Developing a WebSocket server endpoint
      1. Developing an annotated WebSocket server endpoint
    2. Developing WebSocket clients
      1. Developing JavaScript client-side WebSocket code
      2. Developing WebSocket clients in Java
    3. Additional information about the Java API for WebSocket
    4. Summary
  9. Java Messaging Service
    1. Message queues
      1. Sending messages to a message queue
      2. Retrieving messages from a message queue
      3. Browsing message queues
    2. Message topics
      1. Sending messages to a message topic
      2. Receiving messages from a message topic
      3. Creating durable subscribers
    3. Summary
  10. Securing Java EE Applications
    1. Identity stores
      1. Setting up an identity store stored in a relational database
      2. Setting up an identity store stored in an LDAP database
      3. Custom identity stores
    2. Authentication mechanisms
      1. Basic authentication mechanism
      2. Form authentication mechanism
      3. Custom form authentication mechanism
    3. Summary
  11. RESTful Web Services with JAX-RS
    1. An introduction to RESTful web services and JAX-RS
    2. Developing a simple RESTful web service
      1. Configuring the REST resources path for our application
        1. Configuring via the @ApplicationPath annotation
      2. Testing our web service
      3. Converting data between Java and XML with JAXB
    3. Developing a RESTful web service client
    4. Query and path parameters
      1. Query parameters
        1. Sending query parameters via the JAX-RS client API
      2. Path parameters
        1. Sending path parameters via the JAX-RS client API
    5. Server-sent events
      1. JavaScript Server-sent events client
    6. Summary
  12. Microservices Development with Java EE
    1. Introduction to microservices
      1. Advantages of a microservices architecture
      2. Disadvantages of a microservices architecture
    2. Microservices and Java EE
    3. Developing microservices using Java EE
      1. Developing microservices client code
      2. The controller service
    4. Summary
  13. Web Services with JAX-WS
    1. Developing web services with JAX-WS
      1. Developing a web service client
      2. Sending attachments to web services
    2. Exposing EJBs as web services
      1. EJB web service clients
    3. Summary
  14. Servlet Development and Deployment
    1. What is a servlet?
      1. Writing our first servlet
      2. Testing the web application
      3. Processing HTML forms
    2. Request forwarding and response redirection
      1. Request forwarding
      2. Response redirection
    3. Persisting application data across requests
    4. Passing initialization parameters to a servlet via annotations
    5. Servlet filters
    6. Servlet listeners
    7. Pluggability
    8. Configuring web applications programmatically
    9. Asynchronous processing
    10. HTTP/2 server push support
    11. Summary
  15. Configuring and Deploying to GlassFish
    1. Obtaining GlassFish
    2. Installing GlassFish
      1. GlassFish dependencies
      2. Performing the installation
    3. Starting GlassFish
      1. Deploying our first Java EE application
        1. Deploying an application through the web console
        2. Undeploying an application through the GlassFish Admin Console
        3. Deploying an application through the command line
          1. The Autodeploy directory
          2. The asadmin command-line utility
    4. GlassFish domains
      1. Creating domains
      2. Deleting domains
      3. Stopping a domain
    5. Setting up database connectivity
      1. Setting up connection pools
      2. Setting up data sources
    6. Setting JMS resources
      1. Setting up a JMS connection factory
      2. Setting up a JMS message queue
      3. Setting up a JMS message topic
      4. Configuring durable subscribers
    7. Summary