J2EE Blueprints

Java TM Pet Store

 installation and configuration
   setting up order confirmation email
 
The Java Pet Store demo can be configured to send a confirmation e-mail to a customer at when an order is completed. This feature is turned off by default. E-mail order notification uses the mail services of the J2EE platform, and can be enabled at deployment time. This document describes the steps necessary to turn on e-mail order notification.
  1. Turn on the ShoppingClientController's sendConfirmationMail property.
    Start the deploytool. Choose File -> New Application and select the file jps1.1/petstore.ear Click on the ShoppingClientController icon, then click on the Environment tab. Change the sendConfirmationMail to true. Choose Save from the File menu.
  2. Configure the Mailer bean's mail server host name.
    Click on the TheMailer EJB icon, click on the Resource Ref's tab. Click on one of the fields in the MailSession reference, such as application, to enable the Deployment settings box at the bottom of the Resource Ref's pane. In the Deployment Settings Box change the host field from yourMailServerHostName to the host name of your local mail server. Choose Save from the File menu.
  3. Deploy the store.
  4. Click on Tools menu, click Deploy Application, and go through the dialog boxes to complete the deployment.

  5. Test the configuration.
    Create a new user, being sure to include a valid email address (or, choose an existing user with a valid email address). Don't use the default j2ee user name and password at the login page of the pet store, since it has a fictitious email address. If the application is currently running, you can click here to open a new window to the login screen, where you can create the new user. Sign in as the new user, and complete a purchase. You will receive an email confirming your purchase.


Note: If you are tinkering with the source code, you can also enable order notification by following these steps:

  1. Modify the estore_ejb.xml file so that the env-entry-value of sendConfirmationMail is true:
          <env-entry-name>sendConfirmationMail</env-entry-name>
          <env-entry-type>java.lang.Boolean</env-entry-type>
          <env-entry-value>true</env-entry-value>
  2. Modify the file estore_ejbruntime.xml so that the yourMailServerHostName is replaced with the host name of your local mail server:
          <mail-configuration>
             <name>j2ee</name>
             <mail-from>orders@javapetstoredemo.com</mail-from>
             <mail-host>yourMailServerHostName</mail-host>
          </mail-configuration>

  3. (deploytool does essentially these same things.) Rebuild the jps1.1 source code and deploy the mail-enabled pet store.