#include <CORBANAME_Parser.h>
Inheritance diagram for TAO_CORBANAME_Parser:
Public Member Functions | |
virtual | ~TAO_CORBANAME_Parser (void) |
The destructor. | |
virtual int | match_prefix (const char *ior_string) const |
virtual CORBA::Object_ptr | parse_string (const char *ior, CORBA::ORB_ptr orb) throw (CORBA::SystemException) |
Private Member Functions | |
virtual CORBA::Object_ptr | parse_string_dynamic_request_helper (CORBA::Object_ptr naming_context, ACE_CString &key_string) throw (CORBA::SystemException) |
This class implements the <corbaname:> IOR format. It is dynamically loaded by the ORB and used to get reference to a naming service at the given address and port and then resolve an object in that context.
Definition at line 39 of file CORBANAME_Parser.h.
|
The destructor.
Definition at line 24 of file CORBANAME_Parser.cpp.
00025 { 00026 } |
|
Return 1 if ior_string starts with a prefix known to this IOR parser Implements TAO_IOR_Parser. Definition at line 29 of file CORBANAME_Parser.cpp. References corbaname_prefix, and ACE_OS::strncmp().
00030 { 00031 return (ACE_OS::strncmp (ior_string, 00032 corbaname_prefix, 00033 sizeof corbaname_prefix - 1) == 0); 00034 } |
|
Parse the ior argument and return an object reference. The call may raise the standard system exceptions (NO_MEMORY, INV_OBJREF, etc.) Implements TAO_IOR_Parser. Definition at line 66 of file CORBANAME_Parser.cpp. References CORBA::Object::_nil(), TAO_Pseudo_Var_T< T >::_retn(), ACE_CATCH, ACE_CHECK_RETURN, ACE_CString, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ERROR_RETURN, ACE_PRINT_EXCEPTION, ACE_TRY, ACE_TRY_CHECK, corbaname_prefix, TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), LM_ERROR, CORBA::Object_ptr, CORBA::Object_var, CORBA::ORB_ptr, ssize_t, and TAO_debug_level.
00070 { 00071 00072 // Skip the prefix, we know it is there because this method in only 00073 // called if <match_prefix> returns 1. 00074 const char *corbaname = 00075 ior + sizeof corbaname_prefix - 1; 00076 00077 CORBA::Object_ptr obj = CORBA::Object::_nil (); 00078 00079 ACE_TRY 00080 { 00081 // The position of the seperator between the obj_addr and key 00082 // string 00083 ssize_t pos_seperator = 0; 00084 00085 ACE_CString corbaname_str (corbaname, 0, 1); 00086 00087 pos_seperator = corbaname_str.find ("#", 0); 00088 00089 // Get the Key String 00090 ACE_CString key_string; 00091 00092 if (pos_seperator != ACE_CString::npos) 00093 { 00094 key_string = corbaname_str.substring (pos_seperator + 1, 00095 -1); 00096 } 00097 00098 // Prepare a suitable corbaloc string for the name service. 00099 // CORBALOC assumes "NameService" for the object key if none 00100 // is provided, so just pass everything between "corbaname:" 00101 // and "#" as the address 00102 ACE_CString corbaloc_addr ("corbaloc:", 0, 1); 00103 corbaloc_addr += corbaname_str.substring (0, pos_seperator); 00104 00105 // Obtain a reference to the naming context 00106 CORBA::Object_var name_context = 00107 orb->string_to_object (corbaloc_addr.c_str () 00108 ACE_ENV_ARG_PARAMETER); 00109 ACE_TRY_CHECK; 00110 00111 // Check if the Object reference is nil. 00112 if (CORBA::is_nil (name_context.in ())) 00113 ACE_ERROR_RETURN ((LM_ERROR, 00114 "Cannot resolve Naming Service: CORBANAME_Parser\n"), 00115 0); 00116 00117 CORBA::Boolean is_a = 00118 name_context->_is_a ("IDL:omg.org/CosNaming/NamingContextExt:1.0" 00119 ACE_ENV_ARG_PARAMETER); 00120 ACE_TRY_CHECK; 00121 00122 if (!is_a) 00123 { 00124 ACE_ERROR_RETURN ((LM_ERROR, 00125 "Cannot narrow Naming Service: " 00126 "CORBANAME_Parser\n"), 00127 0); 00128 } 00129 00130 if (key_string.length () != 0) 00131 { 00132 00133 // Make a dynamic request for resolve_str in this naming context 00134 obj = this->parse_string_dynamic_request_helper (name_context.in (), 00135 key_string 00136 ACE_ENV_ARG_PARAMETER); 00137 ACE_TRY_CHECK; 00138 } 00139 else 00140 { // There was no key string which implies that the caller wants 00141 // the object reference of the naming service. 00142 obj = name_context._retn (); 00143 } 00144 } 00145 ACE_CATCH (CORBA::SystemException, ex) 00146 { 00147 if (TAO_debug_level >= 4) 00148 { 00149 ACE_PRINT_EXCEPTION (ex, "CORBANAME_Parser"); 00150 } 00151 } 00152 ACE_ENDTRY; 00153 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00154 00155 return obj; 00156 } |
|
Definition at line 38 of file CORBANAME_Parser.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, TAO::Invocation_Adapter::invoke(), and CORBA::Object_ptr.
00042 { 00043 TAO::Arg_Traits<CORBA::Object>::ret_val _tao_retval; 00044 TAO::Arg_Traits<CORBA::Char *>::in_arg_val _tao_id (key_string.c_str ()); 00045 00046 TAO::Argument *_tao_signature [] = 00047 { 00048 &_tao_retval, 00049 &_tao_id 00050 }; 00051 00052 TAO::Invocation_Adapter tao_call (naming_context, 00053 _tao_signature, 00054 2, 00055 "resolve_str", 00056 11, 00057 0); 00058 00059 tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER); 00060 ACE_CHECK_RETURN (_tao_retval.excp ()); 00061 00062 return _tao_retval.retn (); 00063 } |