As a business application based on Java EE 5 technology, the application consists of the following application layers:
• Presentation (UI) layer
• Business layer
• Persistence layer
See the figure below to become familiar with the model of structuring our application.
This layer implements the data model of the application. The components we introduced in the Data Model section are implemented as entity beans using Enterprise JavaBeans (EJB) 3.0 technology. EJB version 3.0 presents a new Java Persistency API. It simplifies and standardizes the object-relational mapping. The new Java Persistence API makes the application independent from the specific vendor’s mapping requirements. The developer can either use annotations or XML descriptors to specify object-relational mapping information.
The entity beans are POJOs (Plain Old Java Objects) annotated with metadata. So they can be serialized and distributed across the network even in a persistence-unaware environment. As a consequence of this change, the data transfer objects (DTOs) become obsolete.
This layer performs the session operation between the components and implements the actual entity management. Generally, the layer implements the following business tasks:
· Employee management: finding objects (employees, skills, departments) by different attributes; creating employee and skill instances.
· Project management: finding projects by different attributes; creating and updating a project (for example, changing the employees assigned to the project, changing the start and end dates, and so on).
· Paging mechanism for results after search: provides a generic mechanism for navigation between result pages (lists) after search for projects, employees and skills. The mechanism is implemented by an ItemListHandler (session EJB) which is created with a particular implementation of an ISearchableJPA. On other hand all the EJBs, responsible for returning the search results of entities, have to implement ISearchableJPA.
You can review the class diagram of the paging mechanism below:
Then the presentation layer calls any of the business methods of ItemListHandler displayed on the following sequence diagram:
When creating or updating a project, the session bean that implements project management capabilities sends a JMS message to a configured JMS destination (a JMS queue). Message-driven beans enable the asynchronous consumption of JMS messages. A concurrent consumption of messages is possible with the EJBcontainer architecture. The typical message driven bean comprises two parts:
· A “sender” part that sends the message to the queue (the session bean calls this part of the bean)
● A “receiver” part that processes the received messages in the queue (the EJB container calls this part automatically upon a message receipt in the queue). In the application, the MDB just converts the message into a text message and stores it in the Projectchanges entity as a history of the project change.
The presentation layer has the required elements to visualize the controller logic presented in the application business layer. For the implementation of this layer we use JavaServer Faces (JSF) 1.2 and JavaServer Pages (JSP) 2.1 technologies.
Unlike pure servlets and JSP technologies that mix the HTML presentation (VIEW) logic with the programming MODEL and CONTROLLER logic in the application, user interface (UI) designers work with XML-like tags and programmers writes the logic using Java beans. Then designers use these beans properties for the application UI.