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

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 Methods

 TAO_Connector_Registry (void)
 Default constructor. More...

 ~TAO_Connector_Registry (void)
 Default destructor. More...

TAO_Connectorget_connector (CORBA::ULong tag)
 Return the connector bridges. More...

TAO_Connectorget_connector (TAO_Endpoint *ep)
int open (TAO_ORB_Core *orb_core)
 Initialize all registered connectors. More...

int close_all (void)
 Close all open connectors. More...

int connect (TAO_GIOP_Invocation *invocation, TAO_Transport_Descriptor_Interface *desc ACE_ENV_ARG_DECL)
int make_mprofile (const char *ior, TAO_MProfile &mprofile ACE_ENV_ARG_DECL)
 Parse a string containing a URL style IOR and return an MProfile. More...

TAO_Profilecreate_profile (TAO_InputCDR &cdr)
 Create a profile based on the contents of <cdr>. More...

char object_key_delimiter (const char *ior)
 Obtain the object key delimiter used by the protocol specified in the provided URL style IOR. More...

TAO_ConnectorSetIterator begin (void)
TAO_ConnectorSetIterator end (void)

Private Methods

 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. More...

size_t size_
 Number of connectors that are currently open. More...


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 58 of file Connector_Registry.h.


Constructor & Destructor Documentation

TAO_Connector_Registry::TAO_Connector_Registry void   
 

Default constructor.

Definition at line 24 of file Connector_Registry.cpp.

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

TAO_Connector_Registry::~TAO_Connector_Registry void   
 

Default destructor.

Definition at line 30 of file Connector_Registry.cpp.

References close_all, connectors_, and size_.

00031 {
00032   this->close_all ();
00033 
00034   delete [] this->connectors_;
00035   this->connectors_ = 0;
00036   this->size_ = 0;
00037 }

TAO_Connector_Registry::TAO_Connector_Registry const TAO_Connector_Registry &    [private]
 


Member Function Documentation

ACE_INLINE TAO_ConnectorSetIterator TAO_Connector_Registry::begin void   
 

Definition at line 10 of file Connector_Registry.i.

References connectors_.

Referenced by close_all, get_connector, make_mprofile, and object_key_delimiter.

00011 {
00012   return this->connectors_;
00013 }

int TAO_Connector_Registry::close_all void   
 

Close all open connectors.

Definition at line 107 of file Connector_Registry.cpp.

References begin, end, and size_.

Referenced by TAO_Thread_Lane_Resources::finalize, and ~TAO_Connector_Registry.

00108 {
00109   TAO_ConnectorSetIterator end = this->end ();
00110 
00111   for (TAO_ConnectorSetIterator i = this->begin ();
00112        i != end;
00113        ++i)
00114     {
00115       if (*i == 0)
00116         continue;
00117 
00118       (*i)->close ();
00119 
00120       delete *i;
00121     }
00122 
00123   this->size_ = 0;
00124 
00125   return 0;
00126 }

int TAO_Connector_Registry::connect TAO_GIOP_Invocation   invocation,
TAO_Transport_Descriptor_Interface *desc    ACE_ENV_ARG_DECL
 

@ todo: This method needs to be removed. There should be no need for the registry to establish connections.

This is where the transport protocol is selected based on some policy. This member will call the connect member of the TAO_Connector class which in turn will call the concrete connector.

Definition at line 129 of file Connector_Registry.cpp.

References ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, TAO_Connector::connect, get_connector, and TAO_Endpoint::tag.

00132 {
00133   TAO_Endpoint *endpoint = desc->endpoint ();
00134   if (endpoint == 0)
00135     return -1;
00136 
00137   // Find the appropriate connector object.
00138   TAO_Connector *connector =
00139     this->get_connector (endpoint->tag ());
00140 
00141   if (connector == 0)
00142       return -1;
00143 
00144   return connector->connect (invocation,
00145                              desc
00146                               ACE_ENV_ARG_PARAMETER);
00147 }

TAO_Profile * TAO_Connector_Registry::create_profile TAO_InputCDR   cdr
 

Create a profile based on the contents of <cdr>.

Definition at line 202 of file Connector_Registry.cpp.

References TAO_Profile::_decr_refcnt, ACE_DEBUG, ACE_LIB_TEXT, ACE_NEW_RETURN, TAO_Connector::create_profile, TAO_Profile::decode, get_connector, ACE_InputCDR::good_bit, LM_DEBUG, TAO_InputCDR::orb_core, and ACE_InputCDR::skip_bytes.

Referenced by operator>>.

00203 {
00204   CORBA::ULong tag = 0;
00205 
00206   // If there is an error we abort.
00207   if ((cdr >> tag) == 0)
00208     return 0;
00209 
00210   TAO_Connector *connector =
00211     this->get_connector (tag);
00212 
00213   if (connector == 0)
00214     {
00215       if (TAO_debug_level > 0)
00216         {
00217           ACE_DEBUG ((LM_DEBUG,
00218                       ACE_LIB_TEXT ("TAO (%P|%t) Unknown profile tag 0x%x\n"),
00219                       tag));
00220         }
00221 
00222       TAO_Profile *pfile = 0;
00223       ACE_NEW_RETURN (pfile,
00224                       TAO_Unknown_Profile (tag,
00225                                            cdr.orb_core ()),
00226                       0);
00227       if (pfile->decode (cdr) == -1)
00228         {
00229           pfile->_decr_refcnt ();
00230           pfile = 0;
00231         }
00232 
00233       return pfile;
00234     }
00235 
00236   // OK, we've got a known profile.  It's going to be encapsulated
00237   // ProfileData.  Create a new decoding stream and context for it,
00238   // and skip the data in the parent stream
00239 
00240   // ProfileData is encoded as a sequence of octet. So first get the
00241   // length of the sequence.
00242   CORBA::ULong encap_len = 0;
00243   if ((cdr >> encap_len) == 0)
00244     return 0;
00245 
00246   // Create the decoding stream from the encapsulation in the buffer,
00247   // and skip the encapsulation.
00248   TAO_InputCDR str (cdr, encap_len);
00249 
00250   if (str.good_bit () == 0
00251       || cdr.skip_bytes (encap_len) == 0)
00252     return 0;
00253 
00254   return connector->create_profile (str);
00255 }

ACE_INLINE TAO_ConnectorSetIterator TAO_Connector_Registry::end void   
 

Definition at line 16 of file Connector_Registry.i.

References connectors_, and size_.

Referenced by close_all, get_connector, make_mprofile, object_key_delimiter, and open.

00017 {
00018   return this->connectors_ + this->size_;
00019 }

ACE_INLINE TAO_Connector * TAO_Connector_Registry::get_connector TAO_Endpoint   ep
 

Definition at line 4 of file Connector_Registry.i.

References get_connector, and TAO_Endpoint::tag.

00005 {
00006   return this->get_connector (ep->tag ());
00007 }

TAO_Connector * TAO_Connector_Registry::get_connector CORBA::ULong    tag
 

Return the connector bridges.

Definition at line 40 of file Connector_Registry.cpp.

References begin, and end.

Referenced by connect, create_profile, get_connector, and TAO_GIOP_Invocation::perform_call.

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

int TAO_Connector_Registry::make_mprofile const char *    ior,
TAO_MProfile &mprofile    ACE_ENV_ARG_DECL
 

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

Definition at line 150 of file Connector_Registry.cpp.

References CORBA_SystemException::_tao_minor_code, ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, begin, end, TAO_CONNECTOR_REGISTRY_NO_USABLE_PROTOCOL, and TAO_DEFAULT_MINOR_CODE.

Referenced by TAO_CORBALOC_Parser::parse_string_mprofile_helper.

00153 {
00154   if (!ior)
00155     // Failure: Null IOR string pointer
00156     ACE_THROW_RETURN (CORBA::INV_OBJREF (
00157       CORBA_SystemException::_tao_minor_code (
00158         TAO_DEFAULT_MINOR_CODE,
00159         EINVAL),
00160       CORBA::COMPLETED_NO),
00161       -1);
00162 
00163   TAO_ConnectorSetIterator first_connector = this->begin ();
00164   TAO_ConnectorSetIterator last_connector = this->end ();
00165 
00166   for (TAO_ConnectorSetIterator connector = first_connector;
00167        connector != last_connector;
00168        ++connector)
00169     {
00170       if (*connector)
00171         {
00172           int mp_result = (*connector)->make_mprofile (ior,
00173                                                        mprofile
00174                                                         ACE_ENV_ARG_PARAMETER);
00175 
00176           ACE_CHECK_RETURN (mp_result);
00177 
00178           if (mp_result == 0)
00179             return 0;  // Success
00180         }
00181       else
00182         // Failure: Null pointer to connector in connector registry.
00183         ACE_THROW_RETURN (CORBA::INV_OBJREF (
00184           CORBA_SystemException::_tao_minor_code (
00185             TAO_DEFAULT_MINOR_CODE,
00186             EINVAL),
00187           CORBA::COMPLETED_NO),
00188           -1);
00189     }
00190 
00191   // Failure: None of the connectors were able to parse the URL style
00192   // IOR into an MProfile.
00193   ACE_THROW_RETURN (CORBA::INV_OBJREF (
00194    CORBA_SystemException::_tao_minor_code (
00195       TAO_CONNECTOR_REGISTRY_NO_USABLE_PROTOCOL,
00196       0),
00197    CORBA::COMPLETED_NO),
00198    -1);
00199 }

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 258 of file Connector_Registry.cpp.

References begin, and end.

Referenced by TAO_ORB_Core::resolve_rir.

00259 {
00260   if (!ior)
00261     {
00262       errno = EINVAL;
00263       return 0; // Failure: Null IOR string pointer
00264     }
00265 
00266   TAO_ConnectorSetIterator first_connector = this->begin ();
00267   TAO_ConnectorSetIterator last_connector =  this->end ();
00268 
00269   for (TAO_ConnectorSetIterator connector = first_connector;
00270        connector != last_connector;
00271        ++connector)
00272     {
00273       if (*connector)
00274         {
00275           if ((*connector)->check_prefix (ior) == 0)
00276             return (*connector)->object_key_delimiter ();
00277         }
00278     }
00279 
00280   // Failure: None of the connectors were able to match their protocol
00281   // against the provided string.
00282   return 0;
00283 }

int TAO_Connector_Registry::open TAO_ORB_Core   orb_core
 

Initialize all registered connectors.

Definition at line 61 of file Connector_Registry.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TEXT_CHAR_TO_TCHAR, ACE_Unbounded_Set< TAO_Protocol_Item * >::begin, connectors_, ACE_Unbounded_Set< TAO_Protocol_Item * >::end, end, LM_ERROR, TAO_Connector::open, TAO_ORB_Core::protocol_factories, ACE_Unbounded_Set< TAO_Protocol_Item * >::size, and size_.

Referenced by TAO_Thread_Lane_Resources::connector_registry.

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

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 115 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 118 of file Connector_Registry.h.

Referenced by close_all, end, open, and ~TAO_Connector_Registry.


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