|
|
This container covers the following topics:
The Problem: To communicate with WebLogic Enterprise (WLE) 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 WLE domain:
Why Bootstrap Objects Are Needed
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 to the following objects:
How Bootstrap Objects Work
Bootstrap objects may represent the first connection to a specific WLE domain depending on the format of the IIOP Server Listener/Handler address. If the Null scheme Universal Resource Locator (URL) format is used (the only address format supported in releases of WLE prior to V5.0), 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 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.
After they are 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 six different references, as follows:
The SecurityCurrent object is used to establish a security context within a WLE domain. The client can then obtain the PrincipalAuthenticator from the principal_authenticator attribute of the SecurityCurrent object.
The TransactionCurrent object is used to participate in a WLE transaction. The basic operations are as follows:
Begin a transaction. Future operations take place within the scope of this transaction.
End the transaction. All operations on this client application have completed successfully.
Abort the transaction. Tell all other participants to roll back.
Suspend participation in the current transaction. This operation returns an object that identifies the transaction and allows the client application to resume the transaction later.
Resume participation in the specified transaction.
The FactoryFinder object is used to obtain a factory. In the WLE system, factories are used to create application objects. The FactoryFinder provides the following different methods to find factories:
The Interface Repository contains the interface descriptions of the CORBA objects that are implemented within the WLE domain. Clients using the Dynamic Invocation Interface (DII) need a reference to the Interface Repository to be able to build CORBA request structures. The ActiveX Client is a special case of this. Internally, the implementation of the COM/IIOP Bridge uses DII, so it must get the reference to the Interface Repository, although this is transparent to the desktop client.
The NotificationService object is used to obtain a reference to the event channel factory (CosNotifyChannelAdmin::EventChannelFactory) in the CosNotification Service. In the WLE system, the EventChannelFactory is used to locate the Notification Service channel.
The Tobj_SimpleEventsService object is used to obtain a reference to the event channel factory (Tobj_SimpleEvents::ChannelFactory) in the BEA Simple Events Service. In the WLE system, the ChannelFactory is used to locate the BEA Simple Events Service channel.
The FactoryFinder and Interface Repository objects are not 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 use.
The Bootstrap object implies an association or "session" between the client application 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.
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 Server 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 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
.
Note:
Client and server applications must use the Tobj_Bootstrap::resolve_initial_references()
method, not the ORB::resolve_initial_references()
method.
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.
Types of Remote Clients Supported
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.
Bootstrap objects have the following capabilities and limitations:
Capabilities and Limitations
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 WLE domain.
Table 4-2 shows the object reference that is returned for each type ID.
Bootstrap Object API
Tobj Module
Table 4-3 describes the Tobj module exceptions.
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 { C++ Mapping
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.
Listing 4-3
Automation (Dual) Bootstrap Interface Mapping
interface DITobj_Bootstrap : IDispatch HRESULT CreateObject( HRESULT destroy_current(); This section describes the C++ member functions and Java methods for Bootstrap objects.
Automation Mapping
{
HRESULT Initialize(
[in] BSTR address);
[in] BSTR progid,
[out, retval] IDispatch** rtrn);
};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
- 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 and the level of security required. 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-6.
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 "
"corbaloc:// hostname : port_number "
"corbalocs:// hostname : 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 remote machine, and the local name resolution facilities must unambiguously resolve hostname to the address of the remote machine.
Note: The hostname must begin with a letter character.
In the second format, 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 remote machine.
In both the first and second 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.
You can specify one or more TCP/IP addresses. You specify multiple addresses using a comma-separated list. For example:
- //m1.acme:3050
- //m1.acme:3050,//m2.acme:3050,//m3.acme:3051
If you specify multiple addresses, the WLE software tries the addresses in order, left to right, until a connection is established. If a syntax error is detected in any of the addresses as it is being tried, a BAD_PARAM exception is returned to the caller immediately and the WLE software aborts the attempt to make a connection. For example, if the first address in the common separated list shown above were //m1.3050, a syntax error would be detected and the attempt to make a connection would be aborted. If the WLE software encounters the end of the address list before it tries an address that is valid, that is, a connection cannot be made to any of the addresses listed, the INVALID_DOMAIN exception is returned to the caller. If an exception other than INVALID_DOMAIN is raised, it is returned to the caller immediately.
WLE also supports random address selection. To used random address selection, you can specify any member of an address list as a grouping of pipe-separated (| ) network addresses enclosed in parentheses. For example:
- (//m1.acme:3050|//m2.acme:3050),//m1.acme:7000
When you use this format, the WLE system randomly selects one of the addresses enclosed in parentheses, either //m1.acme:3050 or //m2.acme:3050 . If an exception other than INVALID_DOMAIN is raised, it is returned to the caller immediately. If a connection cannot be made to the address selected, the next element that follows the addresses enclosed in parentheses is attempted. If the end of the string is encountered before a connection can be made, the INVALID_DOMAIN exception is thrown to the caller.
Note: If you specify an address list in the following format:
(//m1.acme:3050||//m2.acme:3050),//r1.acme:7000
the null address in the pipe-separated list is considered invalid. If the WLE software randomly selects the invalid address, the BAD_PARAM exception is returned to the caller and the WLE software aborts the connection attempt.
The address string can be specified either in the TOBJADDR environment variable or in the address parameter of the Tobj_Bootstrap constructor.
For information about the TOBJADDR environment variable, see the chapter Managing Remote client Applications in the Administration Guide. However, the address specified in Tobj_Bootstrap always take precedence over the TOBJADDR environment variable. To use the TOBJADDR environment variable to specify an address string, you must specify an empty string in the Tobj_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.
The third and fourth formats are called Uniform Resource Locator (URL) address formats and are new in the WLE version 5.0 release. As with the Null scheme URL address format (//hostname:port_number ), you use the URL address formats to specify the location of the IIOP Server Listener/Handler. However, when the corbaloc URL address format is used, the client application's initial connection to the IIOP Server Listener/Handler is deferred until authentication of the principal's, or client's, identity or the first user initiated operation. Using the carbolocs URL address format has the same effect on the deferred connection time as carboloc , but, additionally, the client application makes its initial connection to the ISL/ISH using the Secure Socket Layer (SSL) Protocol. Table 4-4 highlights the differences between to the two URL address formats.
Table 4-4 Differences Between corbaloc and corbalocs URL Address Formats
These new URL address formats are a subset of the definition of object URLs adopted by the OMG as part of the Interoperable Naming Service submission. The WLE software also extends the URL format described in the OMG Interoperable Naming Service submission to support a secure form that is modeled after the URL for secure HTTP, as well as to support the randomize functionality that was supported in the WLE version 4.2.
The corbaloc and corbalocs URL schemes provide locations that are easily manipulated in both TCP/IP and DNS centric environments. These URL schemes contain a DNS-style hostname or IP address and a port_number . Here are some examples of the URL formats:
corbaloc://curly:1024,larry:1022,joe:1999
corbalocs://host1:1024,{host2:1022|host3:1999}
- As an enhancement to the URL syntax described in the OMG Interoperable Naming Service submission, the WLE version 5.0 software has extended the syntax to support a list of multiple URLs, each with a different scheme. Here are some examples of the extension:
corbalocs://curly:1024,corbaloc://larry:1111,
corbalocs://ctxobj:3434,mthd:3434,corbaloc://force:1111In the above example, if the parser reaches the URL corbaloc://force:1111 , it resets its internal state as if it had never attempted secure connections and then begins attempting unprotected connections.
Caution: Do not mix the use of Null scheme URL addresses (//hostname:port_number ) with corbaloc and corbalocs URL addresses.
Note: The Bootstrap object supplied for use with the Netscape embedded Java ORB and JavaSoft JDK ORB does not support corbaloc and corbalocs URLs.
Note: For more information on using the corbaloc and corbalocs URL address formats, see Using Security.
Note: The network address that is specified in the Bootstrap constructor or in TOBJADDR must exactly match the network address in the server application's UBBCONFIG file, both 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 (using the Null URL address format) as //TRIXIE:3500 in the ISL command line option string in the server application's UBBCONFIG file, 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.Note: The error in the previous note is deferred when the URL address format is used, that is, the error does not occur at the time of Bootstrap object construction because the connection to the ISL/ISH is deferred until later.
- Native client
For a native client, the address parameter in the Tobj_Bootstrap constructor must always be an empty string (not a null pointer). The native client connects to the application that is specified in the TUXCONFIG environment variable. The constructor raises CORBA::BAD_PARAM if the address is not empty.
- Server acting as a client
When servers need access to the Bootstrap object, they should obtain a reference to it using the TP framework by invoking TP.bootstrap() . Servers should not attempt to create a new instance of the Bootstrap object.
- 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, this exception is 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. The constructor is specific to the programming language.
- For a native client or server, this exception is 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
A C++ member function (or Java method) that creates Bootstrap objects.
Return Values
A pointer to a newly created Bootstrap object.
Synopsis
Registers the joint client/server's listening port in IIOP Server 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:
- 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. In this case, 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.
- If you are using the BEAWrapper Callbacks API instead of the POA and you want to use bidirectional behavior, you always need to invoke the register_callback_port method, even when you are using a ISH that supports GIOP 1.2.
- If you want to use bidirectional capability for a callback object, you must invoke the register_callback_port method before you pass the callback object reference to the server.
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 .
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.
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, 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
Unable to communicate with the WLE domain at the address specified or TOBJADDR is not defined.
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.TransactionCurrentReturn 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
The requested progid is not one of the valid parameter values specified above.
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 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 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_idSet 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: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.