[Up: Implementation Overview]
[Previous: Implementation Overview] [Next: Interface Repository]

Subsections

- ORB Initialization
- Obtaining Initial References

# ORB

The ORB is implemented as a library (`libmico2.3.6.a`) that is linked into each MICO application.

##
ORB Initialization

Every MICO application has to call the ORB initialization function `ORB_init()` before using MICO functionality.

      int main (int argc, char *argv[])
      {
         CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "mico-local-orb");
         ...
      }

That way the ORB has access to the applications command line arguments. After evaluating them the ORB removes the command line options it understands so the application doesn't have to care about them. You can also put ORB command line arguments into a file called `.micorc` in your home directory. Arguments given on the command line override settings from `.micorc`. Here is a description of all ORB specific command line arguments:

`-ORBNoIIOPServer`
  Do not activate the IIOP server. The IIOP server enables other processes to invoke methods on objects in this process using the Internet Inter ORB Protocol (IIOP). If for some reason you do not want other processes to be able to invoke objects in this process you can use this option. Default is to activate the IIOP server.
`-ORBNoIIOPProxy`
  Do not activate the IIOP proxy. The IIOP proxy enables this process to invoke methods on objects in other processes using IIOP. If you do not want or need this you can use this option. Default is to activate the IIOP proxy.
`-ORBIIOPAddr <address>`
  Set the address the IIOP server should run on. See section 3.3.3 for details on addresses. If you do not specify this option the IIOP server will choose an unused address. This option can be used more than once to make the server listen on several addresses (e.g., a `unix:` and an `inet:` address).
`-ORBIIOPBlocking`
  Make IIOP use sockets in blocking mode. This gains some extra performance, but nested method invocations do not work in this mode.
`-ORBId <ORB identifier>`
  Specify the ORB identifier, `mico-local-orb` is currently the only supported ORB identifier. This option is intended for programs that needed access to different CORBA implementations in the same process. In this case the option `-ORBId` is used to select one of the CORBA implementations.
`-ORBImplRepoIOR <impl repository IOR>`
  Specify a stringified object reference4.1 for the implementation repository the ORB should use.
`-ORBImplRepoAddr <impl repository address>`
  Specify the address of a process that runs an implementation repository. The ORB will then try to bind to an implementation repository object using the given address. See 3.3.3 for details on addresses and the binder. If the bind fails or if you did neither specify `-ORBImplRepoAddr` nor `-ORBImpRepoIOR` the ORB will run a local implementation repository.
`-ORBIfaceRepoIOR <interface repository IOR>`
  The same as `-ORBImplRepoIOR` but for the interface repository.
`-ORBIfaceRepoAddr <interface repository address>`
  The same as `-ORBImplRepoAddr` but for the interface repository.
`-ORBNamingIOR <naming service IOR>`
  The same as `-ORBImplRepoIOR` but for the naming service.
`-ORBNamingAddr <naming address>`
  The same as `-ORBImplRepoAddr` but for the naming service.
`-ORBInitRef <Identifier>=<IOR>`
  Sets the value for the initial reference by the name of `identifer` to the given object reference. This mechanism can be used both for custom and for standard initial references (see above).
`-ORBDefaultInitRef <IOR-base>`
  Defines a location for initial references. `IOR-base` is an `iioploc-` or `iiopname-`Style object reference. When a previously unknown initial reference is searched for using `resolve_initial_references()`, the searched-for identifier is concatenated to the `IOR-base` string to produce the service's location.
`-ORBNoResolve`
  Do not resolve given IP addresses into host names. Use dotted decimal notation instead.
`-ORBDebugLevel <level>`
  Specify the debug level. `<level>` is a non-negative integer with greater values giving more debug output on `cerr`.
`-ORBBindAddr <address>`
  Specify an address which `bind(const char *repoid)` should try to bind to. This option can be used more than once to specify multiple addresses.
`-ORBConfFile <rcfile>`
  Specifies the file from which to read additional command line options (defaults to `~/.micorc`).
`-ORBNoCodeSets`
  Do not add code set information to object references. Since code set conversion is a CORBA 2.1 feature this option may be needed to talk to ORBs which are not CORBA 2.1 compliant. Furthermore it may gain some extra speed.
`-ORBNativeCS <pattern>`
  Specifies the code set the application uses for characters and strings. `<pattern>` is a shell-like pattern that must match the `description` field of a code set in the OSF code set registry4.2. For example the pattern `*8859-1*` will make the ORB use the code set ISO-8859-1 (Latin 1) as the native char code set, which is the default if you do not specify this option. The ORB uses this information to automatically convert characters and strings when talking to an application that uses a different code set.
`-ORBNativeWCS <pattern>`
  Similar to `-ORBNativeWCS`, but specifies the code set the application uses to wide characters and wide strings. Defaults to UTF-16, a 16 bit encoding of Unicode.

##
Obtaining Initial References

The ORB offers two functions for obtaining object references for the interface repository, the implementation repository, and the naming service. Here is an example that shows how to obtain a reference for the interface repository using `resolve_initial_references()`:

      int main (int argc, char *argv[])
      {
        CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "mico-local-orb");
        ...
        CORBA::Object_var obj =
          orb->resolve_initial_references ("InterfaceRepository");
        CORBA::Repository_var repo = CORBA::Repository::_narrow (obj);
        ...
      }

If you specify the interface repository by using the ORB command line option `-ORBIfaceRepoAddr` or `-ORBIfaceRepoIOR`, the reference returned from `resolve_initial_references()` will be the one you specified. Otherwise the ORB will run a local interface repository and you will get a reference to this one.

Obtaining a reference to the implementation repository (`"ImplementationRepository"`) and the naming service (`"NameService"`) works the same way as for the interface repository.

There is another method called `list_initial_services()` that returns a list of names which can be used as arguments for `resolve_initial_references()`. Here is how to use it:

      int main (int argc, char *argv[])
      {
        CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "mico-local-orb");
        ...
        CORBA::ORB::ObjectIdList_var ids = orb->list_initial_services ();
        for (int i = 0; i < ids->length(); ++i)
          cout << ids[i] << endl;
        ...
      }

Initial references can also be specified using the `-ORBInitRef` and `-ORBDefaultInitRef` command line options.

[Previous: Implementation Overview] [Next: Interface Repository]
[Up: Implementation Overview]