|
| WebLogic Server 6.0 Code Examples, BEA Systems, Inc. |
Package examples.wlec.ejb.simpapp
This example demonstrates how to use WebLogic Enterprise Connectivity to access a
WebLogic Enterprise CORBA object from a stateless EJB on WebLogic Server.
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 to access a
WebLogic Enterprise CORBA object from a stateless EJB on WebLogic Server. The example combines a WLS EJB and the WLE Simpapp example. There are two ways to run this example:
In addition to the preceding classes and the interface, this example also uses the ejbSimpappServlet.jsp, ejb-jar.xml and weblogic-ejb-jar.xml deployment files.
The following figure illustrates the WLEC EJB Simpapp example.
When you run the WLEC EJB Simpapp example, the following events occur:
- At startup:
- WLS creates a WLEC connection pool for the WLE Simpapp domain.
- The EJB ejbCreate method obtains a connection from
the connection pool.
The remaining steps are performed at run time.
- If you are running this example from the Java application, the Java application sends a request, including an input string, to the EJB.
or
If you are running this example from an Internet client, the Internet client sends a request and input string to the ejbSimpappServlet. The ejbSimpappServlet sends the request and input string to the EJB.
- Acting as a WLE client, the EJB:
- Activates the connection to the Simpapp domain.
- Invokes the desired operation on the Simple CORBA object with the data that it received from the Java application or jsp.
- 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.
- If you are running the example that uses the Internet client and the ejbSimpappServlet, the jsp compiles the results into
a dynamically-generated HTML page and sends the page to the Internet client.
If you are running the example that uses the Java application, the application displays the output.
The following section describes how to build and run the example:
- Prerequisites
- Build the Example
- Configure the Server
- Run the Example
Install and set up the following:
- WebLogic Server (WLS)
- Java Development Kit (JDK)
- WebLogic Enterprise (WLE)
See Platform Support for WebLogic Enterprise Connectivity for information about the supported versions for each of these products.
- Build and run the WLE Simpapp sample.
See the Java Simpapp Sample Application in the WLE documentation:
- Go to J2EE Topics on the Web.
- Scroll down and click Sample Applications.
- Click Java Simpapp Sample Application.
The build procedure for the Java version of the Simpapp sample generates the client stubs and puts them in your working directory. Client stubs provide the programming interface for CORBA
object operations.
- Set up your WLS development shell as described in
Setting up your environment for building and running the examples.
- Modify classpaths:
- Add %WL_HOME%\lib\wleorb.jar to CLASSPATH in %WL_HOME%\config\examples\setExamplesEnv.cmd (NT) or $WL_HOME/config/examples/setExamplesEnv.sh (UNIX).
- Add %WL_HOME%\lib\wleorb.jar (NT) or $WL_HOME/lib/wleorb.jar (UNIX) to CLASSPATH in start script.
If you are going to start WLS by running startExamplesServer, set CLASSPATH in the startExamplesServer.cmd file (NT) or the startExamplesServer.sh file (UNIX). Otherwise, set CLASSPATH by means of another method such as the command line or the NT System Properties dialog box.
Note: You need to add RemoteObjectReference class to your classpath in start script. This class is bundled under wlej2eecl.jar file in WLE 5.1 and under m3.jar file in WLE 5.0.
%TUXDIR%\udataobj\java\jdk\wlej2eecl.jar
where:
- %TUXDIR%
- Your WLE installation directory.
For information about setting classpaths for WLS, see Setting up your environment for building and running the examples.
- Copy the compiled WLE Simpapp client stubs to your WLS 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 ejbSimpappServlet EJB application.
Run the build.cmd (Windows NT) or build.sh
(UNIX) command in the /examples/wlec/ejb/simpapp directory. On UNIX, you might need to change the permissions on the build.sh file.
- Copy the file ejbSimpapp.html and ejbSimpappServlet.jsp
located in the samples/examples/wlec/ejb/simpapp directory in your WebLogic Server installation
to the config/examples/applications/examplesWebApp directory in your WebLogic Server installation.
This directory is the location of the publically-available files of the examplesWebApp.
Note: For your convenience the build script will copy the ejbSimpapp.html and ejbSimpappServlet.jsp
file to the config/examples/applications/examplesWebApp directory in your WebLogic Server installation.
Configure the Server
- Initialize an IIOP connection pool:
- Start the server with the examples
configuration in a new command shell.
- Bring up the Administration Console in your browser.
- Click to expand the Services node in the left-hand pane.
- Click to expand the WLEC node in the left-hand pane.
- Select the simplepool node.
- Select the Configuration tab in the right-hand pane to display the General and Security tab.
- Select the General tab to display the Primary and Failover addresses.
- Change the Primary Addresses and Failover Addresses from [//wlehost:2468] to [//host:port].
where:
- host
- The name of the local machine.
- port
- The TCP port number at which the ISL process listens for incoming requests; it must be a number between 0 and 65535. The default value is 2468.
- Note: If you are running the example on UNIX change the Domain from [simple] to [simpapp].
NT user can leave the Domain to the default Domain id [simple].
- Click the Apply button to save the assignment.
- 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 and click the Apply button to
save the assignment.
- Deploy wlec_ejb.jar on your server:
- Click to expand the Deployments node in the left-hand pane.
- Click to expand the EJB Deployments node in the left-hand pane.
- 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 and click the Apply button to
save the assignment.
- Make sure that the examplesWebApp is deployed on your server.
Run the Example
- To run the example from the HTML client and servlet:
- Start a web browser and enter the URL for ejbSimpapp.html.
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
- WLS 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 output similar to the following:
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...
Read more about:
- WLS EJBs in:
- WLE CORBA objects in:
- The WLE CORBA Programming Environment:
- Go to Getting Started on the Web.
- Click The WLE CORBA Programming Environment.
- Developing WLE CORBA Applications:
- Go to Getting Started on the Web.
- Click Developing WLE CORBA Applications.
- CORBA Topics on the Web.
- WLE Simpapp example in:
- Go to J2EE Topics on the Web.
- Scroll down and click Sample Applications.
- Click Java Simpapp Sample Application.
- Using WebLogic Enterprise Connectivity.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.