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

TAO_Connector Class Reference

Generic Connector interface definitions. More...

#include <Transport_Connector.h>

Inheritance diagram for TAO_Connector:

Inheritance graph
[legend]
Collaboration diagram for TAO_Connector:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Connector (CORBA::ULong tag)
 default constructor. More...

virtual ~TAO_Connector (void)
 the destructor. More...

CORBA::ULong tag (void) const
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...

virtual int open (TAO_ORB_Core *orb_core)=0
 Initialize object and register with reactor. More...

virtual int close (void)=0
 Shutdown Connector bridge and concrete Connector. More...

virtual int connect (TAO_GIOP_Invocation *invocation, TAO_Transport_Descriptor_Interface *desc ACE_ENV_ARG_DECL)
virtual int connect (TAO_GIOP_Invocation *invocation, TAO_Transport_Descriptor_Interface *desc, ACE_Time_Value *timeout ACE_ENV_ARG_DECL)
virtual TAO_Profilecreate_profile (TAO_InputCDR &cdr)=0
 Create a profile for this protocol and initialize it based on the encapsulation in <cdr>. More...

virtual int check_prefix (const char *endpoint)=0
 Check that the prefix of the provided endpoint is valid for use with a given pluggable protocol. More...

virtual char object_key_delimiter (void) const=0
 Return the object key delimiter to use or expect. More...


Protected Methods

virtual TAO_Profilemake_profile (ACE_ENV_SINGLE_ARG_DECL)=0
 Create a profile with a given endpoint. More...

virtual int set_validate_endpoint (TAO_Endpoint *endpoint)=0
 Set and validate endpoint. We need to do this to initialize our remote *_Addr's which have not been done during IOR decode. More...

virtual int make_connection (TAO_GIOP_Invocation *invocation, TAO_Transport_Descriptor_Interface *desc, ACE_Time_Value *timeout)=0
 Do an actual connect using the underlying transport to make a connection. More...

void orb_core (TAO_ORB_Core *orb_core)
 Set the ORB Core pointer. More...

int create_connect_strategy (void)
 Create a connect strategy. More...

TAO_ORB_Coreorb_core (void)
 Return the TAO_ORB_Core pointer. More...


Protected Attributes

TAO_Connect_Strategyactive_connect_strategy_
 The (a)synch connect strategy. More...


Private Attributes

CORBA::ULong tag_
 IOP protocol tag. More...

TAO_ORB_Coreorb_core_
 Pointer to our ORB core. More...


Detailed Description

Generic Connector interface definitions.

Base class for connector bridge object.

@TODO: Need to rename the class as TAO_Transport_Connector.

Definition at line 44 of file Transport_Connector.h.


Constructor & Destructor Documentation

TAO_Connector::TAO_Connector CORBA::ULong    tag
 

default constructor.

Definition at line 26 of file Transport_Connector.cpp.

00027   : active_connect_strategy_ (0),
00028     tag_(tag),
00029     orb_core_ (0)
00030 {
00031 }

TAO_Connector::~TAO_Connector void    [virtual]
 

the destructor.

Definition at line 33 of file Transport_Connector.cpp.

References active_connect_strategy_.

00034 {
00035   delete this->active_connect_strategy_;
00036 }


Member Function Documentation

virtual int TAO_Connector::check_prefix const char *    endpoint [pure virtual]
 

Check that the prefix of the provided endpoint is valid for use with a given pluggable protocol.

Implemented in TAO_IIOP_Connector.

Referenced by make_mprofile.

virtual int TAO_Connector::close void    [pure virtual]
 

Shutdown Connector bridge and concrete Connector.

Implemented in TAO_IIOP_Connector.

int TAO_Connector::connect TAO_GIOP_Invocation   invocation,
TAO_Transport_Descriptor_Interface   desc,
ACE_Time_Value *timeout    ACE_ENV_ARG_DECL
[virtual]
 

Call is very similar to the previous one but with a timeout.

Definition at line 223 of file Transport_Connector.cpp.

References ACE_DEBUG, ACE_ENV_ARG_DECL_NOT_USED, TAO_Transport_Descriptor_Interface::endpoint, TAO_Transport_Cache_Manager::find_transport, TAO_Transport::id, TAO_ORB_Core::lane_resources, LM_DEBUG, make_connection, orb_core, orb_core_, TAO_Transport_Cache_Manager::purge, set_validate_endpoint, TAO_GIOP_Invocation::transport, and TAO_Thread_Lane_Resources::transport_cache.

00227 {
00228   if (this->set_validate_endpoint (desc->endpoint ()) == -1)
00229     return -1;
00230 
00231 
00232   TAO_Transport *base_transport = 0;
00233 
00234   // Check the Cache first for connections
00235   // If transport found, reference count is incremented on assignment
00236   // @@todo: We need to send the timeout value to the cache registry
00237   // too. That should be the next step!
00238   if (this->orb_core ()->lane_resources ().transport_cache ().find_transport (desc,
00239                                                                               base_transport) == 0)
00240     {
00241       if (TAO_debug_level > 2)
00242         ACE_DEBUG ((LM_DEBUG,
00243                     "TAO (%P|%t) - Transport_Connector::connect, "
00244                     "got an existing Transport[%d]\n",
00245                     base_transport->id ()));
00246 
00247       TAO_Transport *&transport = invocation->transport ();
00248 
00249       // No need to _duplicate and release since base_transport
00250       // is going out of scope.  Transport now has control of
00251       // base_transport.
00252       transport = base_transport;
00253 
00254       // Successfull
00255       return 0;
00256     }
00257 
00258   // @@TODO: This is not the right place for this!
00259   // Purge connections (if necessary)
00260   this->orb_core_->lane_resources ().transport_cache ().purge ();
00261 
00262   return this->make_connection (invocation,
00263                                 desc,
00264                                 timeout);
00265 }

int TAO_Connector::connect TAO_GIOP_Invocation   invocation,
TAO_Transport_Descriptor_Interface *desc    ACE_ENV_ARG_DECL
[virtual]
 

To support pluggable we need to abstract away the details of the connect () method so it can be called from the invocation code independent of the actual transport protocol in use.

Definition at line 212 of file Transport_Connector.cpp.

References ACE_ENV_ARG_DECL, and ACE_ENV_ARG_PARAMETER.

Referenced by TAO_Connector_Registry::connect, and TAO_GIOP_Invocation::perform_call.

00215 {
00216   return this->connect (invocation,
00217                         desc,
00218                         0
00219                         ACE_ENV_ARG_PARAMETER);
00220 }

int TAO_Connector::create_connect_strategy void    [protected]
 

Create a connect strategy.

Definition at line 269 of file Transport_Connector.cpp.

References active_connect_strategy_, TAO_ORB_Core::client_factory, TAO_Client_Strategy_Factory::create_connect_strategy, and orb_core_.

Referenced by TAO_IIOP_Connector::open.

00270 {
00271   if (this->active_connect_strategy_ == 0)
00272     {
00273       this->active_connect_strategy_ =
00274         this->orb_core_->client_factory ()->create_connect_strategy (this->orb_core_);
00275     }
00276 
00277   if (this->active_connect_strategy_ == 0)
00278     return -1;
00279 
00280   return 0;
00281 }

virtual TAO_Profile* TAO_Connector::create_profile TAO_InputCDR   cdr [pure virtual]
 

Create a profile for this protocol and initialize it based on the encapsulation in <cdr>.

Implemented in TAO_IIOP_Connector.

Referenced by TAO_Connector_Registry::create_profile.

virtual int TAO_Connector::make_connection TAO_GIOP_Invocation   invocation,
TAO_Transport_Descriptor_Interface   desc,
ACE_Time_Value   timeout
[protected, pure virtual]
 

Do an actual connect using the underlying transport to make a connection.

Implemented in TAO_IIOP_Connector.

Referenced by connect.

int TAO_Connector::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 39 of file Transport_Connector.cpp.

References TAO_Profile::_decr_refcnt, CORBA_SystemException::_tao_minor_code, ACE_CHECK_RETURN, ACE_CString, ACE_DEBUG, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_TEXT, ACE_THROW_RETURN, check_prefix, LM_DEBUG, make_profile, TAO_Profile::parse_string, TAO_DEFAULT_MINOR_CODE, and TAO_MPROFILE_CREATION_ERROR.

00042 {
00043   // This method utilizes the "Template Method" design pattern to
00044   // parse the given URL style IOR for the protocol being used
00045   // and create an mprofile from it.
00046   //
00047   // The methods that must be defined by all Connector sub-classes are:
00048   //      make_profile
00049   //      check_prefix
00050 
00051   // Check for a valid string
00052   if (!string || !*string)
00053     {
00054       ACE_THROW_RETURN (CORBA::INV_OBJREF (
00055                           CORBA_SystemException::_tao_minor_code (
00056                             TAO_DEFAULT_MINOR_CODE,
00057                             EINVAL),
00058                           CORBA::COMPLETED_NO),
00059                         -1);
00060     }
00061 
00062   // Check for the proper prefix in the IOR.  If the proper prefix isn't
00063   // in the IOR then it is not an IOR we can use.
00064   if (this->check_prefix (string) != 0)
00065     {
00066       return 1;
00067       // Failure: not the correct IOR for this protocol.
00068       // DO NOT throw an exception here since the Connector_Registry
00069       // should be allowed the opportunity to continue looking for
00070       // an appropriate connector.
00071     }
00072 
00073   if (TAO_debug_level > 0)
00074     {
00075       ACE_DEBUG ((LM_DEBUG,
00076                   ACE_TEXT ("TAO (%P|%t) - TAO_Connector::make_mprofile ")
00077                   ACE_TEXT ("<%s>\n"),
00078                   string));
00079     }
00080 
00081   ACE_CString ior;
00082 
00083   ior.set (string, ACE_OS::strlen (string), 1);
00084 
00085   // Find out where the protocol ends
00086   int ior_index = ior.find ("://");
00087 
00088   if (ior_index == ACE_CString::npos)
00089     {
00090       ACE_THROW_RETURN (CORBA::INV_OBJREF (), -1);
00091       // No colon ':' in the IOR!
00092     }
00093   else
00094     {
00095       ior_index += 3;
00096       // Add the length of the colon and the two forward slashes `://'
00097       // to the IOR string index (i.e. 3)
00098     }
00099 
00100   // Find the object key
00101   const int objkey_index =
00102     ior.find (this->object_key_delimiter (), ior_index);
00103 
00104   if (objkey_index == 0 || objkey_index == ACE_CString::npos)
00105     {
00106       ACE_THROW_RETURN (CORBA::INV_OBJREF (), -1);
00107       // Failure: No endpoints specified or no object key specified.
00108     }
00109 
00110   const char endpoint_delimiter = ',';
00111   // The delimiter used to seperate inidividual addresses.
00112 
00113   // Count the number of endpoints in the IOR.  This will be the number
00114   // of entries in the MProfile.
00115 
00116   CORBA::ULong profile_count = 1;
00117   // Number of endpoints in the IOR  (initialized to 1).
00118 
00119   // Only check for endpoints after the protocol specification and
00120   // before the object key.
00121   for (int i = ior_index; i < objkey_index; ++i)
00122     {
00123       if (ior[i] == endpoint_delimiter)
00124         profile_count++;
00125     }
00126 
00127   // Tell the MProfile object how many Profiles it should hold.
00128   // MProfile::set(size) returns the number profiles it can hold.
00129   if (mprofile.set (profile_count) != ACE_static_cast (int, profile_count))
00130     {
00131       ACE_THROW_RETURN (CORBA::INV_OBJREF (
00132                           CORBA_SystemException::_tao_minor_code (
00133                             TAO_MPROFILE_CREATION_ERROR,
00134                             0),
00135                           CORBA::COMPLETED_NO),
00136                         -1);
00137       // Error while setting the MProfile size!
00138     }
00139 
00140   // The idea behind the following loop is to split the IOR into several
00141   // strings that can be parsed by each profile.
00142   // For example,
00143   //    `1.3@moo,shu,1.1@chicken/arf'
00144   // will be parsed into:
00145   //    `1.3@moo/arf'
00146   //    `shu/arf'
00147   //    `1.1@chicken/arf'
00148 
00149   int begin = 0;
00150   int end = ior_index - 1;
00151   // Initialize the end of the endpoint index
00152 
00153   for (CORBA::ULong j = 0; j < profile_count; ++j)
00154     {
00155       begin = end + 1;
00156 
00157       if (j < profile_count - 1)
00158         end = ior.find (endpoint_delimiter, begin);
00159       else
00160         end = objkey_index;  // Handle last endpoint differently
00161 
00162       if (end < ACE_static_cast (int, ior.length ()) && end != ior.npos)
00163         {
00164           ACE_CString endpoint = ior.substring (begin, end - begin);
00165 
00166           // Add the object key to the string.
00167           endpoint += ior.substring (objkey_index);
00168 
00169           // The endpoint should now be of the form:
00170           //    `N.n@endpoint/object_key'
00171           // or
00172           //    `endpoint/object_key'
00173 
00174           TAO_Profile *profile =
00175             this->make_profile (ACE_ENV_SINGLE_ARG_PARAMETER);
00176           ACE_CHECK_RETURN (-1);
00177           // Failure:  Problem during profile creation
00178 
00179           // Initialize a Profile using the individual endpoint
00180           // string.
00181           // @@ Not exception safe!  We need a TAO_Profile_var!
00182           profile->parse_string (endpoint.c_str ()
00183                                  ACE_ENV_ARG_PARAMETER);
00184           ACE_CHECK_RETURN (-1);
00185 
00186           // Give up ownership of the profile.
00187           if (mprofile.give_profile (profile) == -1)
00188             {
00189               profile->_decr_refcnt ();
00190 
00191               ACE_THROW_RETURN (CORBA::INV_OBJREF (
00192                                   CORBA_SystemException::_tao_minor_code (
00193                                      TAO_MPROFILE_CREATION_ERROR,
00194                                      0),
00195                                   CORBA::COMPLETED_NO),
00196                                 -1);
00197               // Failure presumably only occurs when MProfile is full!
00198               // This should never happen.
00199             }
00200         }
00201       else
00202         {
00203           ACE_THROW_RETURN (CORBA::INV_OBJREF (), -1);
00204           // Unable to seperate endpoints
00205         }
00206     }
00207 
00208   return 0;  // Success
00209 }

virtual TAO_Profile* TAO_Connector::make_profile ACE_ENV_SINGLE_ARG_DECL    [protected, pure virtual]
 

Create a profile with a given endpoint.

Implemented in TAO_IIOP_Connector.

Referenced by make_mprofile.

virtual char TAO_Connector::object_key_delimiter void    const [pure virtual]
 

Return the object key delimiter to use or expect.

Implemented in TAO_IIOP_Connector.

virtual int TAO_Connector::open TAO_ORB_Core   orb_core [pure virtual]
 

Initialize object and register with reactor.

Implemented in TAO_IIOP_Connector.

Referenced by TAO_Connector_Registry::open.

ACE_INLINE TAO_ORB_Core * TAO_Connector::orb_core void    [protected]
 

Return the TAO_ORB_Core pointer.

Definition at line 4 of file Transport_Connector.inl.

References orb_core_.

Referenced by connect, TAO_IIOP_Connector::init_tcp_properties, TAO_IIOP_Connector::make_connection, and TAO_IIOP_Connector::open.

00005 {
00006   return this->orb_core_;
00007 }

ACE_INLINE void TAO_Connector::orb_core TAO_ORB_Core   orb_core [protected]
 

Set the ORB Core pointer.

Definition at line 10 of file Transport_Connector.inl.

References orb_core_.

00011 {
00012   this->orb_core_ = orb_core;
00013 }

virtual int TAO_Connector::set_validate_endpoint TAO_Endpoint   endpoint [protected, pure virtual]
 

Set and validate endpoint. We need to do this to initialize our remote *_Addr's which have not been done during IOR decode.

Implemented in TAO_IIOP_Connector.

Referenced by connect.

ACE_INLINE CORBA::ULong TAO_Connector::tag void    const
 

The tag identifying the specific ORB transport layer protocol. For example IOP::TAG_INTERNET_IOP == 0. The tag is used in the IOR to identify the type of profile included. IOR -> {{tag0, profile0} {tag1, profile1} ...}. The IOP module defines the ProfileId typedef to be a CORBA::ULong.

Definition at line 16 of file Transport_Connector.inl.

References tag_.

00017 {
00018   return this->tag_;
00019 }


Member Data Documentation

TAO_Connect_Strategy* TAO_Connector::active_connect_strategy_ [protected]
 

The (a)synch connect strategy.

Definition at line 130 of file Transport_Connector.h.

Referenced by create_connect_strategy, TAO_IIOP_Connector::make_connection, and ~TAO_Connector.

TAO_ORB_Core* TAO_Connector::orb_core_ [private]
 

Pointer to our ORB core.

Definition at line 138 of file Transport_Connector.h.

Referenced by connect, create_connect_strategy, and orb_core.

CORBA::ULong TAO_Connector::tag_ [private]
 

IOP protocol tag.

Definition at line 135 of file Transport_Connector.h.

Referenced by tag.


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