$Id: index.html,v 1.2 2007/01/31 04:36:32 chalin Exp $
Tutorial 4
Abstract
In this tutorial, you will explore more advanced EA patterns used in the data source layer.
Prerequisites and setup
- Ensure that you have successfully completed tutorials 1, 2 and 3 since this tutorial also makes use of them.
- Since you will be using the database, setup an ssh shell with a tunnel to stu.encs.
- Launch Eclipse and load tutorial 04 from CVS.
- Initialize your MySQL database on stu.encs with tables and data for this tutorial.
- In Eclipse, setup your MyResources.properties file, if that hasn't been done already.
Greeting Carl!
- In Eclipse, launch the Tomcat Server on this tutorial's project.
- When asked for a name, enter "Carl" and submit.
- A greeting will be given for Carl along with information about his age an buddy, if any.
- You can also test the servlet in an external web browser by visiting the following URL: http://localhost:8080/344tutorial04.
- The SQL initialization file for this tutorial sets up a Person table with three entries, two of which are for our friends Alice and Bob. Note that Alice is Bob's buddy and Bob is Alice's buddy.
Greeting Alice
- In the Eclipse or browser window, select the back link and then enter "Alice" as a name.
- You will notice that the servlet will seem to take long to respond. It should eventually report an error. Which error is it?
- Figure out what has gone wrong simply by writing a sequence diagram of the messages that are exchanged when the name "Alice" is entered.
Fixing the problem
To fix the problem, you will be required to implement the following two patterns (which were explained in class):
- A Person Identity Map. (While not strictly necessary to solve the problem, it is always a good thing to have as it avoids other problems from cropping up.)
- Lazy Load via a virtual proxy.
Draw class diagram first and show it to the tutor for validation before you start coding.
Optional ...
- Finally move your servlet application to stu.encs.
- Visit http://user0XY.stu.encs.concordia.ca/servlet/ (where you replace user0XY by your user name).