Plants by WebSphere |
|
|
![]() |
|
Run | Configure | Technotes | Javadoc | Build with Ant |
Getting started |
Locating database tables |
Locating source code |
Reviewing coding notes |
You can create a unique e-mail address and password for the Plants by WebSphere Sample by clicking register for your own account here on the Login page. In addition, a default e-mail address and password exist for the Plants by WebSphere Sample that is presented in the following table:
E-mail address | plants@plantsbywebsphere.ibm.com |
Password | plants |
The database tables for this Sample are CUSTOMER, INVENTORY, ORDERINFO, ORDERITEM, IDGENERATOR, BACKORDER, and SUPPLIER. These tables are found in the PLANTSDB database. The PLANTSDB database is in the PlantsByWebSphere.ear file, and is located in the profile_root/installedApps/cell name/PlantsByWebSphere.ear/Database/PLANTSDB directory, where cell name is the name of the cell where your application is installed.
View the table layout in the following SQL statements:
CREATE TABLE CUSTOMER ( CUSTOMERID VARCHAR(250) NOT NULL, PASSWORD VARCHAR(250), FIRSTNAME VARCHAR(250), LASTNAME VARCHAR(250), ADDR1 VARCHAR(250), ADDR2 VARCHAR(250), ADDRCITY VARCHAR(250), ADDRSTATE VARCHAR(250), ADDRZIP VARCHAR(250), PHONE VARCHAR(250)); |
Locate the source code in the
z/OS customers: The source code tree for Samples is not provided on the z/OS platform because Sample applications are not built on the z/OS platform.
Overview |
Servlets |
Enterprise beans |
The Plants by WebSphere Sample incorporates the following technologies:
The Plants by WebSphere application is supported through a series of JSP pages and HTML pages. These pages communicate with the following servlets: AccountServlet, ShoppingServlet, ImageServlet, and AdminServlet. The servlets use the various enterprise bean business methods, which in turn, access data from the database as needed. In general, stateless session beans are used to interface with the entity beans, in order to reduce the number of transactions.
The following section provides information on the servlets used in this application.
The ShoppingServlet servlet processes the majority of interactions between the browser and the enterprise beans. This interaction includes inventory, shopping cart, and order functions. Selecting a shopping category to browse uses a Catalog session bean, to find and display all of the relevant Inventory objects. Displaying the details of an item is also performed using a Catalog session bean to obtain information from an Inventory CMP entity bean.
Adding an item to the shopping cart creates a ShoppingCart stateful session bean. A Catalog session bean obtains the Inventory data, and places the item in the ShoppingCart bean. Viewing and updating the shopping cart is done using the ShoppingCart stateful session bean.
After entering billing and shipping information, the ShoppingCart bean creates a new Order CMP entity bean. Upon completing the checkout procedure, a Mailer stateless session bean is created to send a confirmation e-mail, using the JavaMail API.
The ImageServlet servlet obtains and places product images into the database. The servlet obtains images from the JSP pages and the HTML pages from the database and serves back to the browser through the HTTP response.
The AdminServlet servlet processes the requests from a user (browser) for database re-population.
When processing re-populate requests from the help.jsp page, the AdminServlet servlet creates a bean-managed persistence (BMP) bean called ResetDB. This bean deletes all database tables and re-populates the tables with initial data values from the pbw.properties properties file.
The following section provides information on the enterprise beans used in this application.
Catalog is a stateless session bean. It is the primary access to the Inventory container-managed persistance entity bean (CMP). Stateless session beans generally access entity bean data, while limiting the number of transactions used. The Catalog session bean has business methods to obtain information from one or more Inventory beans. Methods exist to add and remove an Inventory item. The Catalog session bean also has methods to modify existing Inventory beans.
Customer is a CMP entity bean. It contains and manages the account data needed for a customer. The Customer entity bean has methods for creating, finding, and updating customer information, as well as verifying a password and getting fields in the Customer entity bean.
Inventory is a CMP entity bean. This entity bean contains and manages inventory item data. Methods are available for finding, creating, getting, and setting data fields.
Login is a stateless session bean. This session bean interfaces with the Customer CMP entity bean to create and update customer accounts.
Mailer is a stateless session bean. This session bean creates and sends an order confirmation e-mail using the JavaMail API.
Order is a CMP entity bean. This session bean contains and manages order data. Methods are available for finding, creating, and getting data fields.
OrderItem is a CMP entity bean. This entity bean contains and manages a single order item. Methods are available for finding, creating, and getting data fields.
ReportGenerator is a stateless session bean. This session bean generates reports based on information found in orders. The ReportGenerator session bean interfaces with the Order CMP entity bean. The reports consist of top-selling items for a set date range, and top-selling zip codes for a set date range.
ShoppingCart is a stateful session bean. This session bean maintains a list of inventory items to purchase throughout the HTTP session. The ShoppingCart session bean has business methods to add, remove, and update inventory items. The ShoppingCart session bean also has a method to create a new Order CMP entity bean when the customer is ready to complete a purchase.
ResetDB is a BMP entity bean. This entity bean deletes all rows in the database tables.