![]() |
![]() |
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 |
This chapter describes the Bootstrap object.
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.
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:
Why Bootstrap Objects Are Needed
How Bootstrap Objects Work
principal_authenticator
attribute of the SecurityCurrent object.
End the transaction. All operations on this client have completed successfully.
Abort the transaction. Tell all other participants to roll back.
find_factories
).
find_one_factory
).
find_one_factory_by_id
).
find_factories_by_id
).
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 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 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 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.
Bootstrap objects have the following capabilities and limitations:
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.
destroy_current()
on the "active" Bootstrap object before obtaining new Current objects on another Bootstrap object, which then becomes the active Bootstrap object.
//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
Capabilities and Limitations
destroy_current()
on the Bootstrap object associated with one domain before obtaining the Current objects on another domain. Although it is possible to have multiple Bootstrap objects that establish connections to different WLE domains, only one set of Current objects is valid. Attempts to obtain other Current objects without destroying the existing Current objects fail.
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.
Table 4-2 shows the object reference that is returned for each type ID.
Table 4-3 describes the Tobj module exceptions.
Listing 4-1 shows the C++ declarations in the class Tobj_Bootstrap {Bootstrap Object API
Tobj Module
C++ Mapping
Tobj_bootstrap.h
file.
Listing 4-1
Tobj_boostrap.h Declarations
#include <CORBA.h>
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( );
};
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;
}
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:
Listing 4-3 shows Automation Bootstrap interface mapping.
This section describes the C++ member functions and Java methods for Bootstrap objects.
Automation 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
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 oforb
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:
- Remote Client
- For a description of the remote clients supported by WLE systems, see the section "Types of Remote Clients Supported" on page 4-4.
- For remote clients,
address
specifies the network address of an IIOP Server Listener/Handler through which client applications gain access to a WLE domain.- The address may be specified in either of the following formats:
"//hostname:port_number"
"//#.#.#.#:port_number"
- In the first format, the domain finds an address for hostname using the local name resolution facilities (usually DNS). The hostname must be the local machine, and the local name resolution facilities must unambiguously resolve hostname to the address of the local machine.
Note: The hostname must begin with a letter character.
- In the second example, the
#.#.#.#
is in dotted decimal format. In dotted decimal format, each#
should be a number from 0 to 255. This dotted decimal number represents the IP address of the local machine.- In both of the above formats, port_number is the TCP port number at which the domain process listens for incoming requests. The port_number should be a number between 0 and 65535.
Note: The network address that is specified by programmers in the Bootstrap constructor or in
TOBJADDR
must exactly match the network address in the server application'sUBBCONFIG
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 in the server application'sUBBCONFIG
file, specifying either//192.12.4.6:3500
or//trixie:3500
in the Bootstrap constructor or inTOBJADDR
will cause the connection attempt to fail. On UNIX systems, use theuname
-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.- One or more TCP/IP addresses can be specified. Multiple addresses are specified using a comma-separated list. For example:
//m1.acme.com:3050
//m1.acme.com:3050,//m2.acme.com:3050,//m3.acme.com:3051
- If multiple addresses are specified, the addresses are tried in order until
- a connection is established. Any member of an address list can be specified as a parenthesized grouping of pipe-separated network addresses. For example:
(//m1.acme.com:3050|//m2.acme.com:3050)
- The WLE system randomly selects one of the parenthesized addresses. This strategy distributes the load randomly across a set of listener processes.
- The address string can be specified either in the
TOBJADDR
environment variable or in the address parameter of theTobj_Bootstrap
constructor. (For information about theTOBJADDR
environment variable, see the chapter that describes how to manage remote client applications in Administration Guide.) However, the address specified inTobj_Bootstrap
always take precedence over theTOBJADDR
environment variable. To use theTOBJADDR
environment variable to specify an address string, you must specify an empty string in theTobj_Bootstrap
address
parameter.Note: For C++ applications,
TOBJADDR
is an environment variable; for Java applications, it is a property; for Java applets, it is an HTML parameter.- Native Client
- For a native client, the
address
parameter in theTobj_Bootstrap
constructor must always be an empty string (not a null pointer). The native client connects to the application that is specified in theTUXCONFIG
environment variable. The constructor raisesCORBA::BAD_PARAM
if the address is not empty.- Server Acting as a Client
- 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
iforb
is null or ifaddress
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.
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.
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 raisesTobj::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, invokeTobj::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
.
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 exceptionCORBA::BAD_INV_ORDER
. Good programming practice is to release all Current objects before invokingdestroy_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 tologoff
for security and implicitly rolls back any transaction that was begun by the client.The application must invoke
destroy_current()
before invokingresolve-_initial_references
for TransactionCurrent or SecurityCurrent on another domain; otherwise,resolve_initial_refererences
raisesCORBA::NO_PERMISSION
.Return Values
None.
Automation Methods
This section describes the Automation methods for Bootstrap objects.
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'sUBBCONFIG
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 inTOBJADDR
will cause the connection attempt to fail. On UNIX systems, use theuname
-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.
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. Validprogids
are:
Tobj.FactoryFinder
Tobj.SecurityCurrent
Tobj.TransactionCurrentReturn Value
A reference to the interface pointer of the created environmental object.
Exceptions
Table 4-5 describes the exceptions.
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
WLEDomain
oBootstrap.Initialize "//host:port"
`Get the FactoryFinder for the
WLEDomain
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)