Introduction

In today’s business world, applications need to access data, apply business logic, add presentation layers, be mobile, use geolocalization, and communicate with external systems and online services. That’s what companies are trying to achieve while minimizing costs, using standard and robust technologies that can handle heavy loads. If that’s your case, you have the right book in your hands.

Java Enterprise Edition appeared at the end of the 1990s and brought to the Java language a robust software platform for enterprise development. Challenged at each new version, badly understood or misused, overengineered, and competing with open source frameworks, J2EE was seen as a heavyweight technology. Java EE benefited from these criticisms to improve and today focuses on simplicity.

If you are part of the group of people who still think that “EJBs are bad, EJBs are evil,” read this book, and you’ll change your mind. EJBs (Enterprise Java Beans) are great, as is the entire Java EE 7 technology stack. If, on the contrary, you are a Java EE adopter, you will see in this book how the platform has found equilibrium through its ease of development and easy component model. If you are a beginner in Java EE, this is also the right book: it covers the most important specifications in a very understandable manner and is illustrated with a lot of code and diagrams to make it easier to follow.

Open standards are collectively one of the main strengths of Java EE. More than ever, an application written with JPA, CDI, Bean Validation, EJBs, JSF, JMS, SOAP web services, or RESTful web services is portable across application servers. Open source is another of Java EE’s strengths. As you’ll see in this book, most of the Java EE 7 Reference Implementations use open source licensing (GlassFish, EclipseLink, Weld, Hibernate Validator, Mojarra, OpenMQ, Metro, and Jersey).

This book explores the innovations of this new version, and examines the various specifications and how to assemble them to develop applications. Java EE 7 consists of nearly 30 specifications and is an important milestone for the enterprise layer (CDI 1.1, Bean Validation 1.1, EJB 3.2, JPA 2.1), for the web tier (Servlet 3.1, JSF 2.2, Expression Language 3.0), and for interoperability (JAX-WS 2.3 and JAX-RS 2.0). This book covers a broad part of the Java EE 7 specifications and uses the JDK 1.7 and some well-known design patterns, as well as the GlassFish application server, the Derby database, JUnit, and Maven. It is illustrated abundantly with UML diagrams, Java code, and screenshots.

How the Book Is Structured

This book concentrates on the most important Java EE 7 specifications and highlights the new features of this release. The structure of the book follows the architectural layering of an application.

image

Chapter 1 briefly presents Java EE 7 essentials and Appendix A highlights the tools used throughout the book and how to install them (JDK, Maven, JUnit, Derby, and GlassFish).

In the first chapters, I explain the common concerns discussed throughout the book. Chapter 2 describes Context and Dependency Injection 1.1 and Chapter 3 looks at Bean Validation 1.1.

Chapters 4 through 6 describe the persistent tier and focus on JPA 2.1. After a general overview with some hands-on examples in Chapter 4, Chapter 5 dives into object-relational mapping (mapping attributes, relationships, and inheritance), while Chapter 6 shows you how to manage and query entities, their life cycle, callback methods, and listeners.

To develop a transaction business logic layer with Java EE 7, you can naturally use EJBs. Chapters 7 through 9 describe this process. After an overview of the specification and its history, Chapter 7 concentrates on session beans and their programming model. Chapter 8 focuses on the life cycle of EJBs, the timer service, and how to handle authorization. Chapter 9 explains transactions and how JTA 1.2 brings transactions to EJBs as well as CDI Beans.

In Chapters 10 and 11 you will learn how to develop a presentation layer with JSF 2.2. After an overview of the specification, Chapter 10 focuses on how to build a web page with JSF and Facelets components. Chapter 11 shows you how to interact with an EJB back end with CDI backing beans and navigate through pages.

Finally, the last chapters present different ways to interoperate with other systems. Chapter 12 explains how to process XML (using JAXB and JAXP) and JSON (JSON-P 1.0). Chapter 13 shows you how to exchange asynchronous messages with the new JMS 2.0 and Message-Driven Beans. Chapter 14 focuses on SOAP web services, while Chapter 15 covers RESTful web services with the new JAX-RS 2.0.

Downloading and Running the Code

The examples used in this book are designed to be compiled with the JDK 1.7, to be built with Maven 3, to be deployed on GlassFish v4 application server, and to store data in a Derby database. Appendix A shows you how to install all these software packages, and each chapter explains how to build, deploy, run, and test components depending on the technology used. The code has been tested on the Mac OS X platform (but should also work on Windows or Linux). The source code of the examples in the book is available from the Source Code page of the Apress web site at www.apress.com. You can also download the code straight from the public GitHub at https://github.com/agoncal/agoncal-book-javaee7.

Contacting the Author

If you have any questions about the content of this book, the code, or any other topic, please contact the author at [email protected]. You can also visit his web site at www.antoniogoncalves.org and follow him on Twitter at @agoncal.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.52.188