|
Home TOC Index |
|
Search
Feedback |
Resource Adapter Tutorial
This tutorial shows how to deploy the black box resource adapter stored in the
blackbox-tx.rarfile. To test the resource adapter, you will modify theexamples/src/ejb/savingsaccount/SavingsAccountBean.javafile so that it accesses the Cloudscape database through the resource adapter. TheSavingsAccountBean.javafile is also used in another example; see Running the SavingsAccountEJB ExampleSetting Up
- Start the J2EE server.
j2ee -verbose- Follow the instructions in the section, Setting Up the Database.
Deploying the Resource Adapter
- Deploy a black box resource adapter that is packaged in the
blackbox-tx.rarfile.
- UNIX
deploytool -deployConnector \ $J2EE_HOME/lib/connector/blackbox-tx.rar localhost- Windows (Enter the following and all subsequent Windows commands on a single line.)
deploytool -deployConnector %J2EE_HOME%\lib\connector\blackbox-tx.rar localhost- Add a connection factory for the resource adapter. The JNDI name for the connection factory is
eis/MyBlackBoxTx.
- UNIX
j2eeadmin -addConnectorFactory \ eis/MyBlackBoxTx blackbox-tx.rar- Windows
j2eeadmin -addConnectorFactory eis/MyBlackBoxTx blackbox-tx.rar- Verify that the resource adapter has been deployed.
deploytool -listConnectors localhost
- The
deploytoolutility displays these lines:Installed connector(s): Connector Name: blackbox-tx.rar Installed connection factories: Connection Factory JNDI Name: eis/MyBlackBoxTxTesting the Resource Adapter
- If you are new to the J2EE SDK, you should first read the instructions in Chapter 2.
- Locate the
SavingsAccountBean.javasource code, which resides in thej2eetutorial/examples/src/ejb/savingsaccountdirectory.- Edit the
SavingsAccountBean.javasource code, changing the value assigned to thedbNamevariable as follows:private String dbName = "java:comp/env/MyEIS";- Compile the source code in the
savingsaccountdirectory.- Replace the new
SavingsAccountBean.classfile in the existingSavingsAccountApp.earfile.
- In the GUI
deploytool, open thej2eetutorial/examples/ears/SavingsAccountApp.earfile.- On the General tab of the
SavingsAccountJAR, click Edit.- In the Available Files field, locate the
j2eetutorial/examples/build/ejb/SavingsAccountBean.classfile.- Drag and drop the
SavingsAccountBean.classfile from the Available Files field to the Contents field.- Click OK.
- Change the resource factory reference.
- Select the Resource Refs tab of
SavingsAccountEJB.- Select the item whose Coded Name entry is
jdbc/SavingsAccountDB.- Click Delete.
- Click Add.
- Enter the values specified in Table 17-4.
Table 17-4 Resource References Values Field
Value
Coded Name
MyEIS
Type
javax.sql.DataSource
Authentication
Container
JNDI Name
eis/MyBlackBoxTx
- The
eis/MyBlackBoxTxJNDI name matches the name of the connection factory that you added in step 2 of Deploying the Resource Adapter. TheMyEISvalue of the Coded Name field corresponds to this line in theSavingsAccountBean.javasource code:private String dbName = "java:comp/env/MyEIS";- Although it is included in the source code, the
java:comp/env/subcontext is implicit in the Coded Name field of the Resource Refs tab.- Save the
SavingsAccountAppapplication (FileSave).
- Deploy the
SavingsAccountAppapplication.
- Select Tools
Deploy.
- In the Introduction dialog box, select Return Client Jar.
- In the JNDI Names dialog box, verify that the JNDI names in Table 17-5 have been specified.
Table 17-5 JNDI Names Component or Reference Name
JNDI Name
SavingsAccountEJB
MySavingsAccount
MyEIS
eis/MyBlackBoxTx
ejb/SimpleSavingsAccount
MySavingsAccount
- To run the application, follow the directions in the section Running the Client.
|
Home TOC Index |
|
Search
Feedback |