Home TOC |
Search
Feedback |
Resource Adapter Tutorial
This tutorial shows you how to deploy the black box resource adapter stored in the blackbox-tx.rar file. To test the resource adapter, you will modify the examples/src/ejb/account/AccountEJB.java file so that it accesses the Cloudscape database through the resource adapter. The AccountEJB.java file is also used in another example. For more information, see Tips for Running the AccountEJB Example
Setting Up
- Start the J2EE server.
j2ee -verbose- In another terminal window, set the J2EE_HOME environment variable to the directory in which you've installed this release.
- Follow the instructions in the section, Setting Up the Database.
Deploying the Resource Adapter
deploytool -deployConnector \ $J2EE_HOME/lib/connector/blackbox-tx.rar localhost
- (Enter the following command 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.
j2eeadmin -addConnectorFactory \ eis/MyBlackBoxTx blackbox-tx.rar
- (Enter the following command on a single line.)
j2eeadmin -addConnectorFactory eis/MyBlackBoxTx blackbox-tx.rar
- The deploytool 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 may want to review the instructions in Getting Started.
- Locate the AccountEJB.java source code, which resides in the examples/src/ejb/account directory.
- Edit the AccountEJB.java source code, changing the value assigned to the dbName variable as follows:
private String dbName = "java:comp/env/MyEIS";- Compile the source code in the account directory:
- Run the New Enterprise Bean Wizard of the deploytool by selecting File-> New Enterprise Bean. Although the wizard displays many dialog boxes, for this example only the following dialog boxes require input.
- General Dialog Box
- Entity Settings Dialog Box
- Resource References Dialog Box:
- Click Add.
- Enter the values specified in the following table.
Table 36 Resource References Values Field
Value
Coded Name
MyEIS
Type
javax.sql.DataSource
Authentication
Container
JNDI Name
eis/MyBlackBoxTx
- The eis/MyBlackBoxTx JNDI name matches the name of the connection factory that you added in step 2 of Deploying the Resource Adapter. The MyEIS value of the Coded Name field corresponds to this line in the AccountEJB.java source 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 References dialog box.
- Transaction Management Dialog Box:
- For the business methods, in the Transaction Type column select Required. The business methods are debit, credit, getFirstName, getLastName, and getBalance.
- Exit the wizard by clicking Finish.
- Create a J2EE application client.
- Select New->Application Client
- Name the client AccountClient.
- Add the ejb/SimpleAccount enterprise bean reference.
- Select Tools->Deploy Application.
- In the Introduction dialog box, select Return Client Jar.
- In the JNDI Names dialog box, verify that the JNDI names in the following table have been specified.
Table 37 JNDI Names Comp. Name or
Ref. Type
JNDI Name
AccountBean
MyAccount
MyEIS
eis/MyBlackBoxTx
ejb/SimpleAccount
MyAccount
- To run the application, follow the directions in Running the J2EE Application.
Home TOC |
Search
Feedback |