#include <Naming_Context_Interface.h>
Collaboration diagram for TAO_Naming_Context:
Public Member Functions | |
TAO_Naming_Context (TAO_Naming_Context_Impl *impl) | |
Constructor. Initializes with a concrete implementation. | |
~TAO_Naming_Context (void) | |
Destructor. | |
virtual void | bind (const CosNaming::Name &n, CORBA::Object_ptr obj ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName, CosNaming::NamingContext::AlreadyBound) |
virtual void | rebind (const CosNaming::Name &n, CORBA::Object_ptr obj ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName) |
virtual void | bind_context (const CosNaming::Name &n, CosNaming::NamingContext_ptr nc ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName, CosNaming::NamingContext::AlreadyBound) |
virtual void | rebind_context (const CosNaming::Name &n, CosNaming::NamingContext_ptr nc ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName) |
virtual CORBA::Object_ptr | resolve (const CosNaming::Name &n ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName) |
virtual void | unbind (const CosNaming::Name &n ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName) |
virtual CosNaming::NamingContext_ptr | new_context (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException) |
virtual CosNaming::NamingContext_ptr | bind_new_context (const CosNaming::Name &n ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::AlreadyBound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName) |
virtual void | destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::NotEmpty) |
virtual void | list (CORBA::ULong how_many, CosNaming::BindingList_out bl, CosNaming::BindingIterator_out bi ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException) |
virtual char * | to_string (const CosNaming::Name &n ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::InvalidName) |
virtual CosNaming::Name * | to_name (const char *sn ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw (CORBA::SystemException, CosNaming::NamingContext::InvalidName) |
virtual char * | to_url (const char *addr, const char *sn ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw ( CORBA::SystemException, CosNaming::NamingContextExt::InvalidAddress, CosNaming::NamingContext::InvalidName ) |
virtual CORBA::Object_ptr | resolve_str (const char *n ACE_ENV_ARG_DECL_WITH_DEFAULTS) throw ( CORBA::SystemException, CosNaming::NamingContext::NotFound, CosNaming::NamingContext::CannotProceed, CosNaming::NamingContext::InvalidName ) |
virtual PortableServer::POA_ptr | _default_POA (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) |
Returns the Default POA of this Servant object. | |
Protected Attributes | |
TAO_Naming_Context_Impl * | impl_ |
A concrete implementor of the NamingContext functions. | |
Private Types | |
enum | Hint { HINT_ID, HINT_KIND } |
Private Member Functions | |
void | to_name_helper (char *dest, const char *&src, Hint hint) |
void | to_string_helper_assign (char *&k, const char *&src) |
void | to_string_helper_length (CORBA::ULong &len, const char *&src) |
Static Private Member Functions | |
int | to_url_is_alnum_or_punctuation (char c) |
size_t | to_url_validate_and_compute_size (const char *add, const char *sn ACE_ENV_ARG_DECL) |
This class simply forwards all client requests to a concrete NamingContext implementation through its pointer. See README file for more info. Comments for the idl methods describe methods semantics - actual actions are carried out by concrete implementors.
Definition at line 46 of file Naming_Context_Interface.h.
|
Definition at line 250 of file Naming_Context_Interface.h.
|
|
Constructor. Initializes with a concrete implementation.
Definition at line 23 of file Naming_Context_Interface.cpp.
00024 : impl_ (impl) 00025 { 00026 } |
|
Destructor.
Definition at line 28 of file Naming_Context_Interface.cpp.
00029 { 00030 delete impl_; 00031 } |
|
Returns the Default POA of this Servant object.
|
|
Create a binding for name and object in the naming context. Compound names are treated as follows: ctx->bind (<c1; c2; c3; cn>, obj) = (ctx->resolve (<c1; c2; cn-1>))->bind (, obj) if the there already exists a binding for the specified name, exception is thrown. Naming contexts should be bound using and in order to participate in name resolution later. Definition at line 40 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
|
|
This is the version of specifically for binding naming contexts, so that they will participate in name resolution when compound names are passed to be resolved. Definition at line 65 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
00073 { 00074 impl_->bind_context (n, nc ACE_ENV_ARG_PARAMETER); 00075 } |
|
This operation creates a new context and binds it to the name supplied as an argument. The newly-created context is implemented by the same server as the context in which it was bound (the name argument excluding the last component). Definition at line 119 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
00126 { 00127 return impl_->bind_new_context (n ACE_ENV_ARG_PARAMETER); 00128 } |
|
Delete the naming context. The user should take care to any bindings in which the given context is bound to some names, to avoid dangling references when invoking operation. NOTE: is a no-op on the root context. NOTE: after is invoked on a Naming Context, all BindingIterators associated with that Naming Context are also destroyed. Definition at line 131 of file Naming_Context_Interface.cpp. References ACE_ENV_SINGLE_ARG_PARAMETER.
|
|
Returns at most the requested number of bindings in . If the naming context contains additional bindings, they are returned with a BindingIterator. In the naming context does not contain any additional bindings returned as null. Definition at line 139 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
|
|
This operation returns a new naming context implemented by the same naming server in which the operation was invoked. The context is not bound. Definition at line 112 of file Naming_Context_Interface.cpp. References ACE_ENV_SINGLE_ARG_PARAMETER.
00114 { 00115 return impl_->new_context (ACE_ENV_SINGLE_ARG_PARAMETER); 00116 } |
|
This is similar to operation above, except for when the binding for the specified name already exists in the specified context. In that case, the existing binding is replaced with the new one. Definition at line 53 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
|
|
This is a version of specifically for naming contexts, so that they can participate in name resolution when compound names are passed. Definition at line 78 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
00085 { 00086 impl_->rebind_context (n, nc ACE_ENV_ARG_PARAMETER); 00087 } |
|
Return object reference that is bound to the name. Compound name resolve is defined as follows: ctx->resolve (<c1; c2; cn>) = ctx->resolve (<c1; c2 cn-1>)->resolve () The naming service does not return the type of the object. Clients are responsible for "narrowing" the object to the appropriate type. Definition at line 90 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
|
|
Similar to as in the CosNaming::NamingContext interface. It accepts a strigified name as an argument instead of a Name. Definition at line 516 of file Naming_Context_Interface.cpp. References ACE_CHECK_RETURN, and ACE_ENV_ARG_PARAMETER.
00523 { 00524 // Similar to <resolve> above. It accepts a strigified name as an 00525 // argument instead of a Name. 00526 00527 // Get the unstrigified name. 00528 CosNaming::Name_var name = this->to_name (n ACE_ENV_ARG_PARAMETER); 00529 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00530 00531 // Pass this unstringified name to resolve and return an Object_ptr 00532 return this->resolve (name.in () ACE_ENV_ARG_PARAMETER); 00533 } |
|
The in parameter is an stringified name. This function removes the escape character '\' and destringifies the stringified name and returns it. Definition at line 295 of file Naming_Context_Interface.cpp. References ACE_THROW_RETURN, CosNaming::Name, and CORBA::string_alloc().
00299 { 00300 // Returns the Name from its stringified form. 00301 CosNaming::Name n; 00302 00303 // Total number of name components in the name 00304 CORBA::ULong ncomp = 0; 00305 00306 // Total length of the unstrigified name 00307 CORBA::ULong len=0; 00308 00309 00310 for (const char *j = sn; *j != '\0'; ++j) 00311 { 00312 // Make a pass through the Name and count each character 00313 if (*j == '/') 00314 { 00315 ncomp++; 00316 } 00317 else if (*j == '\\') 00318 { 00319 ++j; 00320 00321 if (*j == '\0') 00322 { 00323 // Case: The very last component 00324 ++len; 00325 } 00326 } 00327 00328 // In all cases. 00329 ++len; 00330 } 00331 00332 00333 // Check for InvalidName i.e. Invalid stringified name 00334 // 00335 if (len == 0) 00336 ACE_THROW_RETURN (CosNaming::NamingContext::InvalidName(), 00337 0); 00338 00339 // Assign the length of the return unstringified name. 00340 // 00341 n.length (ncomp+1); 00342 00343 // Keeps track of the number of the name component 00344 // 00345 CORBA::ULong count = 0; 00346 00347 for (const char *k = sn; *k != '\0';) 00348 { 00349 if (count > ncomp) 00350 { 00351 ACE_THROW_RETURN (CosNaming::NamingContext::InvalidName(), 0); 00352 } 00353 00354 char *id = CORBA::string_alloc (len); 00355 char *kind = CORBA::string_alloc (len); 00356 00357 // Assign to the id. 00358 this->to_name_helper (id, k, HINT_ID); 00359 00360 if (*k == '.') 00361 { 00362 k++; 00363 // Assign to kind 00364 this->to_name_helper (kind, k, HINT_KIND); 00365 } 00366 else 00367 { 00368 *kind = '\0'; 00369 } 00370 00371 n[count].id = id; 00372 n[count].kind = kind; 00373 00374 count++; 00375 00376 // End 00377 if (*k == '\0') 00378 break; 00379 k++; 00380 } 00381 00382 return new CosNaming::Name (n); 00383 } |
|
This private function is used as a helper to . It reads character by character from 'src' and depending on the character, either assigns it to 'dest' or returns back to the calling function. If the character is a seperator between the 'id' and 'kind' fields or a seperator between two name components, the control is returned back to the calling function . Definition at line 265 of file Naming_Context_Interface.cpp. References HINT_ID.
00266 { 00267 for (; *src != '\0'; ++src, ++dest) 00268 { 00269 if ((hint == HINT_ID && *src == '.') || *src == '/') 00270 { 00271 *dest = '\0'; 00272 return; 00273 } 00274 00275 if (*src == '\\') 00276 { 00277 src++; 00278 if (*src == '\0') 00279 { 00280 // Case: The very last component 00281 *dest = '\0'; 00282 return; 00283 } 00284 } 00285 00286 // In all cases. 00287 *dest = *src; 00288 } 00289 00290 // Terminate. 00291 *dest = '\0'; 00292 } |
|
Stringify the name using '\' as the escape character. The characters '.' , '/' and '\' are to be escaped. If the input name is invalid i.e. if the number of characters in the name is zero, an InvalidName exception is to be raised. Definition at line 180 of file Naming_Context_Interface.cpp. References ACE_THROW_RETURN, and CORBA::string_alloc().
00184 { 00185 // Accepts a Name and returns a stringified name. 00186 00187 // Check for invalid name. 00188 if (n.length () == 0) 00189 ACE_THROW_RETURN (CosNaming::NamingContext::InvalidName(), 00190 0); 00191 00192 // Length of the return string 00193 CORBA::ULong len = 0; 00194 00195 CORBA::ULong i; 00196 for (i=0; i < n.length (); ++i) 00197 { 00198 const char *id = n[i].id.in (); 00199 00200 // Count number of characters in id 00201 this->to_string_helper_length (len, id); 00202 00203 const char *kind = n[i].kind.in (); 00204 00205 // Count number of characters in kind 00206 this->to_string_helper_length (len, kind); 00207 } 00208 00209 // Allocate memory to the return parameter 00210 // 00211 char *str_name = CORBA::string_alloc (len); 00212 00213 // check for memory allocation 00214 // 00215 if (str_name == 0) 00216 { 00217 ACE_THROW_RETURN (CORBA::NO_MEMORY (), 0); 00218 } 00219 00220 char *k = str_name; 00221 00222 // Stringify the name 00223 for (i=0; i < n.length (); ++i) 00224 { 00225 00226 // Stringify Id 00227 // 00228 const char *id = n[i].id.in (); 00229 this->to_string_helper_assign (k, id); 00230 00231 const char *kind = n[i].kind.in (); 00232 00233 if (*kind != '\0') 00234 { 00235 // If 'kind' is set, 00236 // Append a seperator between the id and kind. 00237 // 00238 *k = '.'; 00239 ++k; 00240 00241 // Stringify Kind 00242 // 00243 this->to_string_helper_assign (k, kind); 00244 } 00245 00246 // If this is not the last name component, add a seperator 00247 // between the name components 00248 // 00249 if (i != (n.length ()-1)) 00250 { 00251 *k = '/'; 00252 ++k; 00253 } 00254 00255 } 00256 // Terminate 00257 *k = '\0'; 00258 ++k; 00259 00260 return str_name; 00261 } |
|
This method functions similar to . If the character read is '.' or '/' or '\', an escape character '\' is prepended before the character. Definition at line 164 of file Naming_Context_Interface.cpp.
00165 { 00166 for (; *src != '\0'; ++src) 00167 { 00168 if (*src == '.' || *src == '\\' || *src == '/') 00169 { 00170 *k = '\\'; 00171 ++k; 00172 } 00173 *k = *src; 00174 ++k; 00175 } 00176 00177 } |
|
This method helps count the number of characters in 'src' so that memory can be allocated for the return parameter. For all '.' , '/' and '\', the count is incremented by 'one' to account for the escape character that needs to be added. Seperators between 'id' and 'kind' as well as seperators between the name components are also counted. Definition at line 150 of file Naming_Context_Interface.cpp.
00151 { 00152 for (const char *j =src; *j != '\0'; ++j) 00153 { 00154 ++len; 00155 if (*j == '.' || *j == '\\' || *j == '/') 00156 ++len; 00157 } 00158 ++len; // '.' seperator or '/' seperator 00159 00160 } |
|
The in parameter addr refers to the address of the naming context and sn refers to the strigified name of the object in that context. This function returns a fully formed URL string like iiopname://1.1@myhost.555xyz.com:9999/a/b/c Definition at line 444 of file Naming_Context_Interface.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE::nibble2hex(), ACE_OS::strcat(), ACE_OS::strcpy(), CORBA::string_alloc(), ACE_OS::strlen(), to_url_is_alnum_or_punctuation(), and to_url_validate_and_compute_size().
00450 { 00451 /// Compute how many characters will be required for the URL 00452 size_t no_char = 00453 TAO_Naming_Context::to_url_validate_and_compute_size (addr, sn 00454 ACE_ENV_ARG_PARAMETER); 00455 ACE_CHECK_RETURN (0); 00456 00457 00458 // The 'corbaname:' tag is to be prepended at the starting of the 00459 // return parameter. 00460 // 00461 char prefix []= "corbaname:"; 00462 00463 // Allocate dynamic memory 00464 // 00465 char *str_url = CORBA::string_alloc (static_cast<CORBA::ULong> (no_char + sizeof (prefix))); 00466 00467 // Copy 'prefix' to the return parameter. 00468 char *dest = ACE_OS::strcpy (str_url , prefix); 00469 00470 /// move to end of dest string 00471 dest += ACE_OS::strlen(dest); 00472 00473 // Concatenate the address 00474 dest = ACE_OS::strcat (dest, addr); 00475 00476 /// Concatenate the seperator between the addr and Name 00477 dest += ACE_OS::strlen(dest); 00478 dest = ACE_OS::strcat (dest, "#"); 00479 00480 /// move to end of dest string 00481 dest += ACE_OS::strlen(dest); 00482 00483 // Now append the stringified object name to the return variable. 00484 // The percent '%' character is used as an escape. If a character 00485 // that requires escaping is present in a name component it is 00486 // encoded as two hexadecimal digits following a '%' character to 00487 // represent the octet. The first hexadecimal character represents 00488 // the low-order nibble of the octet and the second hexadecimal 00489 // character represents the low order nibble. 00490 00491 for (const char *i = sn; *i != '\0'; ++i) 00492 { 00493 if (TAO_Naming_Context::to_url_is_alnum_or_punctuation (*i)) 00494 { 00495 // If the character is a US-ASCII Alphanumeric value... 00496 *dest = *i; ++dest; 00497 continue; 00498 } 00499 // this must be an escaped character 00500 00501 *dest = '%'; ++dest; 00502 00503 // Append the hexadecimal representation of the character. 00504 *dest = ACE::nibble2hex ((*i) >> 4); ++dest; 00505 *dest = ACE::nibble2hex (*i); ++dest; 00506 } 00507 00508 // Terminate the string 00509 *dest = '\0'; 00510 00511 // ACE_OS::strcat (str_url, dest); 00512 return str_url; 00513 } |
|
Return 1 if the character is alphanumeric or a non-scaped punctuation. Definition at line 386 of file Naming_Context_Interface.cpp. Referenced by to_url(), and to_url_validate_and_compute_size().
00387 { 00388 if (isalnum (c)) 00389 return 1; 00390 00391 // NON US-ASCII charcters excluding those in this array are the 00392 // characters that need to be escaped 00393 static char non_escaped_punctuation[] = 00394 { ';', '/', ':', '?', '@', '=', '+', '$', ',', '-', 00395 '_', '.', '!', '~', '*', '\'', '(', ')' }; 00396 const size_t non_escaped_punctuation_count = 00397 sizeof(non_escaped_punctuation)/sizeof(non_escaped_punctuation[0]); 00398 for (const char *j = non_escaped_punctuation; 00399 j != non_escaped_punctuation + non_escaped_punctuation_count; 00400 ++j) 00401 { 00402 // But if the character is one of the 18 non US-ASCII characters 00403 // and hence need not be escaped, then don't increment the 00404 // count. 00405 if (*j == c) 00406 return 1; 00407 } 00408 return 0; 00409 } |
|
Validate the to_url() method input, and compute the size of the returned URL address. Definition at line 412 of file Naming_Context_Interface.cpp. References ACE_THROW_RETURN, ACE_OS::strlen(), and to_url_is_alnum_or_punctuation(). Referenced by to_url().
00416 { 00417 size_t addr_len = ACE_OS::strlen (addr); 00418 00419 // Check for invalid address 00420 if (addr_len == 0) 00421 ACE_THROW_RETURN (CosNaming::NamingContextExt::InvalidAddress (), 00422 0); 00423 00424 // Make a pass through the in string name to count the number of 00425 // characters and if the character 00426 // is to be escaped, increment the number of characters by 3. 00427 size_t sn_len = 0; 00428 for (const char *i = sn; *i != '\0'; ++i) 00429 { 00430 ++sn_len; 00431 00432 if (TAO_Naming_Context::to_url_is_alnum_or_punctuation (*i)) 00433 continue; 00434 sn_len += 3; 00435 } 00436 00437 if (sn_len == 0) 00438 ACE_THROW_RETURN (CosNaming::NamingContextExt::InvalidName (), 0); 00439 00440 return addr_len + sn_len; 00441 } |
|
Remove the name binding from the context. When compound names are used, unbind is defined as follows: ctx->unbind (<c1; c2; cn>) = (ctx->resolve (<c1; c2; cn-1>))->unbind () Definition at line 101 of file Naming_Context_Interface.cpp. References ACE_ENV_ARG_PARAMETER.
|
|
A concrete implementor of the NamingContext functions.
Definition at line 296 of file Naming_Context_Interface.h. |