Java EE 7 with GlassFish 4 Application Server

Book Description

For Java developers who want to learn Java EE, you'll find this practical guide makes it all quite simple. Starting with the installation of Glassfish 4 application server, you'll then progress to developing powerful applications for it.

In Detail

GlassFish is a free, open source application server which supports all the major Java features such as Enterprise JavaBeans, JPA, JavaServer Faces, JMS, RMI, JavaServer Pages, and servlets. It is the first Java EE 7 compliant application server. All major Java EE technologies and API's are covered in this version of Java. GlassFish server allows the user to work with the extensile, adaptable, and lightweight Java EE 7 platform.

This book explores the installation and configuration of GlassFish, and then moves on to Java EE 7 application development, covering all major Java EE 7 APIs. It focuses on going beyond the basics to develop Java applications deployed to the GlassFish 4 application server. The book covers all major Java EE 7 APIs including JSF 2.2, EJB 3.2, CDI 1.1, the Java API for WebSocket, JAX-WS, JAX-RS and more.

The book also introduces JSON-P, the Java API for JSON (Javascript Object Notation) Processing. This advanced topic deals with how the two APIs are used to process JSON function, namely the Model API and the Streaming API. Apart from revisiting Java Server Faces (JSF), it explains why Facelets, the new features introduced in modern versions of JSF, are the preferred view technology over Java Server Pages (JSP)

The later chapters explore competing implementations of the WebSocket standard in Java, describing the updates in JMS; which aims to provide a simpler API and reduction in boilerplate code among a host of other features. Readers will also learn how to secure Java EE applications by taking advantage of GlassFish's built-in security features. Finally, we learn more about the RESTful web service development using the JAX-RS specification.

What You Will Learn

  • Develop web-based applications using JavaServer Faces (JSF) 2.2
  • Interact with databases via the Java Persistence API (JPA) 2.1
  • Create SOAP and RESTful web services via JAX_WS and JAX-RS APIs
  • Develop Enterprise JavaBeans (EJBs), including session and message-driven beans
  • Integrate enterprise application layers via Contexts and Dependency Injection (CDI) API
  • Generate and parse JavaScript Object Notation (JSON) data via the JSON-P API
  • Make WebSocket applications via the standard Java EE 7 WebSocket API

Table of Contents

  1. Java EE 7 with GlassFish 4 Application Server
    1. Table of Contents
    2. Java EE 7 with GlassFish 4 Application Server
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
        3. Instant Updates on New Packt Books
    7. 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
    8. 1. Getting Started with GlassFish
      1. An Overview of Java EE and GlassFish
        1. What's new in Java EE 7?
          1. JavaServer Faces (JSF) 2.2
          2. Java Persistence API (JPA) 2.1
          3. Java API for RESTful Web Services (JAX-RS) 2.0
          4. Java Message Service (JMS) 2.0
          5. Java API for JSON Processing (JSON-P) 1.0
          6. Java API for WebSocket 1.0
        2. GlassFish advantages
      2. Obtaining GlassFish
      3. Installing GlassFish
        1. GlassFish dependencies
        2. Performing the installation
      4. 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
      5. GlassFish domains
        1. Creating Domains
        2. Deleting domains
        3. Stopping a domain
      6. Setting up Database Connectivity
        1. Setting up connection pools
        2. Setting up the data sources
      7. Summary
    9. 2. JavaServer Faces
      1. Introduction to JSF
        1. Facelets
        2. Optional faces-config.xml
          1. 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
        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 2.2 HTML5 support
        1. The HTML5-friendly markup
        2. Pass-through elements
      7. JSF 2.2 Faces Flows
      8. Additional JSF component libraries
      9. Summary
    10. 3. Object Relational Mapping with JPA
      1. The CustomerDB database
      2. Introducing 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. Introducing the Java Persistence Query Language
        4. Introducing 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
    11. 4. Enterprise JavaBeans
      1. Introduction to session beans
        1. Developing a simple session bean
        2. A more realistic example
        3. Invoking session beans from web applications
        4. Introduction to singleton session beans
        5. Asynchronous method calls
      2. Message-driven beans
      3. Transactions in Enterprise JavaBeans
        1. Container-managed transactions
        2. Bean-managed transactions
      4. Enterprise JavaBean life cycles
        1. The stateful session bean life cycle
        2. The stateless session bean life cycle
        3. Message-driven bean life cycle
      5. Introduction to the EJB Timer Service
        1. Calendar-based EJB timer expressions
      6. EJB Security
        1. Client authentication
      7. Summary
    12. 5. Contexts and Dependency Injection
      1. Named beans
      2. Dependency injection
      3. Working with CDI Qualifiers
      4. Named bean scopes
      5. Summary
    13. 6. JSON Processing with JSON-P
      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. Summary
    14. 7. WebSockets
      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
    15. 8. The Java Message Service
      1. Setting up GlassFish for JMS
        1. Setting up a JMS connection factory
        2. Setting up a JMS queue
        3. Setting up a JMS topic
      2. Working with message queues
        1. Sending messages to a message queue
        2. Retrieving messages from a message queue
        3. Asynchronously receiving messages from a message queue
        4. Browsing message queues
      3. Working with message topics
        1. Sending messages to a message topic
        2. Receiving messages from a message topic
        3. Creating durable subscribers
      4. Summary
    16. 9. Securing Java EE Applications
      1. Security realms
        1. Predefined security realms
          1. The admin-realm
          2. The file realm
            1. Basic authentication via the file realm
            2. Form-based authentication
          3. The certificate realm
            1. Creating self-signed certificates
            2. Configuring applications to use the certificate realm
        2. Defining additional realms
          1. Defining additional file realms
          2. Defining additional certificate realms
          3. Defining an LDAP realm
          4. Defining a Solaris realm
          5. Defining a JDBC realm
          6. Defining custom realms
      2. Summary
    17. 10. Web Services with JAX-WS
      1. Developing web services with the JAX-WS API
        1. Developing a web service client
        2. Sending attachments to web services
      2. Exposing EJBs as web services
        1. EJB web service clients
      3. Securing web services
      4. Securing EJB web services
      5. Summary
    18. 11. Developing RESTful Web Services with JAX-RS
      1. Introducing 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. Working with 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. Summary
    19. Index

Product Information

  • Title: Java EE 7 with GlassFish 4 Application Server
  • Author(s): David R. Heffelfinger
  • Release date: March 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781782176886