J2EE[tm] Blueprints > Java[tm] Pet Store > Configuring order confirmation e-mail

Configuring order confirmation e-mail

The Java Pet Store can be configured to send a confirmation e-mail to a customer 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 two ways to enable order confirmation e-mail:

  1. Use the J2EE Reference Implementation deployment tool.

  2. Edit the deployment descriptors manually.


Note: These instructions use $JPS_HOME (UNIX) and %JPS_HOME% (Win32) to denote the root directory of the J2EE Blueprints bundle.

Using the J2EE Reference Implementation deployment tool

Start the deployment tool and follow these steps.

  1. Open the application.

    From the File menu, select Open Application.... In the subsequent file dialog, open petstore.ear, which can be found in $JPS_HOME (UNIX) or %JPS_HOME% (Win32).

  2. Enable confirmation mail.

    In the Local Applications tree, select petstore > Petstore EJB Component > TheShoppingClientController.

    In the inspector, select the Environment tabbed pane. Set the value of the ejb/mail/SendConfirmationMail entry to true.

    Select Save from the File menu.

  3. Configure the mail settings.

    Go back to the Local Applications tree, and select petstore > Mail Component > TheMailer.

    In the inspector, select the Resource Ref's tabbed pane. Select the mail/MailSession entry, which will enable the Deployment Settings box below. Change the value of the Host field to the name of your local SMTP server. Change the value of the User Name field to the name you use to access that server.

    Select Save from the File menu.

  4. Deploy the application.

    If the application is currently deployed, undeploy it. Select petstore from the Server Applications list, and click the Undeploy button.

    To deploy or redeploy the application, select Deploy Application from the Tools menu. Click through the subsequent dialogs to complete the deployment. You shouldn't have to change any of the default values.

  5. Test the configuration.

    Visit the Java Pet Store and create a new user. Make sure to set it up with a valid e-mail address (or, choose an existing user with a valid email address). Don't log in with the j2ee account, since it has a fictitious e-mail address.

    To visit the store, click the following link:

    http://localhost:8000/estore/

Note: These instructions assume that the application is deployed on a machine named localhost and port 8000. You should substitute localhost and 8000 with the name of the machine and the port on which the application is deployed.

Editing the deployment descriptors manually

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

  1. Edit the static EJB deployment descriptor to enable confirmation mail.

    Go to the directory $JPS_HOME/src/petstore/src/ (UNIX) or %JPS_HOME%\src\petstore\src\ (Win32), and open the file estore_ejb.xml.

    Look for these lines:

    <env-entry>
      <env-entry-name>ejb/mail/sendConfirmationMail</env-entry-name>
      <env-entry-type>java.lang.Boolean</env-entry-type>
      <env-entry-value>false</env-entry-value>
    </env-entry>

    Change the value of the env-entry-value entry to true.

  2. Edit the runtime EJB deployment descriptor (for the J2EE Reference Implementation) to configure the mail settings.

    Go to the directory $JPS_HOME/src/petstore/src/ (UNIX) or %JPS_HOME%\src\petstore\src\ (Win32), and open the file estore_ejbruntime.xml.

    Look for these lines:

    <mail-configuration>
      <name>YourName</name>
      <mail-from>orders@javapetstoredemo.com</mail-from>
      <mail-host>YourMailServer</mail-host>
    <mail-configuration>

    Change the value of the mail-host entry to the name of your local SMTP server. Change the value of the name entry to the name you use to access that server.

  3. Build and deploy the application.

    Build the application and deploy the mail-enabled Java Pet Store.


Copyright © 2001 Sun Microsystems, Inc. All Rights Reserved.