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.
- 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.
- 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.
- Deploy the store.
Click on Tools menu, click Deploy
Application, and go through the dialog boxes to complete
the deployment.
- 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:
- 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>
- 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>
-
(
deploytool does essentially these same things.)
Rebuild
the jps1.1 source code and deploy the mail-enabled pet store.
|