Public Member Functions | Private Member Functions

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 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)

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


Constructor & Destructor Documentation

TAO_CORBANAME_Parser::~TAO_CORBANAME_Parser ( void   )  [virtual]

The destructor.

Definition at line 27 of file CORBANAME_Parser.cpp.

{
}


Member Function Documentation

bool TAO_CORBANAME_Parser::match_prefix ( const char *  ior_string  )  const [virtual]

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.

{
  return (ACE_OS::strncmp (ior_string,
                           corbaname_prefix,
                           sizeof corbaname_prefix - 1) == 0);
}

CORBA::Object_ptr TAO_CORBANAME_Parser::parse_string ( const char *  ior,
CORBA::ORB_ptr  orb 
) [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 66 of file CORBANAME_Parser.cpp.

{

  // Skip the prefix, we know it is there because this method in only
  // called if <match_prefix> returns 1.
  const char *corbaname =
    ior + sizeof corbaname_prefix - 1;

  CORBA::Object_ptr obj = CORBA::Object::_nil ();

  try
    {
      // The position of the seperator between the obj_addr and key
      // string
      ACE_CString::size_type pos_seperator = 0;

      ACE_CString corbaname_str (corbaname, 0, 1);

      pos_seperator = corbaname_str.find ("#", 0);

      // Get the Key String
      ACE_CString key_string;

      if (pos_seperator != ACE_CString::npos)
        {
          key_string = corbaname_str.substring (pos_seperator + 1,
                                                ACE_CString::npos);
        }

      // Prepare a suitable corbaloc string for the name service.
      // CORBALOC assumes "NameService" for the object key if none
      // is provided, so just pass everything between "corbaname:"
      // and "#" as the address
      ACE_CString corbaloc_addr ("corbaloc:", 0, 1);
      corbaloc_addr += corbaname_str.substring (0, pos_seperator);

      // Obtain a reference to the naming context
      CORBA::Object_var name_context =
        orb->string_to_object (corbaloc_addr.c_str ()
                               );

      // Check if the Object reference is nil.
      if (CORBA::is_nil (name_context.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot resolve Naming Service: CORBANAME_Parser\n"),
                          0);

      CORBA::Boolean is_a =
        name_context->_is_a ("IDL:omg.org/CosNaming/NamingContextExt:1.0");

      if (!is_a)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Cannot narrow Naming Service: "
                             "CORBANAME_Parser\n"),
                            0);
        }

      if (key_string.length () != 0)
        {

          // Make a dynamic request for resolve_str in this naming context
          obj = this->parse_string_dynamic_request_helper (name_context.in (),
                                                           key_string);
        }
      else
        { // There was no key string which implies that the caller wants
          // the object reference of the naming service.
          obj = name_context._retn ();
        }
    }
  catch (const ::CORBA::SystemException& ex)
    {
      if (TAO_debug_level >= 4)
        {
          ex._tao_print_exception ("CORBANAME_Parser");
        }
    }

  return obj;
}

CORBA::Object_ptr TAO_CORBANAME_Parser::parse_string_dynamic_request_helper ( CORBA::Object_ptr  naming_context,
ACE_CString key_string 
) [private, virtual]

Definition at line 41 of file CORBANAME_Parser.cpp.

{
  TAO::Arg_Traits<CORBA::Object>::ret_val _tao_retval;
  TAO::Arg_Traits<CORBA::Char *>::in_arg_val _tao_id (key_string.c_str ());

  TAO::Argument *_tao_signature [] =
      {
        &_tao_retval,
        &_tao_id
      };

  TAO::Invocation_Adapter tao_call (naming_context,
                                    _tao_signature,
                                    2,
                                    "resolve_str",
                                    11,
                                    0);

  tao_call.invoke (0, 0);

  return _tao_retval.retn ();
}


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines