This is a review of the book Java EE 7 with GlassFish 4 Application Server
What is this book about?
The book is a fast paced tutorial for Java EE 7. It focuses on covering the foundational Java EE specifications including brand new standards in Java EE 7 as well as the exciting specifications which got revamped and improved.
- Utilizes GlassFish 4 (the reference implementation for Java EE 7) as an example to illustrate the core concepts, usage of standard APIs and to deploy and execute sample applications.
- Covers prominent Java EE 7 specifications such as JSF 2.2, JPA 2.1, EJB 3.2, CDI 1.1, JSON-P 1.0 (new in Java EE 7), WebSockets 1.0 (new in Java EE 7), JMS 2.0 (major revamp in Java EE 7), JAX-RS 2.0 (for RESTful Web Services)
- Provides lots of code driven examples to explain API usage
Who has written this book?
This book has been authored by David R. Heffelfinger. More about him here.
Is this book for you ? How can you benefit from it ?
- Java EE can often get intimidating for a beginner. This book however can be used togain a quick overview of the overall Java EE landscape, its specifications, various APIs and their usage, in a structured and organized fashion which is important while learning a new technology stack.
- If you are a relatively experienced Java EE Developer with exposure to Java EE 6 or before, you can leverage this book to empower yourself with new features in Java EE 7 and absorb the concepts with the help of extensive code samples and examples provided in the book.
- A GlassFish enthusiast can grab this book in order to understand Java EE from GlassFish 4 Application Server perspective and benefit directly from the fact that GlassFish is the RI for Java EE 7 and is bound to implement the latest and greatest features which the platform has to offer.
Please do not be mislead by the title of the book and assume that it’s tightly coupled to GlassFish 4 Application Server.
- The book merely uses GlassFish 4 as a medium to explain and apply Java EE concepts in a practical and code driven fashion
- One can carry over the concepts and execute the same examples on any Java EE 7 compliant application server.
Deep Dive into the contents of the book
The book is well organized and divided into distinct chapters. Each chapter dedicated to a specific Java EE standard e.g. EJB 3.2, JPA 2.1 etc
Let’s take a peek into the individual chapters
Chapter 1 – Getting Started With GlassFish
Given the title, it is not surprising that the book begins with an introduction to the GlassFish 4 Application Server and sets the stage for the reader.
- Introduction to Java EE with a focus on the latest offerings in Java EE 7
- GlassFish 4 installation, management and application deployment
- GlassFish 4 domains and JDBC pool setup
Chapter2 – JavaServer Faces
This chapter is all about the JSF API and includes brand new features in JSF 2.2 in Java EE 7.
- Begins with a quick introduction to JSF and Facelets technology
- Then it dives into code driven development of a simple JSF application using Facelets. It goes on to demonstrate validation, component grouping, CDI named beans usage and navigation functionality.
- Using Ajax within JSF is discussed with the help of an example
- To wrap it up, the chapter demonstrates HTML5 support as well as the Faces Flowsfeature in JSF 2.2 coupled with concrete code samples.
Chapter 3- Object Relational Mapping with JPA
This chapter deals with JPA 2.1. It explains different components of JPA, and liberally uses examples and sample code.
- Demonstrates how to code a JPA entity class from scratch
- Illustrates the usage of important JPA components such as the EntityManagerinterface and its usage within CDI named beans to execute actual CRUD operations on the backend repository along with the persistence.xml and its role as the primary configuration provider for JPA
- It talks about JPA entity relationships i.e. one-to-one, one-to-many and many-to-many and explains them with succinct code examples.
- Briefly touches upon the Java Persistence Query Language and demonstrates its utilization within the JPA framework
- Delves into the Criteria API which was introduced in JPA 2.0 and serves as an object oriented way to build queries instead of using String based queries in case of JPQL
- Finally, the reader gets to learn about the using Bean Validation in tandem with JPAin order to apply data validation prior to persistence
Chapter 4 – Enterprise JavaBeans
- Begins with Stateful, Stateless and Singleton beans which fall under the Session Bean category
- The book goes on to provide a code driven demonstration of how one can invoke session beans in an asynchronous fashion with the help of @javax.ejb.Asynchronousannotation
- Message Driven Beans (MDBs) are covered briefly
- The lifecycle of the EJB types (Stateless, Stateful and MDB) are explained with illustrations, along with guidelines to configure/control the same with the help of GlassFish 4 Application Server
- The chapter explains the EJB Timer Service (for managed periodic invocation) functionality and calendar based EJB Timer expressions with the help of code and illustrations
- The chapter concludes with a discussion about configuring EJB security in adeclarative fashion using annotations and XML based configurations
Chapter 5 – Contexts and Dependency Injection
This chapter is all about Contexts and Dependency Injection which is a relatively new specification introduced in Java EE 6
- The chapter starts with an illustration of Named beans and how they can be used from within JSF pages.
- CDI bean scopes – Request, Session, Application, Dependent, Conversation have also been covered in details with the help of relevant examples.
- In depth coverage of Dependency Injection and Qualifiers which are the core features of CDI.
Chapter 6 – JSON Processing with JSON-P
JSON-P is a brand new specification introduced in Java EE 7 which provides a standard API for working with JSON payloads.
- The first half of this chapter introduces the reader to the Model API in JSON-P which is similar to the XML DOM API, based on loading and parsing an in-memory representation of the JSON payload
- The final half deals with the Streaming JSON-P API along with example code to illustrate its concepts.
Chapter 7 – WebSockets
The WebSocket API in a brand new specification in Java EE 7. It enables us to build real-time, full duplex applications using standard Java EE platform
- The book provides detailed coverage of the server side WebSocket API with the help of a simple yet effective example.
- The common server side constructs (annotations) for building a WebSocket endpoint are demonstrated – @ServerEndpoint, @OnMessage, @OnOpen, @OnClose etc
- Finally, a Java based web socket client end-point is demonstrated with the help of a code driven example.
- Both the client side samples showcase the usage of the @ClientEndpoint annotation and how it can be used to build client side logic for interacting with WebSocket server endpoints
Chapter 8 – The Java Message Service
This chapter discusses the Java Message Service API, specifically the 2.0 version which is the latest and revamped version introduced in Java EE 7
- To begin with, JMS related configuration of JMS in GlassFish 4 are covered. This includes JMS Factory connection, JMS Queue and JMS Topic setup.
- The second half of the lesson is all about code driven demonstration of the JMS 2.0 API.
- JMS Queues – how to send messages to a JMS queue
- How to receive messages from a JMS queue in synchronous as well as asynchronous mode. The asynchronous mode involves usage of the MessageListener interface
- JMS Topics – Sending/receiving messages to and from topics and working with durable subscribers are also covered.
Chapter 9 – Securing Java EE applications
This lesson covers Java EE security. It demonstrates core security features e.g. realms and demonstrates how to configure security on GlassFish 4 application server.
- Out-of-the-box security realms in GlassFish 4 are covered. These include admin, file and the certificate realm.
- Each realm is explained with the help of working example
- The discussion around Security realms continues and LDAP, JDBC, Solaris realms are covered in detail.
- The reader also gets to learn about writing his own custom security realmimplementation and plug it into GlassFish 4. This is done with the help of a code drive sample.
Chapter 10 – Web Services with JAX-WS
This lesson is dedicated to SOAP based web services and the JAX-WS API in the Java EE platform which supports building server side web service implementations
- Demonstrates the development of a simple SOAP web service using the JAX-WS APIs and its related annotations such as @WebService, @WebMethod etc. It also used the GlassFish 4 server to deploy and test the implementation end to end.
- Web Service client development using GlassFish 4 related tooling is covered.wsimport is used to build the client side stub and which is then used to invoke the web service end point.
- The focus shifts to EJBs and how they can be exposed as Web Service endpoints along with an example of client for an EJB masquerading as a SOAP web service endpoint
- The final phase of the chapter deals with web service security – both basic as well as EJB based SOAP end points. It does so with the help of security constrains in the web.xml
Chapter 11 – Developing RESTful Web Services with JAX-RS
This chapter is all about building REST style web services and the reader learns how to use the latest version of the JAX-RS API i.e. 2.0 which was introduced in Java EE 7
- It begins with a basic introduction to RESTful web services and the JAX-RS API in general
- The lesson delves into implementation details and demonstrated building and deploying RESTful web services. The process is explained with the help of practical examples which introduces the readers to various JAX-RS annotations namely – @PUT, @POST, @DELETE, @Produces, @Consumes etc. The developed web service is then deployed in GlassFish 4 and tested with the help of curl utility
- As a convenience to the reader, this chapter also deals with JAXB and shows some examples around XML-Java binding using JAXB annotations like @XMLRootElement etc
- To wrap it up, the JAX-RS client API is covered to explain how to develop clients for RESTful endpoints using the standard JAX-RS API. It also explains the concepts behind path and query parameters with the help of specific examples.
- This book does a good job of keeping things simple enough so that a relative beginner reader can grasp the concepts and not get intimidated.
- Leverages sample code, examples and pictorial representations in an effective manner.
- Applicable to a wide variety of audience.
- Covers the entire gamut of Java EE 7 platform (almost) – all the major specifications, APIs and features e.g. WebSockets, JSON-P, JMS, JAX-RS etc
Java EE 7 with GlassFish 4 Application Server provides a great outlook of the Java EE platform along with the latest and greatest features of Java EE 7. It is clear, concise and easy-to-grasp. With plenty of code examples, one can never expect things to get dry or boring.
All in all, a great tool to have in your Java EE arsenal !
Where can you grab the book?
Visit the PacktPub web site to grab your copy now !!
Happy Reading :-)