|
| WebLogic Server 6.0 Code Examples, BEA Systems, Inc. |
Package examples.rmi_iiop.ejb.rmi_iiop
This example demonstrates connectivity between a RMI over IIOP client and an EJB.
See:
Description
Interface Summary |
Trader |
The methods in this interface are the public face of TraderBean. |
TraderHome |
This interface is the home interface for the TraderBean.java,
which in WebLogic is implemented by the code-generated container
class TraderBeanC. |
Class Summary |
Client |
This class illustrates calling a stateless Session Bean and performing
the following exercises:
Create a Trader
Buy some shares using the Trader
Sell some shares using the Trader
Remove the Trader
|
TraderBean |
TraderBean is a stateless Session Bean. |
TradeResult |
This class reflects the results of a buy/sell transaction. |
Package examples.rmi_iiop.ejb.rmi_iiop Description
This example demonstrates connectivity between a RMI over IIOP client and an EJB.
This example illustrates:
- Accessing an EJB from a RMI over IIOP client (a Java RMI application)
This example demonstrates connectivity between a RMI over IIOP client and an EJB. It uses VisiBroker 4.0 for Java.
It uses a stateless session EJB called TraderBean
and presumes some knowledge of EJB deployment. For examples pertaining stricly to EJBs, please see our
EJB examples page.
Included there is a stateless session bean similar to TraderBean.
To get the most out of this example, first read through the source
code files to see what is happening. Start with the XML deployment files to find the general structure of the EJB, i.e. which
classes are used for the different objects and interfaces, then examine the other files to see how the application works.
The following section describes how to build and run the example:
- Build the example
- Configure the server
- Run the example
- Set up your development shell as described in
Setting up your environment.
- Execute the build script provided for this example
in the samples\examples\rmi_iiop\ejb\rmi_iiop
directory of your WebLogic Server installation. The script will perform the following steps:
- Create the build directory, and copy the deployment descriptors into it as shown in this
example for Windows NT/2000:
$ mkdir build build\META-INF build\images
$ copy *.xml build\META-INF
$ copy *.gif build\images
- Compile ejb classes into the build directory (jar preparation) as shown in this
example for Windows NT/2000:
$ javac -d build Trader.java TraderHome.java TradeResult.java TraderBean.java
- Make a EJB jar file, including XML deployment descriptors as shown in this
example for Windows NT/2000:
$ cd build
$ jar cv0f std_ejb_over_iiop.jar META-INF examples images
$ cd ..
- Run ejbc on jar file as shown in this
example for Windows NT/2000:
$ java weblogic.ejbc -compiler javac -idl -idlDirectory idlSources -iiop build\std_ejb_over_iiop.jar %APPLICATIONS%\ejb_over_iiop.jar
- Compile EJB interfaces & client application into the clientclasses directory as shown in this
example for Windows NT/2000:
$ javac -d %CLIENT_CLASSES% Trader.java TraderHome.java TradeResult.java Client.java
- Note: Running the build script places the EJB in %WL_HOME%\config\examples\applications directory, 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 scripts
is found in Building Enterprise JavaBean examples
- Start the server with the examples configuration.
- Make sure that the EJB has been deployed on your examplesServer.
- Bring up the Administration
Console in your browser.
- Click to expand the Deployments node in the left-hand pane.
- Click to expand the EJB node in the left-hand pane.
- Select the ejb_over_iiop node.
- Select the Targets tab in the right-hand pane to display the Available and Chosen targets.
- Deploy the ejb_over_iiop on the examplesServer.
Run the example
- Open a new command shell.
- Set up your development shell as described in
Setting up your environment.
- Set the CLASSPATH as shown in this example for Windows NT/2000:
$ set CLASSPATH=%CLASSPATH%;%WL_HOME%\config\examples\applications\ejb_over_iiop.jar
where WL_HOME is the installation
directory for WebLogic Server.
- Obtain the WebLogic Server Inter-operable Object Reference (IOR) by running the
host2ior utility in the command shell as shown in this example for Windows NT/2000:
$ java utils.host2ior hostname port
where:
- hostname
- Host name of the WebLogic Server
- port
- Port where the WebLogic Server is listening for connections
(weblogic.system.ListenPort).
- Run the client by entering the following command as shown in this example for Windows NT/2000:
$ java examples.rmi_iiop.ejb.rmi_iiop.Client ServerIOR
where ServerIOR is the IOR you obtained by
running the host2ior utility.
- You should get output similar to this from the client application:
Beginning statelessSession.Client
Creating a trader
Buying 100 shares of BEAS.
Buying 200 shares of MSFT.
Buying 300 shares of AMZN.
Buying 400 shares of HWP.
Selling 100 shares of BEAS.
Selling 200 shares of MSFT.
Selling 300 shares of AMZN.
Selling 400 shares of HWP.
Removing the trader
End statelessSession.Client...
There's more...
Read more about WebLogic RMI over IIOP in the Developer Guide,
Using
WebLogic RMI over IIOP.
Read more about WebLogic EJB in the Developer Guide,
BEA WebLogic Server Enterprise JavaBeans.
Read more about WebLogic RMI in the Developer Guide,
Using
WebLogic RMI.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.