Web Application design using Java EE 6

Not long ago I was impressed by Java EE 7 and If I was an architect in any project, I would have designed an application using only Java EE 7 APIs. I am still a fan of JSF and want to use it for developing UI as no doubt in my mind, development is fast and full proof. I don't know how much widely Java EE 7 is accepted by other architects of world, but Spring is a framework with a wide application, and Spring resources are readily available, so lot of Java developers are even unaware or can't imagine of only limiting to Java EE API's if I am not wrong, at least me, I almost forgot what was EJB. Joking. But no doubt I have nightmares of EJB 2.0. Funny!!! unless you were a J2EE developer in 2005, but now we should look forward to 2015.

A little while back I found a very decent open source application developed in Java EE 6 and that too on JBOSS site : TicketMonster. The tutorial is amazing, yes tutorials are not meant to be amazing, but this application is principled and very well documented. Its suits well for an intermediate Java EE developer/designer. I will recommend going through the TicketMonster implementation as it outlines the an Java EE application standard architecture. - http://www.jboss.org/ticket-monster/


The open source application brings together the best features of Java EE 6 + HTML5 + JBoss to create a rich, mobile-optimized and dynamic application.

Use Case - 
The use cases are below - 

Architecture - 

Package Structure of Server side code - 

(Optional package)
contains the backing beans for JSF page. The backing beans also act as controller for JSF pages. 
Controller class (/JSF backing bean) calls EJB (inside package .service) to perform transactional member registration
If any other controllers in application, then they can be placed here. 

contains the JPA entity class, a POJO annotated with @Entity, annotated with Bean Validation (JSR 303) constraints

contains the JAX-RS endpoints, POJOs annotated with @Path
The package contains EJB's which are exposed as REST endpoints, like below - 
public class VenueService 
Most JAX-RS services return a list of entities or individual entity or possibly count (number of entities). 
We will have multiple classes like Venue who will have similar operations (but different path), so the method to retrieve single entity, or list of entities or count can be placed in one common abstract class (for example BaseEntityService).
BaseEntityService will have methods like getAll, getCount, etc. annotated with @Get, but note the class itself will not have @Path annotation, instead classes extending BaseEntityService will have @Path annotation and will be invoked by UI clients. 

The package contains Internal Services.
Like for example MediaManager: The MediaManager is a good illustration of a business service; it performs the retrieval and caching of media objects, encapsulating the operation from the rest of the application. 
MediaManager delegates to a number of internal methods that do the heavy lifting, but exposes a simple API to retrieve the media items like video or images or path of media items. 
MediaManager is not directly called from external clients, instead by other components which depend on it. 
We should also control the lifecycle of this service. The MediaManager stores request-specific state, so should be scoped to the web request, the CDI @RequestScoped is perfect.
This package contains CDI's which can be injected into components which serve client, like classes in .rest package
The .service package can also contain EJB if required(if required transactional). The EJB in this package will only be called by other components (controllers which are invoked by UI, controllers like JSF backing bean).
Or these EJB's can be called by SOAP or REST interfaces (inside different package), the interfaces which can be directly invoked by SOAP or REST clients. 

Contains helper classes providing low-level utilities for the application.
Like package containscontains Resources.java which sets up an alias for @PersistenceContext to be injectable via @Inject
also other Utilities like Base64, Buffer, etc.


  1. Just four steps to design web application development by using Java EE6 . Wonderful Sharing.
    Application design


Post a Comment


Popular Posts