The Java Platform, Enterprise Edition (Java EE), provides a standards-based platform for developing web and enterprise applications. These applications are typically designed as multitier applications, with a frontend tier consisting of a web framework, a middle tier providing security and transactions, and a backend tier providing connectivity to a database or a legacy system. These applications should be responsive and capable of scaling to accommodate the growth in user demand.
The Java EE platform defines APIs for different components in each tier, and also provides some additional services such as naming, injection, and resource management that span across the platform. These components are deployed in containers that provide runtime support. Containers provide a federated view of the underlying Java EE APIs to the application components. Java EE application components never interact directly with other Java EE application components. They use the protocols and methods of the container for interacting with each other and with platform services. Interposing a container between the application components and the Java EE services allows the container to transparently inject the services required by the component, such as declarative transaction management, security checks, resource pooling, and state management. This container-based model and abstraction of resource access allows the platform to offload the developer from common infrastructure tasks.
Each component of the platform is defined in a separate specification that also describes the API, javadocs, and expected runtime behavior.
Java EE 7 was released in June 2013 and provides a simple, easy-to-use, and complete stack for building such web and enterprise applications. The previous versions of the platform, starting with Java EE 5 and continuing with Java EE 6, took the first steps in providing a simplified developer experience.
The Java EE 7 platform built upon the previous version with three main goals:
The WebSocket protocol, developed as part of the collection of technologies that make up HTML5, brings a new level of ease of development and network efficiency to modern, interactive web applications. It provides a two-way, full-duplex communication channel between a client and a server over a single TCP (transmission control protocol) channel. Java EE 7 defines a new standard API to develop and deploy WebSocket clients and endpoints.
JSON is the lingua franca of the Web for lightweight data exchange. Until now, developers were required to bundle third-party libraries for JSON processing. Java EE 7 defines a new portable API to parse, generate, transform, and query JSON using a Streaming API or Object Model API.
JavaServer Faces (JSF) introduces pass-through attributes and elements that allow near-total control over the user experience of each individual element in the view. This allows HTML5-friendly markup to be easily embedded in a page.
The JMS API has been greatly simplified.
JMSContext provides the unified functionality of
Session objects. In
addition, several JMS interfaces implement
Autocloseable and thus are automatically closed after
use. Finally, correct error handling, runtime exceptions instead of
checked exceptions, method chaining on
simplified message sending are further examples of features that the
JMS API has simplified.
Without the Client API (introduced in JAX-RS 2), developers
are required to use basic
HttpUrlConnection APIs and
write all the surrounding code.
More defaults for the application’s use—such as a
DataSource for accessing databases in
operational environments, a preconfigured JMS
accessing a JMS provider, and a preconfigured
ManagedExecutorService—provide a seamless
out-of-the-box experience for new developers starting with the
The Contexts and Dependency Injection (CDI) specification
is now a core component model, and is enabled by default. This makes
the platform a lot more cohesive and integrated. CDI interceptors
are now more widely applicable to beans.
annotation brings transactional semantics to POJOs
(plain old Java objects), outside of an EJB (Enterprise JavaBean).
Bean Validation allows automatic validation of method
arguments and results using interceptors.
Less boilerplate text, more defaults, and a cohesive integrated platform together boost developers’ productivity when building applications using the latest version of the platform.
Batch Applications for the Java Platform is a new functionality in the platform and very important for enterprise customers. It allows developers to easily define noninteractive, bulk-oriented, long-running jobs in an item- or task-oriented way.
Concurrency Utilities for Java EE, another functionality new to the platform, is an extension of the Java SE Concurrency Utilities API, for use in the Java EE container-managed environment so that the proper container-managed runtime context can be made available for the execution of these tasks.
This functionality in the platform allows the developer to leverage the standard APIs and reduces the dependency on third-party frameworks.
The Java EE 7 platform was developed as Java Specification Request (JSR) 342 following JCP 2.9. The JCP process defines three key deliverables for any JSR:
Binary implementation of the proposed specification. The RI helps to ensure that the proposed specifications can be implemented in a binary form and provides constant feedback to the specification process.
The RI of Java EE is built in the GlassFish community.
The different components work together to provide an integrated stack, as shown in Figure 1-1.
In Figure 1-1:
Different components can be logically divided into three tiers: backend tier, middle tier, and web tier. This is only a logical representation, and the components can be restricted to a different tier based upon the application’s requirements.
CDI, Interceptors, and Common Annotations provide concepts that are applicable to a wide variety of components, such as type-safe dependency injection, addressing cross-cutting concerns using interceptors, and a common set of annotations. Concurrency Utilities can be used to run tasks in a managed thread. JTA enables Transactional Interceptors that can be applied to any POJO.
CDI Extensions allow you to extend the platform beyond its existing capabilities in a standard way.
Web Services using JAX-RS and JAX-WS, JSF, JSP, and EL define the programming model for web applications. Web Fragments allow automatic registration of third-party web frameworks in a very natural way. JSON provides a way to parse and generate JSON structures in the web tier. WebSocket allows the setup of a bidirectional, full-duplex communication channel over a single TCP connection.
The RI of Java EE 7 is built in the GlassFish Community. The GlassFish Server Open Source Edition 4.0 provides a full Java EE 7–compliant, free, and open source application server. It is also available in a Web Profile distribution and can be downloaded from http://glassfish.org. The application server is easy to use (ZIP installer and NetBeans/Eclipse/IntelliJ integration), lightweight (downloads starting at 37 MB, small disk/memory footprint), and modular (OSGi-based, containers start on demand).
Prior to Java EE 7, GlassFish Server Open Source Edition 188.8.131.52 provides a Java EE 6−compliant version application server. It also provides clustering with high availability and centralized administration using CLI, Web-based administration console, and REST management/monitoring APIs. The Oracle GlassFish Server is Oracle’s commercially supported GlassFish server distribution and can be downloaded from http://oracle.com/goto/glassfish. As of this writing, there are 18 Java EE 6–compliant application servers.
The main features of the new specifications are described as follows:
Provides server-specific configuration, such as mapping that identifies a WebSocket endpoint in the URI space of the container, subprotocols supported by the endpoint, and extensions required by the applications.
Offers client-specific configurations such as providing custom configuration algorithms.
Enables packaging and deployment on JDK or web containers.
Allows for integration with existing Java EE technologies.
The main features of the updated specifications are described as follows:
Supports asynchronous processing in both the Client API and the Server API.
Defines Message Filters and Entity Interceptors as extension points to customize the request/response processing on the client and server side.
Supports new server-side content negotiation using
Several changes have been made to make the API simpler
and easier to use. For example,
Session, and other objects with a
close method now implement the
java.lang.Autocloseable interface to allow them
to be used in a Java SE 7 try-with-resources statement. New
methods have been added to create a session without the need
to supply redundant arguments. A new method,
has been added to allow an application to extract the body
directly from a
Message without the need to cast
it first to an appropriate subtype.
A message producer can now specify that a message must not be delivered until after a specified time interval.
New send methods have been added to allow an application to send messages asynchronously.
JMS providers must now set the
JMSXDeliveryCount message property.
The lambda syntax is now included in EL. Using lambdas, a complete set of collection operations, such as map and filter is now supported.
In addition to the usual arithmetic and comparison operators, new operators—such as an assignment operator and string concatenation operator—have been added to make EL more expressive.
Enhanced message-driven beans (MDBs) contract with a no-method message listener interface to expose all public methods as message listener methods. This will allow custom Resource Adapters for future MDBs.
EJB API Groups have been defined with clear rules for an EJB Lite Container to support other API groups. This will help define how EJB features beyond EJB Lite can be officially added to a product that does not support full Java EE Profile.
Asynchronous session bean invocations and nonpersistent EJB Timer Service are included in EJB Lite.
An option has been added to disable passivation of stateful session beans.
Resource Library Contracts enable developers to apply facelet templates to an entire application in a reusable and interchangeable manner.
HTML5-friendly markup allows near-total control over the user experience of each individual element in the view.
Stateless Views mean developers no longer have to save
UIComponent state. This allows applications
doing it for them.
Unsynchronized Persistence Contexts mean a persistence context does not have to be enlisted in a transaction. Such persistence contexts can explicitly join a transaction.
Bulk update/delete is supported via
Predefined and user-defined functions can be invoked
Stored procedures can be invoked using
Method-level interceptors can be extended to life-cycle callbacks, adding constructor-level interceptors.
Priority ranges can be dedicated for ordering interceptors using interceptor binding.
@Transactional provides the application to declaratively
control transaction boundaries on CDI-managed beans, as well
as classes defined as managed beans by the Java EE
specification, at both the class and method level where
method-level annotations override those at the class