Naming Service
Summary by Uma Jaipradeep
Implementation by Prasad Joshi
The information presented was gathered from Internet.
Summary Contents
- Naming Service Overview
- Naming Objects in the Distributed Object System
- Naming Contexts
- Object Names
- Binding an Object with a Name
- Resolving a Named Object
- Creating a New naming Context
- Listing the Contents of a Naming Context
- Unbinding an Object from a Naming Context
- Client-Server Naming Scenario
- Implementation of Naming Service
- Links
Listing the Contents of a Naming Context
The procedure that follows demonstrates how you can list out the contents
of a naming context using the CosNaming::NamingContext::list() operation. This is useful if you want to perform some function iteratively over each entry of the naming context. The operation must target an existing naming context.
1.Determine the maximum number of entries you want to handle at a time: When you perform the list() operation in step 3, all of the entries in he target naming context are set aside in an iterator object. You are iterating through this object one or multiple entries at a time, getting that many entries back in a sequence (a subset of the iterator) through which you can then sub-iterate. You need to determine the number of entries you want to get back in the sequence at a time.
Memory and performance should both be considered when determining how many entries you want to handle at a time. Memory for the subset sequence is allocated based on the number of entries requested. To conserve memory, request fewer entries at a time.
Normally, the naming context you are listing, and therefore the iterator that is returned from the list request exists in a different process than your program, often on a different machine. Each request for another subset of entries is affected by network latency. The higher the number of requests required to get all of the entries in the iterator, the greater the impact on the performance of your program. Requesting fewer entries at a time increases the number of requests you have to make to the iterator to get all of the entries in the iterator. If performance is an issue, request more entries at a time. Requesting 1000 entries at a time may be a reasonable number for many situations.
2.Resolve to the target naming context: The target naming context is the appropriate naming context. You can resolve to the target name context with the resolve() operation, using one of the following choices:
If you already have a reference to the target naming context you can skip to step 3.
If you already have a reference to a naming context that is superior to the target naming context, then you can invoke the resolve() operation on the superior naming context, passing in the name of the target naming context. This principle can be applied recursively for any of the successively more superior naming contexts.
If you do not already have a naming context, you can get the root to the system name space using the ORB::resolve_initial_references("NamingService") operation (the CORBA standard approach) or by obtaining it from the CBSeriesGlobal::nameService static function (this static function is set by the CBSeriesGlobal::Initialize() method).
Having acquired the root naming context, you can resolve directly to the intended naming context by invoking the resolve() operation and passing the complete path of intermediate naming context names as a compound name.
3.List out the contents of the naming context into an iterator:
Once you are positioned at the target naming context, you can list its contents using the list() or list_with_string() operation on the target naming context. To keep your logic relatively simple do not extract any of the entries into a subset sequence; leave that to be included within your while loop. However, at the cost of some additional complexity, you can go ahead and extract the initial subset of entries on this request to reduce (by one) the number of times that you have to return to the iterator.
4.Get the next subset of entries from the iterator: You can do this with either the next_one() or next_n() operation on the iterator, depending on whether you want just one entry or more than one entry at a time.
5.Process a subset of the entries: Iterate through the sub-set of entries performing your function on each entry as appropriate for your application.
6.Repeat steps 4 and 5 until all of the entries in the iterator are exhausted: The next_one() and next_n() operations return a value of True if there are still more entries left in the iterator after the operation returns. Steps 4 and 5 should be repeated as long as these operations continue to return
True.
You can combine steps 2 and 3 by supplying a compound name that includes the path to the target name context and the name of the new naming context in the name argument on the list() or list_with_string() operation. In this case step 2 is performed implicitly.
Summary Contents
- Naming Service Overview
- Naming Objects in the Distributed Object System
- Naming Contexts
- Object Names
- Binding an Object with a Name
- Resolving a Named Object
- Creating a New naming Context
- Listing the Contents of a Naming Context
- Unbinding an Object from a Naming Context
- Client-Server Naming Scenario
- Implementation of Naming Service
- Links