To help understand the role of each of the technologies in the J2EE specification, a single case study will be followed throughout the daily exercises. As you work through the 21 days, a functional implementation of a simple enterprise application will be developed.
The chosen case study is a simple Job Agency. Jobs are categorized by Location and Skills required for the job. Customers advertise jobs, and Applicants register their location and skills so they can be matched to jobs. Customers and applicants will be notified of job matches by e-mail.
To illustrate the relationships between the different components in the data model for the Agency, a traditional database ERD diagram is shown in Figure 2.16.
Today's exercise, which is described later, will be to create the database and register it as a javax.sql.DataSource to the J2EE RI.
The case study has a front office part with the following components:
Maintaining the location and job lookup tables
Adding customers and advertising jobs
Registering job applications
The back office part consists of the following:
Matching a new job against existing applicants
Matching a new applicant against existing jobs
The example code shown in each day's lesson will use the Customer functionality (jobs and invoices) from the case study. At the end of each day's work, you will be asked to enhance the case study by adding the Applicant functionality (registering jobs) to the system. A fully-worked solution for the exercises is provided on the CD-ROM included with this book, so that you will have a working case study if you choose to omit any day's exercise.
Note
Material for many days exercises, particularly JNDI, JavaMail, JMS and Java Connectors, will primarily use examples and exercises not related to the case study. The last two days' work discuss J2EE in the context of the wider context of Web applications and do not refer to the Agency case study.
Table 2.3 shows roughly what will be covered on each day. Don't worry if some of the terminology is new to you; all will become clear as you work your way through the book.
By the end of the course, you will have a simple, but working, job agency enterprise application. The agency will have both a GUI-based front end and a Web-based interface and will have given you a good grounding in the relative strengths of each J2EE technologies and how to apply them.
Developing J2EE architectures requires two disciplines:
Good analysis and design skills
Practical hands-on experience with the J2EE technologies
The first comes with time and experience, but the last few days lessons will help point you in the right direction to becoming a J2EE designer.
The second discipline comes with practice. If you read this book and attempt all the exercises, you will learn a lot more than if you just read the book and simply study the example code shown.
The case study exercises are not complex. They have been designed to take between 30 minutes and 2 hours to complete. The exercises only use information presented and your existing knowledge: you will need to know something about JDBC, Swing, and HTML, but you certainly don't need to be an expert in these technologies. The book “Teach Yourself Java in 21 Days” from SAMS Publishing is a good source for improving your knowledge of JDBC and Swing should you require a little refresher course. More importantly, the exercises will give you hands-on coding experience using J2EE.
On the CD-ROM included with this book, you will find all the Java software required to develop all of the code shown in this book.
The CD-ROM contains a directory called CaseStudy. All the example code solutions to the exercises are included in this directory.
There are 21 sub-directories corresponding to each days work. Each day will have one or more of the following directories:
Agency The complete Agency case study so far. This includes code from the examples in the book and the completed exercise if this is based on the case study.
Examples The code for all the example programs show in the book where these examples are not part of the case study.
Exercise Any existing code to be used as a starting point for the exercise. Typically, this will be the Agency case study, including all the example code in the book but excluding the code the reader needs to provide as part of the exercise.
Solution A solution to the set problem if the exercise does not enhance the Agency case study.
The Job Agency case study requires a small database for storing information about customers, jobs, applicants, and invoices. A Java program to create the database has been provided in the Day 2 exercises on the accompanying CD-ROM. The program uses the Cloudscape database provided with the J2EE RI and can easily be adapted to work with any JDBC compatible database.
Find the directory on the CD called CaseStudyDay02Exercise.
Inside this directory is a Java source file, class file, and two script files:
CreateAgency.java A source file for a program to create the Agency database under J2EE RI Cloudscape database.
CreateAgency.class The compiled Java class file for CreateAgency.java
CreateAgency.bat A Windows NT/2000 batch file to run the application to create the database
CreateAgency.sh Unix/Linux Bourne shell script to run the application to create the database
To create the Agency database, you will need write permission to the J2EE installation directory.
Follow the instructions shown earlier in today's lesson for stopping the Cloudscape and J2EE, servers and stop these servers if they are currently running. If you have installed J2EE as suggested, you simply have to enter the following commands from a command (or shell) window:
j2ee –stop cloudscape -stop
The Java CreateAgency program provided in the Day 2 exercises will create the necessary database files in a sub-directory called Agency. To create and install the database, you will need to do the following:
1. | Copy all the files from the Day 2 exercises directory CD-ROM to the cloudscape sub-directory of the J2EE SDK installation directory. |
2. | Change directories to the cloudscape sub-directory of the J2EE SDK home directory and then run the appropriate script program as follows: Under Windows, type cd %J2EE_HOME%cloudscape CreateAgency Under Linux/Unix, type cd $J2EE_HOME/cloudscape ./CreateAgency.sh A new sub-directory called Agency will be created under the current cloudscape directory. |
3. | Having created the database, you must now add a data source called Agency to J2EE (data sources are discussed on Day 4, “Introduction to EJBs”). Run the following command to add the data source (the same command is used for both windows and Linux/Unix): j2eeadmin -addJdbcDatasource jdbc/Agency jdbc:cloudscape:rmi:Agency;create=true If you have not included the J2EE bin directory in your program search path, you will have to run the command as shown below: Under Windows, enter the following command: %J2EE_HOME%inj2eeadmin -addJdbcDatasource jdbc/Agency jdbc:cloudscape:rmi :Agency;create=true Under Linux/Unix, enter the following command: |
Finally, restart the Cloudscape and J2EE servers as described in the earlier section, “Starting the J2EE Reference Implementation (RI).” Normally, you would start the J2EE server and Cloudscape database server in separate windows by using the following commands:
j2ee –verbose cloudscape -start
If you start the J2EE server as shown with the -verbose option, you will see the diagnostic output shown in Listing 2.4 (the line showing the Agency data source configuration is highlighted in bold).
You will test the Agency database configuration on Day 4 when you learn how to create and deploy a simple EJB.
Congratulations, you have installed J2EE successfully and completed today's exercise to configure the Agency database for use with the other exercises in this book.
3.145.179.35