TAO::IIOP_SSL_Connector Class Reference

IIOP-specific Connector (SSL aware) bridge for pluggable protocols. More...

#include <IIOP_SSL_Connector.h>

Inheritance diagram for TAO::IIOP_SSL_Connector:

Inheritance graph
[legend]
Collaboration diagram for TAO::IIOP_SSL_Connector:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_Connect_Concurrency_Strategy<
IIOP_SSL_Connection_Handler
CONNECT_CONCURRENCY_STRATEGY
typedef TAO_Connect_Creation_Strategy<
IIOP_SSL_Connection_Handler
CONNECT_CREATION_STRATEGY
typedef ACE_Connect_Strategy<
IIOP_SSL_Connection_Handler,
ACE_SOCK_CONNECTOR
CONNECT_STRATEGY
typedef ACE_Strategy_Connector<
IIOP_SSL_Connection_Handler,
ACE_SOCK_CONNECTOR
BASE_CONNECTOR

Public Member Functions

 IIOP_SSL_Connector (void)
 Constructor.

 ~IIOP_SSL_Connector (void)
 Destructor.

int open (TAO_ORB_Core *orb_core)
int close (void)

Protected Member Functions

The TAO_Connector Methods
Check the documentation in tao/Transport_Connector.h for details.

int set_validate_endpoint (TAO_Endpoint *ep)
TAO_Transportmake_connection (TAO::Profile_Transport_Resolver *r, TAO_Transport_Descriptor_Interface &desc, ACE_Time_Value *timeout=0)
virtual int cancel_svc_handler (TAO_Connection_Handler *svc_handler)

Private Attributes

CONNECT_STRATEGY connect_strategy_
 Our connect strategy.

BASE_CONNECTOR base_connector_
 The connector initiating connection requests for IIOP_SSL.


Detailed Description

IIOP-specific Connector (SSL aware) 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_Registry.

Definition at line 43 of file IIOP_SSL_Connector.h.


Member Typedef Documentation

typedef ACE_Strategy_Connector<IIOP_SSL_Connection_Handler, ACE_SOCK_CONNECTOR> TAO::IIOP_SSL_Connector::BASE_CONNECTOR
 

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 70 of file IIOP_SSL_Connector.h.

typedef TAO_Connect_Concurrency_Strategy<IIOP_SSL_Connection_Handler> TAO::IIOP_SSL_Connector::CONNECT_CONCURRENCY_STRATEGY
 

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 59 of file IIOP_SSL_Connector.h.

Referenced by open().

typedef TAO_Connect_Creation_Strategy<IIOP_SSL_Connection_Handler> TAO::IIOP_SSL_Connector::CONNECT_CREATION_STRATEGY
 

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 62 of file IIOP_SSL_Connector.h.

Referenced by open().

typedef ACE_Connect_Strategy<IIOP_SSL_Connection_Handler, ACE_SOCK_CONNECTOR> TAO::IIOP_SSL_Connector::CONNECT_STRATEGY
 

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 66 of file IIOP_SSL_Connector.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::IIOP_SSL_Connector::IIOP_SSL_Connector void   ) 
 

Constructor.

Definition at line 22 of file IIOP_SSL_Connector.cpp.

00023   : TAO_IIOP_Connector (),
00024     connect_strategy_ (),
00025     base_connector_ ()
00026 {
00027 }

TAO::IIOP_SSL_Connector::~IIOP_SSL_Connector void   ) 
 

Destructor.

Definition at line 29 of file IIOP_SSL_Connector.cpp.

00030 {
00031 }


Member Function Documentation

int TAO::IIOP_SSL_Connector::cancel_svc_handler TAO_Connection_Handler svc_handler  )  [protected, virtual]
 

Reimplemented from TAO_IIOP_Connector.

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 273 of file IIOP_SSL_Connector.cpp.

References ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::cancel().

00275 {
00276   IIOP_SSL_Connection_Handler* handler=
00277     dynamic_cast<IIOP_SSL_Connection_Handler*> (svc_handler);
00278 
00279   if (handler)
00280     // Cancel from the connector
00281     return this->base_connector_.cancel (handler);
00282 
00283   return -1;
00284 }

int TAO::IIOP_SSL_Connector::close void   )  [virtual]
 

Reimplemented from TAO_IIOP_Connector.

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 65 of file IIOP_SSL_Connector.cpp.

References ACE_Strategy_Connector< SVC_HANDLER, >::close(), ACE_Strategy_Connector< SVC_HANDLER, >::concurrency_strategy(), and ACE_Strategy_Connector< SVC_HANDLER, >::creation_strategy().

Referenced by TAO::SSLIOP::Connector::close().

00066 {
00067   delete this->base_connector_.creation_strategy ();
00068   delete this->base_connector_.concurrency_strategy ();
00069   return this->base_connector_.close ();
00070 }

TAO_Transport * TAO::IIOP_SSL_Connector::make_connection TAO::Profile_Transport_Resolver r,
TAO_Transport_Descriptor_Interface desc,
ACE_Time_Value timeout = 0
[protected, virtual]
 

Reimplemented from TAO_IIOP_Connector.

Definition at line 106 of file IIOP_SSL_Connector.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_TEXT(), TAO::Profile_Transport_Resolver::blocked_connect(), TAO::Transport_Cache_Manager::cache_transport(), TAO_IIOP_Connection_Handler::close(), TAO_Transport::close_connection(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::connect(), TAO_Transport::connection_handler(), TAO_Transport_Descriptor_Interface::endpoint(), EWOULDBLOCK, TAO_IIOP_Endpoint::host(), TAO_Transport::id(), TAO_Transport::is_connected(), TAO_LF_Event::keep_waiting(), TAO_ORB_Core::lane_resources(), LM_DEBUG, LM_ERROR, TAO_IIOP_Endpoint::object_addr(), TAO_Connector::orb_core(), TAO_IIOP_Endpoint::port(), TAO_Transport::purge_entry(), TAO_Wait_Strategy::register_handler(), TAO_Connect_Strategy::synch_options(), TAO_debug_level, ACE_Synch_Options::timeout(), TAO_Connection_Handler::transport(), TAO_Thread_Lane_Resources::transport_cache(), TAO_Connector::wait_for_connection_completion(), and TAO_Transport::wait_strategy().

00110 {
00111   TAO_IIOP_Endpoint *iiop_endpoint =
00112     dynamic_cast<TAO_IIOP_Endpoint *> (desc.endpoint ());
00113 
00114   if (iiop_endpoint == 0)
00115     return 0;
00116 
00117   const ACE_INET_Addr &remote_address =
00118     iiop_endpoint->object_addr ();
00119 
00120   if (TAO_debug_level > 4)
00121     ACE_DEBUG ((LM_DEBUG,
00122                 ACE_TEXT ("(%P|%t) IIOP_SSL_Connector::connect ")
00123                 ACE_TEXT ("making a new connection \n")));
00124 
00125   // Get the right synch options
00126   ACE_Synch_Options synch_options;
00127 
00128   this->active_connect_strategy_->synch_options (max_wait_time, synch_options);
00129 
00130   // If we don't need to block for a transport just set the timeout to
00131   // be zero.
00132   ACE_Time_Value tmp_zero (ACE_Time_Value::zero);
00133   if (!r->blocked_connect ())
00134     {
00135       synch_options.timeout (ACE_Time_Value::zero);
00136       max_wait_time = &tmp_zero;
00137     }
00138 
00139 
00140   IIOP_SSL_Connection_Handler *svc_handler = 0;
00141 
00142   // Connect.
00143   int result =
00144     this->base_connector_.connect (svc_handler, remote_address, synch_options);
00145 
00146   // The connect() method creates the service handler and bumps the
00147   // #REFCOUNT# up one extra.  There are three possibilities from
00148   // calling connect(): (a) connection succeeds immediately - in this
00149   // case, the #REFCOUNT# on the handler is two; (b) connection
00150   // completion is pending - in this case, the #REFCOUNT# on the
00151   // handler is also two; (c) connection fails immediately - in this
00152   // case, the #REFCOUNT# on the handler is one since close() gets
00153   // called on the handler.
00154   //
00155   // The extra reference count in
00156   // TAO_Connect_Creation_Strategy::make_svc_handler() is needed in
00157   // the case when connection completion is pending and we are going
00158   // to wait on a variable in the handler to changes, signifying
00159   // success or failure.  Note, that this increment cannot be done
00160   // once the connect() returns since this might be too late if
00161   // another thread pick up the completion and potentially deletes the
00162   // handler before we get a chance to increment the reference count.
00163 
00164   // Make sure that we always do a remove_reference
00165   ACE_Event_Handler_var svc_handler_auto_ptr (svc_handler);
00166 
00167   TAO_Transport *transport =
00168     svc_handler->transport ();
00169 
00170   if (result == -1)
00171     {
00172       // No immediate result, wait for completion
00173       if (errno == EWOULDBLOCK)
00174         {
00175           // Try to wait until connection completion. Incase we block, then we
00176           // get a connected transport or not. In case of non block we get
00177           // a connected or not connected transport
00178           if (!this->wait_for_connection_completion (r,
00179                                                      transport,
00180                                                      max_wait_time))
00181             {
00182               if (TAO_debug_level > 2)
00183                 ACE_ERROR ((LM_ERROR, "TAO (%P|%t) - IIOP_SSL_Connector::"
00184                                       "make_connection, "
00185                                       "wait for completion failed\n"));
00186             }
00187         }
00188       else
00189         {
00190           // Transport is not usable
00191           transport = 0;
00192         }
00193     }
00194 
00195   // In case of errors transport is zero
00196   if (transport == 0)
00197     {
00198       // Give users a clue to the problem.
00199       if (TAO_debug_level)
00200         {
00201           ACE_DEBUG ((LM_ERROR,
00202                       "TAO (%P|%t) - IIOP_SSL_Connector::make_connection, "
00203                       "connection to <%s:%d> failed (%p)\n",
00204                       iiop_endpoint->host (), iiop_endpoint->port (),
00205                       "errno"));
00206         }
00207 
00208       return 0;
00209     }
00210 
00211   if (transport->connection_handler ()->keep_waiting ())
00212     {
00213       svc_handler->add_reference ();
00214     }
00215 
00216   // At this point, the connection has be successfully connected.
00217   // #REFCOUNT# is one.
00218   if (TAO_debug_level > 2)
00219     ACE_DEBUG ((LM_DEBUG,
00220                 "TAO (%P|%t) - IIOP_SSL_Connector::make_connection, "
00221                 "new connection to <%s:%d> on Transport[%d]\n",
00222                 iiop_endpoint->host (), iiop_endpoint->port (),
00223                 svc_handler->peer ().get_handle ()));
00224 
00225   // Add the handler to Cache
00226   int retval =
00227     this->orb_core ()->lane_resources ().transport_cache ().cache_transport (
00228       &desc,
00229       transport);
00230 
00231   // Failure in adding to cache.
00232   if (retval != 0)
00233     {
00234       // Close the handler.
00235       svc_handler->close ();
00236 
00237       if (TAO_debug_level > 0)
00238         {
00239           ACE_ERROR ((LM_ERROR,
00240                       "TAO (%P|%t) - IIOP_SSL_Connector::make_connection, "
00241                       "could not add the new connection to cache\n"));
00242         }
00243 
00244       return 0;
00245     }
00246 
00247   if (transport->is_connected () &&
00248       transport->wait_strategy ()->register_handler () != 0)
00249     {
00250       // Registration failures.
00251 
00252       // Purge from the connection cache, if we are not in the cache, this
00253       // just does nothing.
00254       (void) transport->purge_entry ();
00255 
00256       // Close the handler.
00257       (void) transport->close_connection ();
00258 
00259       if (TAO_debug_level > 0)
00260         ACE_ERROR ((LM_ERROR,
00261                     "TAO (%P|%t) - IIOP_SSL_Connector [%d]::make_connection, "
00262                     "could not register the transport "
00263                     "in the reactor.\n",
00264                     transport->id ()));
00265 
00266       return 0;
00267     }
00268 
00269   return transport;
00270 }

int TAO::IIOP_SSL_Connector::open TAO_ORB_Core orb_core  )  [virtual]
 

Reimplemented from TAO_IIOP_Connector.

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 34 of file IIOP_SSL_Connector.cpp.

References ACE_NEW_RETURN, CONNECT_CONCURRENCY_STRATEGY, CONNECT_CREATION_STRATEGY, TAO_Connector::create_connect_strategy(), ACE_Strategy_Connector< SVC_HANDLER, >::open(), TAO_Connector::orb_core(), and TAO_ORB_Core::thr_mgr().

Referenced by TAO::SSLIOP::Connector::open().

00035 {
00036   this->orb_core (orb_core);
00037 
00038   // Create our connect strategy
00039   if (this->create_connect_strategy () == -1)
00040     return -1;
00041 
00042   // Our connect creation strategy
00043   CONNECT_CREATION_STRATEGY *connect_creation_strategy = 0;
00044 
00045   ACE_NEW_RETURN (connect_creation_strategy,
00046                   CONNECT_CREATION_STRATEGY (orb_core->thr_mgr (),
00047                                              orb_core),
00048                   -1);
00049 
00050   // Our activation strategy
00051   CONNECT_CONCURRENCY_STRATEGY *concurrency_strategy = 0;
00052 
00053   ACE_NEW_RETURN (concurrency_strategy,
00054                   CONNECT_CONCURRENCY_STRATEGY (orb_core),
00055                   -1);
00056 
00057 
00058   return this->base_connector_.open (this->orb_core ()->reactor (),
00059                                      connect_creation_strategy,
00060                                      &this->connect_strategy_,
00061                                      concurrency_strategy);
00062 }

int TAO::IIOP_SSL_Connector::set_validate_endpoint TAO_Endpoint ep  )  [protected, virtual]
 

Reimplemented from TAO_IIOP_Connector.

Definition at line 73 of file IIOP_SSL_Connector.cpp.

References ACE_DEBUG, ACE_TEXT(), AF_INET, ACE_Addr::get_type(), LM_DEBUG, TAO_IIOP_Endpoint::object_addr(), TAO_Endpoint::tag(), and TAO_debug_level.

00074 {
00075   if (endpoint->tag () != IOP::TAG_INTERNET_IOP)
00076     return -1;
00077 
00078   TAO_IIOP_Endpoint *iiop_endpoint =
00079     dynamic_cast<TAO_IIOP_Endpoint *> (endpoint);
00080 
00081   if (iiop_endpoint == 0)
00082     return -1;
00083 
00084   const ACE_INET_Addr &remote_address = iiop_endpoint->object_addr ();
00085 
00086   // Verify that the remote ACE_INET_Addr was initialized properly.
00087   // Failure can occur if hostname lookup failed when initializing the
00088   // remote ACE_INET_Addr.
00089   if (remote_address.get_type () != AF_INET)
00090     {
00091       if (TAO_debug_level > 0)
00092         {
00093           ACE_DEBUG ((LM_DEBUG,
00094                       ACE_TEXT ("TAO (%P|%t) - IIOP_SSL connection failed.\n")
00095                       ACE_TEXT ("TAO (%P|%t) - This is most likely ")
00096                       ACE_TEXT ("due to a hostname lookup failure.\n")));
00097         }
00098 
00099       return -1;
00100     }
00101 
00102   return 0;
00103 }


Member Data Documentation

BASE_CONNECTOR TAO::IIOP_SSL_Connector::base_connector_ [private]
 

The connector initiating connection requests for IIOP_SSL.

Reimplemented from TAO_IIOP_Connector.

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 95 of file IIOP_SSL_Connector.h.

CONNECT_STRATEGY TAO::IIOP_SSL_Connector::connect_strategy_ [private]
 

Our connect strategy.

Reimplemented from TAO_IIOP_Connector.

Reimplemented in TAO::SSLIOP::Connector.

Definition at line 92 of file IIOP_SSL_Connector.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 16:13:54 2008 for TAO_SSLIOP by doxygen 1.3.6