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

TAO_IIOP_Connector Class Reference

IIOP-specific Connector bridge for pluggable protocols. More...

#include <IIOP_Connector.h>

Inheritance diagram for TAO_IIOP_Connector:

Inheritance graph
[legend]
Collaboration diagram for TAO_IIOP_Connector:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_Connect_Concurrency_Strategy<
TAO_IIOP_Connection_Handler
TAO_IIOP_CONNECT_CONCURRENCY_STRATEGY
typedef TAO_Connect_Creation_Strategy<
TAO_IIOP_Connection_Handler
TAO_IIOP_CONNECT_CREATION_STRATEGY
typedef ACE_Connect_Strategy<
TAO_IIOP_Connection_Handler,
ACE_SOCK_CONNECTOR
TAO_IIOP_CONNECT_STRATEGY
typedef ACE_Strategy_Connector<
TAO_IIOP_Connection_Handler,
ACE_SOCK_CONNECTOR
TAO_IIOP_BASE_CONNECTOR

Public Methods

 TAO_IIOP_Connector (CORBA::Boolean flag=0)
 Constructor. More...

 ~TAO_IIOP_Connector (void)
 Destructor. More...

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

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

TAO_Profilecreate_profile (TAO_InputCDR &cdr)
 Create a profile for this protocol and initialize it based on the encapsulation in <cdr>. More...

virtual int check_prefix (const char *endpoint)
 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
 Return the object key delimiter to use or expect. More...


Protected Methods

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

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

virtual TAO_Profilemake_profile (ACE_ENV_SINGLE_ARG_DECL)
 More TAO_Connector methods, please check the documentation on Transport_Connector.h. More...

int init_tcp_properties (void)
 Obtain tcp properties that must be used by this connector, i.e., initialize <tcp_properties_>. More...


Protected Attributes

TAO_IIOP_Properties tcp_properties_
 TCP configuration properties to be used for all connections established by this connector. More...

CORBA::Boolean lite_flag_
 Do we need to use a GIOP_Lite for sending messages? More...


Private Methods

TAO_IIOP_Endpointremote_endpoint (TAO_Endpoint *ep)
 Return the remote endpoint, a helper function. More...


Private Attributes

TAO_IIOP_CONNECT_STRATEGY connect_strategy_
 Our connect strategy. More...

TAO_IIOP_BASE_CONNECTOR base_connector_
 The connector initiating connection requests for IIOP. More...


Detailed Description

IIOP-specific Connector bridge for pluggable protocols.

Concrete instance of the TAO_Connector class. Responsible for establishing a connection with a server and is called from the Connector_Registory.

Definition at line 46 of file IIOP_Connector.h.


Member Typedef Documentation

typedef ACE_Strategy_Connector<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR> TAO_IIOP_Connector::TAO_IIOP_BASE_CONNECTOR
 

Definition at line 80 of file IIOP_Connector.h.

typedef TAO_Connect_Concurrency_Strategy<TAO_IIOP_Connection_Handler> TAO_IIOP_Connector::TAO_IIOP_CONNECT_CONCURRENCY_STRATEGY
 

Definition at line 69 of file IIOP_Connector.h.

typedef TAO_Connect_Creation_Strategy<TAO_IIOP_Connection_Handler> TAO_IIOP_Connector::TAO_IIOP_CONNECT_CREATION_STRATEGY
 

Definition at line 72 of file IIOP_Connector.h.

typedef ACE_Connect_Strategy<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR> TAO_IIOP_Connector::TAO_IIOP_CONNECT_STRATEGY
 

Definition at line 76 of file IIOP_Connector.h.


Constructor & Destructor Documentation

TAO_IIOP_Connector::TAO_IIOP_Connector CORBA::Boolean    flag = 0
 

Constructor.

Definition at line 52 of file IIOP_Connector.cpp.

References IOP::TAG_INTERNET_IOP.

00053   : TAO_Connector (IOP::TAG_INTERNET_IOP),
00054     lite_flag_ (flag),
00055     connect_strategy_ (),
00056     base_connector_ ()
00057 {
00058 }

TAO_IIOP_Connector::~TAO_IIOP_Connector void   
 

Destructor.

Definition at line 60 of file IIOP_Connector.cpp.

00061 {
00062 }


Member Function Documentation

int TAO_IIOP_Connector::check_prefix const char *    endpoint [virtual]
 

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

Implements TAO_Connector.

Definition at line 317 of file IIOP_Connector.cpp.

References ACE_OS_String::strchr, ACE_OS_String::strlen, and ACE_OS_String::strncasecmp.

00318 {
00319   // Check for a valid string
00320   if (!endpoint || !*endpoint)
00321     return -1;  // Failure
00322 
00323   const char *protocol[] = { "iiop", "iioploc" };
00324 
00325   size_t slot = ACE_OS::strchr (endpoint, ':') - endpoint;
00326 
00327   size_t len0 = ACE_OS::strlen (protocol[0]);
00328   size_t len1 = ACE_OS::strlen (protocol[1]);
00329 
00330   // Check for the proper prefix in the IOR.  If the proper prefix
00331   // isn't in the IOR then it is not an IOR we can use.
00332   if (slot == len0
00333       && ACE_OS::strncasecmp (endpoint, protocol[0], len0) == 0)
00334     return 0;
00335   else if (slot == len1
00336            && ACE_OS::strncasecmp (endpoint, protocol[1], len1) == 0)
00337     return 0;
00338 
00339   return -1;
00340   // Failure: not an IIOP IOR
00341   // DO NOT throw an exception here.
00342 }

int TAO_IIOP_Connector::close void    [virtual]
 

Shutdown Connector bridge and concrete Connector.

Implements TAO_Connector.

Definition at line 106 of file IIOP_Connector.cpp.

References base_connector_, ACE_Strategy_Connector< TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR >::close, ACE_Strategy_Connector< TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR >::concurrency_strategy, and ACE_Strategy_Connector< TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR >::creation_strategy.

00107 {
00108   delete this->base_connector_.concurrency_strategy ();
00109   delete this->base_connector_.creation_strategy ();
00110   return this->base_connector_.close ();
00111 }

TAO_Profile * TAO_IIOP_Connector::create_profile TAO_InputCDR   cdr [virtual]
 

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

Implements TAO_Connector.

Definition at line 278 of file IIOP_Connector.cpp.

References TAO_Profile::_decr_refcnt, ACE_NEW_RETURN, and TAO_Profile::decode.

00279 {
00280   TAO_Profile *pfile;
00281   ACE_NEW_RETURN (pfile,
00282                   TAO_IIOP_Profile (this->orb_core ()),
00283                   0);
00284 
00285   int r = pfile->decode (cdr);
00286   if (r == -1)
00287     {
00288       pfile->_decr_refcnt ();
00289       pfile = 0;
00290     }
00291 
00292   return pfile;
00293 }

int TAO_IIOP_Connector::init_tcp_properties void    [protected]
 

Obtain tcp properties that must be used by this connector, i.e., initialize <tcp_properties_>.

Definition at line 351 of file IIOP_Connector.cpp.

References ACE_CHECK_RETURN, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENV_SINGLE_ARG_PARAMETER, TAO_Protocols_Hooks::call_client_protocols_hook, TAO_IIOP_Properties::enable_network_priority, TAO_ORB_Core::get_protocols_hooks, TAO_IIOP_Properties::no_delay, TAO_ORB_Parameters::nodelay, TAO_Connector::orb_core, TAO_ORB_Core::orb_params, TAO_IIOP_Properties::recv_buffer_size, TAO_IIOP_Properties::send_buffer_size, TAO_ORB_Parameters::sock_rcvbuf_size, TAO_ORB_Parameters::sock_sndbuf_size, and tcp_properties_.

Referenced by open.

00352 {
00353   // Connector protocol properties are obtained from ORB-level
00354   // RTCORBA::ClientProtocolProperties policy override.
00355   // If the override doesn't exist or doesn't contain the
00356   // properties, we use ORB default.
00357   //
00358   // Currently, we do not use Object-level and Current-level policy
00359   // overrides for protocol configuration because connection
00360   // lookup and caching are not done based on protocol
00361   // properties.
00362 
00363   ACE_DECLARE_NEW_CORBA_ENV;
00364 
00365   // Initialize the settings to the ORB defaults.  If RT CORBA is enabled,
00366   // it may override these.
00367   int send_buffer_size = this->orb_core ()->orb_params ()->sock_sndbuf_size ();
00368   int recv_buffer_size = this->orb_core ()->orb_params ()->sock_rcvbuf_size ();
00369   int no_delay = this->orb_core ()->orb_params ()->nodelay ();
00370   int enable_network_priority = 0;
00371 
00372   TAO_Protocols_Hooks *tph = this->orb_core ()->get_protocols_hooks (ACE_ENV_SINGLE_ARG_PARAMETER);
00373   ACE_CHECK_RETURN (-1);
00374 
00375   if (tph != 0)
00376     {
00377       const char protocol [] = "iiop";
00378       const char *protocol_type = protocol;
00379 
00380       int hook_result =
00381         tph->call_client_protocols_hook (send_buffer_size,
00382                                          recv_buffer_size,
00383                                          no_delay,
00384                                          enable_network_priority,
00385                                          protocol_type);
00386 
00387       if(hook_result == -1)
00388         return -1;
00389     }
00390 
00391   // Extract and locally store properties of interest.
00392   this->tcp_properties_.send_buffer_size =
00393     send_buffer_size;
00394   this->tcp_properties_.recv_buffer_size =
00395     recv_buffer_size;
00396   this->tcp_properties_.no_delay =
00397     no_delay;
00398   this->tcp_properties_.enable_network_priority  =
00399     enable_network_priority;
00400 
00401   return 0;
00402 }

int TAO_IIOP_Connector::make_connection TAO_GIOP_Invocation   invocation,
TAO_Transport_Descriptor_Interface   desc,
ACE_Time_Value   timeout = 0
[protected, virtual]
 

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

Implements TAO_Connector.

Definition at line 146 of file IIOP_Connector.cpp.

References TAO_Transport::_duplicate, ACE_ASSERT, ACE_DEBUG, TAO_Connector::active_connect_strategy_, base_connector_, TAO_Transport_Cache_Manager::cache_transport, TAO_Connection_Handler::decr_refcount, TAO_Transport_Descriptor_Interface::endpoint, EWOULDBLOCK, ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::get_handle, TAO_IIOP_Endpoint::host, TAO_Connection_Handler::is_finalized, TAO_ORB_Core::lane_resources, LM_DEBUG, LM_ERROR, TAO_IIOP_Endpoint::object_addr, TAO_Connector::orb_core, ACE_Svc_Handler< ACE_SOCK_STREAM, ACE_NULL_SYNCH >::peer, TAO_IIOP_Endpoint::port, TAO_Connect_Strategy::post_failed_connect, TAO_Wait_Strategy::register_handler, remote_endpoint, TAO_Connect_Strategy::synch_options, TAO_GIOP_Invocation::transport, TAO_Connection_Handler::transport, TAO_Thread_Lane_Resources::transport_cache, TAO_Connect_Strategy::wait, and TAO_Transport::wait_strategy.

00149 {
00150   TAO_IIOP_Endpoint *iiop_endpoint =
00151     this->remote_endpoint (desc->endpoint ());
00152 
00153    if (iiop_endpoint == 0)
00154      return -1;
00155 
00156    const ACE_INET_Addr &remote_address =
00157      iiop_endpoint->object_addr ();
00158 
00159    if (TAO_debug_level > 2)
00160      ACE_DEBUG ((LM_DEBUG,
00161                  "TAO (%P|%t) - IIOP_Connector::make_connection, "
00162                  "to <%s:%d>\n",
00163                  iiop_endpoint->host(), iiop_endpoint->port()));
00164 
00165    // Get the right synch options
00166    ACE_Synch_Options synch_options;
00167 
00168    this->active_connect_strategy_->synch_options (max_wait_time,
00169                                                   synch_options);
00170 
00171    TAO_IIOP_Connection_Handler *svc_handler = 0;
00172 
00173    // Active connect
00174    int result = this->base_connector_.connect (svc_handler,
00175                                                remote_address,
00176                                                synch_options);
00177 
00178 
00179    if (result == -1 && errno == EWOULDBLOCK)
00180      {
00181        if (TAO_debug_level > 2)
00182          ACE_DEBUG ((LM_DEBUG,
00183                      "TAO (%P|%t) - IIOP_Connector::make_connection, "
00184                      "going to wait for connection completion on local"
00185                      "handle [%d]\n",
00186                      svc_handler->get_handle ()));
00187 
00188        result =
00189          this->active_connect_strategy_->wait (svc_handler,
00190                                                max_wait_time);
00191 
00192        if (TAO_debug_level > 2)
00193          {
00194            ACE_DEBUG ((LM_DEBUG,
00195                        "TAO (%P|%t) - IIOP_Connector::make_connection"
00196                        "wait done for handle[%d], result = %d\n",
00197                        svc_handler->get_handle (), result));
00198          }
00199 
00200      }
00201 
00202    int status =
00203      svc_handler->is_finalized ();
00204 
00205    // Reduce the refcount to the svc_handler that we have. The
00206    // increment to the handler is done in make_svc_handler (). Now
00207    // that we dont need the reference to it anymore we can decrement
00208    // the refcount whether the connection is successful ot not.
00209 
00210    // REFCNT: Matches with TAO_Connect_Strategy<>::make_svc_handler()
00211    long refcount = svc_handler->decr_refcount ();
00212 
00213    ACE_ASSERT (refcount >= 0);
00214 
00215    ACE_UNUSED_ARG (refcount);
00216 
00217    if (result == -1)
00218      {
00219        // Give users a clue to the problem.
00220        if (TAO_debug_level)
00221          {
00222            ACE_DEBUG ((LM_ERROR,
00223                        "TAO (%P|%t) - IIOP_Connector::make_connection, "
00224                        "connection to <%s:%d> failed (%p)\n",
00225                        iiop_endpoint->host (), iiop_endpoint->port (),
00226                        "errno"));
00227          }
00228 
00229        (void) this->active_connect_strategy_->post_failed_connect (svc_handler,
00230                                                                    status);
00231 
00232        return -1;
00233      }
00234 
00235    if (TAO_debug_level > 2)
00236      ACE_DEBUG ((LM_DEBUG,
00237                  "TAO (%P|%t) - IIOP_Connector::make_connection, "
00238                  "new connection to <%s:%d> on Transport[%d]\n",
00239                  iiop_endpoint->host (), iiop_endpoint->port (),
00240                  svc_handler->peer ().get_handle ()));
00241 
00242    TAO_Transport *base_transport =
00243      TAO_Transport::_duplicate (svc_handler->transport ());
00244 
00245    // Add the handler to Cache
00246    int retval =
00247      this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
00248                                                                               base_transport);
00249 
00250    if (retval != 0 && TAO_debug_level > 0)
00251      {
00252        ACE_DEBUG ((LM_DEBUG,
00253                    "TAO (%P|%t) - IIOP_Connector::make_connection, "
00254                    "could not add the new connection to cache\n"));
00255      }
00256 
00257    // If the wait strategy wants us to be registered with the reactor
00258    // then we do so.
00259    retval =  base_transport->wait_strategy ()->register_handler ();
00260 
00261    if (retval != 0 && TAO_debug_level > 0)
00262      {
00263        ACE_DEBUG ((LM_DEBUG,
00264                    "TAO (%P|%t) - IIOP_Connector::make_connection, "
00265                    "could not register the new connection in the reactor\n"));
00266      }
00267 
00268    // Handover the transport pointer to the Invocation class.
00269    TAO_Transport *&transport = invocation->transport ();
00270    transport = base_transport;
00271 
00272    return 0;
00273 }

TAO_Profile * TAO_IIOP_Connector::make_profile ACE_ENV_SINGLE_ARG_DECL    [protected, virtual]
 

More TAO_Connector methods, please check the documentation on Transport_Connector.h.

Implements TAO_Connector.

Definition at line 296 of file IIOP_Connector.cpp.

References ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_DECL, ACE_NEW_THROW_EX, and TAO_DEFAULT_MINOR_CODE.

00297 {
00298   // The endpoint should be of the form:
00299   //    N.n@host:port/object_key
00300   // or:
00301   //    host:port/object_key
00302 
00303   TAO_Profile *profile = 0;
00304   ACE_NEW_THROW_EX (profile,
00305                     TAO_IIOP_Profile (this->orb_core ()),
00306                     CORBA::NO_MEMORY (
00307                       CORBA::SystemException::_tao_minor_code (
00308                         TAO_DEFAULT_MINOR_CODE,
00309                         ENOMEM),
00310                       CORBA::COMPLETED_NO));
00311   ACE_CHECK_RETURN (0);
00312 
00313   return profile;
00314 }

char TAO_IIOP_Connector::object_key_delimiter void    const [virtual]
 

Return the object key delimiter to use or expect.

Implements TAO_Connector.

Definition at line 345 of file IIOP_Connector.cpp.

References TAO_IIOP_Profile::object_key_delimiter_.

00346 {
00347   return TAO_IIOP_Profile::object_key_delimiter_;
00348 }

int TAO_IIOP_Connector::open TAO_ORB_Core   orb_core [virtual]
 

Initialize object and register with reactor.

Implements TAO_Connector.

Definition at line 65 of file IIOP_Connector.cpp.

References ACE_NEW_RETURN, base_connector_, connect_strategy_, TAO_Connector::create_connect_strategy, init_tcp_properties, lite_flag_, ACE_Strategy_Connector< TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR >::open, TAO_Connector::orb_core, tcp_properties_, and TAO_ORB_Core::thr_mgr.

00066 {
00067   // @@todo: The functionality of the following two statements could
00068   // be  done in the constructor, but that involves changing the
00069   // interface of the pluggable transport factory.
00070 
00071   // Set the ORB Core
00072   this->orb_core (orb_core);
00073 
00074   // Create our connect strategy
00075   if (this->create_connect_strategy () == -1)
00076     return -1;
00077 
00078   if (this->init_tcp_properties () != 0)
00079     return -1;
00080 
00081   /// Our connect creation strategy
00082   TAO_IIOP_CONNECT_CREATION_STRATEGY *connect_creation_strategy = 0;
00083 
00084   ACE_NEW_RETURN (connect_creation_strategy,
00085                   TAO_IIOP_CONNECT_CREATION_STRATEGY
00086                       (orb_core->thr_mgr (),
00087                        orb_core,
00088                        &(this->tcp_properties_),
00089                        this->lite_flag_),
00090                   -1);
00091 
00092   /// Our activation strategy
00093   TAO_IIOP_CONNECT_CONCURRENCY_STRATEGY *concurrency_strategy = 0;
00094 
00095   ACE_NEW_RETURN (concurrency_strategy,
00096                   TAO_IIOP_CONNECT_CONCURRENCY_STRATEGY (orb_core),
00097                   -1);
00098 
00099   return this->base_connector_.open (this->orb_core ()->reactor (),
00100                                      connect_creation_strategy,
00101                                      &this->connect_strategy_,
00102                                      concurrency_strategy);
00103 }

TAO_IIOP_Endpoint * TAO_IIOP_Connector::remote_endpoint TAO_Endpoint   ep [private]
 

Return the remote endpoint, a helper function.

Definition at line 406 of file IIOP_Connector.cpp.

References TAO_Endpoint::tag.

Referenced by make_connection, and set_validate_endpoint.

00407 {
00408   if (endpoint->tag () != IOP::TAG_INTERNET_IOP)
00409     return 0;
00410 
00411   TAO_IIOP_Endpoint *iiop_endpoint =
00412     ACE_dynamic_cast (TAO_IIOP_Endpoint *,
00413                       endpoint );
00414   if (iiop_endpoint == 0)
00415     return 0;
00416 
00417   return iiop_endpoint;
00418 }

int TAO_IIOP_Connector::set_validate_endpoint TAO_Endpoint   ep [protected, virtual]
 

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

Implements TAO_Connector.

Definition at line 114 of file IIOP_Connector.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, LM_DEBUG, TAO_IIOP_Endpoint::object_addr, and remote_endpoint.

00115 {
00116   TAO_IIOP_Endpoint *iiop_endpoint =
00117     this->remote_endpoint (endpoint);
00118 
00119   if (iiop_endpoint == 0)
00120     return -1;
00121 
00122    const ACE_INET_Addr &remote_address =
00123      iiop_endpoint->object_addr ();
00124 
00125    // Verify that the remote ACE_INET_Addr was initialized properly.
00126    // Failure can occur if hostname lookup failed when initializing the
00127    // remote ACE_INET_Addr.
00128    if (remote_address.get_type () != AF_INET)
00129      {
00130        if (TAO_debug_level > 0)
00131          {
00132            ACE_DEBUG ((LM_DEBUG,
00133                        ACE_LIB_TEXT ("TAO (%P|%t) IIOP connection failed.\n")
00134                        ACE_LIB_TEXT ("TAO (%P|%t) This is most likely ")
00135                        ACE_LIB_TEXT ("due to a hostname lookup ")
00136                        ACE_LIB_TEXT ("failure.\n")));
00137          }
00138 
00139        return -1;
00140      }
00141 
00142    return 0;
00143 }


Member Data Documentation

TAO_IIOP_BASE_CONNECTOR TAO_IIOP_Connector::base_connector_ [private]
 

The connector initiating connection requests for IIOP.

Definition at line 121 of file IIOP_Connector.h.

Referenced by close, make_connection, and open.

TAO_IIOP_CONNECT_STRATEGY TAO_IIOP_Connector::connect_strategy_ [private]
 

Our connect strategy.

Definition at line 118 of file IIOP_Connector.h.

Referenced by open.

CORBA::Boolean TAO_IIOP_Connector::lite_flag_ [protected]
 

Do we need to use a GIOP_Lite for sending messages?

Definition at line 107 of file IIOP_Connector.h.

Referenced by open.

TAO_IIOP_Properties TAO_IIOP_Connector::tcp_properties_ [protected]
 

TCP configuration properties to be used for all connections established by this connector.

Definition at line 104 of file IIOP_Connector.h.

Referenced by init_tcp_properties, and open.


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