SCIOP_Acceptor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // SCIOP_Acceptor.h,v 1.11 2006/06/01 13:16:13 jwillemsen Exp
00004 // ===================================================================
00005 /*
00006  *  @file   SCIOP_Acceptor.h
00007  *
00008  *  SCIOP specific acceptor processing
00009  *
00010  *  @author  Jason Cohen, Lockheed Martin ATL  <jcohen@atl.lmco.com>
00011  *  @author  Keith O'Hara, Lockheed Martin ATL
00012  */
00013 // ===================================================================
00014 
00015 
00016 #ifndef TAO_SCIOP_ACCEPTOR_H
00017 #define TAO_SCIOP_ACCEPTOR_H
00018 #include /**/ "ace/pre.h"
00019 
00020 #include "tao/orbconf.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #if TAO_HAS_SCIOP == 1
00027 
00028 #include "tao/Transport_Acceptor.h"
00029 #include "tao/Strategies/SCIOP_Connection_Handler.h"
00030 #include "tao/Acceptor_Impl.h"
00031 #include "tao/GIOP_Message_Version.h"
00032 
00033 #include "ace/SOCK_SEQPACK_Acceptor.h"
00034 #include "ace/Acceptor.h"
00035 
00036 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00037 
00038 // TAO SCIOP_Acceptor concrete call defination
00039 
00040 /**
00041  * @class TAO_SCIOP_Acceptor
00042  *
00043  * @brief TAO_SCIOP_Acceptor
00044  *
00045  * The SCIOP-specific bridge class for the concrete acceptor.
00046  */
00047 class TAO_Strategies_Export TAO_SCIOP_Acceptor : public TAO_Acceptor
00048 {
00049 public:
00050   /// Constructor.
00051   TAO_SCIOP_Acceptor (CORBA::Boolean flag = false);
00052 
00053   /// Destructor.
00054   ~TAO_SCIOP_Acceptor (void);
00055 
00056   /// @@ Helper method for the implementation repository, should go
00057   ///    away
00058   const ACE_INET_Addr& address (void) const;
00059 
00060   /// Returns the array of endpoints in this acceptor
00061   const ACE_INET_Addr *endpoints (void);
00062 
00063   typedef ACE_Strategy_Acceptor<TAO_SCIOP_Connection_Handler, ACE_SOCK_SEQPACK_ACCEPTOR> TAO_SCIOP_BASE_ACCEPTOR;
00064   typedef TAO_Creation_Strategy<TAO_SCIOP_Connection_Handler> TAO_SCIOP_CREATION_STRATEGY;
00065   typedef TAO_Concurrency_Strategy<TAO_SCIOP_Connection_Handler> TAO_SCIOP_CONCURRENCY_STRATEGY;
00066   typedef TAO_Accept_Strategy<TAO_SCIOP_Connection_Handler, ACE_SOCK_SEQPACK_ACCEPTOR> TAO_SCIOP_ACCEPT_STRATEGY;
00067 
00068   /**
00069    * The TAO_Acceptor methods, check the documentation in
00070    * Transport_Acceptor.h for details.
00071    */
00072   virtual int open (TAO_ORB_Core *orb_core,
00073                     ACE_Reactor *reactor,
00074                     int version_major,
00075                     int version_minor,
00076                     const char *address,
00077                     const char *options = 0);
00078   virtual int open_default (TAO_ORB_Core *orb_core,
00079                             ACE_Reactor *reactor,
00080                             int version_major,
00081                             int version_minor,
00082                             const char *options = 0);
00083   virtual int close (void);
00084   virtual int create_profile (const TAO::ObjectKey &object_key,
00085                               TAO_MProfile &mprofile,
00086                               CORBA::Short priority);
00087   virtual int is_collocated (const TAO_Endpoint *endpoint);
00088   virtual CORBA::ULong endpoint_count (void);
00089 
00090   virtual int object_key (IOP::TaggedProfile &profile,
00091                           TAO::ObjectKey &key);
00092 
00093   /**
00094    * Set the host name for the given addr.
00095    * A hostname may be forced by using specified_hostname.  This
00096    * is useful if the given address corresponds to more than one
00097    * hostname and the desired one cannot be determined in any
00098    * other way.
00099    */
00100   int hostname (TAO_ORB_Core *orb_core,
00101                 ACE_INET_Addr &addr,
00102                 char *&host,
00103                 const char *specified_hostname = 0);
00104 
00105   /**
00106    * Set the host name for the given address using the dotted decimal
00107    * format.
00108    */
00109   int dotted_decimal_address (ACE_INET_Addr &addr,
00110                               char *&host);
00111 
00112 protected:
00113 
00114   /**
00115    * Implement the common part of the open*() methods.  This method is
00116    * virtual to allow a derived class implementation to be invoked
00117    * instead.
00118    */
00119   virtual int open_i (const ACE_Multihomed_INET_Addr &addr,
00120                       ACE_Reactor *reactor);
00121 
00122   /**
00123    * Probe the system for available network interfaces, and initialize
00124    * the <addrs_> array with an ACE_INET_Addr for each network
00125    * interface.  The port for each initialized ACE_INET_Addr will be
00126    * set in the open_i() method.  This method only gets invoked when
00127    * no explicit hostname is provided in the specified endpoint.
00128    */
00129   int probe_interfaces (TAO_ORB_Core *orb_core);
00130 
00131   /**
00132    * Split the string into hostnames separated by the plus character
00133    * ('+').
00134    */
00135   int parse_multiple_hostnames (const char *hostnames,
00136                                 ACE_Array<ACE_CString> &hostnames_out);
00137 
00138   /**
00139    * Parse protocol specific options.
00140    *
00141    * Currently supported:
00142    *    portspan -- specifies the range of ports over which the acceptor
00143    *                should scan looking for a free port (this is convenient
00144    *                for situations where you might normally use an ephemeral
00145    *                port but can't because you're behind a firewall and don't
00146    *                want to permit passage on all ephemeral ports)
00147    */
00148   virtual int parse_options (const char *options);
00149 
00150   /// Obtain tcp properties that must be used by this acceptor, i.e.,
00151   /// initialize <tcp_properties_>.
00152   int init_tcp_properties (void);
00153 
00154   /// Helper method to add a new profile to the mprofile for
00155   /// each endpoint.
00156   int create_new_profile (const TAO::ObjectKey &object_key,
00157                           TAO_MProfile &mprofile,
00158                           CORBA::Short priority);
00159 
00160   /// Helper method to create a profile that contains all of
00161   /// our endpoints.
00162   int create_shared_profile (const TAO::ObjectKey &object_key,
00163                              TAO_MProfile &mprofile,
00164                              CORBA::Short priority);
00165 
00166 protected:
00167 
00168   /// Array of ACE_INET_Addr instances, each one corresponding to a
00169   /// given network interface.
00170   ACE_INET_Addr *addrs_;
00171 
00172   /**
00173    * The number of ports over which the acceptor should search (starting
00174    * at the port specified in each element of addrs_) for an available
00175    * port.  This is specified via the "portspan=" option to the endpoint.
00176    */
00177   u_short port_span_;
00178 
00179   /**
00180    * Cache the information about the endpoints serviced by this
00181    * acceptor.
00182    * There may in fact be multiple hostnames for this endpoint. For
00183    * example, if the IP address is INADDR_ANY (0.0.0.0) then there
00184    * will be possibly a different hostname for each interface.
00185    */
00186   char **hosts_;
00187 
00188   /// The number of host names cached in the hosts_ array (equivalent
00189   /// to the number of endpoints opened by this Acceptor).
00190   CORBA::ULong endpoint_count_;
00191 
00192   /**
00193    * Override the hostname used in the ORBEndPoint.
00194    */
00195   char *hostname_in_ior_;
00196 
00197   /**
00198    * The GIOP version for this endpoint
00199    * @@ Theoretically they shouldn't be here!! We need to look at a
00200    * way to move this out
00201    */
00202   TAO_GIOP_Message_Version version_;
00203 
00204   /// ORB Core.
00205   TAO_ORB_Core *orb_core_;
00206 
00207   /// Should we use GIOP lite??
00208   CORBA::Boolean lite_flag_;
00209 
00210 private:
00211 
00212   /// the concrete acceptor, as a pointer to it's base class.
00213   TAO_SCIOP_BASE_ACCEPTOR base_acceptor_;
00214 
00215   /// Acceptor strategies.
00216   TAO_SCIOP_CREATION_STRATEGY *creation_strategy_;
00217   TAO_SCIOP_CONCURRENCY_STRATEGY *concurrency_strategy_;
00218   TAO_SCIOP_ACCEPT_STRATEGY *accept_strategy_;
00219 
00220 };
00221 
00222 TAO_END_VERSIONED_NAMESPACE_DECL
00223 
00224 #if defined(__ACE_INLINE__)
00225 #include "tao/Strategies/SCIOP_Acceptor.i"
00226 #endif /* __ACE_INLINE__ */
00227 
00228 #endif /* TAO_HAS_SCIOP == 1 */
00229 
00230 #include /**/ "ace/post.h"
00231 #endif  /* TAO_SCIOP_ACCEPTOR_H */

Generated on Thu Nov 9 13:39:29 2006 for TAO_Strategies by doxygen 1.3.6