diff options
author | bala <balanatarajan@users.noreply.github.com> | 2002-04-11 22:06:00 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2002-04-11 22:06:00 +0000 |
commit | 8a9647ca1536154b865c2193cba06b6e0eada5e5 (patch) | |
tree | 763c8d0f491860aa4b0744557382cefc6578fac9 | |
parent | d7eac5ba12bd3a48dbad9c4dfbf6268118a00f4a (diff) | |
download | ATCD-8a9647ca1536154b865c2193cba06b6e0eada5e5.tar.gz |
ChangeLogTag: Thu Apr 11 14:36:37 2002 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r-- | TAO/tao/IIOP_Connector.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Transport_Acceptor.cpp | 24 | ||||
-rw-r--r-- | TAO/tao/Transport_Acceptor.h | 123 | ||||
-rw-r--r-- | TAO/tao/Transport_Acceptor.inl | 7 | ||||
-rw-r--r-- | TAO/tao/Transport_Connector.cpp | 199 | ||||
-rw-r--r-- | TAO/tao/Transport_Connector.h | 125 | ||||
-rw-r--r-- | TAO/tao/Transport_Connector.inl | 20 |
7 files changed, 499 insertions, 1 deletions
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index 79b4ff66727..59c40313155 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -28,7 +28,7 @@ template class ACE_Connector<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>; /* -// TODO: Where are they needed? +// TODO: Where are they needed? If not used needs to be removed. template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<TAO_IIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>; template class ACE_Map_Iterator_Base<ACE_HANDLE, ACE_Svc_Tuple<TAO_IIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>; template class ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*>; diff --git a/TAO/tao/Transport_Acceptor.cpp b/TAO/tao/Transport_Acceptor.cpp new file mode 100644 index 00000000000..c368bd98287 --- /dev/null +++ b/TAO/tao/Transport_Acceptor.cpp @@ -0,0 +1,24 @@ +// -*- C++ -*- +// +// $Id$ + +#include "Transport_Acceptor.h" + + +#if !defined (__ACE_INLINE__) +# include "Transport_Acceptor.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (tao, + Acceptor, + "$Id$") + +TAO_Acceptor::TAO_Acceptor (CORBA::ULong tag) + : tag_ (tag) +{ +} + +TAO_Acceptor::~TAO_Acceptor (void) +{ +} diff --git a/TAO/tao/Transport_Acceptor.h b/TAO/tao/Transport_Acceptor.h new file mode 100644 index 00000000000..2f577d007ff --- /dev/null +++ b/TAO/tao/Transport_Acceptor.h @@ -0,0 +1,123 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Acceptor.h + * + * $Id$ + * + * Interface for the Acceptor component of the TAO pluggable protocol + * framework. + * + * @author Fred Kuhns <fredk@cs.wustl.edu> + */ +//============================================================================= +#ifndef TAO_ACCEPTOR_H +#define TAO_ACCEPTOR_H +#include "ace/pre.h" + +#include "tao/IOPC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + + +// Forward declarations. +class ACE_Addr; +class ACE_Reactor; +class TAO_ORB_Core; +class TAO_MProfile; +class TAO_Endpoint; +class TAO_Transport; + +// **************************************************************** + +/** + * @class TAO_Acceptor + * + * @brief Abstract Acceptor class used for pluggable transports. + * + * Base class for the Acceptor bridge class. + * + * @@TODO: Need to rename the class as TAO_Transport_Acceptor. + */ +class TAO_Export TAO_Acceptor +{ +public: + + TAO_Acceptor (CORBA::ULong tag); + + /// Destructor + virtual ~TAO_Acceptor (void); + + /// The tag, each concrete class will have a specific tag value. + CORBA::ULong tag (void) const; + + /// Method to initialize acceptor for address. + virtual int open (TAO_ORB_Core *orb_core, + ACE_Reactor *reactor, + int version_major, + int version_minor, + const char *address, + const char *options = 0) = 0; + + /** + * Open an acceptor with the given protocol version on a default + * endpoint + */ + virtual int open_default (TAO_ORB_Core *, + ACE_Reactor *reactor, + int version_major, + int version_minor, + const char *options = 0) = 0; + + /// Closes the acceptor + virtual int close (void) = 0; + + /** + * Create the corresponding profile for this endpoint. + * If share_profile is set to true, the pluggable protocol + * implementation should try to add the endpoint to a profile + * in the mprofile that is of the same type. Currently, this + * is used when RT CORBA is enabled. + */ + virtual int create_profile (const TAO_ObjectKey &object_key, + TAO_MProfile &mprofile, + CORBA::Short priority) = 0; + + /// Return 1 if the <endpoint> has the same address as the acceptor. + virtual int is_collocated (const TAO_Endpoint* endpoint) = 0; + + /** + * Returns the number of endpoints this acceptor is listening on. This + * is used for determining how many profiles will be generated + * for this acceptor. + */ + virtual CORBA::ULong endpoint_count (void) = 0; + + /** + * This method fetches the <key> from the <profile>. Protocols that + * are pluggable can send data that are specific in the + * <profile_data> field encapsulated as a octet stream. This method + * allows those protocols to get the object key from the + * encapsulation. + */ + virtual int object_key (IOP::TaggedProfile &profile, + TAO_ObjectKey &key) = 0; + +private: + + /// IOP protocol tag. + CORBA::ULong tag_; + +}; + +#if defined (__ACE_INLINE__) +# include "Transport_Acceptor.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" + +#endif /* TAO_ACCEPTOR_H */ diff --git a/TAO/tao/Transport_Acceptor.inl b/TAO/tao/Transport_Acceptor.inl new file mode 100644 index 00000000000..7d91a8330a3 --- /dev/null +++ b/TAO/tao/Transport_Acceptor.inl @@ -0,0 +1,7 @@ +// -*- C++ -*- +// $Id$ +ACE_INLINE CORBA::ULong +TAO_Acceptor::tag (void) const +{ + return this->tag_; +} diff --git a/TAO/tao/Transport_Connector.cpp b/TAO/tao/Transport_Connector.cpp new file mode 100644 index 00000000000..ff25e1c675a --- /dev/null +++ b/TAO/tao/Transport_Connector.cpp @@ -0,0 +1,199 @@ +#include "Transport_Connector.h" +#include "MProfile.h" +#include "Profile.h" +#include "Environment.h" +#include "debug.h" + + +#if !defined (__ACE_INLINE__) +# include "Transport_Connector.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (tao, + Connector, + "$Id$") + +// Connector +TAO_Connector::TAO_Connector (CORBA::ULong tag) + : tag_(tag), + orb_core_ (0) +{ +} + +TAO_Connector::~TAO_Connector (void) +{ +} + +int +TAO_Connector::make_mprofile (const char *string, + TAO_MProfile &mprofile + ACE_ENV_ARG_DECL) +{ + // This method utilizes the "Template Method" design pattern to + // parse the given URL style IOR for the protocol being used + // and create an mprofile from it. + // + // The methods that must be defined by all Connector sub-classes are: + // make_profile + // check_prefix + + // Check for a valid string + if (!string || !*string) + { + ACE_THROW_RETURN (CORBA::INV_OBJREF ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + EINVAL), + CORBA::COMPLETED_NO), + -1); + } + + // Check for the proper prefix in the IOR. If the proper prefix isn't + // in the IOR then it is not an IOR we can use. + if (this->check_prefix (string) != 0) + { + return 1; + // Failure: not the correct IOR for this protocol. + // DO NOT throw an exception here since the Connector_Registry + // should be allowed the opportunity to continue looking for + // an appropriate connector. + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) - TAO_Connector::make_mprofile ") + ACE_TEXT ("<%s>\n"), + string)); + } + + ACE_CString ior; + + ior.set (string, ACE_OS::strlen (string), 1); + + // Find out where the protocol ends + int ior_index = ior.find ("://"); + + if (ior_index == ACE_CString::npos) + { + ACE_THROW_RETURN (CORBA::INV_OBJREF (), -1); + // No colon ':' in the IOR! + } + else + { + ior_index += 3; + // Add the length of the colon and the two forward slashes `://' + // to the IOR string index (i.e. 3) + } + + // Find the object key + const int objkey_index = + ior.find (this->object_key_delimiter (), ior_index); + + if (objkey_index == 0 || objkey_index == ACE_CString::npos) + { + ACE_THROW_RETURN (CORBA::INV_OBJREF (), -1); + // Failure: No endpoints specified or no object key specified. + } + + const char endpoint_delimiter = ','; + // The delimiter used to seperate inidividual addresses. + + // Count the number of endpoints in the IOR. This will be the number + // of entries in the MProfile. + + CORBA::ULong profile_count = 1; + // Number of endpoints in the IOR (initialized to 1). + + // Only check for endpoints after the protocol specification and + // before the object key. + for (int i = ior_index; i < objkey_index; ++i) + { + if (ior[i] == endpoint_delimiter) + profile_count++; + } + + // Tell the MProfile object how many Profiles it should hold. + // MProfile::set(size) returns the number profiles it can hold. + if (mprofile.set (profile_count) != ACE_static_cast (int, profile_count)) + { + ACE_THROW_RETURN (CORBA::INV_OBJREF ( + CORBA_SystemException::_tao_minor_code ( + TAO_MPROFILE_CREATION_ERROR, + 0), + CORBA::COMPLETED_NO), + -1); + // Error while setting the MProfile size! + } + + // The idea behind the following loop is to split the IOR into several + // strings that can be parsed by each profile. + // For example, + // `1.3@moo,shu,1.1@chicken/arf' + // will be parsed into: + // `1.3@moo/arf' + // `shu/arf' + // `1.1@chicken/arf' + + int begin = 0; + int end = ior_index - 1; + // Initialize the end of the endpoint index + + for (CORBA::ULong j = 0; j < profile_count; ++j) + { + begin = end + 1; + + if (j < profile_count - 1) + end = ior.find (endpoint_delimiter, begin); + else + end = objkey_index; // Handle last endpoint differently + + if (end < ACE_static_cast (int, ior.length ()) && end != ior.npos) + { + ACE_CString endpoint = ior.substring (begin, end - begin); + + // Add the object key to the string. + endpoint += ior.substring (objkey_index); + + // The endpoint should now be of the form: + // `N.n@endpoint/object_key' + // or + // `endpoint/object_key' + + TAO_Profile *profile = + this->make_profile (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + // Failure: Problem during profile creation + + // Initialize a Profile using the individual endpoint + // string. + // @@ Not exception safe! We need a TAO_Profile_var! + profile->parse_string (endpoint.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // Give up ownership of the profile. + if (mprofile.give_profile (profile) == -1) + { + profile->_decr_refcnt (); + + ACE_THROW_RETURN (CORBA::INV_OBJREF ( + CORBA_SystemException::_tao_minor_code ( + TAO_MPROFILE_CREATION_ERROR, + 0), + CORBA::COMPLETED_NO), + -1); + // Failure presumably only occurs when MProfile is full! + // This should never happen. + } + } + else + { + ACE_THROW_RETURN (CORBA::INV_OBJREF (), -1); + // Unable to seperate endpoints + } + } + + return 0; // Success +} diff --git a/TAO/tao/Transport_Connector.h b/TAO/tao/Transport_Connector.h new file mode 100644 index 00000000000..8a39565d65e --- /dev/null +++ b/TAO/tao/Transport_Connector.h @@ -0,0 +1,125 @@ +// This may look like C, but it's really -*- C++ -*- + +//============================================================================= +/** + * @file Connector.h + * + * $Id$ + * + * Define the interface for the Connector component in TAO's + * pluggable protocol framework. + * + * @author Fred Kuhns <fredk@cs.wustl.edu> + */ +//============================================================================= +#ifndef TAO_CONNECTOR_H +#define TAO_CONNECTOR_H +#include "ace/pre.h" + +#include "corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +class TAO_Transport_Descriptor_Interface; +class TAO_InputCDR; +class TAO_GIOP_Invocation; +class TAO_Profile; +class TAO_MProfile; +class TAO_ORB_Core; +/** + * @class TAO_Connector + * + * @brief Generic Connector interface definitions. + * + * Base class for connector bridge object. + * + * @@TODO: Need to rename the class as TAO_Transport_Connector. + */ +class TAO_Export TAO_Connector +{ +public: + + /// default constructor. + TAO_Connector (CORBA::ULong tag); + + /// the destructor. + virtual ~TAO_Connector (void); + + /** + * The tag identifying the specific ORB transport layer protocol. + * For example TAO_TAG_IIOP_PROFILE = 0. The tag is used in the + * IOR to identify the type of profile included. IOR -> {{tag0, + * profile0} {tag1, profole1} ...} GIOP.h defines typedef + * CORBA::ULong TAO_IOP_Profile_ID; + */ + CORBA::ULong tag (void) const; + + /// Parse a string containing a URL style IOR and return an + /// MProfile. + int make_mprofile (const char *ior, + TAO_MProfile &mprofile + ACE_ENV_ARG_DECL); + + /// Initialize object and register with reactor. + virtual int open (TAO_ORB_Core *orb_core) = 0; + + /// Shutdown Connector bridge and concrete Connector. + virtual int close (void) = 0; + + /** + * To support pluggable we need to abstract away the connect() + * method so it can be called from the GIOP code independant of the + * actual transport protocol in use. + */ + virtual int connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc + ACE_ENV_ARG_DECL) = 0; + + /// Initial set of connections to be established. + /* + @@ TODO: Need to be removed from the ORB. People who need this + could use _validate_connections () instead. + virtual int preconnect (const char *preconnections) = 0; + */ + + /// Create a profile for this protocol and initialize it based on the + /// encapsulation in <cdr> + virtual TAO_Profile *create_profile (TAO_InputCDR& cdr) = 0; + + /// Check that the prefix of the provided endpoint is valid for use + /// with a given pluggable protocol. + virtual int check_prefix (const char *endpoint) = 0; + + /// Return the object key delimiter to use or expect. + virtual char object_key_delimiter (void) const = 0; + +protected: + + /// Create a profile with a given endpoint. + virtual TAO_Profile *make_profile (ACE_ENV_SINGLE_ARG_DECL) = 0; + + /// Set the ORB Core pointer + void orb_core (TAO_ORB_Core *orb_core); + + /// Return the TAO_ORB_Core pointer + TAO_ORB_Core *orb_core (void); + +private: + + /// IOP protocol tag. + CORBA::ULong tag_; + + /// Pointer to our ORB core + TAO_ORB_Core *orb_core_; + +}; + +#if defined (__ACE_INLINE__) +# include "Transport_Connector.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /*TAO_CONNECTOR_H*/ diff --git a/TAO/tao/Transport_Connector.inl b/TAO/tao/Transport_Connector.inl new file mode 100644 index 00000000000..c70536bf30d --- /dev/null +++ b/TAO/tao/Transport_Connector.inl @@ -0,0 +1,20 @@ +// -*- C++ -*- +// $Id$ +ACE_INLINE TAO_ORB_Core * +TAO_Connector::orb_core (void) +{ + return this->orb_core_; +} + +ACE_INLINE void +TAO_Connector::orb_core (TAO_ORB_Core *orb_core) +{ + this->orb_core_ = orb_core; +} + + +ACE_INLINE CORBA::ULong +TAO_Connector::tag (void) const +{ + return this->tag_; +} |