Introduction

The Java platform is one of the most widely used platforms for application development in the world. The platform is so popular, that there are several different flavors of Java that can be used for developing applications that run on different mediums. From development of desktop or mobile, to web applications and hardware operating systems, Java can be utilized for development of just about any solution. As such, Java has become a very popular platform for development of enterprise applications, offering web services, reliability, security, and much more.

Java Enterprise Edition was originally released in 1999 as Java 2 Platform, Enterprise Edition (J2EE). Although several enterprise frameworks were available for development of reliable and secure applications on the Java platform, it made sense to standardize some solutions in order to minimize customization and help to make Java Enterprise development more prevalent in the industry. The platform originally included a terse number of specifications for standardization, including Java Servlet, JavaServer Pages, RMI, Java Database Connectivity (JDBC), Java Message Service API (JMS), Java Transaction API (JTA), and Enterprise JavaBeans. Development of J2EE applications had a large learning curve, and it was cumbersome because it required the use of XML for lots of configuration. Even with these setbacks, it became popular amongst larger organizations and companies due to the prevalence of Java and its well-known security benefits. In 2001, J2EE 1.3 was released, adding more specifications to the platform, including the JavaServer Pages Standard Tag Library (JSTL) and Java Authentication and Authorization Service (JAAS). Other specifications, such as Java Servlet, also gained enhancements under the J2EE 1.3 release, making evolutionary enhancements to the platform. The release of J2EE 1.4 in 2003 marked a major milestone for Java Enterprise, as many new specifications were added to the platform, providing standards for even more Java technologies. The release of J2EE 1.4 marked the first iteration of Web Services for J2EE 1.1, JavaServer Faces (JSF), and Java APIs for XML solutions such as JAXP, JAXR, and more. Although the release of J2EE 1.4 included many specifications, it was still deemed as “difficult to learn” and “cumbersome.”

Over the next few years, J2EE was reworked in an attempt to make it easier to learn and utilize. Although XML is an excellent means for configuration, it can be cumbersome and hard to manage, so configuration was a big item that was addressed for the next release. Technologies such as Enterprise JavaBeans (EJB) included some redundant characteristics, making EJB coding time-consuming and difficult to manage, so an overhaul of EJB was also in order. In May of 2006, Java EE 5 was released, leaving the J2EE acronym behind, and changing to simply Java EE. The Java EE 5 platform was significantly easier to use and maintain because features such as annotations were introduced, cutting down the amount of XML configuration significantly. EJBs were made easier to develop, making EJB a marketable technology for object-relational mapping once again. Java Enterprise Edition has since become a widely adopted and mature platform for enterprise development. Java EE 6 was released in 2009, making configuration and technologies even easier, and adding more specifications to the platform. Specifications such as Contexts and Dependency Injection and Bean Validation were introduced, making usability even easier and development more productive.

This latest release, Java EE 7, enhances the platform even more by adding new specifications such as WebSockets and JSON-P. Specifications such as JSF and EJB were enhanced, adding even more features to increase productivity and functionality. This book focuses on Java Enterprise as a whole, covering most of the widely used specifications that make up Java EE. You will learn how to make use of each of the major specifications, through real-world examples and solutions. This book will cover APIs that have not been updated for Java EE 7, as well as those that have been enhanced, providing complete coverage for those who are newer to the platform. It also features recipes that cover the newest features of the platform, so that seasoned Java EE developers can skip those introductory concepts and delve into newer material.

I work with Java Enterprise on a daily basis, and I have a deep passion for the technologies involved in the platform. I hope that this book increases your passion of Java EE and the Java platform in its entirety.

Who This Book Is For

This book is intended for all those who are interested in learning Java Enterprise Edition (Java EE) development and/or already know Java EE but would like some information regarding the new features included in Java EE 7. Those who are new to Java EE development can read this book, and it will allow them to start from scratch to get up and running quickly. Intermediate and advanced Java developers who are looking to update their arsenal with the latest features that Java EE 7 has to offer can also read the book to quickly update and refresh their skill sets.

How This Book Is Structured

This book is structured so that it does not have to be read from cover to cover. In fact, it is structured so that developers can chose which topic(s) they’d like to read about and jump right to them. Each recipe contains a problem to solve, one or more solutions to solve that problem, and a detailed explanation of how the solution works. Although some recipes may build upon concepts that have been discussed in other recipes, they will contain the appropriate references so that the developer can find other related recipes that are beneficial to the solution. The book is designed to allow developers to get up and running quickly with a solution, so that they can be home in time for dinner.

Conventions

Throughout the book, I’ve kept a consistent style for presenting Java code, SQL, command-line text, and results. Where pieces of code, SQL, reserved words, or code fragments are presented in the text, they are presented in fixed-width Courier font, such as this (working) example:

public class MyExample {
    public static void main(String[] args){
       System.out.println("Java EE 7 is excellent!");
    }
}

Downloading the Code

The code for the examples shown in this book is available on the Apress web site, www.apress.com. A link can be found on the book’s information page under the Source Code/Downloads tab. This tab is located underneath the “Related Titles” section of the page.

image Note  The sources for this book may change over time to provide new implementations that incorporate the most up-to-date features in Java EE. That said, if any issues are found within the sources, please submit them via the Apress web site “Errata” form, and code will be adjusted accordingly.

Configuring a Database for the Book Sources

This book’s sources have been developed using the Apache Derby database, which ships with NetBeans IDE and GlassFish. The book sources have also been optimized for use with an Oracle 11g database. Please install and configure the database for use with the book sources using either of those database choices prior to working with the sources. The database configuration involves creation of a database schema or user, as well as execution of the create_database.sql script (contained within the book sources) that goes along with the database of your choice. You must also place the appropriate database JDBC driver into the GlassFish CLASSPATH. You can do this by copying the ojdbc6.jar (Oracle) or derbyclient.jar (Apache Derby) JAR file into your Integrated Development Environment (IDE) project for the book sources, or into the <GlassFish-Home>glassfish4domainsdomain1libext directory. If copying into the GlassFish lib directory, then once the JAR file has been copied into place, the GlassFish server will need to be restarted, if it is already running.

Once the database has been installed/configured, and the SQL scripts contained within the book sources have been executed, please log into the GlassFish administrative console and set up a database connection pool to work with the database of your choice. For more information, please see Recipe 11-5.

After a connection pool has been configured, please update the persistence.xml file that is contained within the book sources accordingly, so that the data source name aligns with the one you’ve assigned to the GlassFish JDBC resource.

Setting Up a NetBeans Project

Before setting up a NetBeans project for the book sources, please install and configure GlassFish v4 accordingly. For more information, please see Recipe 11-1.

image Note  Before setting up a NetBeans project for the book sources, please install and/or configure Apache Derby or Oracle Database accordingly. A note regarding dependencies: this project depends upon the use of the third-party PrimeFaces library. At the time of this book publication, the PrimeFaces 4.0 release was not yet available to the public. That said, the sources can be obtained from the Google Code repository, and the dependency JAR can be built from the sources. Please see the Google Code repository at http://code.google.com/p/primefaces/source/checkout.

Please perform the following steps to set up the NetBeans project:

  1. Open NetBeans IDE 7.3 or greater.
  2. Choose the File image New Project image Java Web image Web Application menu option.
  3. Title the project JavaEERecipes and choose a desired Project Location.
  4. Server and Settings:
    • a.  If you have not yet registered your GlassFish v4 server with NetBeans, please click the Add button in this dialog, and add the server. To do so, you will need to know the location of the GlassFish server on your file system.
    • b.  Java EE Version: Java EE 7 Web.
  5. Frameworks:
    • a.  Select JavaServer Faces, and then accept all defaults.
  6. Click Finish.
  7. Go to your file system and copy the contents from within the JavaEERecipes-BookSourcesNBProjectsrc directory into your new NetBeans project src directory.
  8. Add the required library dependencies to your project by right-clicking the project and choosing the Properties option. Once the Properties dialog is open, select the Libraries, and add the following dependencies:
    • a.  Jython 2.5.3 or later
    • b.  Groovy 2.0.1 or later
    • c.  PrimeFaces 4.0 or later
    • d.  Database JDBC JAR file, if not already placed within the GlassFish lib directory
..................Content has been hidden....................

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