BEA WebLogic Enterprise 4.2    Developer Center     

        HOME   |   SITE MAP   |   SEARCH   |   CONTACT   |   GLOSSARY  |   PDF FILES |   WHAT'S NEW 
 
        C++ REFERENCE    |   TABLE OF CONTENTS   |   PREVIOUS TOPIC   |   NEXT TOPIC  

Bootstrap Object


This chapter describes the Bootstrap object.

Why Bootstrap Objects Are Needed

The Problem: To communicate with WLE objects, a client application must obtain object references. The client application uses the Bootstrap object to obtain initial object references to four key objects in a WLE domain: the FactoryFinder (which is used to locate factory objects), SecurityCurrent (which is used to log on to the system), TransactionCurrent (which is used to manage transactions), and the Interface Repository (which is used to obtain information about available interfaces). However, this poses a problem: How does the client application access the Bootstrap object?

The solution: Bootstrap objects are local programming objects, not remote CORBA objects, in both the client and the server. When Bootstrap objects are created, their constructor requires the network address of a WLE IIOP Server Listener/Handler. Given this information, the Bootstrap object can generate object references for the above-mentioned remote objects in the WLE domain. These object references can then be used to access services available in the WLE domain.

How Bootstrap Objects Work

Bootstrap objects are created by a client or a server application that must access object references for the Interface Repository, or for the FactoryFinder, TransactionCurrent, or SecurityCurrent objects. Bootstrap objects represent the first connection to a specific WLE domain. For a WLE remote client, the Bootstrap object is created with the host and the port for the WLE IIOP Server Listener/Handler. However, for WLE native client and server applications, there is no need to specify a host and port because they execute in a specific WLE domain. The IIOP Server Listener/Handler host and the port ID are included in the WLE domain configuration information.

Once created, Bootstrap objects satisfy requests for object references for objects in a particular WLE domain. Different Bootstrap objects allow the application to use multiple domains.

Using the Bootstrap object, you can obtain four different references, as follows:

The FactoryFinder and Interface Repository objects are not actually implemented in the environmental objects library. However, they are specific to a WLE domain and are thus conceptually similar to the SecurityCurrent and TransactionCurrent objects in usage.

The Bootstrap object implies an association or "session" between the client and the WLE domain. Within the context of this association, the Bootstrap object imposes a containment relationship with the other Current objects (or contained objects), that is, the SecurityCurrent and TransactionCurrent. Current objects are valid only for this domain and only while the Bootstrap object exists.

In addition, a client can have only one instance of each of the Current objects at any time. If a Current object already exists, an attempt to create another Current object does not fail. Instead, another reference to the already existing object is handed out; that is, a client may have more than one reference to the single instance of the Current object.

To create a new instance of a Current object, the application must first invoke the destroy_current() method on the Bootstrap object. This invalidates all of the Current objects, but will not destroy the session with the WLE domain. After invoking destroy_current(), new instances of the Current objects can be created within the WLE domain using the existing Bootstrap object.

To obtain Current objects for another domain, a different Bootstrap object must be constructed. Although it is possible to have multiple Bootstrap objects at one time, only one Bootstrap object may be "active," that is, have Current objects associated with it. Thus, an application must first invoke destroy_current() on the "active" Bootstrap object before obtaining new Current objects on another Bootstrap object, which then becomes the active Bootstrap object.

Servers and native clients are inside of the WLE domain; therefore, no "session" is established. However, the same containment relationships are enforced. Servers and native clients access the domain they are currently in by specifying an empty string, rather than //host:port. Client and server applications must use the Tobj_Bootstrap::resolve_initial_references()method, not the ORB::resolve_initial_references() method.

Types of Remote Clients Supported

Table 4-1 shows the types of remote clients that can use the Bootstrap object to access the other environmental objects, such as FactoryFinder, SecurityCurrent, TransactionCurrent, and InterfaceRepository.

Table 4-1 Remote Clients Supported

Remote Client Description

CORBA C++

CORBA C++ client applications use the WLE C++ environmental objects to access the CORBA objects in a WLE domain, and the WLE Object Request Broker (ORB) to process from CORBA objects. Use the WLE system development commands to build these client applications (see Chapter 10, "Development Commands").

CORBA Java

CORBA Java client applications use the Java environmental objects to access CORBA objects in a WLE domain. However, these client applications use an ORB product other than the WLE ORB to process requests from CORBA objects. These client applications are built using the ORB product's Java development tools. Version 4.2 of the WLE software supports interoperability with Netscape Communicator Version 4.07 and 4.5 depending on the platform.

ActiveX

Use the WLE Automation environmental objects to access CORBA objects in a WLE domain, and the ActiveX Client to process requests from CORBA objects. Use the Application Builder to create bindings for CORBA objects so that they can be accessed from ActiveX client applications. ActiveX client applications are built using a development tool such as Visual Basic, Delphi, or PowerBuilder.

Capabilities and Limitations

Bootstrap objects have the following capabilities and limitations:

Bootstrap Object API

The Bootstrap object application programming interface (API) is described first in terms of the OMG Interface Definition Language (IDL) (for portability), and then in C++, Java, and ActiveX. C++ and Java add the necessary constructor to build a Bootstrap object for a given WLE domain.

Tobj Module

Table 4-2 shows the object reference that is returned for each type ID.

Table 4-2 Returned Object References

ID Returned Object Reference

FactoryFinder

FactoryFinder object (Tobj::FactoryFinder)

InterfaceRepository

InterfaceRepository object (CORBA::Repository)

SecurityCurrent

SecurityCurrent object (SecurityLevel2::Current)

TransactionCurrent

OTS Current object (Tobj::TransactionCurrent)

Table 4-3 describes the Tobj module exceptions.

Table 4-3 Tobj Module Exceptions

Exception Description

Tobj::InvalidName

Raised if id is not one of the names specified in Table 4-2. On the server, resolve_initial_references also raises Tobj::InvalidName when SecurityCurrent is passed.

Tobj::InvalidDomain

On the server application, raised if the WLE server environment is not booted.

CORBA::NO_PERMISSION

Raised if id is TransactionCurrent or SecurityCurrent and another Bootstrap object in the client owns the Current objects.

BAD_PARAM

Raised for the register_callback_port method if the object is nil or if the host contained in the object does not match the connection.

IMP_LIMIT

Raised if the register_callback_port method is called more than once.

C++ Mapping

Listing 4-1 shows the C++ declarations in the Tobj_bootstrap.h file.

Listing 4-1 Tobj_boostrap.h Declarations
#include <CORBA.h>

class Tobj_Bootstrap {
public:
Tobj_Bootstrap(CORBA::ORB_ptr orb, const char* address);
CORBA::Object_ptr resolve_initial_references(
const char* id);
void register_callback_port(CORBA::Object_ptr objref);
void destroy_current( );
};


Java Mapping

Listing 4-2 shows the Tobj_Bootstrap.java mapping.

Listing 4-2 Tobj_Bootstrap.java Mapping
package com.beasys;

public class Tobj_Bootstrap {
public Tobj_Bootstrap(org.omg.CORBA.ORB orb,
String address)
throws org.omg.CORBA.SystemException;
public class Tobj_Bootstrap {
public Tobj_Bootstrap(org.omg.CORBA.ORB orb, String address,
java.applet.Applet applet)
throws org.omg.CORBA.SystemException;

public void register_callback_port(orb.omg.CORBA.Object objref)
throws org.omg.CORBA.SystemException;

public org.omg.CORBA.Object
resolve_initial_references(String id)
throws Tobj.InvalidName,
org.omg.CORBA.SystemException;
public void destroy_current()
throws org.omg.CORBA.SystemException;
}

Mappings for Microsoft Desktop Clients

The Bootstrap object is provided in the BEA ActiveX Client software for use by clients that are implemented on Microsoft desktops. There are two possible interfaces that desktop clients may use:

Automation Mapping

Listing 4-3 shows Automation Bootstrap interface mapping.

Listing 4-3 Automation (Dual) Bootstrap Interface Mapping

interface DITobj_Bootstrap : IDispatch
{
HRESULT Initialize(
[in] BSTR address);

HRESULT CreateObject(
[in] BSTR progid,
[out, retval] IDispatch** rtrn);

HRESULT destroy_current();
};

C++ Member Functions and Java Methods

This section describes the C++ member functions and Java methods for Bootstrap objects.

Tobj_Bootstrap

Synopsis

The Bootstrap object constructor.

C++ Mapping

Tobj_Bootstrap(CORBA::ORB_ptr orb, const char* address);
throws Tobj::InvalidDomain
org.omg.CORBA.SystemException;

Java Mapping

public Tobj_Bootstrap(org.omg.CORBA.ORB orb, String address,
java.applet.Applet applet)
throws com.beasys.Tobj.InvalidDomain,
throws org.omg.CORBA.SystemException;

Parameters

orb
This is a pointer to the ORB object in the client. The Bootstrap object uses the string_to_object method of orb internally.

address
The address of the WLE domain IIOP Server Listener/Handler. The address is specified differently depending on the type of client. There can be three types of clients, as follows:

applet (Applies to Java method only)
This is a pointer to the client applet. If the client applet does not explicitly pass the ISH host and port to the Bootstrap constructor, you can pass this argument, which causes the Bootstrap object to search for the TOBJADDR definition in the HTML file for the applet.

Exception

InvalidDomain
For a remote client, raised if the Bootstrap object cannot connect to the WLE domain. The address of the WLE domain IIOP Server Listener/Handler is specified in the constructor that is specific to the programming language.
For a native client or server, raised if the domain is not booted.

The constructor throws CORBA::BAD_PARAM if orb is null or if address is not in a valid format.

Description

This C++ member function (or Java method) creates Bootstrap objects.

Return Values

A pointer to a newly created Bootstrap object.

Tobj_Bootstrap::register_callback_port

Synopsis

Registers joint client/server's listening port in ISH.

C++ Mapping

void register_callback_port(CORBA::Object_ptr objref);

Java Mapping

public void register_callback_port(orb.omg.CORBA.Object objref)
throws org.omg.CORBA.SystemException;

Parameter

objref
The object reference created by the client.

Exceptions

BAD_PARAM
Raised if the object is nil or if the host contained in the object does not match the connection.

IMP_LIMIT
Raised if the register_callback_port method is called more than once.

Description

This C++ member function (or Java method) is called to notify the ISH of a listening port in the joint client/server. This method should only be used for joint client/server ORBs that do not support GIOP 1.2 bidirectional capabilities (that is GIOP 1.0 and 1.1 client ORBs). For GIOP 1.0 and 1.1, the ISH supports only one listening port per joint client/server; therefore, the register_callback_port method should only be called once per connected joint client/server.

Usage Notes

If the register_callback_port method is not invoked by the joint client/server, the callback port is not registered with the ISH and the server defaults to Asymmetric Outbound IIOP.

Also, if the register_callback_port method in not invoked by the joint client/server, you must start the server's IIOP Server Listener (ISL) with the -O option. The -O option enables Asymmetric outbound IIOP; otherwise, server-to-client invocations will not be allowed by the ISL/ISH.

Return Values

None.

Tobj_Bootstrap::resolve_initial_references

Synopsis

Acquires CORBA object references.

C++ Mapping

CORBA::Object_ptr resolve_initial_references(
const char* id);
throws Tobj::InvalidName,
org.omg.CORBA.SystemException;

Java Mapping

public org.omg.CORBA.Object
resolve_initial_references(String id)
throws Tobj.InvalidName,
org.omg.CORBA.SystemException;

Parameter

id
This parameter must be one of the following:

"FactoryFinder"
"SecurityCurrent"
"TransactionCurrent"
"InterfaceRepository"

Exceptions

InvalidName
Raised if id is not one of the names specified above. On the server, resolve_initial_references also raises Tobj::InvalidName when SecurityCurrent is passed.

CORBA::NO_PERMISSION
Raised if id is TransactionCurrent or SecurityCurrent and another Bootstrap object in the client owns the Current objects.

Description

This C++ member function (or Java method) acquires CORBA object references for the FactoryFinder, SecurityCurrent, TransactionCurrent, and InterfaceRepository objects. For the specific object reference, invoke the _narrow function. For example, for FactoryFinder, invoke Tobj::FactoryFinder::_narrow.

Return Values

Table 4-2, "Returned Object References," on page 4-7 shows the object reference that is returned for each type id.

Tobj_Bootstrap::destroy_current()

Synopsis

Destroys the Current objects for the domain represented by the Bootstrap object.

C++ Mapping

void destroy_current();

Java Mapping

public void destroy_current()
throws org.omg.CORBA.SystemException;

Exception

Raises CORBA::NO_PERMISSION if the Bootstrap object is not the owner of the Current objects.

Description

This C++ member function invalidates the Current objects for the domain represented by the Bootstrap object. After invoking the destroy_current() method, the Current objects are marked as invalid. Any attempt to use the old Current objects from then on throws the exception CORBA::BAD_INV_ORDER. Good programming practice is to release all Current objects before invoking destroy_current().

Note: The destroy_current() method must be invoked on the Bootstrap object for the domain that currently owns the two Current objects (Transaction and Security). This also results in an implicit invocation to logoff for security and implicitly rolls back any transaction that was begun by the client.

The application must invoke destroy_current() before invoking resolve-_initial_references for TransactionCurrent or SecurityCurrent on another domain; otherwise, resolve_initial_refererences raises CORBA::NO_PERMISSION.

Return Values

None.

Automation Methods

This section describes the Automation methods for Bootstrap objects.

Initialize

Synopsis

Initializes the Bootstrap object into a WLE domain.

MIDL Mapping

HRESULT Initialize(
[in] BSTR host);

Automation Mapping

Sub Initialize(address As String)

Parameter

address
The host name and port of the WLE domain IIOP Server Listener/Handler. One or more TCP/IP addresses can be specified. Multiple addresses are specified using a comma-separated list, just as in the C++ mappings. If no address is specified, the value of the TOBJADDR environmental variable is used.

Note: The network address that is specified by programmers in the Bootstrap constructor or in TOBJADDR must exactly match the network address in the application's UBBCONFIG file. The format of the address as well as the capitalization must match. If the addresses do not match, the invocation to the Bootstrap constructor will fail with the following seemingly unrelated error message:

ERROR: Unofficial connection from client at
<tcp/ip address>/<port-number>

For example, if the network address is specified as //TRIXIE:3500 in the ISL command line option string, specifying either //192.12.4.6:3500 or //trixie:3500 in the Bootstrap constructor or in TOBJADDR will cause the connection attempt to fail. On UNIX systems, use the uname -n command on the host system to determine the capitalization used. On Windows NT systems, see the host system's Network control panel to determine the capitalization used.

Return Values

None.

Exceptions

Table 4-4 describes the exceptions.

Table 4-4 Initialize Exceptions

HRESULT Description Meaning

ITF_E_NO_PERMISSION_YES

Bootstrap already initialized

The Bootstrap object has already been initialized. To connect to a new WLE domain, you must create a new Bootstrap object.

E_INVALIDARG

Invalid 'address' parameter

The address supplied is not valid.

E_OUTOFMEMOY

Memory allocation failed

The required memory could not be allocated.

E_FAIL

Invalid domain

Unable to communicate with the WLE domain at the address specified or TOBJADDR is not defined.

<SYSTEM ERROR>

Unable to obtain initial object

Unable to initialize the Bootstrap object. The system error causing the failure is returned in the "Number" member of the error object

CreateObject

Synopsis

Creates an instance of a Current environmental object.

MIDL Mapping

HRESULT CreateObject(
[in] BSTR progid,
[out, retval] IDispatch** rtrn);

Automation Mapping

Function CreateObject(progid As String) As Object

Parameter

progid
The progid of the environmental object to create. Valid progids are:

Tobj.FactoryFinder
Tobj.SecurityCurrent
Tobj.TransactionCurrent

Return Value

A reference to the interface pointer of the created environmental object.

Exceptions

Table 4-5 describes the exceptions.

Table 4-5 CreateObject Exceptions

Exception Description Meaning

ITF_E_NO_PERMISSION_YES

Bootstrap must initialized

The Bootstrap object has not been initialized.

ITF_E_NO_PERMISSION_NO

No permission.

If the progid specifies a transaction or security current and another Bootstrap object in the client owns the current objects.

E_INVALIDARG

Invalid 'progid' parameter

The progid specified is not valid.

E_INVALIDARG

Invalid name

The requested progid is not one of the valid parameter values specified above.

E_INVALIDARG

Unknown object

The requested progid is not registered on your system.

<SYSTEM ERROR>

CoCreate
Instance()
failed

The Bootstrap object could not create an instance of the requested object. The system error is returned in the "Number" member of the error object.

DestroyCurrent

Synopsis

Logs out of the WLE domain and invalidates the TransactionCurrent and SecurityCurrent objects.

MIDL Mapping

HRESULT destroy_current();

Automation Mapping

Sub destroy_current()

Parameters

None.

Return Value

None.

Exceptions

None.

Programming Examples

This section provides programming examples that use Bootstrap objects.

Java Client Example: Getting a SecurityCurrent Object

Listing 4-4 shows how to program a Java client to get a SecurityCurrent object.

Listing 4-4 Programming a Java Client to Get a SecurityCurrent Object

import org.omg.CORBA.*;
import com.beasys.*;

class client {
public static void main(String[] args )
{
Tobj.PrincipalAuthenticator auth = null;

try {
// Initialize ORB
ORB orb = ORB.init();

// Create Bootstrap object
Tobj_Bootstrap bs = new Tobj_Bootstrap(orb,
"//host:1234");

// Get security current
org.omg.CORBA.Object ocur =

bs.resolve_initial_references("SecurityCurrent");
SecurityLevel2.Current cur =
SecurityLevel2.CurrentHelper.narrow(ocur);
}
catch (Tobj.InvalidName e){
System.out.println("Invalid name: " + e);
System.exit(1);
}
catch (Tobj.InvalidDomain e){
System.out.println("Invalid domain address:
//host:port: " + e);
System.exit(1);
}
catch (SystemException e){
System.out.println("Exception getting security
current: " + e);
System.exit(1);
}
}
}


Visual Basic Client Example: Using the Bootstrap Object

Listing 4-5 shows how to program a Visual Basic client to use the Bootstrap object.

Listing 4-5 Programming a Client in Visual Basic

`Declare the Bootstrap object

Public oBootstrap As DITobj_Bootstrap

`Declare the FactoryFinder object

Public oBsFactoryFinder As DITobj_FactoryFinder

`Declare factory for Registrar object

Public oRegistrarFactory As DIUniversityB_RegistrarFactory

`Declare actual Registrar object

Public oRegistrarFactory As DIUniversityB_RegistrarFactory

....

`Create the Bootstrap object

Set oBootstrap = CreateObject("Tobj.Bootstrap")

`Connect to the WLE Domain

oBootstrap.Initialize "//host:port"

`Get the FactoryFinder for the WLE Domain

Set oBSFactoryFinder = oBootstrap.CreateObject("Tobj.FactoryFinder")

`Get a factory for the Registrar object
`using the FactoryFinder method find_one_factory_by_id

Set oRegistrarFactory = oBSFactoryFinder.find_one_factory_by_id("RegistrarFactoryID")

'Create a Registrar object

Set oRegistrar = oRegistrarFactory.find_registrar(exc)



Copyright © 1999 BEA Systems, Inc. All Rights Reserved.
Required browser version: Netscape Communicator version 4.0 or higher, or Microsoft Internet Explorer version 4.0 or higher.
Last update: July 06, 1999.