![]() |
To be able to locate a servant object somewhere in a CORBA environment, a client needs to know the object reference that uniquely identifies the target object.
When an object is created, it is assigned an object reference, which can be bound with a name in the naming service. Any client (or any other object) with access to the naming service can use the associated name to retrieve the object reference.
Object references are bound into the naming service relative to the root naming context. After a client has located the root naming context, it can use the standard CosNaming interface to navigate the name space and retrieve the object reference associated with any name; for example:
// Create a new ::CosNaming::Name to pass to resolve(). // Construct it as the full three-part complex name. ::CosNaming::Name *loggerName = new ::CosNaming::Name; loggerName->length( 3 ); (*loggerName)[0].id = ::CORBA::string_dup( "domain" ); (*loggerName)[0].kind = ""; (*loggerName)[1].id = ::CORBA::string_dup( "WSLoggerContext" ); (*loggerName)[1].kind = ::CORBA::string_dup( "" ); (*loggerName)[2].id = ::CORBA::string_dup( "WSLoggerObject1" ); (*loggerName)[2].kind = ::CORBA::string_dup( "" ); ::CORBA::Object_ptr objPtr = rootNameContext->resolve( *loggerName ); liptr = WSLogger::_narrow( objPtr);
If the client bootstrapping operation does not establish contact with a remote naming service, you can use the alternative strategies to retrieve the IOR of a remote object, as outlined in Strategies for retrieving the IOR of a remote object
Related concepts... | |
Parent: C++ CORBA client, locating the root naming context (bootstrapping) | |
Parent: The CORBA client programming model | |
The CORBA programming model | |