|
|
Oracle Sequence Bean Sample Application
This topic includes the following sections:
How the Oracle Sequence Bean Sample Works
This sample demonstrates creating unique identication numbers using EJBs. You could use these techniques when you create entity beans, which require a unique primary key. This sample uses a container-managed persistence (CMP) based entity bean with a JDBC connection pool to demonstrate the use of the Oracle database's sequence procedure to create unique primary keys. This sample depends on system tables that are shipped with Oracle.
This sample shows:
The Oracle sequence bean sample application implements the following classes:
Class |
Description |
---|---|
Client |
This class demonstrates calling an entity bean, followed by creating two new accounts with an opening balance and an automatically-generated primary key. |
OracleBean |
This is the container-managed persistence based entity bean that uses a database table to create unique keys. |
OraclePK |
This class serves as the interface of the primary key for the OracleBean EJB. |
Building and Running the Oracle Sequence Bean Sample
To build and run the Oracle sequence bean sample application, complete the following steps:
The following sections describe these steps, and also explain the following:
Verifying the Settings of the Environment Variables
Before building and running the sample application, you need to ensure that certain environment variables are set on your system. In most cases, these environment variables are set as part of the installation procedure. However, you need to check the environment variables to ensure they reflect correct information.
Table 5-1 lists the environment variables required to run the Oracle sequence bean sample application.
Table 5-1 Environment Variables
Environment Variable |
Description |
---|---|
TUXDIR |
The directory path where you installed the WebLogic Enterprise software. For example: Windows NT TUXDIR=c:\wledir UNIX TUXDIR=/usr/local/wledir |
JAVA_HOME |
The directory path where you installed the JDK software. For example: Windows NT JAVA_HOME =c:\JDK1.2 UNIX JAVA_HOME =/usr/local/JDK1.2 |
ORACLE_HOME |
The directory path where you installed the Oracle software. For example: ORACLE_HOME=/usr/local/oracle You need to set this environment variable on UNIX operating systems only. |
You may optionally set the following system environment variables to change their default value prior to running the Oracle sequence bean sample application runme command. See the Administration Guide for more information about selecting appropriate values for these environment variables.
Table 5-2 lists the optional environment variables required to run the Oracle sequence bean sample application.
Table 5-2 Optional Environment Variables
Environment Variable |
Description |
---|---|
HOST |
The host name portion of the TCP/IP network address used by the ISL process to accept connections from Java clients. The default value is the name of the local machine. |
PORT |
The TCP port number at which the ISL process listens for incoming requests; it must be a number between 0 and 65535. The default value is 2468. |
IPCKEY |
The address of shared memory; it must be a number greater than 32769 unique to this application on this system. The default value is 55432. |
DB_INSTANCE |
Name of the database instance or server. The default value for Oracle is Beq-Local. This is needed only for the samples that use a database. |
DB_USER |
Name of the database user. The default is scott. This is needed only for the samples that use a database. |
DB_PASSWORD |
Password for the database user. The default is tiger. This is needed only for the samples that use a database. |
DB_DRIVER |
The Java class name of the database driver. The default is the Oracle 8i driver, weblogic.jdbc20.oci815.Driver.This is needed only for the samples that use a database. |
DB_URL |
Database connection URL. The default for Oracle is jdbc:weblogic:oracle:Beq-Local. If the database instance is not named, set DB_INSTANCE to null. This is needed only for the samples that use a database. |
Verifying the Environment Variables
To verify that the information for the environment variables defined during installation is correct, complete the following steps:
Windows NT
The Control Panel appears.
The System Properties window appears.
The Environment page appears.
UNIX
ksh prompt>printenv TUXDIR
ksh prompt>printenv JAVA_HOME
Changing the Environment Variables
To change the environment variable settings, complete the following steps:
Windows NT
The Control Panel appears.
The System Properties window appears.
The Environment page appears.
UNIX
ksh prompt>export TUXDIR=directorypath
ksh prompt>export JAVA_HOME=directorypath
Copying the Files for the Oracle Sequence Bean Sample Application into a Work Directory
You need to copy the files for the Oracle sequence bean sample application into a work directory on your local machine. The following steps describe how to copy all the example files into a work directory.
prompt>ksh
ksh prompt>
Windows NT
%TUXDIR%\samples\j2ee\ejb\sequence\oracle
UNIX
$TUXDIR/samples/j2ee/ejb/sequence/oracle
The files copied into the work directory are in two categories:
Table 5-3 lists and describes all the files for this sample application.
Table 5-3 Sample Application Files
File |
Description |
---|---|
ejb-jar.xml |
The XML deployment descriptor file used to help add the bean to the EJB container. |
weblogic-ejb-extensions.xml |
A file containing the WebLogic Enterprise extensions to the deployment descriptor DTD. |
Client.Java |
The Java source code for the client application. |
OracleBean.java |
The Java source code for the entity bean that uses container-managed persistence. This class contains the business logic method implementations and methods required by the EJB specification 1.1. |
Oracle.java |
The Java source code for the remote interface of the OracleBean class. |
OracleHome.java |
The Java source code for the home interface of the OracleBean class. |
OraclePK.java |
Primary key for the bean. |
ProcessingErrorException.java |
Application-specific exception thrown by the OracleBean class for business methods. |
index.html |
File containing these instructions. |
Table 5-4 lists and describes the utility files for this sample application. These files are generated based on the WebLogic Enterprise installation environment. The following files are generated in the same directory as where the source files are found.
Table 5-4 Utility Files
File |
Description |
---|---|
runme.cmd |
The Windows NT batch file that contains commands to set the environment, boot the server, and execute the client for this sample. |
runme.ksh |
The UNIX Korn shell script that contains commands to boot the server and execute the client for this sample. |
run_client.cmd |
The batch file to run the client application on Windows NT systems. |
run_client.ksh |
The script file to run the client on UNIX systems. |
setenv.cmd |
The batch file to set the necessary environment variables on Windows NT systems. |
setenv.ksh |
The script file to set the necessary environment variables on UNIX systems. |
ubbconfig |
The WebLogic Enterprise server configuration file to be used on UNIX systems. |
ubbconfig.nt |
The WebLogic Enterprise server configuration file to be used on Windows NT systems. |
ejb_sequence_oracle.jar |
The EJB JAR file that contains the source file classes, the container-specific class files generated by the ejbc command, and the deployment descriptor files. This is the EJB JAR file that is deployed on the WebLogic Enterprise server. |
Changing the Protection Attribute on the Files for the Oracle sequence Bean Sample Application
During the installation of the WebLogic Enterprise software, the sample application files are marked read-only. Before you can edit or build the files in the Oracle sequence bean sample application, you need to change the protection attribute of the files you copied into your work directory, as follows:
Windows NT
prompt>attrib /S -r drive:\workdirectory\*.*
UNIX
prompt>ksh
ksh prompt>chmod +w /workdirectory/*.*
On the UNIX operating system platform, you also need to change the permission of runme.ksh and clean.ksh to give execute permission to those files, as follows:
ksh prompt>chmod +x *.ksh
Creating Database Records to Use With the Sample
Before you run the Oracle sequence bean sample application, make sure you do the following:
"create sequence ejbSequence start with 8001"
*** DATABASE INFORMATION SPECIFIC TO INSTALLATION SITE ***
The values you need to provide are for the database URL, user, and password.
Executing the runme Command
The runme command automates the following steps:
To build and run the stateless session bean sample application, make sure you have copied the scripts described in Before you Build and Run the EJB Sample Applications, and enter the runme command, as follows:
Windows NT
prompt>cd workdirectory
prompt>runme sequence oracle
UNIX
ksh prompt>cd workdirectory
ksh prompt>./runme.ksh sequence oracle
A number of messages are displayed, along with whether or not the build procedure was successful. Note that the sample is not only built, but also the servers are booted and the client is run once.
Running the Sample Manually
After you have executed the runme command, you can run the sample manually if you like. To run the samples manually, complete the following steps:
Windows NT
prompt>setenv
UNIX
prompt>. ./setenv.ksh
Windows NT
prompt>tmboot -y
prompt>run_client.cmd
UNIX
prompt>tmboot -y
prompt>./run_client.ksh
Processes and Files Generated by the Sample Application
When the you enter the tmboot command to start the Oracle sequence bean sample application, the following server processes are started:
The BEA Tuxedo system Event Broker.
The following TMFFNAME processes are started:
The JavaServer takes one or more EJB JAR files that were created for the application.
The IIOP Listener/Handler.
Stopping the Sample Application
You can stop the Oracle sequence bean sample application by entering the following command:
prompt>tmshutdown -y
Oracle Sequence Bean Javadoc
The Javadoc for the Oracle sequence bean example is in the following location:
Windows NT
%TUXDIR%/samples/j2ee/ejb/sequence/oracle/index.html
UNIX
$TUXDIR\samples\j2ee\ejb\sequence\oracle\index.html
If you are viewing this document in a browser, you can click the following link to display this Javadoc:
Package samples.j2ee.ejb.sequence.oracle
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|