CORBA::ORB_init

Overview

Initializes the ORB, if necessary, and returns a pointer to it.

Original class CORBA
Exceptions CORBA::SystemException


Intended Usage

This method is intended to be used by client or server applications to both initialize the ORB and obtain a pointer to it. This method can be called multiple times without adverse effect. The return value should be released using CORBA::release(ORB_ptr).

This method accepts optional arguments that configure how the ORB resolves Initial References.

Initialization of data structures used for code-set translation between clients and servers is not done until ORB_init() is called, so that the application has an opportunity to first initialize its locale (for instance, using the setlocale() function). Therefore, if a client or server process is configured to communicate with another process using a different character code set, the application should initialize its locale (for example, using setlocale()), then call ORB_init(), prior to using the ORB or making remote method invocations.

Syntax

static ORB_ptr ORB_init (int& argc, char** argv, const char * orb_identifier);

Input parameters

argc
The number of strings in the argv array of strings. This is typically the argc parameter passed in to the main() function of the application.
argv
An array of strings, whose size is indicated by the argc parameter. This is typically the argv parameter passed in to the main() function of the application. Configuration of initial references can be done by passing the ORBInitRef and ORBDefaultInitRef arguments. They can be used to override the ORB initial reference configuration which affects the behavior of CORBA::resolve_initial_references.

Note: ORB_init removes any arguments it recognizes before returning. The argc value is decremented and the argv array may be reordered as part of consuming the arguments which have been processed. Unrecognized arguments are preserved.

ORBInitRef
The ORBInitRef argument specifies the object reference for an initial service. To specify a reference for more than one service, the -ORBInitRef argument may be used multiple times in the argv array. The format is: -ORBInitRef ObjectID=ObjectURL

Example:

The following is a command line invocation example:

myApp -ORBInitRef NameServer=file://c:/temp/namesvr.ref

// Where myApp is a C++ program that passes 
// the command line args to ORB_init.
#include "corba.h"
...
int main(int argc, char *argv[])
{
//
// Initialize the ORB and obtain a pointer to it
//
CORBA::ORB_ptr p = CORBA::ORB_init(argc, argv, "");
...

ObjectID specifies the identifier for a service. Such a service may be defined in CORBA or may be defined by an application server. ObjectURL can be any of the URL schemes supported by ORB::string_to_object. These are described more fully in the topic Object URLs

If ORB_init encounters a problem with a URL specified by ObjectID it raises a BAD_PARAM exception.

ORBDefaultInitRef
The ORBDefaultInitRef argument specifies an alternative resolution order if an initial reference is not specified with -ORBInitRef. -ORBDefaultInitRef requires a URL to be specified that can be used to create a URL that identifies the service object. This is done be appending a slash `/' character and an service identifier to the value specified by ORBDefaultInitRef.

Example:

The following is a command line invocation example:

myApp -ORBDefaultInitRef corbaloc::myHost.myOrg

// Where myApp is a C++ program that passes 
// the command line args to ORB_init.
#include "corba.h"
...
int main(int argc, char *argv[])
{
// 
// Initialize the ORB and obtain a pointer to it
// 
CORBA::ORB_ptr orbp = CORBA::ORB_init(argc, argv, "WASORB");

// 
// The -ORBDefaultInitRef could cause this resolve to attempt to access
// the NameService using a URL of corbaloc::myHost.myOrg/NameServce.
// 
orbp->resolve_initial_references( "NameService" );
...

orb_identifier
A string that identifies the ORB to be initialized. An empty string returns the default ORB.

Note: Since only one instance of the ORB is supported, calling ORB_init multiple times with different, non-empty, orb_identifier values will result in an exception..

Return values

CORBA::ORB_ptr
A pointer to the ORB object. The return result should be released using CORBA::release(ORB_ptr).

Example

  /* The following is a C++ example */
  #include "corba.h"
  ...
  int main(int argc, char *argv[])
  {
   char * orbid 
   /* Initialize orbid. For CB workstation initialize to "DSOM" */ 
   int rc = 0;
    /* Initialize the ORB and obtain a pointer to it */
    CORBA::ORB_ptr p = CORBA::ORB_init(argc, argv, orbid);
    /* use p in the code */
    ...
    return rc:
  }

Related reference
CORBA module



Searchable topic ID:   rcor_modco3
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/ref/rcor_modco3.html

Library | Support | Terms of Use | Feedback