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:
- Embracing HTML5
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.
- Higher productivity
The JMS API has been greatly simplified.
JMSContext
provides the unified functionality ofConnection
andSession
objects. In addition, several JMS interfaces implementAutocloseable
and thus are automatically closed after use. Finally, correct error handling, runtime exceptions instead of checked exceptions, method chaining onJMSProducer
, and 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 preconfigured
DataSource
for accessing databases in operational environments, a preconfigured JMSConnectionFactory
for accessing a JMS provider, and a preconfiguredManagedExecutorService
—provide a seamless out-of-the-box experience for new developers starting with the platform.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.
@Transactional
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.
- Enterprise demands
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.
Prior to Java EE 7, the Java EE 6 platform improved upon the developer productivity features and added a lot more functionality.
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:
- Specification
A formal document that describes the proposed component and its features.
- Reference Implementation (RI)
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.
- Technology Compliance Kit (TCK)
A set of tests that verify that the RI is in compliance with the specification. This allows multiple vendors to provide compliant implementations.
Java EE 7 consists of the platform specification that defines requirements across the platform. It also consists of the following component specifications:
- Web technologies
- Enterprise technologies
- Web service technologies
- Management and security technologies
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.
JPA and JMS provide the basic services such as database access and messaging. JCA allows connection to legacy systems. Batch is used for performing noninteractive, bulk-oriented tasks.
Managed Beans and EJB provide a simplified programming model using POJOs to use the basic services.
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.
Bean Validation provides a standard means to declare constraints and validate them across different technologies.
JAX-RPC (JSR 101), JAXR (JSR 93), EJB Entity Beans (part of JSR 153), and Java EE Application Deployment (JSR 88) are pruned in this version of the platform.
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 3.1.2.2 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 TCK is available to all Java EE licensees for testing their respective implementations.
Some new specifications have been added to improve the functionality and richness of the platform. Several existing component specifications were revised to make them simpler and easier to use.
The main features of the new specifications are described as follows:
- Java API for WebSocket
Enables a WebSocket client and server endpoint to be defined declaratively via annotations on a POJO, or programmatically via interface implementation.
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.
- Java API for JSON Processing
- Batch Applications for Java Platform
- Concurrency Utilities for Java EE
The main features of the updated specifications are described as follows:
- Java API for RESTful Web Services
Offers a new Client API that can be used to access web resources and provides integration with JAX-RS providers.
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
qs
factor.Enables declarative validation of fields, properties, and parameters injected using
@HeaderParam
,@QueryParam
, etc. Resource classes may be annotated with constraint annotations.
- Java Message Service
Several changes have been made to make the API simpler and easier to use. For example,
Connection
,Session
, and other objects with aclose
method now implement thejava.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,getBody
, has been added to allow an application to extract the body directly from aMessage
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.
- Expression Language
Expression Language (EL) is a specification of its own. It can be configured and used outside of a Java EE container using
ELProcessor
.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.
- Enterprise JavaBeans
Support for EJB 2.1, EJB QL, and JAX-RPC-based Web Service endpoints and client view is now optional.
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.
- Servlets
- JavaServer Faces
Faces Flow provides an encapsulation of related views/pages with application-defined entry and exit points.
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 the
UIComponent
state. This allows applications with JavaScript components to manage the state instead of JSF doing it for them.
- Java Persistence
Database schema and tables may be generated by using
javax
.
persistence.schema-generation.*
properties.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
Criteria
API.Predefined and user-defined functions can be invoked using
FUNCTION
.Stored procedures can be invoked using
StoredProcedureQuery
and@Named
StoredProcedureQuery
.
- Interceptors
Associating interceptors using
InterceptorBinding
is now part of this specification, instead of CDI.@AroundConstruct
designates an interceptor method that receives a callback when the target class constructor is invoked.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.
- Contexts and Dependency Injection
- Bean Validation
- Java Transaction
@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 level.@TransactionScoped
is a new CDI scope that defines bean instances whose life cycle is scoped to the currently active JTA transaction.
- JavaMail
- Java EE Connector Architecture
Get Java EE 7 Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.