Java™ Pet Store Demo 1.4 > Configuring the Demo |
By default, Petstore is set to connect to a server running on localhost
at port 8080. If you've installed the
Application Server using a different HTTP Server port than default 8080
port, you must modify runtime XML files to match this modified
port value accordingly.
To change the port to which Petstore connects, open the following
files in a text editor. (If you edit these files you
ensure that each
time you rebuild the application, the changes are permanent. However,
you
must rebuild the application after following these instructions.)
NOTE:
You must do this before you proceed with compiling/deploying.
Change all instances of "8080" to match your new default HTTP Server port number used
during installation. Files to be modifed to match your default HTTP Server port number are:
<petstore.home>/src/components/catalog/src/sun-ejb-jar.xml
<petstore.home>/src/apps/supplier/src/sun-ejb-jar.xml
<petstore.home>/src/apps/opc/src/sun-ejb-jar.xml
<petstore.home>/src/apps/petstore/src/docroot/WEB-INF/sun-web.xml
For example, if you changed default port from 8080 to 80
during installation, look for
the following XML entry in file <petstore.home>/src/apps/petstore/src/docroot/WEB-INF/sun-web.xml
<resource-ref>
<res-ref-name>url/CatalogDAOSQLURL</res-ref-name>
<jndi-name>http://localhost:8080/petstore/CatalogDAOSQL.xml</jndi-name>
</resource-ref>
which needs to be changed to become:
<resource-ref>
<res-ref-name>url/CatalogDAOSQLURL</res-ref-name>
<jndi-name>http://localhost:80/petstore/CatalogDAOSQL.xml</jndi-name>
</resource-ref>
Replace all occurrences of localhost
and 8080
with the name of the host and the port on which the server is running
in each of these files.
To set up e-mail notifications using the J2EE SDK deployment tool , follow these steps:
The Open Object dialog appears.
Find <petstore.home>/opc.ear (or <petstore.home>/src/apps/opc/build/opc.ear if you built the EAR) and click Open Object.
The OPC EAR appears in the Applications tree on the left panel.
In the inspector on the right panel, select the Env. Entries tab.
Select the param/SendApprovalMail entry, and set its value to true.
In the inspector on the right panel, select the Env. Entries tab.
Select the param/SendConfirmationMail entry, and set its value to true.
In the inspector on the right panel, select the Env. Entries tab.
Select the param/SendCompletedOrderMail entry, and set its value to true.
In the inspector on the right panel, select the Resource Refs tab.
Select the mail/MailSession entry and edit the deployment settings at the bottom of the panel:
Change the Host field to the name of the mail server through which the confirmation e-mails should be sent.
Change the User Name to the name you use to access the mail server.
From the main menu, select File -> Save.
Using a text editor, open <petstore.home>/src/apps/opc/src/ejb-jar.xml
Enable order approval notifications.
Look for these lines:
<env-entry>Ensure that the env-entry-value entry is set to true .
<env-entry-name>param/SendApprovalMail</env-entry-name>
<env-entry-type>java.lang.Boolean</env-entry-type>
<env-entry-value>true</env-entry-value>
</env-entry>
Enable order confirmation notifications.
Look for these lines:
<env-entry>Ensure that the env-entry-value entry is set to true .
<env-entry-name>param/SendConfirmationMail</env-entry-name>
<env-entry-type>java.lang.Boolean</env-entry-type>
<env-entry-value>true</env-entry-value>
</env-entry>
Enable order completion notifications.
Look for these lines:
<env-entry>Ensure that the env-entry-value entry is set to true .
<env-entry-name>param/SendCompletedOrderMail</env-entry-name>
<env-entry-type>java.lang.Boolean</env-entry-type>
<env-entry-value>true</env-entry-value>
</env-entry>
Save your changes to the standard EJB deployment descriptor.
Open the application's build.properties file.
Using a text editor, open <petstore.home>/src/build.properties .
Configure the mail service.
Look for these lines:
mail.host=localhost
mail.username=petstore
mail.fromaddress=petstore@localhost.com
Change the value of the mail.host entry to the name of the mail server through which the confirmation e-mails should be sent.
Change the value of the mail.username entry to the name you use to access the mail server.
Rebuild the OPC EAR.
If you use the provided build files to rebuild the application, the OPC EAR is placed in <petstore.home>/apps/opc/build/opc.ear and copied to <petstore.home>/ for convience. (For more information on building the application, see Building the Demo.)
To test the e-mail notifications, visit the Storefront, create a new user with your e-mail address, and complete an order. If the order is approved, you will receive an e-mail. You will receive one or more e-mails as parts of the order are fulfilled. When the order is completely fulfilled, you will receive one final e-mail. (For more information on how orders work in the pet store application, see Using the Demo.)
To add another localization, follow these steps:
Place these in the subdirectory <petstore.home>/src/apps/petstore/src/docroot/<locale.code>/ , where <locale.code> is the string representation of the locale.
For example, the JSP pages for the Japanese localization are located in the directory <petstore.home>/src/apps/petstore/src/docroot/ ja/.
Create a localized screen definitions file.
Place the screen definitions (which use your localized JSP pages, of course) in a file called <petstore.home>/src/apps/petstore/src/docroot/WEB-INF/screendefinitions_<locale.code>.xml , where <locale.code> is the string representation of the locale.
For example, the Japanese screen definitions are stored in <petstore.home>/src/apps/petstore/src/docroot/WEB-INF/screendefinitions_ ja_JP.xml.
Add new catalog data for the locale.
The XML file <petstore.home>/src/apps/petstore/src/docroot/populate/Populate-UTF8.xml contains the data used to populate the pet store's database. Localizing the catalog for a particular language involves adding new data to this XML file.
To support localization, the CategoryDetails, ProductDetails , and ItemDetails elements take a xml:lang locale attribute. Before adding your own localized data, you may find it helpful to refer to the Japanese data in the XML file for examples.
The Storefront and Supplier applications in the Java Pet Store Demo
can be configured to use a different database from the default one
(Pointbase). Using a different database may require different SQL
statements (e.g. create table
, drop table
)
from the default ones. These statements can be specified by editing
some of the sample application's XML configuration files.
To configure the sample application to use a different database:
Add a new entry to the <petstore.home>/src/apps/petstore/src/docroot/populate/PopulateSQL.xml
configuration file.
Each database for which the sample application is configured has
a DatabaseStatements
entry, which contains fragments
for performing various SQL operations on the application's database
tables. For example, here is a fragment from the default (Pointbase)
entry:
<DatabaseStatements database="pointbase">
<TableStatements table="category">
<CheckStatement>
select * from category
</CheckStatement>
<CreateStatement>
create table category (catid char(10) not null,
constraint pk_category primary key (catid))
</CreateStatement>
<InsertStatement>
insert into category values (?)
</InsertStatement>
<DropStatement>
drop table category
</DropStatement>
</TableStatements>
...
To create a new DatabaseStatements
entry for a
different database, it is easiest to copy the default entry and edit
the fragments in the new copy. Note that each DatabaseStatements
entry has a database
attribute uniquely identifying the
database to which it belongs. So, before editing the new copy, make
sure to change the value of this attribute to a unique identifier.
Remember this identifier as you complete the rest of these steps.
When editing the new DatabaseStatements
entry,
edit only the fragments. The sample application expects certain
elements and attributes in this file. Also, make sure that the
parentheses are balanced.
Add a new entry to the <petstore.home>/src/apps/petstore/src/docroot/CatalogDAOSQL.xml
configuration file.
Each database for which the sample application is configured has
a DAOStatements
entry, which contains fragments for
performing select
statements on the application's
database
tables. For example, here is a fragment from the default (Pointbase)
entry:
<DAOStatements database="pointbase">
<SQLStatement method="GET_CATEGORY">
<SQLFragment parameterNb="2">
select name, descn
from category a, category_details b
where a.catid = b.catid and locale = ? and a.catid = ?
</SQLFragment>
</SQLStatement>
<SQLStatement method="GET_CATEGORIES">
<SQLFragment parameterNb="1">
select a.catid, name, descn
from category a, category_details b
where a.catid = b.catid and locale = ? order by name
</SQLFragment>
</SQLStatement>
...
To create a new DAOStatements
entry for a
different database, it is easier to copy the default entry and edit the
fragments in the new copy. Note that each DAOStatements
entry has a database
attribute uniquely identifying the
database to which it belongs. So, before editing the new copy, make
sure to change the value of this attribute to the unique identifier you
chose in step 1.
When editing the new DAOStatements
entry, edit
only the fragments. The sample application expects certain elements and
attributes in this file. Also, make sure that the parentheses are
balanced.
Edit the Storefront's Web deployment descriptor, <petstore.home>/src/apps/petstore/src/docroot/WEB-INF/web.xml
.
Look for the following entry:
<init-param>
<param-name>Database</param-name>
<param-value>pointbase</param-value>
</init-param>
Change the value of the param-value
sub-entry to
the
unique identifier you chose in step 1.
Also look for the following entry:
<env-entry>
<env-entry-name>param/CatalogDAODatabase</env-entry-name>
<env-entry-value>pointbase</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Change the value of the env-entry-value
sub-entry to
the unique identifier you chose in step 1.
Edit the catalog component's EJB deployment descriptor, <petstore.home>/src/components/catalog/src/ejb-jar.xml
.
Look for the following entry:
<env-entry>
<env-entry-name>param/CatalogDAODatabase</env-entry-name>
<env-entry-value>pointbase</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Change the value of the env-entry-value
sub-entry to
the unique identifier you chose in step 1.
You also have the option of changing the catalog and inventory
information used to populate the sample application's database. To
modify this data, edit the file <petstore.home>/src/apps/petstore/src/docroot/populate/Populate-UTF8.xml
.
Configuring for use with the Oracle Database (using TYPE 4 JDBC driver for Oracle from i-net)
The product application requires the following database setup prior to running:
See the Application Server Release Notes for database version requirements.
Register JDBC DriverCreate
a new Oracle JDBC Connection Pool
If you have followed the instructions for Compiling, Assembling and Deploying the Application against the PointBase server then:
The correct
values for Oracle host (oracleInet.host),
port (oracleInet.port), sid (oracleInet.dbname), user (oracleInet.user), and password (oracleInet.passwd)should first
be specified in <install_dir>/samples/database.properties
Set default.database
as
oracleInet in
the same file.
Run the Sample
Application
You may now
run the application again using the steps under Running the Sample
Application section.
Before deploying or rebuilding this application on an instance of Sun Java System Application Server 8.1 that was installed as part of JES, please follow the steps listed in Section 10 of this file.
Copyright © 2004 Sun Microsystems, Inc. All Rights Reserved.