|
|
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 SecurityCurrent object is used to establish a security context within a BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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 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.
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.
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.
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. |
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:
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
For a description of the remote clients supported by BEA WebLogic Enterprise systems, see the section "Types of Remote Clients Supported".
For remote clients, address specifies the network address of an IIOP Listener/Handler through which client applications gain access to a BEA WebLogic Enterprise 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:
If you specify multiple addresses, the BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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.
BEA WebLogic Enterprise 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:
When you use this format, the BEA WebLogic Enterprise 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 BEA WebLogic Enterprise software randomly selects the invalid address, the BAD_PARAM exception is returned to the caller and the BEA WebLogic Enterprise 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 BEA WebLogic Enterprise version 5.1 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 Listener/Handler. However, when the corbaloc URL address format is used, the client application's initial connection to the IIOP 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 Sockets Layer (SSL) Protocol. Table 4-4 highlights the differences between to the two URL address formats.
URL Address Formats |
Differences in Mode of Operation |
---|---|
corbaloc |
Invocations to the IIOP Listener/Handler are unprotected. Configuring the IIOP Listener/Handler for the SSL protocol is optional. Note: A principal can secure the bootstrapping process by using the SecurityLevel2::Current::authenticate() operation to specify that certificate-based authentication is to be used. |
corbalocs |
Invocations to the IIOP Listener/Handler are protected and the IIOP Listener/Handler or the server ORB must be configured to enable the use of the SSL protocol. |
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 BEA WebLogic Enterprise 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 BEA WebLogic Enterprise 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}
corbalocs://curly:1024,corbaloc://larry:1111,
corbalocs://ctxobj:3434,mthd:3434,corbaloc://force:1111
In 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.
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.
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.
Exception
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
Exceptions
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:
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
"SecurityCurrent"
"TransactionCurrent"
"InterfaceRepository"
"NotificationService"
"Tobj_SimpleEventsService"
Exceptions
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
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.
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. |
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
Tobj.SecurityCurrent
Tobj.TransactionCurrent
Return Value
A reference to the interface pointer of the created environmental object.
Exceptions
Table 4-6 describes the 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. |
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)
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|