Package examples.iiop.ejb.entity.server.wls

This example demonstrates connectivity between a c++ client or a Tuxedo client and an entity bean.

See:

 

Interface Summary

Account The methods in this interface are the public face of AccountBean.
AccountHome This interface is the home interface for the EJBean AccountBean.
 

 

Class Summary

AccountBean Date AccountBean is an EntityBean.
AccountTypes This is a dummy interface that is used to ensue idl generation for concrete valuetypes that are used by EJB.
 

 

Exception Summary

ProcessingErrorException This class is used with the WebLogic EJBean container-managed example package.
 

Package examples.iiop.ejb.entity.server.wls Description

This example demonstrates connectivity between a c++ client or a Tuxedo client and an entity bean. This specific package contains the necessary files to build the EJB used in these examples. You must first build the EJB before you can execute any of the clients. Note that this example demonstrates passing more complex valuetypes than both the stateless session bean RMI-IIOP examples and the RMI Visibroker example. These examples also use Borland Visibroker for C++. These examples use an entity EJB called AccountBean and presumes some knowledge of EJB deployment. For examples pertaining stricly to EJBs, please see our EJB examples page. Included there is an entity bean similar to Account Bean.

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 applications work. There are three different clients that can be executed to call the EJB. Examine the XML build file carefully for each one. Take special note to see how the idl files are created for the C++ and Tuxedo clients.

Note that this example demonstrates the use of derived datatypes that are not usually visible to the Java programmer. When accessing an EJB finder, for example, the Java programmer sees a Collection or Enumeration--but the programmer doesn't have to pay attention to the underlying implementation since the JDK runtime will network classload it. However the C++ programmer must know the type that comes across the wire so that he can register a valuetype factory for it (in order that the ORB can unmarshall it). Examples of this in this case are EJBObjectEnum, Vector and ArrayList. Simply running appc on the defined EJB interfaces will *not* generate these definitions because they do not appear in the interface. For this reason appc will also accept Java classes that are not remote interfaces--specifically for the purpose of generating IDL for these interfaces.

Keeping this in mind, the following are key points covered in this example.

1. Generating IDL for interfaces not exposed in the EJB definitions-- for example EJBObjectEnum. Under IIOP you have to know the valuetype coming across the wire in order to be able to unmarshall it. This is most relevant to entity finders which return strange valuetypes--and although they inherit from some general superclass, such as Enumeration, you still have to generate code for the actual type: such as EJBObjectEnum. The rmic compiler allows you to do this.

2. Implementing java valuetypes in C++. The example uses the valuetypes for EJBObjectEnum, Vectorg and ArrayList. By default the generated C++ only includes data, not functions, so we have extended the definition of these (in the built _i files) to look more like there java counterparts.

3. Using custom valuetypes. Java types that are serializable but that define writeObject() are mapped to custom valuetypes in IDL, this means that the user has to write C++ code to hand unmarshall the valuetype. This is demonstrated in the definition of ArrayList (ArrayList_i.cpp).

4. Marshalling complex datatypes. The example also shows how to construct a complex valuetype in C++ in order to pass it in to WebLogic server.

The following section describes how to build and run the example:

  1. Build the example
  2. Configure the server
  3. Run the example

Build the EJB and set up your WebLogic Server

  1. Set up your development shell as described in Setting up your environment.

  2. There is an iiop.properties file contained in the WL_HOME\samples\server\examples\src\examples\iiop directory. This file must point to your installation of Visibroker. For example: INPRISE_HOME=c:\Inprise\vbroker. Check your PATH to make sure it is set correctly.

  3. Execute the build script provided for this example in the WL_HOME\samples\server\examples\src\examples\iiop\ejb\entity\server\wls directory of your WebLogic Server installation. The script will perform the following steps:

    1. 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

    2. Compile ejb classes into the build directory (jar preparation)

    3. Make a EJB jar file, including XML deployment descriptors

    4. Run appc on the jar file. Notice the use of the -iiop option.

    5. Compile EJB interfaces & client application into the clientclasses directory contained in the examples domain (WL_HOME\samples\server\examples\build\clientclasses).

  4. Note: Running the build script places the EJB in WL_HOME\samples\domains\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 More About Building Examples.

Configure the server

  1. Start the server with the examples configuration.

  2. Make sure that the EJB has been deployed on your examplesServer.

  3. Bring up the Administration Console in your browser.

    1. Click to expand the Deployments node in the left-hand pane.
    2. Click to expand the EJB Modules node in the left-hand pane.
    3. Select the iiop_ejb_entity node.
    4. Select the Targets tab in the right-hand pane to display the servers and clusters to which you can deploy this EJB. If not already chosen, choose the examplesServer server and click Apply.
    5. The EJB should be deployed.

Run the example

    There are two different client applications included in this example. Each requires different steps to build and execute. The following links contain information pertinent to each respective client:

    C++ Client (requires visibroker)

    Tuxedo Client (requires Tuxedo 8.0)

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 EJBs.

Read more about WebLogic RMI in the Developer Guide, Using WebLogic RMI.