BEA Logo BEA BEA Tuxedo Release [Release Number]

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   BEA Tuxedo Doc Home   |   Guide to the CORBA University Sample Applications   |   Previous Topic   |   Next Topic   |   Contents   |   Index

The Basic Sample Application

 

This topic includes the following sections:

Refer to Readme.txt in the \basic directory for troubleshooting information and the latest information about using the Basic sample application.

For an explanation of concepts associated with CORBA applications and a description of the development process for CORBA applications, see Getting Started with BEA Tuxedo CORBA Applications.

 


How the Basic Sample Application Works

The Basic sample application allows users to browse for available courses and get details on selected courses. Figure 3-1 illustrates how the Basic sample application works.

Figure 3-1 The Basic Sample Application


 
 

The Basic sample application demonstrates the following features:

 


The OMG IDL for the Basic Sample Application

The first step in creating client and server applications is to specify all of the CORBA interfaces and their methods using OMG IDL. The Basic sample application implements the following CORBA interfaces:

Interface

Description

Operations

RegistrarFactory

Creates object references to the Registrar object.

find_registrar()

Registrar

Obtains course information from the database.

get_courses_synopsis()

get_courses_details()

CourseSynopsisEnumerator

Gets synopses of courses that match the search criteria from the course database and reads them into memory; returns the first subset of the synopses to the Registrar object, which in turns returns them to the client application; and provides a means for a client application to retrieve the remainder of the synopses.

get_next_n()

destroy()


 

Listing 3-1 shows the univb.idl file that defines the CORBA interfaces in the Basic sample application. A copy of this file is included in the directory for the Basic sample application.


 

Listing 3-1 OMG IDL for the Basic Sample Application

module UniversityB
{
   typedef unsigned long CourseNumber;
typedef sequence<CourseNumber> CourseNumberList;
   struct CourseSynopsis
{
CourseNumber course_number;
string title;
};
   typedef sequence<CourseSynopsis> CourseSynopsisList;

interface CourseSynopsisEnumerator
{
CourseSynopsisList get_next_n(
in unsigned long number_to_get,
out unsigned long number_remaining
);
void destroy();
};
   typedef unsigned short Days;
const Days MONDAY = 1;
const Days TUESDAY = 2;
const Days WEDNESDAY = 4;
const Days THURSDAY = 8;
const Days FRIDAY = 16;

struct ClassSchedule
{
Days class_days; // bitmask of days
unsigned short start_hour; // whole hours in military time
unsigned short duration; // minutes
};
   struct CourseDetails
{
CourseNumber course_number;
double cost;
unsigned short number_of_credits;
ClassSchedule class_schedule;
unsigned short number_of_seats;
string title;
string professor;
string description;
};
   typedef sequence<CourseDetails> CourseDetailsList;

interface Registrar
{
CourseSynopsisList
get_courses_synopsis(
in string search_criteria,
in unsigned long number_to_get, // 0 = all
out unsigned long number_remaining,
out CourseSynopsisEnumerator rest
);
CourseDetailsList get_courses_details(in CourseNumberList
courses);
   interface RegistrarFactory
{
Registrar find_registrar(
);
};
};

 


Generating the Client Stubs and the Skeletons

Note: The CORBA client applications in the University sample applications use static invocation. For an example of using the dynamic invocation interface, see Creating CORBA Client Applications. When creating CORBA Java client applications, see your Java ORB's documentation for information about compiling the OMG IDL to get client stubs. ActiveX client applications do not use client stubs.

The interface specification defined in OMG IDL is used by the IDL compiler to generate client stubs for the client application and skeletons for the server application. The client stubs are used by the client application for all operation invocations. You use the skeleton, along with the code you write, to create the server application that implements the CORBA objects. For information about generating and using client stubs and skeletons, see Getting Started with BEA Tuxedo CORBA Applications.

During the development process, you would use the idl command to compile the OMG IDL file and produce client stubs and skeletons. This task has been automated in the makefile for the Basic sample application. For a description of the idl command, see the BEA Tuxedo Command Reference.

 


Writing the Client Application

The CORBA environment in BEA Tuxedo supports three types of client applications:

Note: The ActiveX client application is written in Visual Basic.

During the development process, you would write client application code that does the following:

C++, Java, and Visual Basic versions of the client application code in the Basic sample application are provided. For information about writing client applications, see Getting Started with BEA Tuxedo CORBA Applications and Creating CORBA Client Applications.

Writing the Server Application

During the development process, you would write the following:

C++ code for the Server object and the method implementations in the University server application are provided.

During the development process, you use the genicf command to create an Implementation Configuration File (ICF). You then edit the ICF file to define activation and transaction policies for the Registrar, RegistrarFactory, and CourseSynopsisEnumerator objects. For the Basic sample application, the Registrar, RegistrarFactory, and CourseSynopsisEnumerator objects have an activation policy of process and a transaction policy of ignore. An ICF file for the Basic sample application is provided.

For information about writing server applications, see Creating CORBA Server Applications.

 


Configuring the Basic Sample Application

A key part of any CORBA application is the UBBCONFIG file. Although creating a UBBCONFIG file is the task of the administrator, it is important for programmers to understand that the file exists and how the file is used. When system administrators create a configuration file, they are describing the CORBA application using a set of parameters that the BEA Tuxedo software interprets to create a runnable application.

There are two forms of the configuration file:

For information about the UBBCONFIG file and the tmloadcf command, see Setting Up a BEA Tuxedo Application and the BEA Tuxedo Command Reference.

 


Building the Basic Sample Application

To build the Basic sample application, complete the following steps:

  1. Copy the files for the Basic sample application into a work directory.

  2. Change the protection on the files for the Basic sample application.

  3. Set the environment variables.

  4. Initialize the University database.

  5. Load the UBBCONFIG file.

  6. Build the client and server sample applications.

The following sections describe these steps.

Note: Before you can build or run the Basic sample application, you need to complete the steps in Setting Up Your Environment.

Copying the Files for the Basic Sample Application into a Work Directory

The files for the Basic sample application are located in the following directories:

Windows 2000

drive:\TUXDIR\samples\corba\university\basic

UNIX

/usr/TUXDIR/samples/corba/university/basic

In addition, you need to copy the utils directory into your work directory. The utils directory contains files that set up logging, tracing, and access to the University database.

Table 3-1 lists and describes the files you will use to create the Basic sample application.

Table 3-1 Files Included in the Basic Sample Application

File

Description

univb.idl

The OMG IDL that declares the CourseSynopsisEnumerator, Registrar, and RegistrarFactory interfaces.

univbs.cpp

The C++ source code for the University server application in the Basic sample application.

univb_i.h
univb_i.cpp

The C++ source code for method implementations of the CourseSynopsisEnumerator, Registrar, and RegistrarFactory interfaces.

univbc.cpp

The C++ source code for the CORBA C++ client application in the Basic sample application.

frmBrowser.frm
frmBrowser.frx

The Visual Basic source code for the ActiveX client application in the Basic sample application.

modPublicDeclarations.bas

A Visual Basic file that contains the declarations for variables used in the sample applications.

frmTracing.frm
frmTracing.frx

The files that provide tracing capabilities to the ActiveX client application.

University.vbp

The Visual Basic project file for the ActiveX client application in the Basic sample application.

University.vbw

The Visual Basic workspace file for the ActiveX client application in the Basic sample application.

UnivBApplet.java

The Java source code for the CORBA Java client application in the Basic sample application.

univb_utils.h
univb_utils.cpp

The files that define database access functions for the CORBA C++ client application.

univb.icf

The Implementation Configuration File (ICF) for the Basic sample application.

setenvb.sh

A UNIX script that sets the environment variables needed to build and run the Basic sample application.

setenvb.cmd

An MS-DOS command procedure that sets the environment variables needed to build and run the Basic sample application.

ubb_b.mk

The configuration file for the UNIX operating system platform.

ubb_b.nt

The configuration file for the Windows 2000 operating system platform.

makefileb.mk

The makefile for the Basic sample application on the UNIX operating system platform.

makefileb.nt

The makefile for the Basic sample application on the Windows 2000 operating system platform.

log.cpp, log.h, log_client.cpp, and log_server.cpp

The client and server applications that provide logging and tracing functions for the sample applications. These files are located in the \utils directory.

oradbconn.cpp and oranoconn.cpp

The files that provide access to an Oracle SQL database instance. These files are located in the \utils directory.

samplesdb.cpp and samplesdb.h

The files that provide print functions for the database exceptions in the sample applications. These files are located in the \utils directory.

unique_id.cpp and unique_id.h

C++ Unique ID class routines for the sample applications. These files are located in the \utils directory.

samplesdbsql.h and samplesdbsql.pc

C++ class methods that implement access to the SQL database. These files are located in the \utils directory.

university.sql

The SQL for the University database. This file is located in the \utils directory.


 

Changing the Protection on the File for the Basic Sample Application

During the installation of the BEA Tuxedo software, the sample application files are marked read-only. Before you can edit the files or build the files in the Basic sample application, you need to change the protection of the files you copied into your work directory, as follows:

Windows 2000

prompt>attrib -r drive:\workdirectory\*.*

UNIX

prompt>chmod u+rw /workdirectory/*.*

Setting the Environment Variables

Use the following command to set the environment variables used to build the client and server applications in the Basic sample application:

Windows 2000

prompt>setenvb

UNIX

prompt>/bin/ksh

prompt>. ./setenvb.sh

Initializing the University Database

Use the following command to initialize the University database used with the Basic sample application:

Windows 2000

prompt>nmake -f makefileb.nt initdb

UNIX

prompt>make -f makefileb.mk initdb

Loading the UBBCONFIG File

Use the following command to load the UBBCONFIG file:

Windows 2000

prompt>tmloadcf -y ubb_b.nt

UNIX

prompt>tmloadcf -y ubb_b.mk

 


Compiling the Basic Sample Application

During the development process, you would use the buildobjclient and buildobjserver commands to build the client and server applications. However, for the Basic sample application, this step has been done for you.

The directory for the Basic sample application contains a makefile that builds the client and server sample applications.

Use the following commands to build the CORBA C++ client and server application in the Basic sample application:

Windows 2000

prompt>nmake -f makefileb.nt

UNIX

prompt>make -f makefileb.mk

To build the CORBA Java client application:

Windows 2000

prompt>nmake -f makefileb.nt javaclient

UNIX

prompt>make -f makefileb.mk javaclient

For information about building and using the ActiveX client application, see Starting the ActiveX Client Application.

For more information about the buildobjclient and buildobjserver commands, see the BEA Tuxedo Command Reference.

 


Running the Basic Sample Application

To run the Basic sample application, complete the following steps:

  1. Start the University server application.

  2. Start one or more of the client applications.

Starting the Server Application

Start the system and sample application server applications in the Basic sample application by entering the following command:

prompt>tmboot -y

This command starts the following server processes:

Before using another sample application, enter the following command to stop the system and sample application server processes:

prompt>tmshutdown

Starting the CORBA C++ Client Application

Start the CORBA C++ client application in the Basic sample application by entering the following command:

prompt>univb_client

Starting the CORBA Java Client Application

To run the CORBA Java client application in the Basic sample application, complete the following steps:

  1. Modify the following lines in the UnivBApplet.html file:

    code="UnivBApplet.class"
    codebase=.
    to read as follows:

    code="UnivBApplet"
    archive="UnivBApplet.jar,m3envobj.jar"

  2. Copy the modified UnivBApplet.html file to the source directory for the Web server (the directory varies by Web server product).

  3. After executing the makefile to build the Basic sample application, create a UnivBApplet.jar file, as follows:

    1. Create a tmp directory under the directory where you built the sample application and copy the UniversityB subdirectory and the class files it contains into the tmp directory.

      Copy the class files in the Basic sample application directory that were generated by the makefile into the tmp directory, set the directory (cd) to the tmp directory, and issue one of the following commands to create a .JAR file that contains all the Basic sample application classes:

      jar -cf ..\UnivBApplet.jar *.*
      (Microsoft Windows 2000 systems)
      jar -cf ../UnivBApplet.jar * (UNIX systems)

  4. Copy the UnivBApplet.jar file you just created to the source directory for the Web server (the directory name varies by Web server product).

  5. Copy the m3envobj.jar file from the appropriate subdirectory (%TUXDIR%\udataobj\java Microsoft Windows 2000 systems or ${TUXDIR}/udataobj/java UNIX systems) to the Web server source directory.

  6. Make sure the Basic server application is running, start up your Web browser, and point it to the node where the Web server is running.

Note: On Microsoft Windows 2000 systems, the node name needs to be in all uppercase characters. For example, if the node is specified as SERVER in the UBBCONFIG file and in the UnivBApplet.html file, set your browser to http://SERVER/UnivBApplet.html.

Starting the ActiveX Client Application

Note: For the University sample applications, the task of loading the OMG IDL for the CORBA interfaces into the Interface Repository is automated by the makefile.

Before you can start the ActiveX client application, you must use the Application Builder to create ActiveX bindings for the CORBA interfaces.

To create an ActiveX binding for a CORBA interface, complete the following steps:

  1. Click the BEA Application Builder icon in the BEA Tuxedo program group.

    The Domain logon window appears.

  2. In the Domain Logon window, enter the host name and port number that you specified in the ISL parameter in the UBBCONFIG file. You must match exactly the capitalization used in the UBBCONFIG file. For example: //BEANIE:2500.

    The Application Builder logon window appears.

  3. Highlight the UniversityB folder in the Services window and drag it to the Workstation Views window, or copy the UniversityB folder from the Services window and paste it into the Workstation Views window.

    A confirmation window appears.

  4. Click Create to create the ActiveX bindings for the CORBA interfaces in the Basic sample application.

    The Application Builder creates the following:

To open the ActiveX client application, complete the following steps:

  1. Open the University project in Visual Basic.

  2. Run the University project.

  3. From the Run menu, click Start.

    A logon window appears.

  4. In the Logon window, enter the host name and port number that you specified in the ISL parameter in the UBBCONFIG file. You must match exactly the capitalization used in the UBBCONFIG file.

 


Using the Client Applications in the Basic Sample Application

The following sections briefly explain how to use the client applications that are included in the Basic sample application.

The CORBA C++ Client Application

After starting the CORBA C++ client application, a menu with the following options appears:

<F>   Find courses
<A>   List all courses
<D>   Display course details
<E>   Exit

To find courses that match a particular curriculum subject, complete the following steps:

  1. At the Options prompt, enter F.

  2. Enter a text string at the Enter search string: prompt. For example, computer. You can enter any combination of uppercase and lowercase letters.

    A list of all the courses that match that search string appears.

To list all the courses in the database, complete the following steps:

  1. At the Options prompt, enter A.

    A list of ten courses appears.

  2. Enter y to continue viewing lists of ten courses or n to return to the Options menu.

To display the details of a particular course, complete the following steps:

  1. At the Options prompt, enter D.

  2. Enter a course number followed by -1 at the Course Number prompt. For example:

    100011
    100039
    -1

    A summary of that course appears.

To exit the C++ CORBA client application, enter E at the Options prompt.

The CORBA Java Client Application

To find courses that match a particular curriculum subject, complete the following steps:

  1. In the text box under the search string? prompt, enter a text string. You can enter the title of a course, the name of a professor, or the description of a course. For example, computer.

  2. Click the Show button.

    A list of all the courses that match that search string appears.

To list all the courses in the database, complete the following steps:

  1. Place your cursor in the Course Name Search String text box.

  2. Press Enter.

    A list of all the courses in the course database appears.

To display the details of a particular course, complete the following steps:

  1. Select a course in the Course Number/Course Name window.

  2. Click the Details button.

    A summary of details for the selected course appears.

To exit the CORBA Java client application, choose Quit from the Applet menu.

The ActiveX Client Application

When you log on to the ActiveX client application, the Course Browser window appears. Use the Course Browser window to find courses available at the university.

To find courses that match a particular curriculum subject, complete the following steps:

  1. In the text box next to the Find Courses button, enter a text string or use the pull-down menu to choose a curriculum subject. For example, computer.

  2. Click the Find Courses button.

    A list of all the courses that match that search string appears.

To display the details of a particular course, complete the following steps:

  1. Select a course in the window next to the Get Details button.

  2. Click the Get Details button or double-click the course name.

    A summary of details for the selected course appears.

  3. To enter the course into the schedule, double-click the course name.

To exit the ActiveX client application, choose Exit from the File menu.

 

back to top previous page next page