#include <CORBANAME_Parser.h>
Inheritance diagram for TAO_CORBANAME_Parser:


Public Member Functions | |
| virtual | ~TAO_CORBANAME_Parser (void) |
| The destructor. | |
| virtual bool | match_prefix (const char *ior_string) const |
| virtual CORBA::Object_ptr | parse_string (const char *ior, CORBA::ORB_ptr orb) |
Private Member Functions | |
| virtual CORBA::Object_ptr | parse_string_dynamic_request_helper (CORBA::Object_ptr naming_context, ACE_CString &key_string) |
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 41 of file CORBANAME_Parser.h.
|
|
The destructor.
Definition at line 27 of file CORBANAME_Parser.cpp.
00028 {
00029 }
|
|
|
Return true if ior_string starts with a prefix known to this IOR parser Implements TAO_IOR_Parser. Definition at line 32 of file CORBANAME_Parser.cpp. References corbaname_prefix, and ACE_OS::strncmp().
00033 {
00034 return (ACE_OS::strncmp (ior_string,
00035 corbaname_prefix,
00036 sizeof corbaname_prefix - 1) == 0);
00037 }
|
|
||||||||||||
|
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_CString, ACE_ERROR_RETURN, corbaname_prefix, TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), LM_ERROR, CORBA::Object_ptr, CORBA::Object_var, CORBA::ORB_ptr, parse_string_dynamic_request_helper(), CORBA::ORB::string_to_object(), and TAO_debug_level.
00067 {
00068
00069 // Skip the prefix, we know it is there because this method in only
00070 // called if <match_prefix> returns 1.
00071 const char *corbaname =
00072 ior + sizeof corbaname_prefix - 1;
00073
00074 CORBA::Object_ptr obj = CORBA::Object::_nil ();
00075
00076 try
00077 {
00078 // The position of the seperator between the obj_addr and key
00079 // string
00080 ACE_CString::size_type pos_seperator = 0;
00081
00082 ACE_CString corbaname_str (corbaname, 0, 1);
00083
00084 pos_seperator = corbaname_str.find ("#", 0);
00085
00086 // Get the Key String
00087 ACE_CString key_string;
00088
00089 if (pos_seperator != ACE_CString::npos)
00090 {
00091 key_string = corbaname_str.substring (pos_seperator + 1,
00092 ACE_CString::npos);
00093 }
00094
00095 // Prepare a suitable corbaloc string for the name service.
00096 // CORBALOC assumes "NameService" for the object key if none
00097 // is provided, so just pass everything between "corbaname:"
00098 // and "#" as the address
00099 ACE_CString corbaloc_addr ("corbaloc:", 0, 1);
00100 corbaloc_addr += corbaname_str.substring (0, pos_seperator);
00101
00102 // Obtain a reference to the naming context
00103 CORBA::Object_var name_context =
00104 orb->string_to_object (corbaloc_addr.c_str ()
00105 );
00106
00107 // Check if the Object reference is nil.
00108 if (CORBA::is_nil (name_context.in ()))
00109 ACE_ERROR_RETURN ((LM_ERROR,
00110 "Cannot resolve Naming Service: CORBANAME_Parser\n"),
00111 0);
00112
00113 CORBA::Boolean is_a =
00114 name_context->_is_a ("IDL:omg.org/CosNaming/NamingContextExt:1.0");
00115
00116 if (!is_a)
00117 {
00118 ACE_ERROR_RETURN ((LM_ERROR,
00119 "Cannot narrow Naming Service: "
00120 "CORBANAME_Parser\n"),
00121 0);
00122 }
00123
00124 if (key_string.length () != 0)
00125 {
00126
00127 // Make a dynamic request for resolve_str in this naming context
00128 obj = this->parse_string_dynamic_request_helper (name_context.in (),
00129 key_string);
00130 }
00131 else
00132 { // There was no key string which implies that the caller wants
00133 // the object reference of the naming service.
00134 obj = name_context._retn ();
00135 }
00136 }
00137 catch (const ::CORBA::SystemException& ex)
00138 {
00139 if (TAO_debug_level >= 4)
00140 {
00141 ex._tao_print_exception ("CORBANAME_Parser");
00142 }
00143 }
00144
00145 return obj;
00146 }
|
|
||||||||||||
|
Definition at line 41 of file CORBANAME_Parser.cpp. References TAO::Invocation_Adapter::invoke(), and CORBA::Object_ptr. Referenced by parse_string().
00043 {
00044 TAO::Arg_Traits<CORBA::Object>::ret_val _tao_retval;
00045 TAO::Arg_Traits<CORBA::Char *>::in_arg_val _tao_id (key_string.c_str ());
00046
00047 TAO::Argument *_tao_signature [] =
00048 {
00049 &_tao_retval,
00050 &_tao_id
00051 };
00052
00053 TAO::Invocation_Adapter tao_call (naming_context,
00054 _tao_signature,
00055 2,
00056 "resolve_str",
00057 11,
00058 0);
00059
00060 tao_call.invoke (0, 0);
00061
00062 return _tao_retval.retn ();
00063 }
|
1.3.6