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
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.
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.
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" ); ...
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
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: }