diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tao/IORInterceptor | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/tao/IORInterceptor')
-rw-r--r-- | TAO/tao/IORInterceptor/IORInfo.cpp | 197 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInfo.h | 173 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInfo.inl | 20 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInfo.pidl | 66 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor.h | 23 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor.pidl | 67 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.cpp | 60 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.h | 70 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp | 254 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h | 97 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor_Details.cpp | 23 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/IORInterceptor_Details.h | 63 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/TAO_IORInterceptor.pc.in | 11 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/TAO_IORInterceptor.rc | 30 | ||||
-rw-r--r-- | TAO/tao/IORInterceptor/iorinterceptor_export.h | 40 |
15 files changed, 1194 insertions, 0 deletions
diff --git a/TAO/tao/IORInterceptor/IORInfo.cpp b/TAO/tao/IORInterceptor/IORInfo.cpp new file mode 100644 index 00000000000..de6dd91494d --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInfo.cpp @@ -0,0 +1,197 @@ +#include "tao/IORInterceptor/IORInfo.h" +#include "tao/PortableServer/Root_POA.h" + +#include "tao/PolicyC.h" +#include "tao/IOPC.h" +#include "tao/ORB_Constants.h" + + +ACE_RCSID (IORInterceptor, + IORInfo, + "$Id$") + +#if !defined (__ACE_INLINE__) +# include "tao/IORInterceptor/IORInfo.inl" +#endif /* __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_IORInfo::TAO_IORInfo (TAO_Root_POA *poa) + : poa_ (poa), + components_established_ (false) +{ +} + +TAO_IORInfo::~TAO_IORInfo (void) +{ +} + +CORBA::Policy_ptr +TAO_IORInfo::get_effective_policy (CORBA::PolicyType type + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + CORBA::Policy_var policy = + this->poa_->get_policy (type ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + if (!CORBA::is_nil (policy.in ())) + { + return policy._retn (); + } + + // TODO: Now check the global ORB policies. + // ........ + + // No policy matching the given PolicyType was found. + ACE_THROW_RETURN (CORBA::INV_POLICY (CORBA::OMGVMCID | 3, + CORBA::COMPLETED_NO), + CORBA::Policy::_nil ()); +} + +void +TAO_IORInfo::add_ior_component (const IOP::TaggedComponent &component + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->components_established_) + ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, + CORBA::COMPLETED_NO)); + + // Add the given tagged component to all profiles. + this->poa_->save_ior_component (component + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_IORInfo::add_ior_component_to_profile ( + const IOP::TaggedComponent &component, + IOP::ProfileId profile_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->components_established_) + ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, + CORBA::COMPLETED_NO)); + + this->poa_->save_ior_component_and_profile_id (component, + profile_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +char * +TAO_IORInfo::manager_id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + return poa_manager->get_id (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +PortableInterceptor::AdapterState +TAO_IORInfo::state (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableInterceptor::NON_EXISTENT); + + return this->poa_->get_adapter_state (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +PortableInterceptor::ObjectReferenceTemplate * +TAO_IORInfo::adapter_template (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // Return the Object Reference Template whenever an IOR Interceptor + // is invoked. Its value is the template created for the adapter + // policies and the IOR Interceptor calls to add_ior_component and + // add_ior_component_to_profile. It's a const value and its value + // never changes. + PortableInterceptor::ObjectReferenceTemplate *adapter_template = + this->poa_->get_adapter_template (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (adapter_template == 0) + { + ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, + CORBA::COMPLETED_NO), + 0); + } + + return adapter_template; +} + +PortableInterceptor::ObjectReferenceFactory * +TAO_IORInfo::current_factory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // Return the current_factory that is used to create the object + // references by the adapter. Though initially, its value is the + // same as the adapter_template, unlike adapter_template, its value + // can be changed. The value of the current_factory can be changed + // only during the call to components_established method. + PortableInterceptor::ObjectReferenceFactory *adapter_factory = + this->poa_->get_obj_ref_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (adapter_factory == 0) + { + ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, + CORBA::COMPLETED_NO), + 0); + } + + return adapter_factory; +} + +void +TAO_IORInfo::current_factory ( + PortableInterceptor::ObjectReferenceFactory * current_factory + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->check_validity (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->poa_->set_obj_ref_factory (current_factory + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_IORInfo::check_validity (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->poa_ == 0) + { + // Although not defined by the spec, duplicate the behavior used + // by the ORBInitInfo object once CORBA::ORB_init() has been + // called. Specifically, the IORInfo object is no longer valid + // once the POA has invoked all IORInterceptor interception + // points. This also prevents memory access violations from + // occuring if the POA is destroyed before this IORInfo object. + ACE_THROW (CORBA::OBJECT_NOT_EXIST (TAO::VMCID, + CORBA::COMPLETED_NO)); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IORInterceptor/IORInfo.h b/TAO/tao/IORInterceptor/IORInfo.h new file mode 100644 index 00000000000..3d4803a6792 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInfo.h @@ -0,0 +1,173 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file IORInfo.h + * + * $Id$ + * + * @author Ossama Othman <ossama@uci.edu> + */ +// =================================================================== + +#ifndef TAO_IOR_INFO_H +#define TAO_IOR_INFO_H + +#include /**/ "ace/pre.h" + +#include "tao/IORInterceptor/IORInfoC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// Forward declarations. +class TAO_Root_POA; + +/** + * @class TAO_IORInfo + * + * @brief This class exposes an interface that allows IORInterceptors add + * tagged components to IORs. + */ +class TAO_IORInfo + : public virtual PortableInterceptor::IORInfo, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructor. + TAO_IORInfo (TAO_Root_POA *poa); + + /** + * @name PortableInterceptor::IORInfo Methods + * + * Methods exposed by the PortableInterceptor::IORInfo interface. + */ + //@{ + + /// Return the policy matching the given policy type that is in + /// effect for the object whose IOR is being created. + virtual CORBA::Policy_ptr get_effective_policy ( + CORBA::PolicyType type + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Add the given tagged component to all profiles. + virtual void add_ior_component ( + const IOP::TaggedComponent & component + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Add the given tagged component to all profiles matching the given + /// ProfileId. + virtual void add_ior_component_to_profile ( + const IOP::TaggedComponent & component, + IOP::ProfileId profile_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual char * manager_id ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual PortableInterceptor::AdapterState state ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual PortableInterceptor::ObjectReferenceTemplate * adapter_template ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual PortableInterceptor::ObjectReferenceFactory * current_factory ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void current_factory ( + PortableInterceptor::ObjectReferenceFactory * current_factory + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + //@} + + /// Invalidate this IORInfo instance. + /** + * Once the IOR interception points have been invoked, this IORInfo + * instance is no longer valid. + */ + void invalidate (void); + + /// Inform the this IORInfo object that the + /// IORInterceptor::components_established() interception point has + /// been called. + /** + * This method is used to inform the IORInfo object when the + * add_ior_component() and add_ior_component_to_profile() methods + * are invalid. They are only valid in the + * IORInterceptor::establish_components() interception point. + */ + void components_established (void); + +protected: + + /// Protected destructor to enforce proper memory managment through + /// the reference counting mechanism. + ~TAO_IORInfo (void); + + /// Check if this IORInfo instance is valid. + /** + * Once all IORInterceptor interception points have been called, + * this IORInfo object is no longer valid. Throw an exception in + * that case. + */ + void check_validity (ACE_ENV_SINGLE_ARG_DECL); + +private: + + /// Prevent copying through the copy constructor and the assignment + /// operator. + TAO_IORInfo (const TAO_IORInfo &); + void operator= (const TAO_IORInfo &); + +private: + + /// Pointer to POA + TAO_Root_POA * poa_; + + /// True if the IORInterceptor::components_established() + /// interception point was called. False otherwise. + /** + * This flag is used to prevent the add_ior_component() and + * add_ior_component_to_profile() methods from being incorrectly + * called after the IORInterceptor::establish_components() + * interception point has been called. + */ + CORBA::Boolean components_established_; + +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/IORInterceptor/IORInfo.inl" +#endif /* __ACE_INLINE__ */ + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* TAO_IOR_INFO_H */ diff --git a/TAO/tao/IORInterceptor/IORInfo.inl b/TAO/tao/IORInterceptor/IORInfo.inl new file mode 100644 index 00000000000..dfb66194baf --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInfo.inl @@ -0,0 +1,20 @@ +// -*- C++ -*- +// +// $Id$ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +TAO_IORInfo::invalidate (void) +{ + this->poa_ = 0; +} + +ACE_INLINE void +TAO_IORInfo::components_established (void) +{ + this->components_established_ = true; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IORInterceptor/IORInfo.pidl b/TAO/tao/IORInterceptor/IORInfo.pidl new file mode 100644 index 00000000000..86b21230a74 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInfo.pidl @@ -0,0 +1,66 @@ +// -*- IDL -*- + +/** + * @file IORInfo.pidl + * + * $Id$ + * + * @brief Pre-compiled IDL source for the IORInfo + * components in the ORB. + * + * The following is from orbos/99-12-02 Portable Interceptors spec, + * the full IDL is downloadable from orbos/99-12-02. This file contains + * interfaces from PortableInterceptor.idl that depend on + * ObjectReferenceFactory and ObjectReferenceTemplate, which inherit + * directly or indirectly from CORBA::ValueBase. This separate file + * has been created to remove the dependency from the rest of module + * PortableInterceptor. + * + * This file was used to generate the code in IORInfoC.* + * The command used to generate code is: + * + * tao_idl + * -o orig -Gp -SS -Gd -Ge 1 -Sa -St -Sci + * -I$(TAO_ROOT) + * -Wb,export_macro=TAO_IORInterceptor_Export + * -Wb,export_include="iorinterceptor_export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * IORInfo.pidl + */ + +// File: IORInfo.idl +#ifndef _IORINFO_IDL_ +#define _IORINFO_IDL_ + +#include "tao/PortableInterceptor.pidl" +#include "tao/Policy_Forward.pidl" +#include "tao/IOP_IOR.pidl" +#include "tao/ObjRefTemplate/ObjectReferenceTemplate_include.pidl" + +module PortableInterceptor +{ + typeprefix PortableInterceptor "omg.org"; + + local interface IORInfo + { + CORBA::Policy get_effective_policy (in CORBA::PolicyType type); + + void add_ior_component (in IOP::TaggedComponent a_component); + + void add_ior_component_to_profile ( + in IOP::TaggedComponent a_component, + in IOP::ProfileId profile_id + ); + + readonly attribute AdapterManagerId manager_id; + + readonly attribute AdapterState state; + + readonly attribute ObjectReferenceTemplate adapter_template; + + attribute ObjectReferenceFactory current_factory; + }; +}; + +#endif /* _IORINFO_IDL_ */ diff --git a/TAO/tao/IORInterceptor/IORInterceptor.h b/TAO/tao/IORInterceptor/IORInterceptor.h new file mode 100644 index 00000000000..802055759e9 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor.h @@ -0,0 +1,23 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file IORInterceptor.h + * + * $Id$ + * + * @author Bala Natarajan <bala@dre.vanderbilt.edu> + */ +//============================================================================= +#ifndef TAO_IORINTERCEPTOR_IORINTERCEPTOR_H +#define TAO_IORINTERCEPTOR_IORINTERCEPTOR_H +#include /**/ "ace/pre.h" + +#include "tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/post.h" +#endif /*TAO_IORINTERCEPTOR_IORINTERCEPTOR_H*/ diff --git a/TAO/tao/IORInterceptor/IORInterceptor.pidl b/TAO/tao/IORInterceptor/IORInterceptor.pidl new file mode 100644 index 00000000000..40568168fd8 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor.pidl @@ -0,0 +1,67 @@ +// -*- IDL -*- + +/** + * @file IORInterceptor.pidl + * + * $Id$ + * + * @brief Pre-compiled IDL source for the IOR Interceptor + * components in the ORB. + * + * The following is from orbos/99-12-02 Portable Interceptors spec, + * the full IDL is downloadable from orbos/99-12-02. This file contains + * interfaces from PortableInterceptor.idl that depend on + * ObjectReferenceFactory and ObjectReferenceTemplate, which inherit + * directly or indirectly from CORBA::ValueBase. This separate file + * has been created to remove the dependency from the rest of module + * PortableInterceptor. + * + * This file was used to generate the code in IORInterceptorC.* + * The command used to generate code is: + * + * tao_idl + * -o orig -Gp -Gd -Ge 1 -Sa -St -Sci -SS + * -I$(TAO_ROOT) + * -Wb,export_macro=TAO_IORInterceptor_Export + * -Wb,export_include="iorinterceptor_export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * IORInterceptor.pidl + * + * Please apply the patch in IORInterceptor.diff to the generated stubs and + * skeletons. + */ + +// File: IORInterceptor.idl +#ifndef _IOR_INTERCEPTOR_IDL_ +#define _IOR_INTERCEPTOR_IDL_ + +#include "tao/PI/Interceptor.pidl" +#include "tao/IORInterceptor/IORInfo.pidl" +#include "tao/ObjRefTemplate/ObjectReferenceTemplate.pidl" + +module PortableInterceptor +{ + typeprefix PortableInterceptor "omg.org"; + + local interface IORInterceptor : Interceptor + { + void establish_components (in IORInfo info); + }; + + local interface IORInterceptor_3_0 : IORInterceptor + { + void components_established (in IORInfo info); + + void adapter_manager_state_changed ( + in AdapterManagerId id, + in AdapterState state + ); + void adapter_state_changed ( + in ObjectReferenceTemplateSeq templates, + in AdapterState state + ); + }; +}; + +#endif /* _IOR_INTERCEPTOR_IDL_ */ diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.cpp b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.cpp new file mode 100644 index 00000000000..a917dc798d4 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.cpp @@ -0,0 +1,60 @@ +// $Id$ + +#include "tao/IORInterceptor/IORInterceptor_Adapter_Impl.h" +#include "tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.h" + +#include "tao/ORB_Core.h" + +ACE_RCSID (IORInterceptor, + IORInterceptor_Adapter_Factory_Impl, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_IORInterceptor_Adapter_Factory_Impl::~TAO_IORInterceptor_Adapter_Factory_Impl (void) +{ +} + +TAO_IORInterceptor_Adapter * +TAO_IORInterceptor_Adapter_Factory_Impl::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_IORInterceptor_Adapter_Impl *nia = 0; + ACE_NEW_THROW_EX (nia, + TAO_IORInterceptor_Adapter_Impl (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (nia); + + return nia; +} + + +// ********************************************************************* + +// Initialization and registration of dynamic service object. + +int +TAO_IORInterceptor_Adapter_Factory_Impl::Initializer (void) +{ + TAO_ORB_Core::iorinterceptor_adapter_factory_name ( + "Concrete_IORInterceptor_Adapter_Factory" + ); + + return + ACE_Service_Config::process_directive ( + ace_svc_desc_TAO_IORInterceptor_Adapter_Factory_Impl + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DEFINE ( + TAO_IORInterceptor_Adapter_Factory_Impl, + ACE_TEXT ("Concrete_IORInterceptor_Adapter_Factory"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_IORInterceptor_Adapter_Factory_Impl), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0 + ) + +ACE_FACTORY_DEFINE (TAO_IORInterceptor, TAO_IORInterceptor_Adapter_Factory_Impl) diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.h b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.h new file mode 100644 index 00000000000..a08507cd6a6 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Factory_Impl.h @@ -0,0 +1,70 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file IORInterceptor_Adapter_Factory_Impl.h + * + * $Id$ + * + * @author George Edwards <g.edwards@vanderbilt.edu> + */ +//============================================================================= + + +#ifndef TAO_IORINTERCEPTOR_ADAPTER_FACTORY_IMPL_H +#define TAO_IORINTERCEPTOR_ADAPTER_FACTORY_IMPL_H + +#include /**/ "ace/pre.h" + +#include "tao/IORInterceptor/iorinterceptor_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/IORInterceptor_Adapter_Factory.h" +#include "ace/Service_Config.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_IORInterceptor_Adapter; + +/** + * @class TAO_IORInterceptor_Adapter_Factory_Impl + * + * @brief TAO_IORInterceptor_Adapter_Factory_Impl. + * + * Class that creates instances of TAO_IORInterceptor_Adapter (one per ORB). + * This is the derived class that contains the actual implementations. + */ +class TAO_IORInterceptor_Export TAO_IORInterceptor_Adapter_Factory_Impl + : public TAO_IORInterceptor_Adapter_Factory +{ +public: + virtual ~TAO_IORInterceptor_Adapter_Factory_Impl (void); + + virtual TAO_IORInterceptor_Adapter * create ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Used to force the initialization of the ORB code. + static int Initializer (void); +}; + +static int +TAO_Requires_IORInterceptor_Initializer = + TAO_IORInterceptor_Adapter_Factory_Impl::Initializer (); + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE (TAO_IORInterceptor_Adapter_Factory_Impl) +ACE_FACTORY_DECLARE (TAO_IORInterceptor, TAO_IORInterceptor_Adapter_Factory_Impl) + +#define TAO_IORINTERCEPTOR_SAFE_INCLUDE +#include "tao/IORInterceptor/IORInterceptorC.h" +#undef TAO_IORINTERCEPTOR_SAFE_INCLUDE + +#include /**/ "ace/post.h" + +#endif /* TAO_IORINTERCEPTOR_ADAPTER_FACTORY_IMPL_H */ diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp new file mode 100644 index 00000000000..4b9bc703257 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.cpp @@ -0,0 +1,254 @@ +// $Id$ + +#include "tao/IORInterceptor/IORInterceptor_Adapter_Impl.h" +#include "tao/IORInterceptor/IORInfo.h" +#include "tao/debug.h" +#include "tao/ORB_Constants.h" +#include "tao/PI/PI.h" +#include "tao/PortableServer/Root_POA.h" +#include "tao/PortableServer/Non_Servant_Upcall.h" + +ACE_RCSID (IORInterceptor, + IORInterceptor_Adapter_Impl, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_IORInterceptor_Adapter_Impl::~TAO_IORInterceptor_Adapter_Impl (void) +{ +} + +void +TAO_IORInterceptor_Adapter_Impl::add_interceptor ( + PortableInterceptor::IORInterceptor_ptr i + ACE_ENV_ARG_DECL + ) +{ + this->ior_interceptor_list_.add_interceptor (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_IORInterceptor_Adapter_Impl::add_interceptor ( + PortableInterceptor::IORInterceptor_ptr i, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL + ) +{ + this->ior_interceptor_list_.add_interceptor (i, + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_IORInterceptor_Adapter_Impl::destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL) +{ + this->ior_interceptor_list_.destroy_interceptors (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + delete this; +} + +void +TAO_IORInterceptor_Adapter_Impl::establish_components ( + TAO_Root_POA* poa + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + const size_t interceptor_count = this->ior_interceptor_list_.size (); + + if (interceptor_count == 0) + return; + + TAO_IORInfo *tao_info = 0; + ACE_NEW_THROW_EX (tao_info, + TAO_IORInfo (poa), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + PortableInterceptor::IORInfo_var info = tao_info; + + // Release the POA during IORInterceptor calls to avoid potential + // deadlocks. + TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*poa); + ACE_UNUSED_ARG (non_servant_upcall); + + for (size_t i = 0; i < interceptor_count; ++i) + { + ACE_TRY + { + this->ior_interceptor_list_.interceptor (i)->establish_components ( + info.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // According to the Portable Interceptors specification, + // IORInterceptor::establish_components() must not throw an + // exception. If it does, then the ORB is supposed to + // ignore it and continue processing the remaining + // IORInterceptors. + if (TAO_debug_level > 1) + { + CORBA::String_var name = + this->ior_interceptor_list_.interceptor (i)->name ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + // @@ What do we do if we get an exception here? + + if (name.in () != 0) + { + ACE_DEBUG ((LM_WARNING, + "(%P|%t) Exception thrown while processing " + "IORInterceptor \"%s\">\n", + ACE_TEXT_CHAR_TO_TCHAR (name.in ()))); + } + + ACE_PRINT_TAO_EXCEPTION (ACE_ANY_EXCEPTION, + "Ignoring exception in " + "IORInterceptor::establish_components"); + } + } + ACE_ENDTRY; + ACE_CHECK; + } + + tao_info->components_established (); + + this->components_established (info.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // The IORInfo instance is no longer valid. Invalidate it to + // prevent the user from peforming "illegal" operations. + tao_info->invalidate (); +} + +void +TAO_IORInterceptor_Adapter_Impl::components_established ( + PortableInterceptor::IORInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Iterate over the registered IOR interceptors so that they may be + // given the opportunity to add tagged components to the profiles + // for this servant. + const size_t interceptor_count = this->ior_interceptor_list_.size (); + + // All the establish_components() interception points have been + // invoked. Now call the components_established() interception point + // on all the IORInterceptors. + for (size_t j = 0; j < interceptor_count; ++j) + { + ACE_TRY + { + PortableInterceptor::IORInterceptor_ptr ior_interceptor = + this->ior_interceptor_list_.interceptor (j); + + PortableInterceptor::IORInterceptor_3_0_var ior_3_interceptor = + PortableInterceptor::IORInterceptor_3_0::_narrow (ior_interceptor); + if (!CORBA::is_nil (ior_3_interceptor.in ())) + { + ior_3_interceptor->components_established ( + info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + ACE_THROW (CORBA::OBJ_ADAPTER (CORBA::OMGVMCID | 6, + CORBA::COMPLETED_NO)); + } + ACE_ENDTRY; + ACE_CHECK; + } +} + +void +TAO_IORInterceptor_Adapter_Impl::adapter_state_changed ( + const TAO::ObjectReferenceTemplate_Array &array_obj_ref_template, + PortableInterceptor::AdapterState state + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + const size_t interceptor_count = this->ior_interceptor_list_.size (); + + if (interceptor_count == 0) + return; + + PortableInterceptor::ObjectReferenceTemplateSeq seq_obj_ref_template; + + seq_obj_ref_template.length ( + static_cast <CORBA::ULong> (array_obj_ref_template.size())); + + for (size_t counter = 0; counter < array_obj_ref_template.size(); ++counter) + { + PortableInterceptor::ObjectReferenceTemplate *member = + array_obj_ref_template[counter]; + + CORBA::add_ref (member); + + seq_obj_ref_template[counter] = member; + } + + for (size_t i = 0; i < interceptor_count; ++i) + { + PortableInterceptor::IORInterceptor_ptr ior_interceptor = + this->ior_interceptor_list_.interceptor (i); + + PortableInterceptor::IORInterceptor_3_0_var ior_3_interceptor = + PortableInterceptor::IORInterceptor_3_0::_narrow (ior_interceptor); + if (!CORBA::is_nil (ior_3_interceptor.in ())) + { + ior_3_interceptor->adapter_state_changed ( + seq_obj_ref_template, + state + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } +} + +void +TAO_IORInterceptor_Adapter_Impl::adapter_manager_state_changed ( + const char * id, + PortableInterceptor::AdapterState state + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + /// Whenever the POAManager state is changed, the + /// adapter_manager_state_changed method is to be invoked on all the IOR + /// Interceptors. + const size_t interceptor_count = this->ior_interceptor_list_.size (); + + if (interceptor_count == 0) + return; + + for (size_t i = 0; i < interceptor_count; ++i) + { + PortableInterceptor::IORInterceptor_ptr ior_interceptor = + this->ior_interceptor_list_.interceptor (i); + + PortableInterceptor::IORInterceptor_3_0_var ior_3_interceptor = + PortableInterceptor::IORInterceptor_3_0::_narrow (ior_interceptor); + if (!CORBA::is_nil (ior_3_interceptor.in ())) + { + ior_3_interceptor->adapter_manager_state_changed ( + id, + state + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h new file mode 100644 index 00000000000..5dc289f77d8 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Adapter_Impl.h @@ -0,0 +1,97 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file IORInterceptor_Adapter_Impl.h + * + * $Id$ + * + * @author Jeff Parsons <parsons@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef TAO_IORINTERCEPTOR_ADAPTER_IMPL_H +#define TAO_IORINTERCEPTOR_ADAPTER_IMPL_H + +#include /**/ "ace/pre.h" + +#include "tao/IORInterceptor/iorinterceptor_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/IORInterceptor/IORInterceptor.h" +#include "tao/IORInterceptor_Adapter.h" +#include "tao/PI/Interceptor_List_T.h" +#include "tao/IORInterceptor/IORInterceptor_Details.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + typedef Interceptor_List< ::PortableInterceptor::IORInterceptor, + IORInterceptor_Details> + IORInterceptor_List; +} + +class TAO_Root_POA; + +/** + * @class TAO_IORInterceptor_Adapter_Impl + * + * @brief TAO_IORInterceptor_Adapter_Impl. + * + * Class that adapts various functions involving the PortableInterceptor + * interfaces IORInfo and IORInterceptor. This is the derived class + * that contains the actual implementations. + */ +class TAO_IORInterceptor_Adapter_Impl + : public TAO_IORInterceptor_Adapter +{ +public: + virtual ~TAO_IORInterceptor_Adapter_Impl (void); + + virtual void add_interceptor ( + PortableInterceptor::IORInterceptor_ptr interceptor + ACE_ENV_ARG_DECL); + + virtual void add_interceptor ( + PortableInterceptor::IORInterceptor_ptr interceptor, + const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + + virtual void destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL); + + virtual void establish_components (TAO_Root_POA *poa ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Call the IORInterceptor::components_established() method on all + /// registered IORInterceptors. + virtual void components_established (PortableInterceptor::IORInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void adapter_state_changed ( + const TAO::ObjectReferenceTemplate_Array &array_obj_ref_template, + PortableInterceptor::AdapterState state + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void adapter_manager_state_changed ( + const char * id, + PortableInterceptor::AdapterState state + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// List of IOR interceptors maintained + TAO::IORInterceptor_List ior_interceptor_list_; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_IORINTERCEPTOR_ADAPTER_IMPL_H */ diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Details.cpp b/TAO/tao/IORInterceptor/IORInterceptor_Details.cpp new file mode 100644 index 00000000000..77835d4cfd0 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Details.cpp @@ -0,0 +1,23 @@ +#include "tao/IORInterceptor/IORInterceptor_Details.h" + +ACE_RCSID (IORInterceptor, + IORInterceptor_Details, + "$Id$") + +#include "tao/SystemException.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + void + IORInterceptor_Details::apply_policies ( + const CORBA::PolicyList &/*policies*/ + ACE_ENV_ARG_DECL) + { + // There are currently no policies that apply to IOR Interceptors. + ACE_THROW (CORBA::INV_POLICY ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IORInterceptor/IORInterceptor_Details.h b/TAO/tao/IORInterceptor/IORInterceptor_Details.h new file mode 100644 index 00000000000..bb2ce8b0fa8 --- /dev/null +++ b/TAO/tao/IORInterceptor/IORInterceptor_Details.h @@ -0,0 +1,63 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file IORInterceptor_Details.h + * + * $Id$ + * + * This file declares a class that manages the details + * about a registered client request interceptor. Policies can be + * used when interceptors are registered, and the policy values + * will be processed and used to modify the values of the + * IORInterceptor_Details object associated with the registered + * client request interceptor. + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_IOR_INTERCEPTOR_DETAILS_H +#define TAO_IOR_INTERCEPTOR_DETAILS_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Policy_ForwardC.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class IORInterceptor_Details + * + * @brief The policy-driven details for a registered IOR interceptor + * + * Each time an IOR interceptor is registered with an ORB, an + * IORInterceptor_Details object will be created and associated with + * the registered IOR interceptor. If the interceptor is + * registered with policies, the policies will be used to adjust the + * values in the IORInterceptor_Details appropriately. + * + * Currently, there are no policies that are applicable to + * IOR Interceptors. + */ + class IORInterceptor_Details + { + public: + void apply_policies (const CORBA::PolicyList& policies + ACE_ENV_ARG_DECL); + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_IOR_INTERCEPTOR_DETAILS_H */ diff --git a/TAO/tao/IORInterceptor/TAO_IORInterceptor.pc.in b/TAO/tao/IORInterceptor/TAO_IORInterceptor.pc.in new file mode 100644 index 00000000000..95d2ae883cb --- /dev/null +++ b/TAO/tao/IORInterceptor/TAO_IORInterceptor.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: TAO_IORInterceptor +Description: TAO IOR Interceptor Library +Requires: TAO_PI, TAO_CodecFactory, TAO_ObjRefTemplate, TAO_Valuetype, TAO_PortableServer, TAO_AnyTypeCode, TAO +Version: @VERSION@ +Libs: -L${libdir} -lTAO_IORInterceptor +Cflags: -I${includedir} diff --git a/TAO/tao/IORInterceptor/TAO_IORInterceptor.rc b/TAO/tao/IORInterceptor/TAO_IORInterceptor.rc new file mode 100644 index 00000000000..6ce65995cb2 --- /dev/null +++ b/TAO/tao/IORInterceptor/TAO_IORInterceptor.rc @@ -0,0 +1,30 @@ +#include "..\Version.h" + +1 VERSIONINFO + FILEVERSION TAO_MAJOR_VERSION,TAO_MINOR_VERSION,TAO_BETA_VERSION,0 + PRODUCTVERSION TAO_MAJOR_VERSION,TAO_MINOR_VERSION,TAO_BETA_VERSION,0 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x0L + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "FileDescription", "IORInterceptor\0" + VALUE "FileVersion", TAO_VERSION "\0" + VALUE "InternalName", "TAO_IORInterceptorDLL\0" + VALUE "LegalCopyright", "\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "TAO_IORInterceptor.DLL\0" + VALUE "ProductName", "TAO\0" + VALUE "ProductVersion", TAO_VERSION "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/TAO/tao/IORInterceptor/iorinterceptor_export.h b/TAO/tao/IORInterceptor/iorinterceptor_export.h new file mode 100644 index 00000000000..4c6180c412a --- /dev/null +++ b/TAO/tao/IORInterceptor/iorinterceptor_export.h @@ -0,0 +1,40 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_IORINTERCEPTOR_EXPORT_H +#define TAO_IORINTERCEPTOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_IORINTERCEPTOR_HAS_DLL) +# define TAO_IORINTERCEPTOR_HAS_DLL 0 +# endif /* ! TAO_IORINTERCEPTOR_HAS_DLL */ +#else +# if !defined (TAO_IORINTERCEPTOR_HAS_DLL) +# define TAO_IORINTERCEPTOR_HAS_DLL 1 +# endif /* ! TAO_IORINTERCEPTOR_HAS_DLL */ +#endif + +#if defined (TAO_IORINTERCEPTOR_HAS_DLL) && (TAO_IORINTERCEPTOR_HAS_DLL == 1) +# if defined (TAO_IORINTERCEPTOR_BUILD_DLL) +# define TAO_IORInterceptor_Export ACE_Proper_Export_Flag +# define TAO_IORINTERCEPTOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_IORINTERCEPTOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_IORINTERCEPTOR_BUILD_DLL */ +# define TAO_IORInterceptor_Export ACE_Proper_Import_Flag +# define TAO_IORINTERCEPTOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_IORINTERCEPTOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_IORINTERCEPTOR_BUILD_DLL */ +#else /* TAO_IORINTERCEPTOR_HAS_DLL == 1 */ +# define TAO_IORInterceptor_Export +# define TAO_IORINTERCEPTOR_SINGLETON_DECLARATION(T) +# define TAO_IORINTERCEPTOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_IORINTERCEPTOR_HAS_DLL == 1 */ + +#endif /* TAO_IORINTERCEPTOR_EXPORT_H */ + +// End of auto generated file. |