Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_CORBANAME_Parser Class Reference

Implements the <corbaname:> IOR format. More...

#include <CORBANAME_Parser.h>

Inheritance diagram for TAO_CORBANAME_Parser:

Inheritance graph
[legend]
Collaboration diagram for TAO_CORBANAME_Parser:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_CORBANAME_Parser (void)
 Constructor. More...

virtual ~TAO_CORBANAME_Parser (void)
 The destructor. More...

virtual int match_prefix (const char *ior_string) const
 Return 1 if <ior_string> starts with a prefix known to this IOR parser. More...

virtual CORBA::Object_ptr parse_string (const char *ior, CORBA::ORB_ptr orb ACE_ENV_ARG_DECL_NOT_USED) throw (CORBA::SystemException)

Private Methods

virtual CORBA::Object_ptr parse_string_dynamic_request_helper (CORBA::Object_ptr naming_context, ACE_CString &key_string ACE_ENV_ARG_DECL) throw (CORBA::SystemException)

Detailed Description

Implements the <corbaname:> IOR format.

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 35 of file CORBANAME_Parser.h.


Constructor & Destructor Documentation

ACE_INLINE TAO_CORBANAME_Parser::TAO_CORBANAME_Parser void   
 

Constructor.

Definition at line 4 of file CORBANAME_Parser.i.

00005 {
00006 }

TAO_CORBANAME_Parser::~TAO_CORBANAME_Parser void    [virtual]
 

The destructor.

Definition at line 15 of file CORBANAME_Parser.cpp.

00016 {
00017 }


Member Function Documentation

int TAO_CORBANAME_Parser::match_prefix const char *    ior_string const [virtual]
 

Return 1 if <ior_string> starts with a prefix known to this IOR parser.

Implements TAO_IOR_Parser.

Definition at line 22 of file CORBANAME_Parser.cpp.

References corbaname_prefix, and ACE_OS_String::strncmp.

00023 {
00024   return (ACE_OS::strncmp (ior_string,
00025                            corbaname_prefix,
00026                            sizeof corbaname_prefix - 1) == 0);
00027 }

CORBA::Object_ptr TAO_CORBANAME_Parser::parse_string const char *    ior,
CORBA::ORB_ptr orb    ACE_ENV_ARG_DECL_NOT_USED
throw (CORBA::SystemException) [virtual]
 

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 128 of file CORBANAME_Parser.cpp.

References ACE_CATCH, ACE_CHECK_RETURN, ACE_CString, ACE_ENDTRY, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ERROR_RETURN, ACE_PRINT_EXCEPTION, ACE_TRY, ACE_TRY_CHECK, corbaname_prefix, CORBA::is_nil, LM_ERROR, and ACE_OS_String::strncmp.

00132 {
00133 
00134   // Skip the prefix, we know it is there because this method in only
00135   // called if <match_prefix> returns 1.
00136   const char *corbaname =
00137     ior + sizeof corbaname_prefix - 1;
00138 
00139   CORBA::Object_ptr obj = CORBA::Object::_nil ();
00140 
00141   ACE_TRY
00142     {
00143       char rir_prot [] = "rir:";
00144 
00145       // The position of the seperator between the obj_addr and key
00146       // string
00147       CORBA::ULong pos_seperator = 0;
00148 
00149       ACE_CString corbaname_str (corbaname, 0, 1);
00150 
00151       pos_seperator = corbaname_str.find ("#", 0);
00152 
00153       // Get the Key String
00154       ACE_CString key_string =
00155         corbaname_str.substring (pos_seperator + 1,
00156                                  -1);
00157 
00158       // Make it in a form understandable by <corbaloc> scheme
00159       ACE_CString corbaloc_addr ("corbaloc:", 0, 1);
00160 
00161       if (ACE_OS::strncmp (corbaname,
00162                            rir_prot,
00163                            sizeof (rir_prot)) != 0)
00164         {
00165           // Implies that <iiop:> protocol is to be used.
00166           // So .. we need to get the host address where an object of
00167           // type NamingContext can be found.
00168           // Get the obj_addr
00169           ACE_CString obj_addr = corbaname_str.substring (0,
00170                                                           pos_seperator);
00171 
00172           corbaloc_addr += obj_addr;
00173 
00174         }
00175 
00176       ACE_CString name_service ("/NameService", 0, 1);
00177       corbaloc_addr += name_service;
00178 
00179       // Obtain a reference to the naming context
00180       CORBA::Object_var name_context =
00181         orb->string_to_object (corbaloc_addr.c_str ()
00182                                 ACE_ENV_ARG_PARAMETER);
00183       ACE_TRY_CHECK;
00184 
00185       // Check if the Object reference is nil.
00186       if (CORBA::is_nil (name_context.in ()))
00187         ACE_ERROR_RETURN ((LM_ERROR,
00188                            "Cannot resolve Naming Service: CORBANAME_Parser\n"),
00189                           0);
00190 
00191       CORBA::Boolean is_a =
00192         name_context->_is_a ("IDL:omg.org/CosNaming/NamingContextExt:1.0"
00193                               ACE_ENV_ARG_PARAMETER);
00194       ACE_TRY_CHECK;
00195 
00196       if (!is_a)
00197         {
00198           ACE_ERROR_RETURN ((LM_ERROR,
00199                              "Cannot narrow Naming Service: "
00200                              "CORBANAME_Parser\n"),
00201                             0);
00202         }
00203 
00204       // Make a dynamic request for resolve_str in this naming context
00205       obj = this->parse_string_dynamic_request_helper (name_context.in (),
00206                                                        key_string
00207                                                         ACE_ENV_ARG_PARAMETER);
00208       ACE_TRY_CHECK;
00209     }
00210   ACE_CATCH (CORBA::SystemException, ex)
00211     {
00212       if (TAO_debug_level >= 4)
00213         {
00214           ACE_PRINT_EXCEPTION (ex, "CORBANAME_Parser");
00215         }
00216     }
00217   ACE_ENDTRY;
00218   ACE_CHECK_RETURN (CORBA::Object::_nil ());
00219 
00220   return obj;
00221 }

CORBA::Object_ptr TAO_CORBANAME_Parser::parse_string_dynamic_request_helper CORBA::Object_ptr    naming_context,
ACE_CString &key_string    ACE_ENV_ARG_DECL
throw (CORBA::SystemException) [private, virtual]
 

Definition at line 31 of file CORBANAME_Parser.cpp.

References ACE_CATCH, ACE_CHECK_RETURN, ACE_CString, ACE_ENDTRY, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW_RETURN, ACE_TRY, ACE_TRY_CHECK, TAO_GIOP_Synch_Invocation::inp_stream, TAO_GIOP_Twoway_Invocation::invoke, TAO_Stub::orb_core, TAO_GIOP_Invocation::out_stream, TAO_GIOP_Invocation::prepare_header, TAO_GIOP_Invocation::restart_flag, TAO_GIOP_Twoway_Invocation::start, TAO_DEFAULT_MINOR_CODE, TAO_INVOKE_OK, TAO_INVOKE_RESTART, and TAO_TWOWAY_RESPONSE_FLAG.

00035 {
00036   CORBA::Object_ptr _tao_retval = CORBA::Object::_nil ();
00037 
00038   CORBA::Object_var _tao_safe_retval (_tao_retval);
00039 
00040   TAO_Stub *istub = naming_context->_stubobj ();
00041   if (istub == 0)
00042     ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
00043 
00044   TAO_GIOP_Twoway_Invocation _tao_call (
00045       istub,
00046       "resolve_str",
00047       11,
00048       1,
00049       istub->orb_core ()
00050     );
00051 
00052   for (;;)
00053     {
00054       _tao_call.start (ACE_ENV_SINGLE_ARG_PARAMETER);
00055       ACE_CHECK_RETURN (CORBA::Object::_nil ());
00056 
00057       CORBA::Short _tao_response_flag = TAO_TWOWAY_RESPONSE_FLAG;
00058 
00059       _tao_call.prepare_header (
00060           ACE_static_cast (CORBA::Octet, _tao_response_flag)
00061            ACE_ENV_ARG_PARAMETER
00062         );
00063       ACE_CHECK_RETURN (CORBA::Object::_nil ());
00064 
00065       TAO_OutputCDR &_tao_out = _tao_call.out_stream ();
00066       if (!(
00067             (_tao_out << key_string.c_str ())
00068           ))
00069         ACE_THROW_RETURN (
00070             CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_NO),
00071             CORBA::Object::_nil ()
00072           );
00073 
00074       int _invoke_status = 0;
00075       ACE_TRY
00076         {
00077           _invoke_status = _tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER);
00078           ACE_TRY_CHECK (CORBA::Object::_nil ());
00079         }
00080       ACE_CATCH (CORBA::UNKNOWN, ex)
00081         {
00082           ACE_UNUSED_ARG (ex);
00083 
00084           ACE_THROW_RETURN (
00085               CORBA::BAD_PARAM (CORBA::OMGVMCID | 10,
00086                                 CORBA::COMPLETED_YES),
00087               CORBA::Object::_nil ()
00088             );
00089         }
00090       ACE_ENDTRY;
00091       ACE_CHECK_RETURN (CORBA::Object::_nil ());
00092 
00093       if (_invoke_status == TAO_INVOKE_RESTART)
00094         {
00095           _tao_call.restart_flag (1);
00096           continue;
00097         }
00098       if (_invoke_status != TAO_INVOKE_OK)
00099         {
00100           // @@ Is there any way we can reach this point?  Any
00101           //    USER_EXCEPTION response will be caught by the UNKNOWN
00102           //    catch block above.  Any SYSTEM_EXCEPTION response will
00103           //    be simply raised, and any RESTART is handled
00104           //    already...  leave this here "just in case".
00105           ACE_THROW_RETURN (
00106               CORBA::BAD_PARAM (CORBA::OMGVMCID | 10,
00107                                 CORBA::COMPLETED_YES),
00108               CORBA::Object::_nil ()
00109             );
00110         }
00111       TAO_InputCDR &_tao_in = _tao_call.inp_stream ();
00112       if (!(
00113             (_tao_in >> _tao_safe_retval.inout ())
00114           ))
00115         {
00116           ACE_THROW_RETURN (
00117               CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES),
00118               CORBA::Object::_nil ()
00119             );
00120         }
00121       break;
00122     }
00123 
00124   return _tao_safe_retval._retn ();
00125 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:13:06 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002