Getting Started with Enterprise JavaBeans™

G

Appendix C

Tutorial Home Section Home Previous Section Next

Get

Get

About the Example Applications

Figure C-1: The "Alice's World" Site
Alice's World Site      When trying to decide on example code to illustrate the material presented in Getting Started with Enterprise JavaBeans, I wanted something that was conceptually simple, but had the functionality required in real world applications. In addition, the examples should reinforce and add to the tutorial text, and possibly bring some amusement to what can be dead boring, detailed technical information. Last, I wanted no shopping carts! While shopping carts are great, sometimes it seems that every article or tutorial uses them for example apps. There actually are other things being done with J2EE.

     The result is the "Alice's World" site. Alice's World presents three applications: a metric/English measure conversion program, a survey program, and a program to display the results of the survey. These applications exhibit the functionality required in nearly every real program: gather data, process it, store it, and display the resulting information. The client applications are all servlet/JSP based. While a detailed explanation of the programs is "beyond the scope of the tutorial" — that favorite technical author's excuse, but the tutorial is, after all, about Enterprise JavaBeans — I felt that a section describing the rationale and flow of the examples was warranted. That's particularly true for the survey application, because it is revisited three times in the tutorial — much as happens while developing an application in the field. Each revision adds to or refines the application until it is complete. Each revision also introduces a different type of bean into the mix. You can see the applications in action before, or instead of, deploying them yourself at conceptGO's Community page.

     The bean and client applications for the Metric Converter are deployed separately. This is what should happen in the real world: EJBs, and all of our code really, should aim for decoupling and reusability as much as possible. In the Survey and Survey Results applications, the client and associated beans are deployed together, mostly for administrative reasons, but the beans can still be accessed by other clients.

     You may notice that the application tasks could have been done without using EJBs or J2EE at all, but the design seemed justified for the tutorial. If I had included a "J2EE-worthy" application, you would be reading this six months later and 600 pages longer. In that scenario, the material may well have lost its focus. However, you should keep this critical mindset when designing your own applications, to avoid the "When you have a hammer..." syndrome, and to use the proper tools and techniques for useful, efficient, and effective applications.


     Deploying the Alice Application
     So, remember Alice? The Alice's World page is a small JSP that primarily invokes the sample applications. If there had not been the need to have a vehicle to execute the program that creates and resets the database, it could have been just an HTML page. It does provide the opportunity to take our first look at deploying a J2EE application. If you prefer, you can take the easy route: after downloading the source code, start J2EE and deploytool, copy Alice.ear from the Alice/prod directory to the Alice directory, and open Alice.ear in deploytool. Select the "Alice" application, then "Deploy" from the Tools menu. You can also deploy any or all of the other applications, including the beans, using the same method: copy the appropriate EAR from the example directory's prod directory, open the EAR in deploytool, then select the "Deploy" menu item, and continue at the step labeled Deployment.

     To deploy the Alice application from scratch, follow these directions:


     Create new application
     Create new Web component
     Deployment

     We can now actually deploy the Alice application:

     The Alice application is deployed.


     If you look in the Alice folder, you will see that it now contains Alice.ear. To run Alice, start your browser and enter http://localhost:8000/Alice; you should see the Alice home page as depicted in Figure C-1. Understand that none of the example applications have been deployed yet, so you can't do anything but look at the Alice display for now. The other applications will be deployed in the appropriate example sections of the tutorial.



Tutorial Home Section Home Previous Section Next