diff options
Diffstat (limited to 'TAO/orbsvcs')
38 files changed, 2343 insertions, 0 deletions
diff --git a/TAO/orbsvcs/Transport_Current/Current_Impl.h b/TAO/orbsvcs/Transport_Current/Current_Impl.h index c4f423b1a7f..2db62af3df4 100644 --- a/TAO/orbsvcs/Transport_Current/Current_Impl.h +++ b/TAO/orbsvcs/Transport_Current/Current_Impl.h @@ -244,3 +244,126 @@ TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" #endif /* CURRENT_IMPL_H */ +// $Id$ + +#ifndef CURRENT_IMPL_H +#define CURRENT_IMPL_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/Transport_Current/TCC.h" +#include "tao/LocalObject.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_Transport; + +namespace TAO +{ + namespace Transport + { + + // Forward decl + class Stats; + + /** + * @class Current_impl + * + * @brief Implementation of the TAO::Transport::Current + * interface. + * + * Current_Impl is useful for obtaining information about the + * Transport, associated with the calling thread. + */ + class TAO_Transport_Current_Export Current_Impl + : public virtual Current + , public virtual TAO_Local_RefCounted_Object + { + public: + + /// Constructor. + Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id); + + /** + * These are methods exposed by the + * PortableInterceptor::Current interface. + */ + //@{ + virtual CORBA::Long id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT bytes_sent (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT bytes_received (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT messages_sent (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT messages_received (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::TimeBase::TimeT open_since (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + //@} + + protected: + + /** + * Some helper methods + */ + //@{ + /// A (strategy) method used to obtain the transport ptr + const TAO_Transport* transport (ACE_ENV_SINGLE_ARG_DECL) const + ACE_THROW_SPEC ((NoContext)); + + /// A Stats instance. If protocol is unavailable (0) or the + /// TAO_HAS_TRANSPORT_CURRENT macro is defined as anything but + /// 1, a single static instance will be used. + const TAO::Transport::Stats* transport_stats (ACE_ENV_SINGLE_ARG_DECL) const + ACE_THROW_SPEC ((NoContext)); + //@} + + /// Destructor is protected to enforce the fact this class is + /// reference counted, and should not be destroyed using + /// delete() by anything other than the reference counting + /// mechanism. + virtual ~Current_Impl (void); + + private: + + /// Prevent copying through the copy constructor and the + /// assignment operator. + //@{ + Current_Impl (const Current_Impl &); + void operator= (const Current_Impl &); + //@} + + private: + + // The ORB (core) that owes us. + TAO_ORB_Core* core_; + + // The ORB's TSS slot id for the Transport ptr + size_t tss_slot_id_; + + }; + + }; + +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +/* #if defined (__ACE_INLINE__) */ +/* # include "Current_Impl.inl" */ +/* #endif /\* __ACE_INLINE__ *\/ */ + +#include /**/ "ace/post.h" + +#endif /* CURRENT_IMPL_H */ diff --git a/TAO/orbsvcs/Transport_Current/Current_Loader.h b/TAO/orbsvcs/Transport_Current/Current_Loader.h index 4c20a22971a..1c04853ed9d 100644 --- a/TAO/orbsvcs/Transport_Current/Current_Loader.h +++ b/TAO/orbsvcs/Transport_Current/Current_Loader.h @@ -180,3 +180,94 @@ ACE_FACTORY_DECLARE (TAO_Transport_Current, #include /**/ "ace/post.h" #endif /* TAO_TRANSPORT_CURRENT_LOADER_H */ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Current_Loader.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + + +#ifndef TAO_TRANSPORT_CURRENT_LOADER_H +#define TAO_TRANSPORT_CURRENT_LOADER_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Object.h" +#include "tao/Versioned_Namespace.h" +#include "orbsvcs/Transport_Current/Transport_Current_Export.h" + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class ORBInitializer_Registry_Adapter; + + namespace Transport + { + + class TAO_Transport_Current_Export Current_Loader + : public ACE_Service_Object + { + public: + + /// A helper method for obtaining access to the the Transport + /// Factory Manager instance. + static Current_Loader* instance (void); + + public: + + /// Initializes object when dynamic linking occurs. + virtual int init (int argc, ACE_TCHAR *argv[]); + + protected: + + // Protected destructor to enforce reference counting discipline + virtual ~Current_Loader (void); + + ORBInitializer_Registry_Adapter* orbinitializer_registry (void); + + private: + + /// A cache for the registry pointer + ORBInitializer_Registry_Adapter* oir_; + }; + + }; +}; + + +#if defined (TAO_AS_STATIC_LIBS) +namespace TAO +{ + namespace Transport + { + int current_static_initializer (void); + }; +}; + + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* defined (TAO_AS_STATIC_LIBS) */ + + +ACE_STATIC_SVC_DECLARE_EXPORT (TAO_Transport_Current, + TAO_Transport_Current_Loader) + +ACE_FACTORY_DECLARE (TAO_Transport_Current, + TAO_Transport_Current_Loader) + +#include /**/ "ace/post.h" + +#endif /* TAO_TRANSPORT_CURRENT_LOADER_H */ diff --git a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.cpp b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.cpp index 5934098926b..74a2cec0f32 100644 --- a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.cpp +++ b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.cpp @@ -110,3 +110,59 @@ TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" #endif /* CURRENT_ORBINITIALIZER_CPP */ +// $Id$ + +#ifndef CURRENT_ORBINITIALIZER_CPP +#define CURRENT_ORBINITIALIZER_CPP + +#include "tao/ORB_Constants.h" + +#include "orbsvcs/Transport_Current/Current_ORBInitializer.h" + +// #if defined (__ACE_INLINE__) +// #include "orbsvcs/Transport_Current/Current_ORBInitializer.inl" +// #endif /* __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + template <typename Impl> + Current_ORBInitializer<Impl>::Current_ORBInitializer(const ACE_TCHAR* id) + : Current_ORBInitializer_Base (id) + { + } + + + template <typename Impl> + TAO::Transport::Current_ptr + Current_ORBInitializer<Impl>::make_current_instance (TAO_ORB_Core* core, + size_t tss_slot_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Create the Current + Current_ptr tmp = 0; + ACE_NEW_THROW_EX (tmp, + Impl (core, tss_slot_id), + CORBA::NO_MEMORY + (CORBA::SystemException::_tao_minor_code (TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + return tmp; + } + + } + +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* CURRENT_ORBINITIALIZER_CPP */ diff --git a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.h b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.h index 6fc292895a6..c1582c284c5 100644 --- a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.h +++ b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer.h @@ -138,3 +138,73 @@ TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" #endif /* CURRENT_ORBINITIALIZER_H */ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Current_ORBInitializer.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + + +#ifndef CURRENT_ORBINITIALIZER_H +#define CURRENT_ORBINITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "orbsvcs/Transport_Current/Current_ORBInitializer_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + template <typename Impl> + class TAO_Transport_Current_Export Current_ORBInitializer + //class Current_ORBInitializer + : public Current_ORBInitializer_Base + { + public: + Current_ORBInitializer (const ACE_TCHAR* id); + + + protected: + virtual TAO::Transport::Current_ptr + make_current_instance (TAO_ORB_Core* c, + size_t s + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + }; + + }; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + + +// #if defined (__ACE_INLINE__) +// #include "orbsvcs/Transport_Current/Current_ORBInitializer.inl" +// #endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "orbsvcs/Transport_Current/Current_ORBInitializer.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("orbsvcs/Transport_Current/Current_ORBInitializer.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* CURRENT_ORBINITIALIZER_H */ diff --git a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.h b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.h index 423eca25949..f5567c1a7ac 100644 --- a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.h +++ b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.h @@ -136,3 +136,72 @@ TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" #endif /* CURRENT_ORBINITIALIZER_BASE_H */ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Current_ORBInitializer_Base.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + + +#ifndef CURRENT_ORBINITIALIZER_BASE_H +#define CURRENT_ORBINITIALIZER_BASE_H + +#include /**/ "ace/pre.h" + +#include "ace/SString.h" +#include "tao/PI/PI.h" + +#include "orbsvcs/Transport_Current/Transport_Current_Export.h" +#include "orbsvcs/Transport_Current/TCC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + class TAO_Transport_Current_Export Current_ORBInitializer_Base : + public PortableInterceptor::ORBInitializer + { + public: + Current_ORBInitializer_Base (const ACE_TCHAR* id); + virtual ~Current_ORBInitializer_Base (void); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED ) + ACE_THROW_SPEC( (CORBA::SystemException) ); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_NOT_USED ) + ACE_THROW_SPEC( (CORBA::SystemException) ); + + protected: + virtual TAO::Transport::Current_ptr + make_current_instance (TAO_ORB_Core* core, + size_t tss_slot_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) = 0; + + protected: + const ACE_TString id_; + }; + + }; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* CURRENT_ORBINITIALIZER_BASE_H */ diff --git a/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.h b/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.h index 4005249a461..1449dca9c81 100644 --- a/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.h +++ b/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.h @@ -214,3 +214,111 @@ TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" #endif /* IIOP_CURRENT_IMPL_H */ +/** + * @file IIOP_Current_Impl.h + * + * @brief Provide implementation for the IIOPTraits interface + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ + +#ifndef IIOP_CURRENT_IMPL_H +#define IIOP_CURRENT_IMPL_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/Transport_Current/TC_IIOPC.h" +#include "orbsvcs/Transport_Current/Current_Impl.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_Transport; +class TAO_IIOP_Connection_Handler; + +namespace TAO +{ + namespace Transport + { + + /** + * @class IIOP_Current_Impl + * + * @brief Implementation of the TAO::Transport::IIOPCurrent + * interface. + * + * IIOP_Current_Impl is useful for obtaining information about the + * IIOP Transport, associated with the calling thread. + */ + class TAO_Transport_Current_Export IIOP_Current_Impl + : public virtual IIOP::Current + , public virtual Current_Impl + { + public: + + /// Constructor. + IIOP_Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id); + + //@{ + virtual ::CORBA::Long id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::SSLIOP::Current_ptr ssliop_current (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::CORBA::Long remote_port (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual char* remote_host (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::CORBA::Long local_port (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual char* local_host (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + //@} + + + protected: + + /// Destructor + /** + * Protected destructor to enforce the fact this class is reference + * counted, and should not be destroyed using delete() by anything + * other than the reference counting mechanism. + */ + virtual ~IIOP_Current_Impl (void); + + private: + + /// Returns the IIOP connection handler associated with the + /// Transport. Will throw NO_IMPLEMENT if the (selected) transport + /// () == 0, or if transport->connection_handler () == 0. Will + /// throw NoContext, if no transport has been selected yet. + TAO_IIOP_Connection_Handler* handler (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + private: + + /// Prevent copying through the copy constructor and + /// assignment operator. + //@{ + IIOP_Current_Impl (const IIOP_Current_Impl &); + void operator= (const IIOP_Current_Impl &); + //@} + + }; + }; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* IIOP_CURRENT_IMPL_H */ diff --git a/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.h b/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.h index 41b30729608..cf0bd538c8a 100644 --- a/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.h +++ b/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.h @@ -134,3 +134,71 @@ ACE_FACTORY_DECLARE (TAO_Transport_Current, TAO_Transport_IIOP_Current_Loader) #endif /* TAO_TRANSPORT_IIOP_TRAITS_LOADER_H */ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file IIOP_Current_Loader.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_TRANSPORT_IIOP_TRAITS_LOADER_H +#define TAO_TRANSPORT_IIOP_TRAITS_LOADER_H + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/Transport_Current/Current_Loader.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + + namespace Transport + { + + namespace IIOP + { + class TAO_Transport_Current_Export Current_Loader + : public TAO::Transport::Current_Loader + { + public: + /// Initializes object when dynamic linking occurs. + virtual int init (int argc, ACE_TCHAR *argv[]); + }; + } + } +} + + + +#if defined (TAO_AS_STATIC_LIBS) +namespace TAO +{ + namespace Transport + { + namespace IIOP + { + int current_static_initializer (void); + } + } +} + +#endif /* defined (TAO_AS_STATIC_LIBS) */ + + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE_EXPORT (TAO_Transport_Current, + TAO_Transport_IIOP_Current_Loader) + +ACE_FACTORY_DECLARE (TAO_Transport_Current, + TAO_Transport_IIOP_Current_Loader) + +#endif /* TAO_TRANSPORT_IIOP_TRAITS_LOADER_H */ diff --git a/TAO/orbsvcs/Transport_Current/IIOP_Transport_Current.h b/TAO/orbsvcs/Transport_Current/IIOP_Transport_Current.h index bf6315ce6bc..bcade1176dd 100644 --- a/TAO/orbsvcs/Transport_Current/IIOP_Transport_Current.h +++ b/TAO/orbsvcs/Transport_Current/IIOP_Transport_Current.h @@ -32,3 +32,20 @@ static int tao_iiop_transport_current_initializer_called = #endif /* TAO_AS_STATIC_LIBS */ +// -*- C++ -*- +// $Id$ + + +#include "orbsvcs/Transport_Current/TCC.h" +#include "orbsvcs/Transport_Current/TC_IIOPC.h" +#include "orbsvcs/Transport_Current/IIOP_Current_Loader.h" + +#if defined (TAO_AS_STATIC_LIBS) + +// Only do this for static builds. It causes a circular dependency for +// dynamic builds. +static int tao_iiop_transport_current_initializer_called = + TAO::Transport::IIOP::current_static_initializer (); + +#endif /* TAO_AS_STATIC_LIBS */ + diff --git a/TAO/orbsvcs/Transport_Current/TC.idl b/TAO/orbsvcs/Transport_Current/TC.idl index 55464973668..05e2075f57d 100644 --- a/TAO/orbsvcs/Transport_Current/TC.idl +++ b/TAO/orbsvcs/Transport_Current/TC.idl @@ -112,3 +112,60 @@ module TAO }; #endif /* TAO_TRANSPORT_CURRENT_IDL */ +/** + * @file TC.idl + * + * @brief Defines the TAO::Transport::Current interface + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ + +#ifndef TAO_TRANSPORT_CURRENT_IDL +#define TAO_TRANSPORT_CURRENT_IDL + +#include <IOP.pidl> +#include <TimeBase.pidl> + +module TAO +{ + /// A type used to represent counters + typedef unsigned long long CounterT; + + module Transport + { + /// Used to signal that a call was made within improper invocation + /// context. Also, this exception is thrown if no Transport has + /// been selected for the current thread, for example in a + /// collocated invocation. + + exception NoContext + { + }; + + // The primary interface, providing access to Transport + // information, available to the current thread. + + local interface Current + { + /// Transport ID, unique within the process. + readonly attribute long id raises (NoContext); + + /// Bytes sent/received through the transport. + readonly attribute CounterT bytes_sent raises (NoContext); + readonly attribute CounterT bytes_received raises (NoContext); + + /// Messages (requests and replies) sent/received using the current + /// protocol. + readonly attribute CounterT messages_sent raises (NoContext); + readonly attribute CounterT messages_received raises (NoContext); + + /// The absolute time (miliseconds) since the transport has been + /// open. + readonly attribute TimeBase::TimeT open_since raises (NoContext); + }; + }; +}; + +#endif /* TAO_TRANSPORT_CURRENT_IDL */ diff --git a/TAO/orbsvcs/Transport_Current/TC.mpc b/TAO/orbsvcs/Transport_Current/TC.mpc index ef9d4780503..4c6b7a8c58a 100644 --- a/TAO/orbsvcs/Transport_Current/TC.mpc +++ b/TAO/orbsvcs/Transport_Current/TC.mpc @@ -64,3 +64,36 @@ project(*) : taolib_with_idl, tao_versioning_idl_defaults, core, interceptors, p } } +//$Id$ + +project(*) : taolib_with_idl, tao_versioning_idl_defaults, core, interceptors, pi { + + sharedname = TAO_TC + dynamicflags = TAO_TRANSPORT_CURRENT_BUILD_DLL + + Source_Files { + Current_Impl.cpp + Current_Loader.cpp + Current_ORBInitializer_Base.cpp + } + + Header_Files { + Current_Impl.h + Current_Loader.h + Current_ORBInitializer.h + Current_ORBInitializer_Base.h + Transport_Current.h + } + + Template_Files { + Current_ORBInitializer.cpp + } + + idlflags += -Wb,export_include=orbsvcs/Transport_Current/Transport_Current_Export.h + idlflags += -Wb,export_macro=TAO_Transport_Current_Export + + IDL_Files { + TC.idl + } +} + diff --git a/TAO/orbsvcs/Transport_Current/TC_IIOP.idl b/TAO/orbsvcs/Transport_Current/TC_IIOP.idl index d167e2f5b80..2eac72f81b3 100644 --- a/TAO/orbsvcs/Transport_Current/TC_IIOP.idl +++ b/TAO/orbsvcs/Transport_Current/TC_IIOP.idl @@ -110,3 +110,59 @@ module TAO }; #endif /* TAO_TRANSPORT_IIOP_CURRENT_IDL */ +/** + * @file TC_IIOP.idl + * + * @brief Defines the TAO::Transport::IIOP::Current interface + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ + +#ifndef TAO_TRANSPORT_IIOP_CURRENT_IDL +#define TAO_TRANSPORT_IIOP_CURRENT_IDL + +#include "TC.idl" + +/// Provide a forward reference for the SSLIOP::Current +module SSLIOP +{ + interface Current; +}; + + +module TAO +{ + module Transport + { + module IIOP + { + // The primary interface, providing access to IIOP-specific + // transport information, if it is indeed an IIOP (-like) transport + // that has been selected. + + local interface Current : TAO::Transport::Current + { + /// Remote host + readonly attribute string remote_host raises (NoContext); + + /// Remote port Using long (signed) type to better accomodate + /// the Java mapping, which has no support for unsigned values + readonly attribute long remote_port raises (NoContext); + + /// Local host + readonly attribute string local_host raises (NoContext); + + /// Local port + readonly attribute long local_port raises (NoContext); + + /// If this is a "secure" transport, this method will give you + /// the corresponding SSLIOP::Current + readonly attribute ::SSLIOP::Current ssliop_current raises (NoContext); + }; + }; + }; +}; + +#endif /* TAO_TRANSPORT_IIOP_CURRENT_IDL */ diff --git a/TAO/orbsvcs/Transport_Current/TC_IIOP.mpc b/TAO/orbsvcs/Transport_Current/TC_IIOP.mpc index c72b1f4d866..d7be92acf3b 100644 --- a/TAO/orbsvcs/Transport_Current/TC_IIOP.mpc +++ b/TAO/orbsvcs/Transport_Current/TC_IIOP.mpc @@ -52,3 +52,30 @@ project(*) : taolib_with_idl, tao_versioning_idl_defaults, core, interceptors, p TC_IIOP.idl } } +//$Id$ + +project(*) : taolib_with_idl, tao_versioning_idl_defaults, core, interceptors, pi, tc { + + sharedname = TAO_TC_IIOP + + dynamicflags = TAO_TRANSPORT_CURRENT_BUILD_DLL + libs += TAO_TC + + Source_Files { + IIOP_Current_Impl.cpp + IIOP_Current_Loader.cpp + } + + Header_Files { + IIOP_Current_Impl.h + IIOP_Current_Loader.h + IIOP_Transport_Current.h + } + + idlflags += -Wb,export_include=orbsvcs/Transport_Current/Transport_Current_Export.h + idlflags += -Wb,export_macro=TAO_Transport_Current_Export + + IDL_Files { + TC_IIOP.idl + } +} diff --git a/TAO/orbsvcs/Transport_Current/Transport_Current.h b/TAO/orbsvcs/Transport_Current/Transport_Current.h index 0ed49c895d8..93a8003be5a 100644 --- a/TAO/orbsvcs/Transport_Current/Transport_Current.h +++ b/TAO/orbsvcs/Transport_Current/Transport_Current.h @@ -30,3 +30,19 @@ static int tao_transport_current_initializer_called = #endif /* TAO_AS_STATIC_LIBS */ +// -*- C++ -*- +// $Id$ + + +#include "orbsvcs/Transport_Current/TCC.h" +#include "orbsvcs/Transport_Current/Current_Loader.h" + +#if defined (TAO_AS_STATIC_LIBS) + +// Only do this for static builds. It causes a circular dependency for +// dynamic builds. +static int tao_transport_current_initializer_called = + TAO::Transport::current_static_initializer (); + +#endif /* TAO_AS_STATIC_LIBS */ + diff --git a/TAO/orbsvcs/Transport_Current/Transport_Current_Export.h b/TAO/orbsvcs/Transport_Current/Transport_Current_Export.h index 91d1a8b24fc..91d9c1ddf66 100644 --- a/TAO/orbsvcs/Transport_Current/Transport_Current_Export.h +++ b/TAO/orbsvcs/Transport_Current/Transport_Current_Export.h @@ -106,3 +106,57 @@ #endif /* TAO_TRANSPORT_CURRENT_EXPORT_H */ // End of auto generated file. + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl -d TAO_Transport_Current +// ------------------------------ +#ifndef TAO_TRANSPORT_CURRENT_EXPORT_H +#define TAO_TRANSPORT_CURRENT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (TAO_TRANSPORT_CURRENT_HAS_DLL) +# define TAO_TRANSPORT_CURRENT_HAS_DLL 1 +#endif /* ! TAO_TRANSPORT_CURRENT_HAS_DLL */ + +#if defined (TAO_TRANSPORT_CURRENT_HAS_DLL) && (TAO_TRANSPORT_CURRENT_HAS_DLL == 1) +# if defined (TAO_TRANSPORT_CURRENT_BUILD_DLL) +# define TAO_Transport_Current_Export ACE_Proper_Export_Flag +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_TRANSPORT_CURRENT_BUILD_DLL */ +# define TAO_Transport_Current_Export ACE_Proper_Import_Flag +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_TRANSPORT_CURRENT_BUILD_DLL */ +#else /* TAO_TRANSPORT_CURRENT_HAS_DLL == 1 */ +# define TAO_Transport_Current_Export +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARATION(T) +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_TRANSPORT_CURRENT_HAS_DLL == 1 */ + +// Set TAO_TRANSPORT_CURRENT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TAO_TRANSPORT_CURRENT_NTRACE) +# if (ACE_NTRACE == 1) +# define TAO_TRANSPORT_CURRENT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TAO_TRANSPORT_CURRENT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TAO_TRANSPORT_CURRENT_NTRACE */ + +#if (TAO_TRANSPORT_CURRENT_NTRACE == 1) +# define TAO_TRANSPORT_CURRENT_TRACE(X) +#else /* (TAO_TRANSPORT_CURRENT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TAO_TRANSPORT_CURRENT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TAO_TRANSPORT_CURRENT_NTRACE == 1) */ + +#endif /* TAO_TRANSPORT_CURRENT_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.h b/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.h index bbda0f5f7a2..1cd7bdebacd 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.h +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.h @@ -286,3 +286,147 @@ namespace Test #endif /* _MSC_VER */ #endif /* CLIENT_REQUEST_INTERCEPTOR_H */ +// -*- C++ -*- + +//============================================================================= +/** + * @file Client_Request_Interceptor.h + * + * $Id$ + * + * Implementation header for the client request interceptor for the + * Transport::Current test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef CLIENT_REQUEST_INTERCEPTOR_H +#define CLIENT_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" +#include "tao/ORB.h" +#include "tao/CORBA_String.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + + +namespace Test +{ + + /// A metod doing the actual testing, so we could change it for the + /// different traits implementations + + typedef int (*TEST) (CORBA::ORB_ptr ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + + /** + * @class Client_Request_Interceptor + * + * @brief Client request interceptor that exercises + * Transport::Current support. + * + * This client request interceptor forwards a request to a secondary + * object by throwing the PortableInterceptor::ForwardRequest + * exception from within the send_request() interception point. It + * only forwards the initial request. See the README file for + * details. + */ + class Client_Request_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual TAO_Local_RefCounted_Object + { + public: + + /// Constructor. + Client_Request_Interceptor (const char *orb_id, + TEST test); + /** + * @name Methods Required by the Client Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all client request interceptors. + */ + //@{ + /// Return the name of this ClientRequestinterceptor. + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + + CORBA::Long interceptions (void); + + private: + void test_transport_current (const ACE_TCHAR* amethod ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, CORBA::UserException)); + + private: + ///The ID of the ORB this interceptor is registered with. + CORBA::String_var orb_id_; + + /// Pseudo-reference to the ORB this interceptor is registered + /// with. + CORBA::ORB_var orb_; + + /// The number of requests intercepted by this interceptor. + CORBA::ULong request_count_; + + /// Stringified reference to the object the initial request will be + /// forwarded to by this interceptor. + CORBA::String_var forward_str_; + + /// Synchronize internal state... + TAO_SYNCH_MUTEX lock_; + + /// Unique request ID + unsigned long requestID_; + + /// Test function + TEST test_; + }; + +}; // namespace Test + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* CLIENT_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.h b/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.h index dd73bc04c11..0f741dead1b 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.h +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.h @@ -158,3 +158,83 @@ private: }; #endif /* CURRENT_TEST_IMPL_H */ +// -*- C++ -*- + +//============================================================================= +/** + * @file Current_Test_Impl.h + * + * $Id$ + * + * Implementation header for the "test" IDL interface for the + * TAO::TransportCurrent test. + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + +#ifndef CURRENT_TEST_IMPL_H +#define CURRENT_TEST_IMPL_H + +#include "Current_TestS.h" +#include "orbsvcs/Transport_Current/TCC.h" + +/** + * @class Current_Test_Impl + * + * @brief Simple test class. + * + * This class implements the "test" interface used in this test. + */ +class Current_Test_Impl : public virtual POA_TAO::Transport::CurrentTest +{ +public: + + /// Constructor. + Current_Test_Impl (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, int do_collocated_calls = 1); + + /// Destructor. + ~Current_Test_Impl (void); + + /// Main servant test method. + virtual void invoked_by_client (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// No-op method used so that a client request interceptor will be + /// invoked when invoking this method from the above invoke_me() + /// method. Say that 10 times fast. :-) + virtual void invoked_during_upcall (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Shutdown the ORB. + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CORBA::Long self_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((::CORBA::SystemException)); + +public: + /// Reports if unexpected errors have been encountered for the + /// lifetime of the instance + bool is_successful (void) const; + +private: + void test_transport_current (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Main servant test method. + void invoked_by_client_i (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((::CORBA::SystemException, TAO::Transport::NoContext)); + +private: + /// Pseudo-reference to the ORB. + CORBA::ORB_var orb_; + + /// Pseudo-reference to the POA (cache) + PortableServer::POA_var poa_; + + /// + int do_collocated_calls_; +}; + +#endif /* CURRENT_TEST_IMPL_H */ diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Framework.mpc b/TAO/orbsvcs/tests/Transport_Current/Framework/Framework.mpc index 4dc6c02369a..2c6ea40e1ed 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Framework.mpc +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Framework.mpc @@ -52,3 +52,30 @@ project(*Client): taoclient, tc, pi, dynamicinterface { Current_Test.idl } } +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver, tc, pi_server { + Source_Files { + server.cpp + Current_Test_Impl.cpp + Server_Request_Interceptor.cpp + Tester.cpp + Server_Main.cpp + } + IDL_Files { + Current_Test.idl + } +} + +project(*Client): taoclient, tc, pi, dynamicinterface { + after += *Server + Source_Files { + Client_Request_Interceptor.cpp + client.cpp + Tester.cpp + } + IDL_Files { + Current_Test.idl + } +} diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/ORBInitializer_T.h b/TAO/orbsvcs/tests/Transport_Current/Framework/ORBInitializer_T.h index 7faa5e3d024..24f2cdb3a99 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/ORBInitializer_T.h +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/ORBInitializer_T.h @@ -122,3 +122,65 @@ namespace Test #endif /* ORBINITIALIZER_T_H */ +// -*- C++ -*- + +//============================================================================= +/** + * @file ORBInitializer_T.h + * + * $Id$ + * + * @author Iliyan jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + +#ifndef ORBINITIALIZER_T_H +#define ORBINITIALIZER_T_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +/* #include "tao/LocalObject.h" */ +/* #include "tao/ORB.h" */ +/* #include "tao/CORBA_String.h" */ + +namespace Test +{ + // A template class for ORBInitializer, which registers + // interceptors. Partial specializations exist to handle client and + // server request interceptors. + template <typename Interceptor> + class ORBInitializer : public PortableInterceptor::ORBInitializer + { + public: + ORBInitializer (typename Interceptor::_ptr_type interceptor) + : interceptor_ (Interceptor::_duplicate (interceptor)) + { + }; + + ~ORBInitializer (void) + { + }; + + virtual void pre_init(PortableInterceptor::ORBInitInfo* ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + }; + + virtual void post_init(PortableInterceptor::ORBInitInfo* ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + typename Interceptor::_var_type interceptor_; + }; + +}; + +#endif /* ORBINITIALIZER_T_H */ + + diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/README b/TAO/orbsvcs/tests/Transport_Current/Framework/README index 4ffb7eaea5e..569b6f32794 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/README +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/README @@ -42,3 +42,25 @@ By default, the client and server will each have only one thread. Use "-t N" parameter to override that. The "-n N" client-side parameter determines how many times a particular client thread will call the server. The default is 1. +This test intents to show the usage and the expected behavior of the +Transport Current framework. The topology is the same as in the basic +Hello test: a client invokes a method on the server and then shuts it +down and exits. The special features of the test is that it attempts +to obtain Transport Traits information, using the Transport Current. + +There are four basic contexts in which a Transport information can be +requested, by definition: + + * on the client side, outside client-side interceptor; + * client side, inside an interceptor; + * server side, inside an up-call; + * server side, inside an interceptor; + +The test implements the client and the server side interceptors that +simply call a test method when invoked. A simple interception count +serves to validate the expected behavior. + +By default, the client and server will each have only one thread. Use +"-t N" parameter to override that. The "-n N" client-side parameter +determines how many times a particular client thread will call the +server. The default is 1. diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.h b/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.h index 14dac8f484c..f8ae3df150a 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.h +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.h @@ -274,3 +274,141 @@ namespace Test #endif /* _MSC_VER */ #endif /* SERVER_REQUEST_INTERCEPTOR_H */ +// -*- C++ -*- + +//============================================================================= +/** + * @file Server_Request_Interceptor.h + * + * $Id$ + * + * Implementation header for the server request interceptor for the + * PortableInterceptor::ForwardRequest test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef SERVER_REQUEST_INTERCEPTOR_H +#define SERVER_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Current_TestC.h" + +#include "orbsvcs/Transport_Current/TCC.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" +#include "tao/PI_Server/PI_Server.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#include "ORBInitializer_T.h" + +namespace Test +{ + + /// A metod doing the actual testing, so we could change it for the + /// different traits implementations + + typedef int (*TEST) (CORBA::ORB_ptr ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /** + * @class Server_Request_Interceptor + * + * @brief Simple concrete server request interceptor. + * + */ + class Server_Request_Interceptor + : public virtual PortableInterceptor::ServerRequestInterceptor, + public virtual TAO_Local_RefCounted_Object + { + public: + + /// Constructor. + Server_Request_Interceptor (const char*orb_id, TEST test); + + /// Destructor. + virtual ~Server_Request_Interceptor (void); + + virtual void test_transport_current (const char* amethod + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual bool self_test (void) const; + + /** + * @name Methods Required by the Server Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all server request interceptors. + */ + //@{ + /// Return the name of this ServerRequestinterceptor. + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_exception ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_other ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + + protected: + + /// The number of requests intercepted by this interceptor. + CORBA::ULong request_count_; + + CORBA::String_var orb_id_; + + TEST test_; + + }; + + // A specialization to handle server-side interceptor registration + template <> + void ORBInitializer<PortableInterceptor::ServerRequestInterceptor>::post_init + (PortableInterceptor::ORBInitInfo* oii ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* SERVER_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/client-static.conf b/TAO/orbsvcs/tests/Transport_Current/Framework/client-static.conf index 4b547610207..113ddafe1a0 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/client-static.conf +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/client-static.conf @@ -1,2 +1,3 @@ static TAO_Transport_Current_Loader "" static TAO_Transport_Current_Loader "" +static TAO_Transport_Current_Loader "" diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/client.conf b/TAO/orbsvcs/tests/Transport_Current/Framework/client.conf index 5effabfb371..4c0725eb55c 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/client.conf +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/client.conf @@ -1,2 +1,3 @@ dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" +dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/run_test.pl b/TAO/orbsvcs/tests/Transport_Current/Framework/run_test.pl index 8e01498fbb7..4605c491ace 100755 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/run_test.pl +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/run_test.pl @@ -116,3 +116,62 @@ if ($server != 0) { unlink $iorfile; exit $status; +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::Run_Test; + +$status = 0; + +#$confmod = "-static"; + +$iorfile = PerlACE::LocalFile ("server.ior"); +$confserver = PerlACE::LocalFile ("server$confmod.conf"); +$confclient = PerlACE::LocalFile ("client$confmod.conf"); +unlink $iorfile; + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("server", + "@ARGV -ORBSvcConf server.conf -o server.ior"); +} +else { + $SV = new PerlACE::Process ("server", + "@ARGV -ORBSvcConf $confserver -o $iorfile"); +} + +$CL = new PerlACE::Process ("client", + "@ARGV -n 1 -ORBSvcConf $confclient -k file://$iorfile"); + +print STDERR $SV->CommandLine()."\n"; +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "$0: ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +print STDERR $CL->CommandLine()."\n"; +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "$0: ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "$0: ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/server-static.conf b/TAO/orbsvcs/tests/Transport_Current/Framework/server-static.conf index 4b547610207..113ddafe1a0 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/server-static.conf +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/server-static.conf @@ -1,2 +1,3 @@ static TAO_Transport_Current_Loader "" static TAO_Transport_Current_Loader "" +static TAO_Transport_Current_Loader "" diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/server.conf b/TAO/orbsvcs/tests/Transport_Current/Framework/server.conf index 5effabfb371..4c0725eb55c 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/server.conf +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/server.conf @@ -1,2 +1,3 @@ dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" +dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/simple.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/simple.cpp index 05243f8af20..f3845750338 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/simple.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/simple.cpp @@ -170,3 +170,89 @@ main (int argc, char *argv[]) return testCurrentLoader (argc, argv) || testCurrentORBInitializer (argc, argv); } +// -*- C++ -*- + +#include "tao/ORB.h" +#include "tao/Object.h" + +#include "ace/Service_Config.h" +#include "ace/Dynamic_Service.h" + +ACE_RCSID (Transport_Current, + simple, + "$Id$") + +int +testCurrentORBInitializer (int argc, char *argv[]) +{ + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (orb.in () == 0) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Unable to create orb\n")), -1); + + CORBA::Object_var obj = + orb->resolve_initial_references ("TAO::Transport::Current" + ACE_ENV_ARG_PARAMETER); + + if (obj.in () == 0) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Unable to get the Transport Current\n")), -1); + + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("testCurrentORBInitializer: OK\n"))); + return 0; +} + + +int +testCurrentLoader (int, char *[]) +{ + + ACE_Service_Object *factory = 0; + + factory = ACE_Dynamic_Service<ACE_Service_Object>::instance + (ACE_TEXT ("TAO_Transport_Current_Loader")); + + int done = +#if defined (TAO_AS_STATIC_LIBS) + true; +#else + (factory != 0); +#endif /* TAO_AS_STATIC_LIBS */ + + if (factory == 0) + { + if (done) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Unable to instantiate TAO::Transport::Current_Factory\n")), + -1); + else + { + +#if !defined (TAO_AS_STATIC_LIBS) + int ret = ACE_Service_Config::process_directive + (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Transport_Current_Loader", + "TAO_Transport_Current", + "_make_TAO_Transport_Current_Loader", + "")); + ACE_ASSERT (ret == 0); + + factory = ACE_Dynamic_Service<ACE_Service_Object>::instance + (ACE_TEXT ("TAO_Transport_Current_Loader")); + +#endif /* !TAO_AS_STATIC_LIBS */ + } + } + + // ACE_ASSERT (factory != 0); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("testCurrentLoader: OK\n"))); + return 0; + +} + + +int +main (int argc, char *argv[]) +{ + return testCurrentLoader (argc, argv) + || testCurrentORBInitializer (argc, argv); +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp index 84be62c3e9d..6141fb1b9c7 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/Current_Test_Impl.cpp @@ -229,6 +229,145 @@ Current_Test_Impl::invoked_by_client (ACE_ENV_SINGLE_ARG_DECL) ACE_ENV_SINGLE_ARG_DECL); ACE_TRY_CHECK; + TAO::Transport::CurrentTest_var self = + TAO::Transport::CurrentTest::_narrow (selfobject.in () + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (TAO_debug_level >= 1) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Making a collocated invocation to invoked_during_upcall().\n"))); + } + self->invoked_during_upcall (ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + else + { + if (TAO_debug_level >= 1) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - skipping collocated calls\n"))); + } + + } + +} + +void +Current_Test_Impl::invoked_during_upcall (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Test method invoked ") + ACE_TEXT ("by the server during upcall.\n"))); + } +} + +void +Current_Test_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - shutting down.\n"))); + } + + this->orb_->shutdown (0 + ACE_ENV_ARG_PARAMETER); +} +// -*- C++ -*- + +#include "Current_Test_Impl.h" + +#include "orbsvcs/Transport_Current/TC_IIOPC.h" +#include "orbsvcs/Transport_Current/TCC.h" + +ACE_RCSID (Transport_Current, + Current_Test_Impl, + "$Id$") + + +Current_Test_Impl::Current_Test_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + int do_collocated_calls) + : orb_ (CORBA::ORB::_duplicate (orb)) + , poa_ (PortableServer::POA::_duplicate (poa)) + , do_collocated_calls_ (do_collocated_calls) +{ +} + +Current_Test_Impl::~Current_Test_Impl (void) +{ +} + +::CORBA::Long +Current_Test_Impl::self_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((::CORBA::SystemException)) +{ + return 0; +} + +void +Current_Test_Impl::test_transport_current (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Testing access to IIOP Transport Current ...\n"))); + } + + CORBA::Object_var tcobject = + this->orb_->resolve_initial_references ("TAO::Transport::IIOP::Current" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO::Transport::IIOP::Current_var tc = + TAO::Transport::IIOP::Current::_narrow (tcobject.in () + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (CORBA::is_nil (tc.in())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Unable to narrow down to TAO::Transport::IIOP::Current\n"))); + ACE_THROW (CORBA::INTERNAL ()); + } + + CORBA::String_var rhost (tc->remote_host ()); + CORBA::String_var lhost (tc->local_host ()); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - [%s:%d] -> [%s:%d]\n"), + rhost.in (), tc->remote_port (), + lhost.in (), tc->local_port ())); + + if (TAO_debug_level > 2) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Successfully accessed IIOP Transport Current\n"))); + } +} + + + +void +Current_Test_Impl::invoked_by_client (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level >= 1) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) server - Test method invoked by client.\n"))); + } + + this->test_transport_current (ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (this->do_collocated_calls_) + { + CORBA::Object_var selfobject = + poa_->servant_to_reference (this + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + TAO::Transport::Current_Test_var self = TAO::Transport::Current_Test::_narrow (selfobject.in () ACE_ENV_SINGLE_ARG_DECL); diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc index 271c07bfdaf..e8dc8e713f3 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP.mpc @@ -82,3 +82,45 @@ project(*Client): taoclient, tc, pi, dynamicinterface { ../Framework/Current_Test.idl } } +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver, tc, pi_server { + + idlflags += -o ../Framework + + libs += TAO_TC_IIOP + includes += ../Framework + + Source_Files { + ../Framework/server.cpp + ../Framework/Server_Request_Interceptor.cpp + Current_Test_Impl.cpp + IIOP_Server_Request_Interceptor.cpp + IIOP_Server_Main.cpp + IIOP_Tester.cpp + } + + IDL_Files { + ../Framework/Current_Test.idl + } +} + +project(*Client): taoclient, tc, pi, dynamicinterface { + + after += *Server* + + includes += ../Framework + libs += TAO_TC_IIOP + + idlflags += -o ../Framework + + Source_Files { + ../Framework/Client_Request_Interceptor.cpp + ../Framework/client.cpp + IIOP_Tester.cpp + } + IDL_Files { + ../Framework/Current_Test.idl + } +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp index cce444d8662..3bd1b2bb12e 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp @@ -21,3 +21,26 @@ ACE_TMAIN (int argc, Test::IIOP_Server_Request_Interceptor cri ("test_orb", test_transport_current); return server_main (argc, argv, &cri); } +// -*- C++ -*- + +// $Id$ + +#include "IIOP_Server_Request_Interceptor.h" + +/// Prototype +int server_main (int argc, + ACE_TCHAR *argv[], + Test::Server_Request_Interceptor *cri); + +int +test_transport_current (CORBA::ORB_ptr orb + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::UserException)); + +int +ACE_TMAIN (int argc, + ACE_TCHAR *argv[]) +{ + Test::IIOP_Server_Request_Interceptor cri ("test_orb", test_transport_current); + return server_main (argc, argv, &cri); +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp index 92950ce0b7f..bbc77e6b8f0 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp @@ -321,3 +321,326 @@ namespace Test { } } +// -*- C++ -*- + +#include "ace/Log_Msg.h" +#include "tao/ORB_Constants.h" +#include "orbsvcs/Transport_Current/TC_IIOPC.h" + +ACE_RCSID (ForwardRequest, + Server_Request_Interceptor, + "$Id$") + +#include "IIOP_Server_Request_Interceptor.h" + +namespace Test { + + using namespace TAO; + + IIOP_Server_Request_Interceptor::IIOP_Server_Request_Interceptor (const char* orbid, TEST test) + : Server_Request_Interceptor (orbid, test) + , iiop_test_successful_ (true) + , mult_thr_test_successful_ (true) + { + } + + IIOP_Server_Request_Interceptor::~IIOP_Server_Request_Interceptor (void) + { + } + + char * + IIOP_Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return CORBA::string_dup ("II SRI"); + } + + /// + TAO::Transport::IIOP::Current_ptr + IIOP_Server_Request_Interceptor::resolve_iiop_transport_current (const char* orbid + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::String_var name (this->name ()); + + int tmpargc = 0; + CORBA::ORB_var orb = CORBA::ORB_init (tmpargc, + 0, + orbid + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var tcobject = + orb->resolve_initial_references (ACE_TEXT_ALWAYS_CHAR ("TAO::Transport::IIOP::Current") + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + return TAO::Transport::IIOP::Current::_narrow (tcobject.in () + ACE_ENV_ARG_PARAMETER); + } + + /// On every request, a client-supplied (via the context) id is used + /// as index in an array, where we store the endpoint + void + IIOP_Server_Request_Interceptor::push_request_info (size_t requestID + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::String_var name (this->name ()); + + TAO::Transport::IIOP::Current_var tc = + resolve_iiop_transport_current (this->orb_id_.in () + ACE_ENV_ARG_PARAMETER); + + CORBA::String_var host (tc->remote_host()); + EndPoint ep (tc->remote_port(), host.in ()); + + if (requestID < sizeof (endPoints_)) + endPoints_[requestID] = ep; + else + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%P|%t) ") + ACE_TEXT ("push_request_info: Can't track that many requests %d\n"), + name.in (), + requestID)); + + } + + void + IIOP_Server_Request_Interceptor::pop_request_info (size_t requestID) + { + static EndPoint dummy; + CORBA::String_var name (this->name ()); + + if (requestID >= sizeof (endPoints_)) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%P|%t) ") + ACE_TEXT ("pop_request_info: Can't track that many requests %d\n"), + name.in (), + requestID)); + return; + } + + TAO::Transport::IIOP::Current_var tc = + resolve_iiop_transport_current (this->orb_id_.in () + ACE_ENV_ARG_PARAMETER); + + CORBA::String_var host (tc->remote_host()); + EndPoint ep (tc->remote_port(), host.in ()); + + if (ep != endPoints_[requestID]) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%P|%t) ") + ACE_TEXT ("pop_request_info: The expected host and port don't match for request %d\n"), + name.in (), + requestID)); + return; + } + + endPoints_[requestID] = dummy; + } + + + /// Checks if all the endpoints, encountered on the way in have been + /// cleaned on the way out of the interception point + bool + IIOP_Server_Request_Interceptor::self_test (void) + { + CORBA::String_var name (this->name ()); + bool has_remaining_endpoints = false; + for (size_t count = 0; + count < sizeof (endPoints_); + count ++) + { + if (endPoints_[count].port_ != 0) + { + has_remaining_endpoints = true; + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s (%S|%t) Endpoint at ") + ACE_TEXT ("index=%d is not been removed yet\n"), + name.in ())); + } + } + + return Server_Request_Interceptor::self_test () + && iiop_test_successful_ + && !has_remaining_endpoints; + } + + + + void + IIOP_Server_Request_Interceptor::inbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::String_var name (this->name ()); + CORBA::String_var op (ri->operation(ACE_ENV_ARG_PARAMETER)); + ACE_CHECK; + + if (TAO_debug_level >=1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("%s (%P|%t) Intercepted operation %s ()\n"), + name.in (), + op.in ())); + + ACE_TRY + { + IOP::ServiceId id = Transport::CurrentTest::ContextTag; + IOP::ServiceContext_var sc = + ri->get_request_service_context (id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + const char *buf = + ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); + + long requestID = ACE_OS::atoi (buf); + + this->push_request_info (requestID); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s (%P|%t) Service context") + ACE_TEXT (" is unavailable when invoking %s (). ") + ACE_TEXT ("A colocated invocation would have ") + ACE_TEXT ("no service context.\n"), + name.in (), + op.in ())); + } + ACE_ENDTRY; + + } + + void + IIOP_Server_Request_Interceptor::outbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + IOP::ServiceId id = Transport::CurrentTest::ContextTag; + + IOP::ServiceContext_var sc = + ri->get_request_service_context (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + const char *buf = + ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); + + this->pop_request_info (ACE_OS::atoi (buf)); + } + + + + + + + void + IIOP_Server_Request_Interceptor::receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) + { + ACE_TRY + { + inbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Inbound_process_context failed in ") + ACE_TEXT(" receive_request_service_contexts.\n"), + name.in ())); + } + ACE_ENDTRY; + + Server_Request_Interceptor::receive_request_service_contexts (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + } + + + void + IIOP_Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + ACE_TRY + { + outbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") + ACE_TEXT("send_reply.\n"), + name.in ())); + } + ACE_ENDTRY; + + Server_Request_Interceptor::send_reply (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + } + + void + IIOP_Server_Request_Interceptor::send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) + { + ACE_TRY + { + outbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") + ACE_TEXT("send_exception.\n"), + name.in ())); + + } + ACE_ENDTRY; + + Server_Request_Interceptor::send_exception (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + void + IIOP_Server_Request_Interceptor::send_other (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) + { + ACE_TRY + { + outbound_process_context (ri ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + CORBA::String_var name (this->name ()); + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") + ACE_TEXT("send_other.\n"), + name.in ())); + } + ACE_ENDTRY; + + Server_Request_Interceptor::send_other (ri ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + +} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h index 00b45f19ee6..4184e4bbc7a 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.h @@ -322,3 +322,165 @@ namespace Test #endif /* _MSC_VER */ #endif /* ISERVER_REQUEST_INTERCEPTOR_H */ +// -*- C++ -*- + +//============================================================================= +/** + * @file IIOP_Server_Request_Interceptor.h + * + * $Id$ + * + * Implementation header for the server request interceptor for the + * IIOP_Threading test. + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + * @author Ciju John <johnc@ociweb.com> + */ +//============================================================================= + +#ifndef ISERVER_REQUEST_INTERCEPTOR_H +#define ISERVER_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Server_Request_Interceptor.h" +#include "orbsvcs/Transport_Current/IIOP_Transport_Current.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +namespace Test +{ + + class IIOP_Server_Request_Interceptor + : public virtual Test::Server_Request_Interceptor + , public virtual TAO_Local_RefCounted_Object + { + public: + + /// Constructor. + IIOP_Server_Request_Interceptor (const char* orbid, TEST test); + + /// Destructor. + virtual ~IIOP_Server_Request_Interceptor (); + + /// queries the status of the test + bool self_test (); + + /** + * @name Methods Required by the Server Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all server request interceptors. + */ + //@{ + /// Return the name of this ServerRequestinterceptor. + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// incomming interception point + virtual void receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + /// outgoing interception point + virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// outgoing interception point + virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + /// outgoing interception point + virtual void send_other (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + //@} + + protected: + + /// process incomming requests context + void inbound_process_context + (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// process outgoing requests context + void outbound_process_context + (PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// saves the incomming request info + void push_request_info (size_t requestID + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// clears the outgoing request info + void pop_request_info (size_t requestID); + + TAO::Transport::IIOP::Current_ptr resolve_iiop_transport_current (const char* orbid + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + + /// transport ID dtata structure + typedef struct EP { + CORBA::UShort port_; + CORBA::String_var host_; + + EP () + : port_(0) + , host_ () + {}; + + EP (CORBA::UShort port, const char* host) + : port_(port) + , host_ (host) + {}; + + bool operator== (const struct EP &ep) const + { + return (this->port_ == ep.port_) && + (strcmp (this->host_.in (), ep.host_.in ()) == 0); + }; + bool operator!= (const struct EP &ep) const + { + return !(this->operator== (ep)); + }; + + } EndPoint; + + private: + + /// IIOPTraits test status + bool iiop_test_successful_; + + /// Multi-threaded test status + bool mult_thr_test_successful_; + + /// Endpoints hash table + EndPoint endPoints_[1001]; + }; + +}; /* namespace Test */ + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* ISERVER_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp index 2b87ba0e285..ec76e46eee5 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp @@ -79,3 +79,84 @@ test_transport_current (CORBA::ORB_ptr orb return 0; } +// -*- C++ -*- + +// $Id$ + +#include "orbsvcs/Transport_Current/IIOP_Transport_Current.h" + +using namespace TAO; + + +/// Test referencing the TC data outside of the context of an upcall, +/// or a client-side interceptor + +int +test_transport_current (CORBA::ORB_ptr orb + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::UserException)) +{ + // Get the Current object. + CORBA::Object_var tcobject = + orb->resolve_initial_references (ACE_TEXT_ALWAYS_CHAR ("TAO::Transport::IIOP::Current") + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + + if (TAO_debug_level >= 1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Tester (%P|%t) Resolved initial reference for IIOP::Current\n"))); + + Transport::IIOP::Current_var tc = + Transport::IIOP::Current::_narrow (tcobject.in () + ACE_ENV_SINGLE_ARG_DECL); + ACE_TRY_CHECK; + + if (TAO_debug_level >= 1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Tester (%P|%t) Narowed the IIOP Transport Current\n"))); + + if (CORBA::is_nil (tc.in ())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Tester (%P|%t) ERROR: Could not resolve ") + ACE_TEXT ("TAO::Transport::IIOP::Current object.\n"))); + + ACE_TRY_THROW (CORBA::INTERNAL ()); + } + + ::CORBA::String_var rhost (tc->remote_host (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_TRY_CHECK; + + ::CORBA::String_var lhost (tc->local_host (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_TRY_CHECK; + + ::CORBA::Long id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT bs = tc->bytes_sent (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT br = tc->bytes_received (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT rs = tc->messages_sent (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::TAO::CounterT rr = tc->messages_received (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Tester (%P|%t) Transport [%q] [%s:%d -> %s:%d] ") + ACE_TEXT ("Sent/Received [bytes=%q/%q, messages=%q/%q]\n"), + (ACE_UINT64)id, + rhost.in (), tc->remote_port (ACE_ENV_SINGLE_ARG_PARAMETER), + lhost.in (), tc->local_port (ACE_ENV_SINGLE_ARG_PARAMETER), + (ACE_UINT64)bs, + (ACE_UINT64)br, + (ACE_UINT64)rs, + (ACE_UINT64)rr)); + return 0; +} + diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/README b/TAO/orbsvcs/tests/Transport_Current/IIOP/README index 0d1ea8db316..d83d071a53a 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/README +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/README @@ -48,3 +48,28 @@ creation (as it did in lab conditions). See ../Framework/README for more detail on how and what contexts are tested. +This test has two parts, which run automatically: + +Part 1: + +IIOP_Transport_Current test: Demonstrates how in the application the +user can resolve the IIOP_Transport_Current and use it to obtain +IIOP-related transport properties for the current Transport. + +Part 2: + +Multi threading test: In this test the server has a Thread Pool. Using +Interceptors, the test tracks the transports that are used in the +individual invocations at various stage of the up-call. This validates +that the TC framework accurately tracks the correct transport for an +invocation, no matter what stage of the up-call in a multi-threaded +environment. + +We force creation of multiple transport by using the: static +Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" +directive. While this isn't 100% guaranteed, having multiple client +threads and making simultaneous invocations should trigger new transport +creation (as it did in lab conditions). + +See ../Framework/README for more detail on how and what contexts are +tested. diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf index 21ba9549422..84beeafa7bf 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_dynamic.conf @@ -4,3 +4,6 @@ dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" +static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" +dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" +dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf index 0a2ca3b3151..ba19c06e24f 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/client_static.conf @@ -4,3 +4,6 @@ static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" #static TAO_Transport_Current_Loader "" #static TAO_Transport_IIOP_Current_Loader "" static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" +#static TAO_Transport_Current_Loader "" +#static TAO_Transport_IIOP_Current_Loader "" +static Client_Strategy_Factory "-ORBTransportMuxStrategy exclusive" diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl b/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl index cbb4b0a6e7d..4eedc12459b 100755 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/run_test.pl @@ -140,3 +140,74 @@ if ($server != 0) { unlink $iorfile; exit $status; +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::Run_Test; + +$status = 0; + +$client = PerlACE::LocalFile ("client"); + +$mode = shift (@ARGV); +if ( $mode =~ /-dynamic/) { + $client_conf_file = PerlACE::LocalFile ("client_dynamic.conf"); + $server_conf_file = PerlACE::LocalFile ("server_dynamic.conf"); +} +elsif ( $mode =~ /-static/) { + $client_conf_file = PerlACE::LocalFile ("client_static.conf"); + $server_conf_file = PerlACE::LocalFile ("server_static.conf"); +} +else { + print STDERR "Unknown $mode. Specify -static or -dynamic\n"; + exit 1; +} + +$iorfile = PerlACE::LocalFile ("server.ior"); +unlink $iorfile; + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("server", + "@ARGV -c 0 -ORBSvcConf $server_conf_file -o server.ior"); +} +else { + $SV = new PerlACE::Process ("server", + "@ARGV -c 0 -ORBSvcConf $server_conf_file -o $iorfile"); +} + +$CL = new PerlACE::Process ($client, + "@ARGV -n 1 -ORBSvcConf $client_conf_file -k file://$iorfile"); + +print STDERR $SV->CommandLine()."\n"; +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "$0: ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +print STDERR $CL->CommandLine()."\n"; +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "$0: ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "$0: ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf index ac6f857d827..cfc55520f9d 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_dynamic.conf @@ -2,3 +2,5 @@ dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" +dynamic TAO_Transport_Current_Loader Service_Object * TAO_TC:_make_TAO_Transport_Current_Loader() "" +dynamic TAO_Transport_IIOP_Current_Loader Service_Object * TAO_TC_IIOP:_make_TAO_Transport_IIOP_Current_Loader() "" diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf index 2649683408d..18bc6c22fe6 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/server_static.conf @@ -2,3 +2,5 @@ static TAO_Transport_Current_Loader "" static TAO_Transport_IIOP_Current_Loader "" static TAO_Transport_Current_Loader "" static TAO_Transport_IIOP_Current_Loader "" +static TAO_Transport_Current_Loader "" +static TAO_Transport_IIOP_Current_Loader "" |