TAO_DIOP_Endpoint Class Reference

TAO_DIOP_Endpoint. More...

#include <DIOP_Endpoint.h>

Inheritance diagram for TAO_DIOP_Endpoint:

Inheritance graph
[legend]
Collaboration diagram for TAO_DIOP_Endpoint:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_DIOP_Endpoint (void)
 Default constructor.

 TAO_DIOP_Endpoint (const char *host, CORBA::UShort port, const ACE_INET_Addr &addr, CORBA::Short priority=TAO_INVALID_PRIORITY)
 TAO_DIOP_Endpoint (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses)
 Constructor.

 TAO_DIOP_Endpoint (const char *host, CORBA::UShort port, CORBA::Short priority)
 Constructor. This constructor is used when decoding endpoints.

 ~TAO_DIOP_Endpoint (void)
 Destructor.

const ACE_INET_Addrobject_addr (void) const
 Return a reference to the .

const char * host (void) const
const char * host (const char *h)
CORBA::UShort port (void) const
 Return the port number.

CORBA::UShort port (CORBA::UShort p)
 Set the port number.

TAO_Endpoint Methods
Please check the documentation in Endpoint.h for details.

virtual TAO_Endpointnext (void)
virtual int addr_to_string (char *buffer, size_t length)
virtual TAO_Endpointduplicate (void)
CORBA::Boolean is_equivalent (const TAO_Endpoint *other_endpoint)
CORBA::ULong hash (void)
 Return a hash value for this object.


Private Member Functions

int set (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses)
 Helper method for setting INET_Addr.


Private Attributes

CORBA::String_var host_
 String representing the host name.

CORBA::UShort port_
 TCP port number.

ACE_INET_Addr object_addr_
int object_addr_set_
 Flag to indicate if the address has been resolved and set.

TAO_DIOP_Endpointnext_

Friends

class TAO_DIOP_Profile
class TAO_SSLIOP_Profile

Detailed Description

TAO_DIOP_Endpoint.

DIOP-specific implementation of PP Framework Endpoint interface.

Definition at line 44 of file DIOP_Endpoint.h.


Constructor & Destructor Documentation

TAO_DIOP_Endpoint::TAO_DIOP_Endpoint void   ) 
 

Default constructor.

Definition at line 59 of file DIOP_Endpoint.cpp.

References TAO_TAG_DIOP_PROFILE.

00060   : TAO_Endpoint (TAO_TAG_DIOP_PROFILE),
00061     host_ (),
00062     port_ (0),
00063     object_addr_ (),
00064     object_addr_set_ (0),
00065     next_ (0)
00066 {
00067 }

TAO_DIOP_Endpoint::TAO_DIOP_Endpoint const char *  host,
CORBA::UShort  port,
const ACE_INET_Addr addr,
CORBA::Short  priority = TAO_INVALID_PRIORITY
 

Constructor. This is the most efficient constructor since it does not require any address resolution processing.

Definition at line 43 of file DIOP_Endpoint.cpp.

References TAO_TAG_DIOP_PROFILE.

00047   : TAO_Endpoint (TAO_TAG_DIOP_PROFILE,
00048                   priority)
00049     , host_ ()
00050     , port_ (port)
00051     , object_addr_ (addr)
00052     , object_addr_set_ (0)
00053     , next_ (0)
00054 {
00055   if (host != 0)
00056     this->host_ = host;
00057 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_DIOP_Endpoint::TAO_DIOP_Endpoint const ACE_INET_Addr addr,
int  use_dotted_decimal_addresses
 

Constructor.

Definition at line 30 of file DIOP_Endpoint.cpp.

References set(), and TAO_TAG_DIOP_PROFILE.

00033   : TAO_Endpoint (TAO_TAG_DIOP_PROFILE)
00034     , host_ ()
00035     , port_ (0)
00036     , object_addr_ (addr)
00037     , object_addr_set_ (0)
00038     , next_ (0)
00039 {
00040   this->set (addr, use_dotted_decimal_addresses);
00041 }

TAO_DIOP_Endpoint::TAO_DIOP_Endpoint const char *  host,
CORBA::UShort  port,
CORBA::Short  priority
 

Constructor. This constructor is used when decoding endpoints.

Definition at line 69 of file DIOP_Endpoint.cpp.

References TAO_Endpoint::priority(), and TAO_TAG_DIOP_PROFILE.

00072   : TAO_Endpoint (TAO_TAG_DIOP_PROFILE),
00073     host_ (),
00074     port_ (port),
00075     object_addr_ (),
00076     object_addr_set_ (0),
00077     next_ (0)
00078 {
00079   if (host != 0)
00080     this->host_ = host;
00081 
00082   this->priority (priority);
00083 }

TAO_DIOP_Endpoint::~TAO_DIOP_Endpoint void   ) 
 

Destructor.

Definition at line 85 of file DIOP_Endpoint.cpp.

00086 {
00087 
00088 }


Member Function Documentation

int TAO_DIOP_Endpoint::addr_to_string char *  buffer,
size_t  length
[virtual]
 

Implements TAO_Endpoint.

Definition at line 122 of file DIOP_Endpoint.cpp.

References ACE_OS::sprintf(), and ACE_OS::strlen().

00123 {
00124   size_t const actual_len =
00125     ACE_OS::strlen (this->host_.in ()) // chars in host name
00126     + sizeof (':')                     // delimiter
00127     + ACE_OS::strlen ("65536")         // max port
00128     + sizeof ('\0');
00129 
00130   if (length < actual_len)
00131     return -1;
00132 
00133   ACE_OS::sprintf (buffer, "%s:%d",
00134                    this->host_.in (), this->port_);
00135 
00136   return 0;
00137 }

TAO_Endpoint * TAO_DIOP_Endpoint::duplicate void   )  [virtual]
 

Implements TAO_Endpoint.

Definition at line 154 of file DIOP_Endpoint.cpp.

References ACE_NEW_RETURN, and TAO_Endpoint::priority().

00155 {
00156   TAO_DIOP_Endpoint *endpoint = 0;
00157 
00158   ACE_NEW_RETURN (endpoint,
00159                   TAO_DIOP_Endpoint (this->host_.in (),
00160                                      this->port_,
00161                                      this->object_addr_,
00162                                      this->priority ()),
00163                   0);
00164 
00165   return endpoint;
00166 }

CORBA::ULong TAO_DIOP_Endpoint::hash void   )  [virtual]
 

Return a hash value for this object.

Implements TAO_Endpoint.

Definition at line 182 of file DIOP_Endpoint.cpp.

References ACE_GUARD_RETURN, ACE::hash_pjw(), port(), and TAO_SYNCH_MUTEX.

Referenced by TAO_DIOP_Profile::hash().

00183 {
00184   if (this->hash_val_ != 0)
00185     return this->hash_val_;
00186 
00187   {
00188     ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00189                       guard,
00190                       this->addr_lookup_lock_,
00191                       this->hash_val_);
00192     // .. DCL
00193     if (this->hash_val_ != 0)
00194       return this->hash_val_;
00195 
00196     this->hash_val_ =
00197       ACE::hash_pjw (this->host ()) + this->port ();
00198   }
00199 
00200   return this->hash_val_;
00201 }

const char * TAO_DIOP_Endpoint::host const char *  h  ) 
 

Copy the string into and return the resulting pointer. This object maintains ownership of this string.

Definition at line 140 of file DIOP_Endpoint.cpp.

00141 {
00142   this->host_ = h;
00143 
00144   return this->host_.in ();
00145 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const char * TAO_DIOP_Endpoint::host void   )  const
 

Return a pointer to the host string. This object maintains ownership of this string.

Definition at line 8 of file DIOP_Endpoint.i.

Referenced by TAO_DIOP_Profile::encode_endpoints(), TAO_DIOP_Acceptor::is_collocated(), and is_equivalent().

00009 {
00010   return this->host_.in ();
00011 }

CORBA::Boolean TAO_DIOP_Endpoint::is_equivalent const TAO_Endpoint other_endpoint  )  [virtual]
 

Return true if this endpoint is equivalent to . Two endpoints are equivalent iff their port and host are the same.

Implements TAO_Endpoint.

Definition at line 169 of file DIOP_Endpoint.cpp.

References host(), port(), and ACE_OS::strcmp().

Referenced by TAO_DIOP_Profile::do_is_equivalent().

00170 {
00171   TAO_Endpoint *endpt = const_cast<TAO_Endpoint *> (other_endpoint);
00172 
00173   TAO_DIOP_Endpoint *endpoint = dynamic_cast<TAO_DIOP_Endpoint *> (endpt);
00174   if (endpoint == 0)
00175     return 0;
00176 
00177   return (this->port () == endpoint->port ()
00178           && ACE_OS::strcmp(this->host (), endpoint->host()) == 0);
00179 }

TAO_Endpoint * TAO_DIOP_Endpoint::next void   )  [virtual]
 

Implements TAO_Endpoint.

Definition at line 148 of file DIOP_Endpoint.cpp.

00149 {
00150   return this->next_;
00151 }

const ACE_INET_Addr & TAO_DIOP_Endpoint::object_addr void   )  const
 

Return a reference to the .

Definition at line 204 of file DIOP_Endpoint.cpp.

References ACE_GUARD_RETURN, TAO_Endpoint::addr_lookup_lock_, object_addr_, object_addr_set_, ACE_INET_Addr::set(), ACE_Addr::set_type(), and TAO_SYNCH_MUTEX.

Referenced by TAO_DIOP_Connector::make_connection(), and TAO_DIOP_Connector::set_validate_endpoint().

00205 {
00206   // The object_addr_ is initialized here, rather than at IOR decode
00207   // time for several reasons:
00208   //   1. A request on the object may never be invoked.
00209   //   2. The DNS setup may have changed dynamically.
00210   //   ...etc..
00211 
00212   // Double checked locking optimization.
00213   if (!this->object_addr_set_)
00214     {
00215       // We need to modify the object_addr_ in this method.  Do so
00216       // using a  non-const copy of the <this> pointer.
00217       TAO_DIOP_Endpoint *endpoint =
00218         const_cast<TAO_DIOP_Endpoint *> (this);
00219 
00220       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00221                         guard,
00222                         endpoint->addr_lookup_lock_,
00223                         this->object_addr_ );
00224 
00225       if (!this->object_addr_set_)
00226         {
00227           if (endpoint->object_addr_.set (this->port_,
00228                                           this->host_.in ()) == -1)
00229             {
00230               // If this call fails, it most likely due a hostname
00231               // lookup failure caused by a DNS misconfiguration.  If
00232               // a request is made to the object at the given host and
00233               // port, then a CORBA::TRANSIENT() exception should be
00234               // thrown.
00235 
00236               // Invalidate the ACE_INET_Addr.  This is used as a flag
00237               // to denote that ACE_INET_Addr initialization failed.
00238               endpoint->object_addr_.set_type (-1);
00239             }
00240           else
00241             {
00242               endpoint->object_addr_set_ = 1;
00243             }
00244         }
00245     }
00246   return this->object_addr_;
00247 }

ACE_INLINE CORBA::UShort TAO_DIOP_Endpoint::port CORBA::UShort  p  ) 
 

Set the port number.

Definition at line 20 of file DIOP_Endpoint.i.

00021 {
00022   return this->port_ = p;
00023 }

ACE_INLINE CORBA::UShort TAO_DIOP_Endpoint::port void   )  const
 

Return the port number.

Definition at line 14 of file DIOP_Endpoint.i.

Referenced by TAO_DIOP_Profile::encode_endpoints(), hash(), TAO_DIOP_Acceptor::is_collocated(), is_equivalent(), and TAO_DIOP_Profile::to_string().

00015 {
00016   return this->port_;
00017 }

int TAO_DIOP_Endpoint::set const ACE_INET_Addr addr,
int  use_dotted_decimal_addresses
[private]
 

Helper method for setting INET_Addr.

Definition at line 91 of file DIOP_Endpoint.cpp.

References ACE_DEBUG, ACE_TEXT, ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_port_number(), LM_DEBUG, MAXHOSTNAMELEN, CORBA::string_dup(), and TAO_debug_level.

Referenced by TAO_DIOP_Endpoint().

00093 {
00094   char tmp_host[MAXHOSTNAMELEN + 1];
00095 
00096   if (use_dotted_decimal_addresses
00097       || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0)
00098     {
00099       const char *tmp = addr.get_host_addr ();
00100       if (tmp == 0)
00101         {
00102           if (TAO_debug_level > 0)
00103             ACE_DEBUG ((LM_DEBUG,
00104                         ACE_TEXT ("\n\nTAO (%P|%t) ")
00105                         ACE_TEXT ("DIOP_Endpoint::set ")
00106                         ACE_TEXT ("- %p\n\n"),
00107                         ACE_TEXT ("cannot determine hostname")));
00108           return -1;
00109         }
00110       else
00111         this->host_ = tmp;
00112     }
00113   else
00114     this->host_ = CORBA::string_dup (tmp_host);
00115 
00116   this->port_ = addr.get_port_number();
00117 
00118   return 0;
00119 }


Friends And Related Function Documentation

friend class TAO_DIOP_Profile [friend]
 

Definition at line 48 of file DIOP_Endpoint.h.

friend class TAO_SSLIOP_Profile [friend]
 

Definition at line 49 of file DIOP_Endpoint.h.


Member Data Documentation

CORBA::String_var TAO_DIOP_Endpoint::host_ [private]
 

String representing the host name.

Definition at line 124 of file DIOP_Endpoint.h.

Referenced by TAO_DIOP_Profile::parse_string_i().

TAO_DIOP_Endpoint* TAO_DIOP_Endpoint::next_ [private]
 

DIOP Endpoints can be stringed into a list. Return the next endpoint in the list, if any.

Definition at line 138 of file DIOP_Endpoint.h.

Referenced by TAO_DIOP_Profile::add_endpoint(), TAO_DIOP_Profile::do_is_equivalent(), TAO_DIOP_Profile::encode_endpoints(), and TAO_DIOP_Profile::hash().

ACE_INET_Addr TAO_DIOP_Endpoint::object_addr_ [private]
 

Cached instance of for use in making invocations, etc.

Definition at line 131 of file DIOP_Endpoint.h.

Referenced by TAO_DIOP_Profile::decode_profile(), and object_addr().

int TAO_DIOP_Endpoint::object_addr_set_ [private]
 

Flag to indicate if the address has been resolved and set.

Definition at line 134 of file DIOP_Endpoint.h.

Referenced by object_addr().

CORBA::UShort TAO_DIOP_Endpoint::port_ [private]
 

TCP port number.

Definition at line 127 of file DIOP_Endpoint.h.

Referenced by TAO_DIOP_Profile::parse_string_i().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:41:08 2006 for TAO_Strategies by doxygen 1.3.6