BEA Logo BEA WebLogic Enterprise Release 5.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WebLogic Enterprise Doc Home   |   Programming Topics   |   Previous Topic   |   Next Topic   |   Contents   |   Index

C++ Bootstrap Object Programming Reference

 

This topic includes the following sections:

 


Why Bootstrap Objects Are Needed

The Problem: To communicate with BEA WebLogic Enterprise objects, a client application must obtain object references. The client application uses the Bootstrap object to obtain initial object references to six key objects in a BEA WebLogic Enterprise domain:

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 BEA WebLogic Enterprise IIOP Listener/Handler. Given this information, the Bootstrap object can generate object references for the above-mentioned remote objects in the BEA WebLogic Enterprise domain. These object references can then be used to access services available in the BEA WebLogic Enterprise domain.

 


How Bootstrap Objects Work

Bootstrap objects are created by a client or a server application that must access object references to the following objects:

Bootstrap objects may represent the first connection to a specific BEA WebLogic Enterprise domain depending on the format of the IIOP Listener/Handler address. If the Null scheme Universal Resource Locator (URL) format is used (the only address format supported in releases of BEA WebLogic Enterprise prior to V5.1), the Bootstrap objects represent the first connection. However, if the URL format is used, the connection will not occur until after Bootstrap object creation. For more information on address formats and connection times, refer to Tobj_Bootstrap.

For a BEA WebLogic Enterprise remote client, the Bootstrap object is created with the host and the port for the BEA WebLogic Enterprise IIOP Listener/Handler. However, for BEA WebLogic Enterprise native client and server applications, there is no need to specify a host and port because they execute in a specific BEA WebLogic Enterprise domain. The IIOP Listener/Handler host and the port ID are included in the BEA WebLogic Enterprise domain configuration information.

After they are created, Bootstrap objects satisfy requests for object references for objects in a particular BEA WebLogic Enterprise domain. Different Bootstrap objects allow the application to use multiple domains.

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

The FactoryFinder and Interface Repository objects are not implemented in the environmental objects library. However, they are specific to a BEA WebLogic Enterprise domain and are thus conceptually similar to the SecurityCurrent and TransactionCurrent objects in use.

The Bootstrap object implies an association or "session" between the client application and the BEA WebLogic Enterprise 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.

Note: Resolving the SecurityCurrent when using the new URL address format (corbaloc://hostname:port_number) is a local operation; that is, no connection is made by the client to the IIOP Listener/Handler.

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 application 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 does not destroy the session with the BEA WebLogic Enterprise domain. After invoking destroy_current(), new instances of the Current objects can be created within the BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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.

Note: 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

Client

Description

CORBA C++

CORBA C++ client applications use the BEA WebLogic Enterprise C++ environmental objects to access the CORBA objects in a BEA WebLogic Enterprise domain, and the BEA WebLogic Enterprise Object Request Broker (ORB) to process from CORBA objects. Use the BEA WebLogic Enterprise system development commands to build these client applications (see Commands, System Processes, and MIB Reference).

CORBA Java

CORBA Java client applications use the Java environmental objects to access CORBA objects in a BEA WebLogic Enterprise domain. However, these client applications use an ORB product other than the BEA WebLogic Enterprise ORB to process requests from CORBA objects. These client applications are built using the ORB product's Java development tools. The BEA WebLogic Enterprise (C++) software supports interoperability with Netscape Communicator versions 4.07 and 4.5, depending on the platform.

ActiveX

Use the BEA WebLogic Enterprise Automation environmental objects to access CORBA objects in a BEA WebLogic Enterprise 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, which are built using a development tool such as Microsoft Visual Basic, Delphi, or PowerBuilder.

This container describes how to use the Bootstrap object in C++ and ActiveX client applications. For reference information about how to use the Bootstrap object in Java client applications, see the chapter Java Bootstrap Object Reference in the CORBA Java Programming Reference.

 


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. The C++ and Java descriptions add the necessary constructor to build a Bootstrap object for a particular BEA WebLogic Enterprise 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)

NotificationService

EventChannelFactory object

(CosNotifyChannelAdmin::EventChannelFactory)

Tobj_SimpleEventsService

BEA Simple Events ChannelFactory object (Tobj_SimpleEvents::ChannelFactory)

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 BEA WebLogic Enterprise 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 if the object is nil or if the hostname 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;
}


Microsoft Desktop Client Mappings

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::BAD_PARAM
org.omg.CORBA.SystemException;

Java Mapping

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

Parameters

orb

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 BEA WebLogic Enterprise domain IIOP Listener/Handler. The address is specified differently depending on the type of client and the level of security required. 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

BAD_PARAM

Raised if the object is nil or if the host contained in the object does not match the connection or the host address (//hostname:port_number) is not in a valid format.

Description

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

Return Values

A pointer to a newly created Bootstrap object.

Tobj_Bootstrap::register_callback_port

Synopsis

Registers the joint client/server's listening port in IIOP Handler (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 joint client/server.

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

The following information must be given consideration when using this method:

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"
"NotificationService"
"Tobj_SimpleEventsService"

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, NotificationService, Tobj_SimpleEventsService, 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 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 subsequent attempt to use the old Current objects will throw 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_references 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 BEA WebLogic Enterprise domain.

MIDL Mapping

HRESULT Initialize(
[in] BSTR host);

Automation Mapping

Sub Initialize(address As String)

Parameter

address

The host name and port of the BEA WebLogic Enterprise domain IIOP Listener/Handler. One or more TCP/IP addresses can be specified. Multiple addresses are specified using a comma-separated list, 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 in the Bootstrap constructor or in TOBJADDR must exactly match the network address in the application's UBBCONFIG file, both the format of the address as well as the capitalization. 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 settings in the Control Panel to determine the correct capitalization.

Return Values

None.

Exceptions

Table 4-5 describes the exceptions.

Table 4-5 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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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-6 describes the exceptions.

Table 4-6 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 BEA WebLogic Enterprise 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 the following 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 BEA WebLogic Enterprise Domain

oBootstrap.Initialize  "//host:port"

`Get the FactoryFinder for the BEA WebLogic Enterprise 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)