TAO_Connector_Registry Class Reference

Per-ORB TAO Connector Registry. More...

#include <Connector_Registry.h>

Collaboration diagram for TAO_Connector_Registry:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Connector_Registry (void)
 Default constructor.
 ~TAO_Connector_Registry (void)
 Default destructor.
TAO_Connectorget_connector (CORBA::ULong tag) const
 Return the connector bridges.
int open (TAO_ORB_Core *orb_core)
 Initialize all registered connectors.
int close_all (void)
 Close all open connectors.
int make_mprofile (const char *ior, TAO_MProfile &mprofile)
TAO_Profilecreate_profile (TAO_InputCDR &cdr)
 Create a profile based on the contents of cdr.
char object_key_delimiter (const char *ior)
TAO_ConnectorSetIterator begin (void) const
TAO_ConnectorSetIterator end (void) const

Private Member Functions

 TAO_Connector_Registry (const TAO_Connector_Registry &)
void operator= (const TAO_Connector_Registry &)

Private Attributes

TAO_Connector ** connectors_
 List of connectors that are currently open.
size_t size_
 Number of connectors that are currently open.

Detailed Description

Per-ORB TAO Connector Registry.

Connector Registry and Generic Connector interface definitions. All loaded ESIOP or GIOP connector bridges must register with this object. This class is able to dynamically load a set of concrete protocol connectors which have registered with the service configurator and added their Factory name to the Resource_Factory line of the svc.conf file.

Definition at line 52 of file Connector_Registry.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Connector_Registry::TAO_Connector_Registry ( void   ) 

Default constructor.

Definition at line 25 of file Connector_Registry.cpp.

00026   : connectors_ (0),
00027     size_ (0)
00028 {
00029 }

TAO_Connector_Registry::~TAO_Connector_Registry ( void   ) 

Default destructor.

Definition at line 31 of file Connector_Registry.cpp.

References close_all(), and connectors_.

00032 {
00033   this->close_all ();
00034 
00035   delete [] this->connectors_;
00036 }

TAO_Connector_Registry::TAO_Connector_Registry ( const TAO_Connector_Registry  )  [private]


Member Function Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_ConnectorSetIterator TAO_Connector_Registry::begin ( void   )  const

Definition at line 8 of file Connector_Registry.inl.

References connectors_.

Referenced by make_mprofile(), object_key_delimiter(), and TAO_CORBALOC_Parser::parse_string().

00009 {
00010   return this->connectors_;
00011 }

int TAO_Connector_Registry::close_all ( void   ) 

Close all open connectors.

Definition at line 100 of file Connector_Registry.cpp.

References end(), and size_.

Referenced by TAO_Thread_Lane_Resources::finalize(), and ~TAO_Connector_Registry().

00101 {
00102   const TAO_ConnectorSetIterator end = this->end ();
00103 
00104   for (TAO_ConnectorSetIterator i = this->begin ();
00105        i != end;
00106        ++i)
00107     {
00108       if (*i == 0)
00109         continue;
00110 
00111       (*i)->close ();
00112 
00113       delete *i;
00114     }
00115 
00116   this->size_ = 0;
00117 
00118   return 0;
00119 }

TAO_Profile * TAO_Connector_Registry::create_profile ( TAO_InputCDR cdr  ) 

Create a profile based on the contents of cdr.

Definition at line 170 of file Connector_Registry.cpp.

References TAO_Profile::_decr_refcnt(), ACE_DEBUG, ACE_NEW_RETURN, ACE_TEXT, TAO_Connector::create_profile(), TAO_Profile::decode(), get_connector(), ACE_InputCDR::good_bit(), LM_DEBUG, LM_WARNING, TAO_InputCDR::orb_core(), ACE_InputCDR::skip_bytes(), TAO_debug_level, and TAO_ORB_Core_instance().

Referenced by operator>>(), and CORBA::Object::tao_object_initialize().

00171 {
00172   CORBA::ULong tag = 0;
00173 
00174   // If there is an error we abort.
00175   if ((cdr >> tag) == 0)
00176     return 0;
00177 
00178   TAO_Connector *connector =
00179     this->get_connector (tag);
00180 
00181   if (connector == 0)
00182     {
00183       if (TAO_debug_level > 0)
00184         {
00185           ACE_DEBUG ((LM_DEBUG,
00186                       ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry::")
00187                       ACE_TEXT ("create_profile: Unknown profile tag 0x%x\n"),
00188                       tag));
00189         }
00190 
00191       TAO_ORB_Core *orb_core = cdr.orb_core ();
00192       if (orb_core == 0)
00193         {
00194           orb_core = TAO_ORB_Core_instance ();
00195           if (TAO_debug_level > 0)
00196             {
00197               ACE_DEBUG ((LM_WARNING,
00198                           ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry")
00199                           ACE_TEXT ("::create_profile: ")
00200                           ACE_TEXT ("WARNING: extracting object from ")
00201                           ACE_TEXT ("default ORB_Core\n")));
00202             }
00203         }
00204 
00205 
00206       TAO_Profile *pfile = 0;
00207       ACE_NEW_RETURN (pfile,
00208                       TAO_Unknown_Profile (tag,
00209                                            orb_core),
00210                       0);
00211       if (pfile->decode (cdr) == -1)
00212         {
00213           pfile->_decr_refcnt ();
00214           pfile = 0;
00215         }
00216 
00217       return pfile;
00218     }
00219 
00220   // OK, we've got a known profile.  It's going to be encapsulated
00221   // ProfileData.  Create a new decoding stream and context for it,
00222   // and skip the data in the parent stream
00223 
00224   // ProfileData is encoded as a sequence of octet. So first get the
00225   // length of the sequence.
00226   CORBA::ULong encap_len = 0;
00227   if ((cdr >> encap_len) == 0)
00228     return 0;
00229 
00230   // Create the decoding stream from the encapsulation in the buffer,
00231   // and skip the encapsulation.
00232   TAO_InputCDR str (cdr, encap_len);
00233 
00234   if (str.good_bit () == 0
00235       || cdr.skip_bytes (encap_len) == 0)
00236     return 0;
00237 
00238   return connector->create_profile (str);
00239 }

ACE_INLINE TAO_ConnectorSetIterator TAO_Connector_Registry::end ( void   )  const

Definition at line 14 of file Connector_Registry.inl.

References connectors_, and size_.

Referenced by close_all(), get_connector(), make_mprofile(), object_key_delimiter(), open(), and TAO_CORBALOC_Parser::parse_string().

00015 {
00016   return this->connectors_ + this->size_;
00017 }

TAO_Connector * TAO_Connector_Registry::get_connector ( CORBA::ULong  tag  )  const

Return the connector bridges.

Definition at line 39 of file Connector_Registry.cpp.

References end().

Referenced by create_profile(), and TAO::Profile_Transport_Resolver::try_connect_i().

00040 {
00041   const TAO_ConnectorSetIterator end = this->end ();
00042 
00043   for (TAO_ConnectorSetIterator connector = this->begin ();
00044        connector != end;
00045        ++connector)
00046     {
00047       if ((*connector)->tag () == tag)
00048         return *connector;
00049     }
00050 
00051   return 0;
00052 }

int TAO_Connector_Registry::make_mprofile ( const char *  ior,
TAO_MProfile mprofile 
)

Parse a string containing a URL style IOR and return an MProfile.

Definition at line 122 of file Connector_Registry.cpp.

References CORBA::SystemException::_tao_minor_code(), begin(), CORBA::COMPLETED_NO, end(), and TAO_CONNECTOR_REGISTRY_NO_USABLE_PROTOCOL.

Referenced by CORBA::ORB::url_ior_string_to_object().

00125 {
00126   if (!ior)
00127     // Failure: Null IOR string pointer
00128     throw ::CORBA::INV_OBJREF (
00129       CORBA::SystemException::_tao_minor_code (
00130         0,
00131         EINVAL),
00132       CORBA::COMPLETED_NO);
00133 
00134   const TAO_ConnectorSetIterator first_connector = this->begin ();
00135   const TAO_ConnectorSetIterator last_connector = this->end ();
00136 
00137   for (TAO_ConnectorSetIterator connector = first_connector;
00138        connector != last_connector;
00139        ++connector)
00140     {
00141       if (*connector)
00142         {
00143           const int mp_result =
00144             (*connector)->make_mprofile (ior,
00145                                          mprofile
00146                                         );
00147 
00148           if (mp_result == 0)
00149             return 0;  // Success
00150         }
00151       else
00152         // Failure: Null pointer to connector in connector registry.
00153         throw ::CORBA::INV_OBJREF (
00154           CORBA::SystemException::_tao_minor_code (
00155             0,
00156             EINVAL),
00157           CORBA::COMPLETED_NO);
00158     }
00159 
00160   // Failure: None of the connectors were able to parse the URL style
00161   // IOR into an MProfile.
00162   throw ::CORBA::INV_OBJREF (
00163     CORBA::SystemException::_tao_minor_code (
00164       TAO_CONNECTOR_REGISTRY_NO_USABLE_PROTOCOL,
00165       0),
00166     CORBA::COMPLETED_NO);
00167 }

char TAO_Connector_Registry::object_key_delimiter ( const char *  ior  ) 

Obtain the object key delimiter used by the protocol specified in the provided URL style IOR.

Definition at line 242 of file Connector_Registry.cpp.

References begin(), and end().

Referenced by TAO_ORB_Core::resolve_rir().

00243 {
00244   if (!ior)
00245     {
00246       errno = EINVAL;
00247       return 0; // Failure: Null IOR string pointer
00248     }
00249 
00250   const TAO_ConnectorSetIterator first_connector = this->begin ();
00251   const TAO_ConnectorSetIterator last_connector =  this->end ();
00252 
00253   for (TAO_ConnectorSetIterator connector = first_connector;
00254        connector != last_connector;
00255        ++connector)
00256     {
00257       if (*connector)
00258         {
00259           if ((*connector)->check_prefix (ior) == 0)
00260             return (*connector)->object_key_delimiter ();
00261         }
00262     }
00263 
00264   // Failure: None of the connectors were able to match their protocol
00265   // against the provided string.
00266   return 0;
00267 }

int TAO_Connector_Registry::open ( TAO_ORB_Core orb_core  ) 

Initialize all registered connectors.

Definition at line 55 of file Connector_Registry.cpp.

References ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_Unbounded_Set_Ex< T, C >::begin(), connectors_, ACE_Unbounded_Set_Ex< T, C >::end(), end(), ACE_Auto_Basic_Ptr< X >::get(), LM_ERROR, TAO_ORB_Core::protocol_factories(), ACE_Auto_Basic_Ptr< X >::release(), ACE_Unbounded_Set_Ex< T, C >::size(), and size_.

Referenced by TAO_Thread_Lane_Resources::connector_registry().

00056 {
00057   TAO_ProtocolFactorySet * const pfs =
00058     orb_core->protocol_factories ();
00059 
00060   // The array containing the TAO_Connectors will never contain more
00061   // than the number of loaded protocols in the ORB core.
00062   if (this->connectors_ == 0)
00063     ACE_NEW_RETURN (this->connectors_,
00064                     TAO_Connector *[pfs->size ()],
00065                     -1);
00066 
00067   // Open one connector for each loaded protocol!
00068   const TAO_ProtocolFactorySetItor end = pfs->end ();
00069 
00070   for (TAO_ProtocolFactorySetItor factory = pfs->begin ();
00071        factory != end;
00072        ++factory)
00073     {
00074       auto_ptr <TAO_Connector> connector (
00075         (*factory)->factory ()->make_connector ());
00076 
00077       if (connector.get ())
00078         {
00079          if (connector->open (orb_core) != 0)
00080            {
00081              ACE_ERROR_RETURN ((LM_ERROR,
00082                                 ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry")
00083                                 ACE_TEXT ("::open: unable to open connector for ")
00084                                 ACE_TEXT ("<%s>.\n"),
00085                                 ACE_TEXT_CHAR_TO_TCHAR((*factory)->protocol_name ().c_str ())),
00086                                -1);
00087            }
00088 
00089          this->connectors_[this->size_++] =
00090            connector.release ();
00091         }
00092       else
00093         return -1;
00094     }
00095 
00096   return 0;
00097 }

void TAO_Connector_Registry::operator= ( const TAO_Connector_Registry  )  [private]


Member Data Documentation

TAO_Connector** TAO_Connector_Registry::connectors_ [private]

List of connectors that are currently open.

Definition at line 94 of file Connector_Registry.h.

Referenced by begin(), end(), open(), and ~TAO_Connector_Registry().

size_t TAO_Connector_Registry::size_ [private]

Number of connectors that are currently open.

Definition at line 97 of file Connector_Registry.h.

Referenced by close_all(), end(), and open().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:25 2010 for TAO by  doxygen 1.4.7