This hands-on lab builds a typical 3-tier Java EE 7 Web application that allows customers to view the show timings for a movie in a 7-theater Cineplex and make reservations. Users can add new movies and delete existing movies. Customers can discuss the movie in a chat room. Total sales from each showing are calculated at the end of the day. Customers also accrue points for watching movies.
This figure shows the key components of the application. The User Interface initiates all the flows in the application. Show Booking, Add/Delete Movie and Ticket Sales interact with the database; Movie Points may interact with the database, however, this is out of scope for this application; and Chat Room does not interact with the database.
The different functions of the application, as detailed above, utilize various Java technologies and web standards in their implementation. The following figure shows how Java EE technologies are used in different flows.
The table below details the components and the selected technology used in its’ implementation.
This document is not a comprehensive tutorial of Java EE. The attendees are expected to know the basic Java EE concepts such as EJB, JPA, JAX-RS, and CDI. The Java EE 7 Tutorial is a good place to learn all these concepts. However enough explanation is provided in this guide to get you started with the application.
|
Warning
|
This is a sample application and the code may not be following the best practices to prevent SQL injection, cross-side scripting attacks, escaping parameters, and other similar features expected of a robust enterprise application. This is intentional such as to stay focused on explaining the technology. It is highly recommended to make sure that the code copied from this sample application is updated to meet those requirements. |
The attendees will start with an existing maven application and by following the instructions and guidance provided by this lab they will:
-
Read existing source code to gain an understanding of the structure of the application and use of the selected platform technologies.
-
Add new and update existing code with provided fragments in order to demonstrate usage of different technology stacks in the Java EE 7 platform.
While you are copy/pasting the code from this document into NetBeans, here are couple of tips that will be really useful and make your experience enjoyable!
- Source Code Formatting
-
NetBeans provides capability to neatly format the source code following conventions. This can be done for any type of source code, whether its XML or Java or something else. It is highly recommended to use this functionality after the code is copy/pasted from this document to the editor. This keeps the code legible.
- Automatic Imports
-
Copy/pasting the Java code from this document in NetBeans editor does not auto-import the classes. This is required to be done manually in order for the classes to compile. This can be fixed for each missing import statement by clicking on the yellow bulb shown in the side bar.
Alternatively all the imports can be resolved by right-clicking on the editor pane and selecting ``Fix Imports'' as shown.
This functionality is also accessible using the following keyboard shortcuts:
Shortcut Operating System Command+Shift+I
OSX
Ctrl+Shift+I
Windows
Ctrl+Shift+I
Linux
The defaults may work in most of the cases. Choices are shown in case a class is available to import from multiple packages. If multiple packages are available then specific packages to import from are clearly marked in the document.
Following the complete instructions in this document can take any where from two to four hours. The wide time range accommodates for learning the new technologies, finding your way in NetBeans, copy/pasting the code, and debugging the errors.
The recommended flow is where you follow through the instructions in all sections in the listed sequence. Alternatively, you may like to cover section [walk-through] through [jsf] in an order of your choice, based upon your interest and preference of the technology. However section [jaxrs] is a pre-requisite for [json].
Here is an approximate time estimate for each section:
| Section Title | Estimated Time |
|---|---|
15 - 30 mins |
|
30 - 45 mins |
|
30 - 45 mins |
|
30 - 45 mins |
|
30 - 45 mins |
|
30 - 45 mins |
|
30 - 45 mins |
The listed time for each section is only an estimate and by no means restrict you within that. These sections have been completed in much shorter time, and you can do it too!





