|
WebLogic Server 6.1 Code Examples, BEA Systems, Inc. | |||||
See:
Description
| Interface Summary | |
| Artist | |
| ArtistHome | |
| Band | |
| BandHome | |
| FanClub | |
| FanClubHome | |
| MusicLibrary | |
| MusicLibraryHome | |
| Recording | |
| RecordingHome | |
| Class Summary | |
| ArtistBean | |
| BandBean | |
| BandInfo | |
| BandPK | |
| Client | |
| FanClubBean | |
| FanClubPK | |
| MusicLibraryBean | |
| RecordingBean | |
| RecordingInfo | |
| RecordingPK | |
This example is a package that demonstrates the use of local interfaces; one-to-one, one-to-many, many-to-many relationships; client.jar; automatic primary key generation; and automatic table creation. It uses Enterprise JavaBeans written to the EJB 2.0 specification.
The example includes entity EJBeans calledArtistBean, BandBean, FanClubBean, and RecordingBean and a stateless session bean called MusicLibraryBean.
The example demonstrates:
The EJB 2.0 examples included in the WebLogic Server 6.1 distribution are not shipped pre-built. To run these examples, you must build the example following the specific examples instructions.
To get the most out of this example, first read through the sourcecode files.
The following four sections cover what to do:
We provide a build script for you to build the example:
The build script is build.xml.
Run the build script using the following Java ant command:
$ant
The script will build the example and place the files in thecorrect locations in your WebLogic Server distribution:
Running the build script places the EJB in /config/examples/applications, where it automatically deploys once the server is started. If you are already running the server and build another EJB, it is automatically placed in this directory and instantly deployed.
Additional information on using the build scriptsis found in Building Enterprise JavaBean examples
You will need to set up the persistent storage of theEJBeans. You will use a database for the persistent storage of the entity EJBeans. Each instance of an EJBean is written to a row in a table. Although most of the EJB examples in this release use the evaluation copy of the Cloudscape database, included with WebLogic Server, however, you will NEED to use Oracle to create the tables for this example. You must create these tables using the oracle.ddl file supplied with this example's package. These tables must exist in the database and be accessible before you can successfully build the example. Use the following instructions to create your tables:
java utils.Schema"jdbc:weblogic:oracle"weblogic.jdbc.oci.Driver-u rob-p young.\oracle.sql
where "jdbc:weblogic:oracle" is the URL for your database; weblogic.jdbc.oci.Driver is the name of the driver; u is the user ID; p is the password; and oracle.sql is the ddl file supplied with this example.
The following tables must be created and exist in the database before you run example:
Note that the persistent storage is completely invisible to theclient; the actual storage is handled automatically by the containerand not by the EJBean. All database properties, such as the loginname and password, are defined in the connection pool. A preconfigured Oracle connection pool is included in the example server.
A list of EJBs deployed on the server displays.
For your convenience, a sample connection pool, called oraclePool is included with this example. You can use this connection pool for this EJB example, however, you will need to make the following modifications:
# In the left pane, expand the Services node and choose JDBC.
# Click oraclePool to display the configuration information in the right pane.
# Click the Connections tab and view the attribute settings.
# Update the Name and URL information to reflect that name and URL of your Oracle database. The URL should be
URL=jdbc:weblogic:oracle,\
# Make sure that the Driver Classname is set correctly to the sample Oracle driver. The Driver Class name should be
DriverName=weblogic.jdbc.oci.Driver,\
# Revise the Properties and Password information as needed for your environment.
In this example, the fileRealm for the access control list (ACL) is preconfigured to allowaccess for everyone.
If you need more information about how to use connection pools, read UsingWebLogic JDBC: Using connection pools.
set CLASSPATH=%CLASSPATH%;.\BandEJBClient.jar
$ java examples.ejb20.bands.Client
If you're not running the WebLogic Server with its default settings,you will have to run the client using:
$ java examples.ejb20.bands.Client "t3://WebLogicURL:Port"
where:
Welcome to the Hipster Music Library...Added these bands...Band Name: Genesis Band Founder: Peter Gabriel startDate: 1969-12-31Band Name: Beastie Boys Band Founder: Mike Diamond startDate: 1981-12-31Band Name: Britney Spears Band Founder: Britney Spears startDate: 1997-12-31Band Name: Seth's Saxophone All-Stars Band Founder: Saxophone Seth startDate: 1998-11-12Added these Recordings...Recording: Title: Duke Band: Genesis Recording Date: 1982-03-05Recording: Title: Invisible Touch Band: Genesis Recording Date: 1985-03-05Recording: Title: Sounds of Science Band: Beastie Boys Recording Date: 1997-03-05Recording: Title: Licensed To Ill Band: Beastie Boys Recording Date: 1990-03-05Recording: Title: Paul's Boutique Band: Beastie Boys Recording Date: 1989-03-05Recording: Title: Britney's First Album Band: Britney Spears Recording Date: 1999-03-05Recording: Title: Saxophone Seth Plays the Blues Band: Seth's Saxophone All-Stars Recording Date: 2001-03-23Printing out Fan-Club Write-Up for each BandWrite-up for band: Genesis is: Genesis Fan ClubWrite-up for band: Beastie Boys is: Beastie Boys Fan ClubWrite-up for band: Britney Spears is: Britney Spears Fan ClubWrite-up for band: Seth's Saxophone All-Stars is: Seth's Saxophone All-Stars Fan ClubGood bye...
|
Documentation is available at http://e-docs.bea.com/wls/docs61 |
|||||