Your First Cup: An Introduction to the Java EE Platform
3.1 Architecture of the Example Applications
The example applications consist of four main components:
DukesAgeResource, a JAX-RS RESTful web service;
DukesBirthdayBean, an enterprise bean;
FirstcupUser, a Java Persistence API entity; and
firstcup-war, a web application created with JavaServer Faces Facelets technology.
Figure 3-1 Architecture of the First Cup Example Applications
Description of "Figure 3-1 Architecture of the First Cup Example Applications"
DukesAgeResource is a JAX-RS resource that calculates the age of Duke, the Java mascot. Duke was born May 23, 1995, when the first demo of Java technology was publicly released.
DukesBirthdayBean is a local, no-interface view stateless session bean that calculates the difference between the user's age and Duke's age, and stores the user-submitted data in a Java Persistence API entity.
FirstcupUser is a Java Persistence API entity that represents a particular user's birthday. It is stored in a Java DB database table, and managed by
DukesBirthdayBean's business methods.
firstcup-war web application is a JavaServer Faces Facelets application that accesses
DukesAgeResource to display Duke's age, reads in a date provided by the user, accesses
DukesBirthdayBean to calculate who is older, and then displays the difference in years between the user and Duke and the average age difference of all users.
firstcup-war web application consists of the following:
greeting.xhtml: An XHTML page that uses the JavaServer Faces Facelets tag libraries. Users can type their birth date in a field and submit it for comparison against Duke's birth date.
response.xhtml: A Facelets-enabled XHTML page that tells the user whether he or she is older or younger than Duke, based on the date the user entered in the
greeting.xhtmlpage, and displays the average age difference of all users.
DukesBDay.java: A CDI bean that defines properties to hold the user's birth date, uses the JAX-RS Client API to get Duke's current age from the
DukesAgeResourceweb service, and calculate the age difference between the user and Duke from the enterprise bean.
web.xml: The web application's deployment descriptor, which is used to configure certain aspects of a web application when it is installed. In this case, it is used to provide a mapping to the application's
FacesServletinstance, which accepts incoming requests, passes them to the life cycle for processing, and initializes resources. It also specifies
greeting.xhtmlas the welcome file for the application.
WebMessages_es.properties: Java programming language properties files that contain the localized strings used in
response.xhtml. By default, the English language strings in
WebMessages.propertiesare used, but Spanish language strings are also provided in
DukesBirthdayBean.java: as described above, the enterprise bean packaged within the
DukesBirthdayBeancalculates the difference between the user's birthday and Duke's birthday.
3.1.1 Tiers in the Example Applications
The example applications have one web tier component (the
firstcup web client), three business tier components (the
DukesAgeResource web service, the
FirstcupUser entity, and the
DukesBirthdayBean enterprise bean), and one enterprise information system (EIS) tier (the data in the Java DB database table). The user's web browser is the client tier component, as it accesses the rest of the application through the web tier.
3.1.2 Java EE Technologies Used in the Example Applications
DukesAgeResource web service is a JAX-RS resource. The
DukesBirthdayBean enterprise bean is a stateless session bean. The
FirstcupUser entity is a Java Persistence API entity. The
DukesBDay CDI managed bean uses the JAX-RS client API to access the
DukesAgeResource web service. The
firstcup-war web client is a JavaServer Faces application that runs in the web container of the Java EE server.