Book Image

Digital Java EE 7 Web Application Development

By : Peter Pilgrim
Book Image

Digital Java EE 7 Web Application Development

By: Peter Pilgrim

Overview of this book

Digital Java EE 7 presents you with an opportunity to master writing great enterprise web software using the Java EE 7 platform with the modern approach to digital service standards. You will first learn about the lifecycle and phases of JavaServer Faces, become completely proficient with different validation models and schemes, and then find out exactly how to apply AJAX validations and requests. Next, you will touch base with JSF in order to understand how relevant CDI scopes work. Later, you’ll discover how to add finesse and pizzazz to your digital work in order to improve the design of your e-commerce application. Finally, you will deep dive into AngularJS development in order to keep pace with other popular choices, such as Backbone and Ember JS. By the end of this thorough guide, you’ll have polished your skills on the Digital Java EE 7 platform and be able to creat exiting web application.
Table of Contents (21 chapters)
Digital Java EE 7 Web Application Development
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Java EE 7 architecture


Java EE is an open standard, an enterprise platform, and a specification for applications that execute on a server. For the digital worker, Java EE provides many services for building web applications including Servlets, JavaServer Faces, Facelets, Context and Dependency Injection, Java Message Services, WebSocket, and crucial Java for RESTful services.

Java EE 7 was announced and released in June 2013, and the overreaching theme was better HTML5 support and increased productivity. Currently, it looks like the future Java EE 8 specification might add support for the administrative configuration of services and application aspects through declarative annotations (extension of JSR 220).

Standard platform components and API

Java EE architecture is a container and layer-based architecture. At the crux of the design is an application server and an increasingly cloud-based solution, although this is yet to be standardized in the specification.

In the non-cloud-based Java EE, we can think of Java EE as four separate containers: the first one is the EJB container for life cycle management of Enterprise Java Beans and the second container is the Web container for life cycle management of the Java Servlets and Managed Beans. The third container is called the Application Client container, which manages the lifecycle of the client-side components. Finally, the fourth container is reserved for Java Applets and their life cycles.

Most of the time, digital engineers are concerned about the EJB, web, and the managed CDI bean containers.

Note

If you are interested in a full description of the architecture, please refer to my first book, The Java EE 7 Developer Handbook by Packt Publishing. You can consider it as a sister book to this one.

According to the Java EE 7 specification, there are two official implementation profiles: the full and the web profile. A fully conformant Java EE product such as Glassfish or JBoss WildFly application server implements the full profile, which means it has all containers: EJB, CDI, and web. A server like Apache Tomcat, which builds against the Java EE 7 web profile, implements only the web container. A server like Tom EE that extends the Apache Tomcat implements the web container, and may add extra facilities like CDI, EJB, and even JMS and JAX-RS.

The following diagram illustrates the full profile Java EE 7 architecture as an enterprise solution. The Java EE platform is an abstraction of the hardware, disk storage, networking, and the machine code. Java EE relies on the presence of a Java Virtual Machine for operation. There are versions of JVM that have been ported to hardware chips like Intel, ARM, AMD, Sparc, FreeScale, and others as well as to operating systems including Windows, Mac OS, Linux, Solaris, and even Raspberry Pi.

Therefore, Java and the other alternative languages can execute seamlessly on this chip architecture, and this applies to the enterprise applications. The Java EE provides additional standard API to the standard core Java SE. Let's take a brief look at some of the Java EE features.

Java EE 7 takes advantage of the New Input Output (NIO) feature in the Java SE edition to allow Java Servlets 3.1 to handle asynchronous communication.

JavaServer Faces 2.2 is now enhanced with tighter CDI integration, improved life cycle events, and a new queue control for AJAX requests. For the digital engineer, there is sensible HTML5 support, resource library contracts, faces flows, and stateless views.

An illustration of the Java EE 7 full platform and JSR specifications

Expression Language 3.0 is not truly a new specification, but it is a broken-out specification from Servlets, JavaServer Pages, and JavaServer Faces. Developers can access the expression evaluator and invoke processing on custom expressions like, say, their own custom tag libraries or server-side business logic.

Perhaps, the most important change in Java EE 7 is the strengthening of the CDI in order to improve type-safety and the easier development of CDI extensions. CDI, Interceptors, and Common Annotations improve the type-safe dependency injection and the observation of life cycle events inside the CDI container. These three specifications together ensure that extensions, which address crosscutting concerns and can be applied to any component, can be written. Developers can now write portable CDI extensions to extend the platform in a standard way.

RESTful Services (JAX-RS) has three crucial enhancements: the addition of client-side API to invoke a REST endpoint, asynchronous I/O support for the client and server endpoints, and hypermedia linking.

Bean validation is a constraint validation solution for domain and value object. It now supports method-level validation and also has better integration with the rest of the Java EE platform.

WebSocket API 1.0 is a new specification added to Java EE 7. It allows the Java application to communicate with the HTML5 WebSocket clients.

Java EE 7 continues the theme that was started in the earlier editions of the platform: improvements for ease-of-development and allowing the developers to write POJOs.