|
|
| WebLogic Server 6.1 Code Examples, BEA Systems, Inc. |
Package examples.wlec.ejb.simpapp
This example demonstrates how to use WebLogic Enterprise Connectivity (WLEC) to access a
BEA Tuxedo CORBA object from a WebLogic Server stateless Enterprise JavaBean (EJB).
See:
Description
|
Interface Summary |
| Converter |
The methods in this interface are the public face of
ConverterBean. |
| ConverterHome |
This interface is the home interface for the
ConverterBean.java,
which in WebLogic is implemented by the code-generated container
class ConverterBeanC. |
|
Class Summary |
| Client |
This class illustrates using a stateless SessionBean that calls
an IIOP handler which in turn calls a CORBA Simpapp server. |
| ConverterBean |
ConverterBean is a stateless SessionBean. |
| ConverterResult |
This class reflects the results of a conversion. |
Package examples.wlec.ejb.simpapp Description
This example demonstrates how to use WebLogic Enterprise Connectivity (WLEC) to access a
BEA Tuxedo CORBA object from a WebLogic Server stateless Enterprise JavaBean (EJB). The WebLogic Server EJB interacts with a CORBA object in the BEA Tuxedo CORBA Simpapp example.
There are two ways to run the WLEC EJB example:
This example uses the ejbSimpappServlet.jsp, ejb-jar.xml and weblogic-ejb-jar.xml deployment files.
When you run the WLEC EJB Simpapp example:
-
WebLogic Server creates a WLEC connection pool for the Simpapp sample application.
-
The WebLogic Server EJB uses the ejbCreate method to obtain a connection from the WLEC connection pool.
- The Java application or the Internet client forwards the request to the EJB:
- The Java application sends the request, including an input string, directly to the WebLogic Server EJB.
-
The Internet client sends the request and input string to the ejbSimpapp servlet. The ejbSimpapp servlet sends the request and input string to the EJB.
- Acting as a CORBA client, the WebLogic Server EJB:
- Activates the connection to the Simpapp sample application which is running in a BEA Tuxedo domain.
- Invokes the desired operation on the CORBA object, Simple, with the data that it received from the Java application or the ejbSimpappServlet.
- The Simple object performs the specified operation and returns the results to the EJB. The Simple object can perform two operations:
- Accept a string and return the string in uppercase.
- Accept a string and return the string in lowercase.
- The EJB sends the results to the Java application or the ejbSimpappServlet.
- The Java application displays the output.
- The ejbSimpappServlet compiles the results into a dynamically-generated HTML page and sends the page to the Internet client.
The following sections describe how to build and run the example:
- Prerequisites
- Build the Example
- Configure the Server
- Run the Example
Install and configure the following:
- WebLogic Server
- WebLogic Enterprise Connectivity
- BEA Tuxedo version 8.0
Note: BEA Tuxedo version 8.0 combines the CORBA functionality previously found in the WebLogic Enterprise product with the ATMI functionality.
See BEA WebLogic Server Platform Support for information about the supported versions for WebLogic Server and WebLogic Enterprise Connectivity. For information about the supported platforms for BEA Tuxedo, see Installing the BEA Tuxedo System.
- Build and run the Java Simpapp sample application in the BEA Tuxedo product.
The build procedure for the Simpapp sample application generates the client stubs and puts them in your working directory. Client stubs provide the programming interface for CORBA object operations.
- Start the client and server in the Java Simpapp sample application.
- Set up your WebLogic Server development shell as described in
Setting up your environment for building and running the examples.
- Modify your CLASSPATH as follows:
- Add %WL_HOME%\lib\wleorb.jar to the CLASSPATH in %WL_HOME%\config\examples\setExamplesEnv.cmd (Windows 2000) or $WL_HOME/config/examples/setExamplesEnv.sh (UNIX).
- Add %WL_HOME%\lib\wleorb.jar (Windows 2000) or $WL_HOME/lib/wleorb.jar (UNIX) to the CLASSPATH for the startup script.
- Add %WL_HOME%\lib\wlepool.jar (Window 2000) or $WL_HOME/lib/wlepool.jar (UNIX) to the CLASSPATH for the startup script.
For information about setting the CLASSPATH for WebLogic Server, see Setting up your environment for building and running the examples.
- Copy the compiled Simpapp client stubs to your WebLogic Server SERVER_CLASSES directory, where SERVER_CLASSES is an environment variable that you set when you set up your development environment. The files you need to copy are:
- Simple.class
- SimpleFactory.class
- SimpleHelper.class
- SimpleFactoryHelper.class
- _SimpleStub.class
- _SimpleFactoryStub.class
- Build the ejbSimpapp servlet by running the ant build script in the /examples/wlec/ejb/simpapp directory.
- Copy the ejbSimpapp.html and ejbSimpappServlet.jsp files
located in the samples/examples/wlec/ejb/simpapp directory in the WebLogic Server directory structure
to the config/examples/applications/examplesWebApp directory.
The config/examples/applications/examplesWebApp directory is the location of the public files for examplesWebApp.
Note: For your convenience the build script copies the ejbSimpapp.html and ejbSimpappServlet.jsp
files to the config/examples/applications/examplesWebApp directory in your WebLogic Server installation.
Configure the Server
-
Start WebLogic Server.
- Bring up the WebLogic Server Administration Console in a browser.
- Create a WLEC Connection Pool:
- Go to the Services->WLEC node in the left pane of the Administration Console.
- Click the Create a new WLEC Connection Pool link.
- Click the General tab.
- Create a new WLEC connection pool called simplepool.
- In the Primary Address attribute, enter the address of the IIOP Listener/Handler that
will be used to establish a connection between the WLEC connection pool and the BEA Tuxedo domain in which the Simpapp sample application runs.
The format of the
address is //hostname:port where hostname is the name of the machine on which BEA Tuxedo is running
and port is the TCP port at which the IIOP Listener/Handler listens for incoming requests. The port value must be a number between 0 and 65535. The default value is 2468.
- In the Failover Address attribute, enter the address of an IIOP Listener/Hander that can be used if connections
cannot be established with the IIOP Listener/Handler defined in the Primary Address attribute.
The format of the
address is //hostname:port where hostname is the name of the machine on which BEA Tuxedo is running
and port is the TCP port at which the IIOP Listener/Handler listens for incoming requests. The port value must be a number between 0 and 65535. The default value is 2468.
For more information about creating WLEC connection pools, see Managing Security.
- If you are running the WLEC EJB example on the UNIX platform, change the Domain attribute from simple to simpapp. If you are running the example on Windows 2000, use the default Domain id simple.
- Click the Create button.
- Select the Targets tab.
- Move the examplesServer from the Target column to the Chosen column.
- Click the Apply button.
- Deploy wlec_ejb.jar on your server:
- Click the Deployments node in the Administration Console.
- Click to expand the EJB Deployments node.
- Select the wlec_ejb.jar node.
- Select the Targets tab in the right-hand pane to display the Available and Chosen
targets.
- Move the examplesServer from the Target column to the Chosen column.
- Click the Apply button.
- Make sure that the examplesWebApp is deployed on your server.
-
Shutdown WebLogic Server.
-
Restart WebLogic Server.
Run the Example
To run the example from the Internet client:
- Start a web browser and enter the URL for the ejbSimpapp servlet.
For example:
http://localhost:7001/examplesWebApp/ejbSimpapp.html
- On the HTML form:
- Enter some text in either uppercase or lowercase.
- Select the operation (TO UPPER or TO LOWER).
- Click GO.
- Watch for the results. An uppercase string converts to lowercase and vice versa.
To run the example from the Java application:
- In your development shell, execute the following command:
java examples.wlec.ejb.simpapp.Client [url] [user] [password]
The parameters are optional, but if any are supplied, they are interpreted in this order:
url
- WebLogic Server URL. For example, t3://localhost:7001.
user
- Username, default null.
password
- User password, default null. It should be at least 8 characters.
For more information, see the Client class.
- Watch for the results. The Java application generates the following output:
Beginning simpapp.Client...
Start of Conversion for: It Works
Converting to lower case: It Works
...Converted: it works
Converting to upper case: It Works
...Converted: IT WORKS
Removing Converter
End simpapp.Client...
There's More...
For more information about WebLogic Server EJBs, see:
For more information about BEA Tuxedo CORBA, see the
BEA Tuxedo documentation.
For more information about WLEC, see Using WebLogic Enterprise Connectivity.
Copyright © 2001 BEA Systems, Inc. All Rights Reserved.