TAO_COIOP_Acceptor Class Reference

TAO_COIOP_Acceptor. More...

#include <COIOP_Acceptor.h>

Inheritance diagram for TAO_COIOP_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for TAO_COIOP_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_COIOP_Acceptor (void)
 Constructor.

 ~TAO_COIOP_Acceptor (void)
 Destructor.

The TAO_Acceptor Methods
Please check the documentation in Transport_Acceptor.h for details.

virtual int open (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, int version_major, int version_minor, const char *address, const char *options=0)
virtual int open_default (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, int version_major, int version_minor, const char *options=0)
virtual int close (void)
virtual int create_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)
virtual int is_collocated (const TAO_Endpoint *endpoint)
virtual CORBA::ULong endpoint_count (void)
virtual int object_key (IOP::TaggedProfile &profile, TAO::ObjectKey &key)

Protected Member Functions

virtual int parse_options (const char *options)
 Parse protocol specific options.

int create_new_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)
int create_shared_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)

Protected Attributes

ACE_Utils::UUID uuid_
TAO_GIOP_Message_Version version_
TAO_ORB_Coreorb_core_
 ORB Core.


Detailed Description

TAO_COIOP_Acceptor.

The COIOP-specific bridge class for the concrete acceptor.

Definition at line 45 of file COIOP_Acceptor.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_COIOP_Acceptor::TAO_COIOP_Acceptor void   ) 
 

Constructor.

Definition at line 25 of file COIOP_Acceptor.cpp.

References TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_TAG_COIOP_PROFILE.

00026   : TAO_Acceptor (TAO_TAG_COIOP_PROFILE),
00027     uuid_ (*ACE_Utils::UUID_GENERATOR::instance ()->generateUUID ()),
00028     version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR),
00029     orb_core_ (0)
00030 {
00031 }

TAO_COIOP_Acceptor::~TAO_COIOP_Acceptor void   ) 
 

Destructor.

Definition at line 33 of file COIOP_Acceptor.cpp.

References close().

00034 {
00035   // Make sure we are closed before we start destroying the
00036   // strategies.
00037   this->close ();
00038 }


Member Function Documentation

int TAO_COIOP_Acceptor::close void   )  [virtual]
 

Implements TAO_Acceptor.

Definition at line 172 of file COIOP_Acceptor.cpp.

Referenced by ~TAO_COIOP_Acceptor().

00173 {
00174   return 0;
00175 }

int TAO_COIOP_Acceptor::create_new_profile const TAO::ObjectKey object_key,
TAO_MProfile mprofile,
CORBA::Short  priority
[protected]
 

Helper method to add a new profile to the mprofile for each endpoint.

Definition at line 57 of file COIOP_Acceptor.cpp.

References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, TAO_ORB_Core::codeset_manager(), TAO_COIOP_Profile::endpoint(), TAO_MProfile::give_profile(), TAO_MProfile::grow(), TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, TAO_ORB_Core::orb_params(), TAO_Endpoint::priority(), TAO_Codeset_Manager::set_codeset(), TAO_Tagged_Components::set_orb_type(), TAO_ORB_Parameters::std_profile_components(), TAO_Profile::tagged_components(), TAO_ORB_TYPE, and uuid_.

Referenced by create_profile().

00060 {
00061   // Adding this->endpoint_count_ to the TAO_MProfile.
00062   if (mprofile.grow (1) == -1)
00063     return -1;
00064 
00065   TAO_COIOP_Profile *pfile = 0;
00066   ACE_NEW_RETURN (pfile,
00067                   TAO_COIOP_Profile (uuid_,
00068                                       object_key,
00069                                       this->version_,
00070                                       this->orb_core_),
00071                   -1);
00072   pfile->endpoint ()->priority (priority);
00073 
00074   if (mprofile.give_profile (pfile) == -1)
00075     {
00076       pfile->_decr_refcnt ();
00077       pfile = 0;
00078       return -1;
00079     }
00080 
00081   // Do not add any tagged components to the profile if configured
00082   // by the user not to do so, or if an IIOP 1.0 endpoint is being
00083   // created (IIOP 1.0 did not support tagged components).
00084   if (this->orb_core_->orb_params ()->std_profile_components () != 0
00085       && (this->version_.major >= 1 && this->version_.minor > 0))
00086     {
00087       pfile->tagged_components ().set_orb_type (TAO_ORB_TYPE);
00088 
00089       TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager();
00090       if (csm)
00091         csm->set_codeset(pfile->tagged_components());
00092     }
00093 
00094   return 0;
00095 }

int TAO_COIOP_Acceptor::create_profile const TAO::ObjectKey object_key,
TAO_MProfile mprofile,
CORBA::Short  priority
[virtual]
 

Implements TAO_Acceptor.

Definition at line 44 of file COIOP_Acceptor.cpp.

References create_new_profile(), create_shared_profile(), and TAO_INVALID_PRIORITY.

00047 {
00048   // Check if multiple endpoints should be put in one profile or if
00049   // they should be spread across multiple profiles.
00050   if (priority == TAO_INVALID_PRIORITY)
00051     return this->create_new_profile (object_key, mprofile, priority);
00052   else
00053     return this->create_shared_profile (object_key, mprofile, priority);
00054 }

int TAO_COIOP_Acceptor::create_shared_profile const TAO::ObjectKey object_key,
TAO_MProfile mprofile,
CORBA::Short  priority
[protected]
 

Helper method to create a profile that contains all of our endpoints.

Definition at line 98 of file COIOP_Acceptor.cpp.

References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, TAO_COIOP_Profile::add_endpoint(), TAO_ORB_Core::codeset_manager(), TAO_COIOP_Profile::endpoint(), TAO_MProfile::get_profile(), TAO_MProfile::give_profile(), TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, TAO_ORB_Core::orb_params(), TAO_Endpoint::priority(), TAO_MProfile::profile_count(), TAO_Codeset_Manager::set_codeset(), TAO_Tagged_Components::set_orb_type(), TAO_ORB_Parameters::std_profile_components(), TAO_Profile::tag(), TAO_Profile::tagged_components(), TAO_ORB_TYPE, TAO_PHandle, TAO_TAG_COIOP_PROFILE, and uuid_.

Referenced by create_profile().

00101 {
00102   size_t index = 0;
00103   TAO_Profile *pfile = 0;
00104   TAO_COIOP_Profile *coiop_profile = 0;
00105 
00106   // First see if <mprofile> already contains a COIOP profile.
00107   for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i)
00108     {
00109       pfile = mprofile.get_profile (i);
00110       if (pfile->tag () == TAO_TAG_COIOP_PROFILE)
00111       {
00112         coiop_profile = dynamic_cast<TAO_COIOP_Profile *> (pfile);
00113         break;
00114       }
00115     }
00116 
00117   // If <mprofile> doesn't contain a COIOP_Profile, we need to create
00118   // one.
00119   if (coiop_profile == 0)
00120     {
00121       ACE_NEW_RETURN (coiop_profile,
00122                       TAO_COIOP_Profile (uuid_,
00123                                         object_key,
00124                                         this->version_,
00125                                         this->orb_core_),
00126                       -1);
00127       coiop_profile->endpoint ()->priority (priority);
00128 
00129       if (mprofile.give_profile (coiop_profile) == -1)
00130         {
00131           coiop_profile->_decr_refcnt ();
00132           coiop_profile = 0;
00133           return -1;
00134         }
00135 
00136       if (this->orb_core_->orb_params ()->std_profile_components () != 0
00137           && (this->version_.major >= 1 && this->version_.minor >= 1))
00138         {
00139           coiop_profile->tagged_components ().set_orb_type (TAO_ORB_TYPE);
00140           TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager();
00141           if (csm)
00142             csm->set_codeset(pfile->tagged_components());
00143         }
00144 
00145       index = 1;
00146     }
00147 
00148   TAO_COIOP_Endpoint *endpoint = 0;
00149   ACE_NEW_RETURN (endpoint,
00150                   TAO_COIOP_Endpoint (uuid_),
00151                   -1);
00152   endpoint->priority (priority);
00153   coiop_profile->add_endpoint (endpoint);
00154 
00155   return 0;
00156 }

CORBA::ULong TAO_COIOP_Acceptor::endpoint_count void   )  [virtual]
 

Implements TAO_Acceptor.

Definition at line 220 of file COIOP_Acceptor.cpp.

00221 {
00222   return 1;
00223 }

int TAO_COIOP_Acceptor::is_collocated const TAO_Endpoint endpoint  )  [virtual]
 

Implements TAO_Acceptor.

Definition at line 159 of file COIOP_Acceptor.cpp.

References TAO_COIOP_Endpoint::uuid(), and uuid_.

00160 {
00161   const TAO_COIOP_Endpoint *endp =
00162     dynamic_cast<const TAO_COIOP_Endpoint *> (endpoint);
00163 
00164   // Make sure the dynamically cast pointer is valid.
00165   if (endp == 0)
00166     return false;
00167 
00168   return (endp->uuid() == uuid_);
00169 }

int TAO_COIOP_Acceptor::object_key IOP::TaggedProfile profile,
TAO::ObjectKey key
[virtual]
 

Implements TAO_Acceptor.

Definition at line 226 of file COIOP_Acceptor.cpp.

References ACE_DEBUG, ACE_TEXT, LM_DEBUG, CORBA::Octet, IOP::TaggedProfile::profile_data, ACE_InputCDR::read_octet(), ACE_InputCDR::read_string(), and TAO_debug_level.

00228 {
00229   // Create the decoding stream from the encapsulation in the buffer,
00230 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00231   TAO_InputCDR cdr (profile.profile_data.mb ());
00232 #else
00233   TAO_InputCDR cdr (reinterpret_cast<char*> (profile.profile_data.get_buffer ()),
00234                     profile.profile_data.length ());
00235 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
00236 
00237   CORBA::Octet major;
00238   CORBA::Octet minor = CORBA::Octet();
00239 
00240   // Read the version. We just read it here. We don't*do any*
00241   // processing.
00242   if (!(cdr.read_octet (major) && cdr.read_octet (minor)))
00243   {
00244     if (TAO_debug_level > 0)
00245       {
00246         ACE_DEBUG ((LM_DEBUG,
00247                     ACE_TEXT ("TAO (%P|%t) COIOP_Profile::decode - v%d.%d\n"),
00248                     major,
00249                     minor));
00250       }
00251     return -1;
00252   }
00253 
00254   CORBA::String_var uuid;
00255 
00256   // Get host and port. No processing here too..
00257   if (cdr.read_string (uuid.out ()) == 0)
00258     {
00259       if (TAO_debug_level > 0)
00260         {
00261           ACE_DEBUG ((LM_DEBUG,
00262                       ACE_TEXT ("TAO (%P|%t) TAO_COIOP_Acceptor::object_key - ")
00263                       ACE_TEXT ("error while decoding host/port")));
00264         }
00265       return -1;
00266     }
00267 
00268   // ... and object key.
00269   if ((cdr >> object_key) == 0)
00270     return -1;
00271 
00272   // We are NOT bothered about the rest.
00273 
00274   return 1;
00275 }

int TAO_COIOP_Acceptor::open TAO_ORB_Core orb_core,
ACE_Reactor reactor,
int  version_major,
int  version_minor,
const char *  address,
const char *  options = 0
[virtual]
 

Implements TAO_Acceptor.

Definition at line 178 of file COIOP_Acceptor.cpp.

References ACE_Utils::UUID::from_string(), parse_options(), TAO_GIOP_Message_Version::set_version(), and uuid_.

00184 {
00185   this->orb_core_ = orb_core;
00186 
00187   if (major >=0 && minor >= 0)
00188     this->version_.set_version (static_cast<CORBA::Octet> (major),
00189                                 static_cast<CORBA::Octet> (minor));
00190   // Parse options
00191   if (this->parse_options (options) == -1)
00192     return -1;
00193 
00194   uuid_.from_string (address);
00195 
00196   return 0;
00197 }

int TAO_COIOP_Acceptor::open_default TAO_ORB_Core orb_core,
ACE_Reactor reactor,
int  version_major,
int  version_minor,
const char *  options = 0
[virtual]
 

Implements TAO_Acceptor.

Definition at line 200 of file COIOP_Acceptor.cpp.

References parse_options(), and TAO_GIOP_Message_Version::set_version().

00205 {
00206   this->orb_core_ = orb_core;
00207 
00208   if (major >=0 && minor >= 0)
00209     this->version_.set_version (static_cast<CORBA::Octet> (major),
00210                                 static_cast<CORBA::Octet> (minor));
00211 
00212   // Parse options
00213   if (this->parse_options (options) == -1)
00214     return -1;
00215 
00216   return 0;
00217 }

int TAO_COIOP_Acceptor::parse_options const char *  options  )  [protected, virtual]
 

Parse protocol specific options.

Definition at line 278 of file COIOP_Acceptor.cpp.

References ACE_CString, ACE_ERROR_RETURN, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, and LM_ERROR.

Referenced by open(), and open_default().

00279 {
00280   if (str == 0)
00281     return 0;  // No options to parse.  Not a problem.
00282 
00283   // Use an option format similar to the one used for CGI scripts in
00284   // HTTP URLs.
00285   // e.g.:  option1=foo&option2=bar
00286 
00287   ACE_CString options (str);
00288 
00289   size_t len = options.length ();
00290 
00291   const char option_delimiter = '&';
00292 
00293   // Count the number of options.
00294 
00295   CORBA::ULong option_count = 1;
00296   // Number of endpoints in the string  (initialized to 1).
00297 
00298   // Only check for endpoints after the protocol specification and
00299   // before the object key.
00300   for (size_t i = 0; i < len; ++i)
00301     if (options[i] == option_delimiter)
00302       option_count++;
00303 
00304   // The idea behind the following loop is to split the options into
00305   // (option, name) pairs.
00306   // For example,
00307   //    `option1=foo&option2=bar'
00308   // will be parsed into:
00309   //    `option1=foo'
00310   //    `option2=bar'
00311 
00312   ACE_CString::size_type begin = 0;
00313   ACE_CString::size_type end = 0;
00314 
00315   for (CORBA::ULong j = 0; j < option_count; ++j)
00316     {
00317       if (j < option_count - 1)
00318         end = options.find (option_delimiter, begin);
00319       else
00320         end = len;
00321 
00322       if (end == begin)
00323         {
00324           ACE_ERROR_RETURN ((LM_ERROR,
00325                              ACE_TEXT ("TAO (%P|%t) Zero length COIOP option.\n")),
00326                             -1);
00327         }
00328       else if (end != ACE_CString::npos)
00329         {
00330           ACE_CString opt = options.substring (begin, end);
00331 
00332           ACE_CString::size_type const slot = opt.find ("=");
00333 
00334           if (slot == len - 1
00335               || slot == ACE_CString::npos)
00336             ACE_ERROR_RETURN ((LM_ERROR,
00337                                ACE_TEXT ("TAO (%P|%t) COIOP option <%s> is ")
00338                                ACE_TEXT ("missing a value.\n"),
00339                                ACE_TEXT_CHAR_TO_TCHAR (opt.c_str ())),
00340                               -1);
00341 
00342           ACE_CString name = opt.substring (0, slot);
00343           ACE_CString value = opt.substring (slot + 1);
00344 
00345           begin = end + 1;
00346 
00347           if (name.length () == 0)
00348             ACE_ERROR_RETURN ((LM_ERROR,
00349                                ACE_TEXT ("TAO (%P|%t) Zero length COIOP ")
00350                                ACE_TEXT ("option name.\n")),
00351                               -1);
00352 
00353           if (name == "priority")
00354             {
00355               ACE_ERROR_RETURN ((LM_ERROR,
00356                                  ACE_TEXT ("TAO (%P|%t) Invalid COIOP endpoint format: ")
00357                                  ACE_TEXT ("endpoint priorities no longer supported. \n")),
00358                                 -1);
00359             }
00360           else
00361             {
00362               ACE_ERROR_RETURN ((LM_ERROR,
00363                                  ACE_TEXT ("TAO (%P|%t) Invalid COIOP option: <%s>\n"),
00364                                  ACE_TEXT_CHAR_TO_TCHAR (name.c_str ())),
00365                                 -1);
00366             }
00367         }
00368       else
00369         {
00370           break;  // No other options.
00371         }
00372     }
00373   return 0;
00374 }


Member Data Documentation

TAO_ORB_Core* TAO_COIOP_Acceptor::orb_core_ [protected]
 

ORB Core.

Definition at line 115 of file COIOP_Acceptor.h.

ACE_Utils::UUID TAO_COIOP_Acceptor::uuid_ [protected]
 

Cache the information about the endpoints serviced by this acceptor.

Definition at line 105 of file COIOP_Acceptor.h.

Referenced by create_new_profile(), create_shared_profile(), is_collocated(), and open().

TAO_GIOP_Message_Version TAO_COIOP_Acceptor::version_ [protected]
 

The GIOP version for this endpoint @ Theoretically they shouldn't be here!! We need to look at a way to move this out

Definition at line 112 of file COIOP_Acceptor.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 16:02:15 2008 for TAO_Strategies by doxygen 1.3.6