diff options
author | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-02-02 21:50:42 +0000 |
---|---|---|
committer | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-02-02 21:50:42 +0000 |
commit | d2cec7eebe8dbf2b5c9848b2862ad679da60ffd2 (patch) | |
tree | faa533bcad617bf7fb702f42360baecc9ff85d83 | |
parent | a9673dfa71fa986e90dfbc53dfb3faf1b876790c (diff) | |
download | ATCD-d2cec7eebe8dbf2b5c9848b2862ad679da60ffd2.tar.gz |
*** empty log message ***
23 files changed, 1689 insertions, 20 deletions
diff --git a/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Activator.cpp b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Activator.cpp new file mode 100644 index 00000000000..c2798a31f8e --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Activator.cpp @@ -0,0 +1,73 @@ +#include "Dynamic_Component_Activator.h" +#include "CIAO_common.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ciao, + Dynamic_Component_Activator, + "$Id$") + +namespace CIAO +{ + Dynamic_Component_Activator::Dynamic_Component_Activator (CORBA::ORB_ptr o) + : orb_ (CORBA::ORB::_duplicate (o)) + { + } + + Dynamic_Component_Activator::~Dynamic_Component_Activator (void) + { + } + + PortableServer::Servant + Dynamic_Component_Activator::incarnate (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableServer::ForwardRequest)) + { + Dynamic_Component_Servant_Base* servant = 0; + PortableServer::ObjectId new_oid (oid); + + if (this->servant_map_.find (oid, servant) == 0) + { + return servant->create (new_oid); + } + + return 0; + } + + void + Dynamic_Component_Activator::etherealize ( + const PortableServer::ObjectId &, + PortableServer::POA_ptr , + PortableServer::Servant , + CORBA::Boolean , + CORBA::Boolean + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + } + + void Dynamic_Component_Activator::add_servant_map + (PortableServer::ObjectId &oid, + Dynamic_Component_Servant_Base* servant + ACE_ENV_ARG_DECL) + { + this->servant_map_.bind (oid, servant); + } + + void Dynamic_Component_Activator::delete_servant_map + (PortableServer::ObjectId &oid + ACE_ENV_ARG_DECL) + { + Dynamic_Component_Servant_Base* servant = 0; + if (this->servant_map_.unbind (oid, servant) != 0) + { + ACE_DEBUG ((LM_DEBUG, "Invalid object reference\n")); + return; + } + + return; + } + +} diff --git a/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Activator.h b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Activator.h new file mode 100644 index 00000000000..7f4285daf12 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Activator.h @@ -0,0 +1,109 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dynamic_Component_Activator.h + * + * $Id$ + * + * @authors Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu> + * Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef CIAO_DYNAMIC_SWAPPING_ACTIVATOR_H +#define CIAO_DYNAMIC_SWAPPING_ACTIVATOR_H +#include /**/ "ace/pre.h" + +#include "ace/Array_Base.h" +#include "ciao/CIAO_Server_Export.h" +#include "ciao/CCM_ContainerC.h" +#include "ciao/Deployment_CoreC.h" + +#include "tao/PortableServer/Key_Adapters.h" +#include "ace/Hash_Map_Manager_T.h" +#include "Dynamic_Component_Servant_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/PortableServer.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +namespace CIAO +{ + + class Dynamic_Component_Servant_Base; + /** + * @class Dynamic_Component_Activator + * + * @brief Activator that is registered with the POA for facet and + * consumer servants. + * + */ + class CIAO_SERVER_Export Dynamic_Component_Activator + : public virtual PortableServer::ServantActivator + , public virtual TAO_Local_RefCounted_Object + { + public: + Dynamic_Component_Activator (CORBA::ORB_ptr o); + + virtual ~Dynamic_Component_Activator (void); + + /// Template methods overridden to get callbacks. + /** + * If you would like to know the details of the following two + * methods, please PortableServer documentation. This is probably + * not the place to document what these mean. + */ + PortableServer::Servant incarnate ( + const PortableServer::ObjectId &oid, + PortableServer::POA_ptr poa + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableServer::ForwardRequest)); + + void etherealize (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr adapter, + PortableServer::Servant servant, + CORBA::Boolean cleanup_in_progress, + CORBA::Boolean remaining_activations + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void add_servant_map (PortableServer::ObjectId &oid, + Dynamic_Component_Servant_Base* servant + ACE_ENV_ARG_DECL); + + void delete_servant_map (PortableServer::ObjectId &oid + ACE_ENV_ARG_DECL); + + private: + /// Pointer to our ORB + CORBA::ORB_var orb_; + + /// Mutex that synchronizes access to the array. + ACE_SYNCH_MUTEX mutex_; + + ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, + Dynamic_Component_Servant_Base *, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> + servant_map_; + + }; +} + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /*CIAO_DYNAMIC_SWAPPING_ACTIVATOR_H*/ diff --git a/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_Base.cpp b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_Base.cpp new file mode 100644 index 00000000000..e7a0daceadd --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_Base.cpp @@ -0,0 +1,26 @@ +#include "Dynamic_Component_Servant_Base.h" +#include "CIAO_common.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ciao, + Dynamic_Component_Servant_Base, + "$Id$") + +namespace CIAO +{ + Dynamic_Component_Servant_Base::Dynamic_Component_Servant_Base (void) + { + ACE_ASSERT (0); + } + + Dynamic_Component_Servant_Base::Dynamic_Component_Servant_Base + (Session_Container * c) + : container_ (c) + { + } + + Dynamic_Component_Servant_Base::~Dynamic_Component_Servant_Base (void) + { + } +} diff --git a/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_Base.h b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_Base.h new file mode 100644 index 00000000000..fff68f5965d --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_Base.h @@ -0,0 +1,54 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dynamic_Component_Servant_Base.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_DYNAMIC_COMPONENT_SERVANT_BASE_H +#define CIAO_DYNAMIC_COMPONENT_SERVANT_BASE_H + +#include /**/ "ace/pre.h" + +#include "CCM_ComponentS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/PortableServer.h" +#include "CIAO_Server_Export.h" + +namespace CIAO +{ + class Session_Container; + class CIAO_SERVER_Export Dynamic_Component_Servant_Base + { + public: + explicit Dynamic_Component_Servant_Base (void); + + Dynamic_Component_Servant_Base (Session_Container *c); + + virtual ~Dynamic_Component_Servant_Base (void); + + virtual PortableServer::Servant + create (PortableServer::ObjectId &oid) = 0; + + virtual void destroy (PortableServer::ObjectId &oid) = 0; + + virtual void update_destroy_count () = 0; + + protected: + Session_Container *container_; + }; + +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_DYNAMIC_COMPONENT_SERVANT_BASE_H */ diff --git a/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_T.cpp b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_T.cpp new file mode 100644 index 00000000000..6d44811b457 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_T.cpp @@ -0,0 +1,112 @@ +// $Id$ + +#ifndef CIAO_DYNAMIC_COMPONENT_SERVANT_T_C +#define CIAO_DYNAMIC_COMPONENT_SERVANT_T_C + +#include "Dynamic_Component_Servant_T.h" + +namespace CIAO +{ + template <typename COMP_SVNT, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename EXEC, + typename EXEC_VAR, + typename COMP> + Dynamic_Component_Servant<COMP_SVNT, COMP_EXEC, COMP_EXEC_VAR, + EXEC, EXEC_VAR, COMP> + ::Dynamic_Component_Servant + (Components::EnterpriseComponent_ptr ec, + Components::CCMHome_ptr home, + Home_Servant_Impl_Base *home_servant, + Session_Container *c) + :Dynamic_Component_Servant_Base (c), + executor_ (Components::EnterpriseComponent::_duplicate (ec)), + home_servant_ (home_servant), + home_ (Components::CCMHome::_duplicate (home)), + component_removed_ (0) + { + } + + template <typename COMP_SVNT, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename EXEC, + typename EXEC_VAR, + typename COMP> + void Dynamic_Component_Servant<COMP_SVNT, COMP_EXEC, COMP_EXEC_VAR, + EXEC, EXEC_VAR, COMP>::update_destroy_count () + { + component_removed_ = 1; + } + + template <typename COMP_SVNT, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename EXEC, + typename EXEC_VAR, + typename COMP> + Dynamic_Component_Servant<COMP_SVNT, COMP_EXEC, COMP_EXEC_VAR, + EXEC, EXEC_VAR, COMP>::~Dynamic_Component_Servant (void) + { + } + + template <typename COMP_SVNT, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename EXEC, + typename EXEC_VAR, + typename COMP> + void Dynamic_Component_Servant + <COMP_SVNT, COMP_EXEC, COMP_EXEC_VAR, + EXEC, EXEC_VAR, COMP>::destroy (PortableServer::ObjectId &oid) + { + COMP_SVNT *servant; + if (this->servant_map_.find (oid, servant) == 0) + { + servant->remove (); + component_removed_ = 1; + } + } + + template <typename COMP_SVNT, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename EXEC, + typename EXEC_VAR, + typename COMP> + PortableServer::Servant Dynamic_Component_Servant + <COMP_SVNT, COMP_EXEC, COMP_EXEC_VAR, + EXEC, EXEC_VAR, COMP>::create (PortableServer::ObjectId &oid) + { + CIAO::Swap_Exec_var swap_exec = CIAO::Swap_Exec::_narrow + (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + + ::Components::EnterpriseComponent_var ciao_ec = + swap_exec->incarnate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (COMP::_nil ()); + + COMP_EXEC_VAR ciao_comp = COMP_EXEC::_narrow (ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (COMP::_nil ()); + + COMP_SVNT *svt = new COMP_SVNT(ciao_comp.in (), this->home_.in (), + this->home_servant_, + this->container_); + + if (component_removed_ == 1) + { + // svt->ciao_preactivate (); + // svt->ciao_activate (); + // svt->ciao_postactivate (); + component_removed_ = 0; + } + + PortableServer::ServantBase_var safe (svt); + this->servant_map_.bind (oid, svt); + return safe._retn (); + } +} + +#endif /* CIAO_DYNAMIC_COMPONENT_SERVANT_T_C */ diff --git a/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_T.h b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_T.h new file mode 100644 index 00000000000..9e4c8828fc8 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Dynamic_Component_Servant_T.h @@ -0,0 +1,78 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dynamic_Component_Servant_T.h + * + * $Id$ + * + * This file contains the declaration of a mixin base class for + * the generated home servant class. + * + */ +//============================================================================= + + +#ifndef CIAO_DYNAMIC_COMPONENT_SERVANT_T_H +#define CIAO_DYNAMIC_COMPONENT_SERVANT_T_H + +#include /**/ "ace/pre.h" + +#include "Dynamic_Component_Servant_Base.h" +#include "SwapExecC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/Key_Adapters.h" +#include "ace/Hash_Map_Manager_T.h" + +namespace CIAO +{ + template <typename COMP_SVNT, typename COMP_EXEC, + typename COMP_EXEC_VAR, typename EXEC, typename EXEC_VAR, + typename COMP> + class Dynamic_Component_Servant + : public virtual Dynamic_Component_Servant_Base + { + public: + Dynamic_Component_Servant (Components::EnterpriseComponent_ptr ec, + Components::CCMHome_ptr home, + Home_Servant_Impl_Base *home_servant, + Session_Container *c); + + virtual ~Dynamic_Component_Servant (void); + + virtual PortableServer::Servant + create (PortableServer::ObjectId &oid); + + virtual void destroy (PortableServer::ObjectId &oid); + + virtual void update_destroy_count (); + + protected: + Components::EnterpriseComponent_var executor_; + Home_Servant_Impl_Base *home_servant_; + Components::CCMHome_var home_; + ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, + COMP_SVNT *, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> + servant_map_; + int component_removed_; + }; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Dynamic_Component_Servant_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Dynamic_Component_Servant_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* CIAO_DYNAMIC_COMPONENT_SERVANT_T_H */ diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h index 0580c562d39..f5526252907 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h @@ -30,6 +30,8 @@ using CIAO::Utility::write_IOR; + + /** * * @class NodeApplication_Impl diff --git a/TAO/CIAO/DAnCE/ciao/SwapExec.idl b/TAO/CIAO/DAnCE/ciao/SwapExec.idl new file mode 100644 index 00000000000..566781019e3 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/SwapExec.idl @@ -0,0 +1,12 @@ +// $Id$ + +#include "CCM_Container.idl" + +module CIAO +{ + local interface Swap_Exec : ::Components::EnterpriseComponent + { + Components::EnterpriseComponent incarnate (); + Components::EnterpriseComponent etherealize (); + }; +}; diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Container.cpp b/TAO/CIAO/DAnCE/ciao/Swapping_Container.cpp new file mode 100644 index 00000000000..087e269815b --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Container.cpp @@ -0,0 +1,290 @@ +// $Id$ + +#include "Container_Base.h" +#include "Swapping_Container.h" +#include "ace/DLL.h" +#include "tao/Utils/PolicyList_Destroyer.h" +#include "ace/OS_NS_stdio.h" + +#if !defined (__ACE_INLINE__) +# include "Swapping_Container.inl" +#endif /* __ACE_INLINE__ */ + +namespace CIAO +{ + + ACE_Atomic_Op <ACE_SYNCH_MUTEX, long> + Swapping_Container::serial_number_ (0); + + Swapping_Container::Swapping_Container (CORBA::ORB_ptr o) + : Session_Container (o), + number_ (0) + { + } + + Swapping_Container::~Swapping_Container () + { + } + + PortableServer::POA_ptr + Swapping_Container::the_home_servant_POA (void) const + { + return this->home_servant_poa_.in (); + } + + CORBA::Object_ptr + Swapping_Container::get_home_objref (PortableServer::Servant p + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return this->the_home_servant_POA ()->servant_to_reference (p + ACE_ENV_ARG_PARAMETER); + } + + int + Swapping_Container::init (const char *name, + const CORBA::PolicyList *more_policies + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + char buffer[MAXPATHLEN]; + + if (name == 0) + { + this->number_ = ++Swapping_Container::serial_number_; + ACE_OS::sprintf (buffer, "CIAO::Swapping_Container-%ld", + this->number_); + name = buffer; + } + + CORBA::Object_var poa_object = + this->orb_->resolve_initial_references("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + -1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + + this->create_servant_POA (name, + more_policies, + root_poa.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + + + this->create_home_servant_POA ("home servant POA", + more_policies, + root_poa.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + this->create_connections_POA (root_poa.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + return 0; + } + + void + Swapping_Container::add_servant_map + (PortableServer::ObjectId &oid, + Dynamic_Component_Servant_Base* servant + ACE_ENV_ARG_DECL) + { + this->dsa_->add_servant_map (oid, servant); + } + + void + Swapping_Container::delete_servant_map + (PortableServer::ObjectId &oid + ACE_ENV_ARG_DECL) + { + this->dsa_->delete_servant_map (oid); + } + + void + Swapping_Container::create_home_servant_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root + ACE_ENV_ARG_DECL) + { + CORBA::PolicyList policies (0); + + if (p != 0) + policies = *p; + + PortableServer::POAManager_var poa_manager = + root->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + + this->home_servant_poa_ = + root->create_POA (name, + poa_manager.in (), + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + void + Swapping_Container::create_connections_POA ( + PortableServer::POA_ptr root + ACE_ENV_ARG_DECL) + { + PortableServer::POAManager_var poa_manager = + root->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + TAO::Utils::PolicyList_Destroyer policies (3); + policies.length (3); + + policies[0] = + root->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policies[1] = + root->create_request_processing_policy + (PortableServer::USE_SERVANT_MANAGER + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK; + + // Servant Retention Policy + policies[2] = + root->create_servant_retention_policy (PortableServer::RETAIN + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->facet_cons_poa_ = + root->create_POA ("facet_consumer_poa", + poa_manager.in (), + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->sa_, + Servant_Activator (this->orb_.in ()), + CORBA::NO_MEMORY ()); + + this->facet_cons_poa_->set_servant_manager ( + this->sa_ + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK; + } + + void + Swapping_Container::create_servant_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root + ACE_ENV_ARG_DECL) + { + CORBA::PolicyList policies (0); + + if (p != 0) + policies = *p; + + PortableServer::POAManager_var poa_manager = + root->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong policy_length = policies.length (); + policies.length (policy_length + 1); + policies[policy_length] = + root->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_length = policies.length (); + policies.length (policy_length + 1); + policies[policy_length] = + root->create_request_processing_policy ( + PortableServer::USE_SERVANT_MANAGER + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_length = policies.length (); + policies.length (policy_length + 1); + policies[policy_length] = + root->create_servant_retention_policy (PortableServer::RETAIN + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->component_poa_ = + root->create_POA (name, + poa_manager.in (), + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->dsa_, + Dynamic_Component_Activator (this->orb_.in ()), + CORBA::NO_MEMORY ()); + + this->component_poa_->set_servant_manager ( + this->dsa_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + } + + void + Swapping_Container::ciao_uninstall_home (Components::CCMHome_ptr homeref + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + PortableServer::POA_ptr tmp = this->home_servant_poa_.in (); + PortableServer::ObjectId_var oid = + tmp->reference_to_id (homeref + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + tmp->deactivate_object (oid.in () + ACE_ENV_ARG_PARAMETER); + } + + CORBA::Object_ptr + Swapping_Container::install_servant (PortableServer::Servant p, + Container::OA_Type t + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + PortableServer::POA_ptr tmp = 0; + + if (t == Container::Component) + { + tmp = this->home_servant_poa_.in (); + } + else + tmp = this->facet_cons_poa_.in (); + + PortableServer::ObjectId_var oid + = tmp->activate_object (p + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Object_var objref + = tmp->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return objref._retn (); + } +} diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Container.h b/TAO/CIAO/DAnCE/ciao/Swapping_Container.h new file mode 100644 index 00000000000..3372d356b3e --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Container.h @@ -0,0 +1,128 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Swapping_Container.h + * + * $Id$ + * + * Header file for CIAO's Dynamic Swapping container implementations + * + * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu> + * Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +//============================================================================= + + +#ifndef CIAO_SWAPPING_CONTAINER_H +#define CIAO_SWAPPING_CONTAINER_H +#include /**/ "ace/pre.h" + +#include "tao/ORB.h" +#include "tao/PortableServer/PortableServer.h" +#include "tao/PortableServer/Servant_Base.h" +#include "ciao/CCM_ContainerC.h" +#include "ciao/Container_Base.h" +#include "ciao/Deployment_CoreC.h" +#include "ciao/Dynamic_Component_Activator.h" +#include "ciao/CIAO_Server_Export.h" +#include "ciao/Servant_Activator.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace CIAO +{ + class Dynamic_Component_Servant_Base; + + class CIAO_SERVER_Export Swapping_Container : public Session_Container + { + public: + + Swapping_Container (CORBA::ORB_ptr o); + + virtual ~Swapping_Container (void); + + /// Initialize the container with a name. + virtual int init (const char *name = 0, + const CORBA::PolicyList *more_policies = 0 + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Object_ptr install_servant (PortableServer::Servant p, + Container::OA_Type t + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Object_ptr get_objref (PortableServer::Servant p + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void ciao_uninstall_home (Components::CCMHome_ptr homeref + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Object_ptr get_home_objref (PortableServer::Servant p + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void add_servant_map (PortableServer::ObjectId &oid, + Dynamic_Component_Servant_Base* servant + ACE_ENV_ARG_DECL); + + virtual void delete_servant_map (PortableServer::ObjectId &oid + ACE_ENV_ARG_DECL); + + PortableServer::POA_ptr the_home_servant_POA (void) const; + + private: + + /// Create POA for the component. + void create_servant_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root + ACE_ENV_ARG_DECL); + + void create_home_servant_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root + ACE_ENV_ARG_DECL); + + void create_connections_POA (PortableServer::POA_ptr root + ACE_ENV_ARG_DECL); + protected: + long number_; + + // @@ Jai, why should this be static? + static ACE_Atomic_Op <ACE_SYNCH_MUTEX, long> serial_number_; + + Dynamic_Component_Activator *dsa_; + + }; +} + +// Macro for registration of an OBV factory in the generated +// servant class. Similar to the macro for TAO in +// tao/ValueType/ValueFactory.h but here we take advantage of +// the fact that we have access to the current ORB indirectly +// through the context and container. +#define CIAO_REGISTER_OBV_FACTORY(FACTORY, VALUETYPE) \ + { \ + CORBA::ValueFactory factory = new FACTORY; \ + CORBA::ORB_ptr orb = \ + this->context_->_ciao_the_Container ()->the_ORB (); \ + CORBA::ValueFactory prev_factory = \ + orb->register_value_factory ( \ + VALUETYPE::_tao_obv_static_repository_id (), \ + factory); \ + CORBA::remove_ref (prev_factory); \ + CORBA::add_ref (factory); \ + } + +#if defined (__ACE_INLINE__) +# include "Swapping_Container.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* CIAO_SWAPPING_CONTAINER_H */ diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Container.inl b/TAO/CIAO/DAnCE/ciao/Swapping_Container.inl new file mode 100644 index 00000000000..b2c00a33346 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Container.inl @@ -0,0 +1,10 @@ +// $Id$ + +ACE_INLINE CORBA::Object_ptr +CIAO::Swapping_Container::get_objref (PortableServer::Servant p + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->the_POA ()->servant_to_reference (p + ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_Base.cpp b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_Base.cpp new file mode 100644 index 00000000000..67802096476 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_Base.cpp @@ -0,0 +1,44 @@ +// $Id$ + +#include "Swapping_Servant_Home_Impl_Base.h" + +namespace CIAO +{ + Swapping_Servant_Home_Impl_Base::Swapping_Servant_Home_Impl_Base (void) + { + ACE_ASSERT (0); + } + + Swapping_Servant_Home_Impl_Base::Swapping_Servant_Home_Impl_Base + (Swapping_Container * c) + : container_ (c) + { + } + + Swapping_Servant_Home_Impl_Base::~Swapping_Servant_Home_Impl_Base (void) + { + } + + // Operations for CCMHome interface. + + CORBA::IRObject_ptr + Swapping_Servant_Home_Impl_Base::get_component_def ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + CORBA::IRObject::_nil ()); + } + + CORBA::IRObject_ptr + Swapping_Servant_Home_Impl_Base::get_home_def ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + CORBA::IRObject::_nil ()); + } + +} diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_Base.h b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_Base.h new file mode 100644 index 00000000000..88b3033deca --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_Base.h @@ -0,0 +1,66 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Swapping_Servant_Home_Impl_Base.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_SWAPPING_SERVANT_HOME_IMPL_BASE_H +#define CIAO_SWAPPING_SERVANT_HOME_IMPL_BASE_H + +#include /**/ "ace/pre.h" + +#include "CCM_ComponentS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "CIAO_Server_Export.h" + +namespace CIAO +{ + class Swapping_Container; + + /** + * @class Swapping_Servant_Home_Impl_Base + * + */ + // @@ Jai, why are you inheriting from "home" here? What is the + // point? + // @@ JAI, probably my class naming convention was the problem. + // This is a home implementation and that is why inheriting from + // "home". + // + class CIAO_SERVER_Export Swapping_Servant_Home_Impl_Base + : public virtual POA_Components::CCMHome + { + public: + explicit Swapping_Servant_Home_Impl_Base (void); + + Swapping_Servant_Home_Impl_Base (Swapping_Container * c); + + virtual ~Swapping_Servant_Home_Impl_Base (void); + + // Operations for CCMHome interface. + virtual ::CORBA::IRObject_ptr + get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CORBA::IRObject_ptr + get_home_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + Swapping_Container *container_; + }; +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_SWAPPING_SERVANT_HOME_IMPL_BASE_H */ diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_T.cpp b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_T.cpp new file mode 100644 index 00000000000..804884efb95 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_T.cpp @@ -0,0 +1,298 @@ +// $Id$ + +#ifndef CIAO_SWAPPING_SERVANT_IMPL_T_C +#define CIAO_SWAPPING_SERVANT_IMPL_T_C + +#include "Swapping_Servant_Home_Impl_T.h" +#include "Dynamic_Component_Servant_T.h" + +namespace CIAO +{ + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::Swapping_Servant_Home_Impl ( + EXEC * exe, + Session_Container * c, const char* obj_id, const char* repo_id) + : Home_Servant_Impl_Base (c), + executor_ (EXEC::_duplicate (exe)), obj_id_ (obj_id), repo_id_ (repo_id) + { + } + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::~Swapping_Servant_Home_Impl (void) + { + const DYNAMIC_SERVANT_MAP_ITERATOR end = + this->dynamic_servant_map_.end (); + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId (this->obj_id_); + + this->container_->delete_servant_map (oid); + + for (DYNAMIC_SERVANT_MAP_ITERATOR iter = + this->dynamic_servant_map_.begin (); + iter != end; ++iter) + { + // (*iter).int_id_->destroy (oid); + } + } + + // Operations for CCMHome interface. + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + void + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::remove_component ( + ::Components::CCMObject_ptr + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)) + { + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId (this->obj_id_); + + Dynamic_Component_Servant_Base *servant; + if (this->dynamic_servant_map_.find (oid, servant) == 0) + { + servant->destroy (oid); + } + } + + // Operations for keyless home interface. + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + Components::CCMObject_ptr + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::create_component ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)) + { + return this->create (ACE_ENV_SINGLE_ARG_PARAMETER); + } + + // Operations for implicit home interface. + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + COMP * + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::create ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)) + { + if (this->executor_.in () == 0) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + COMP::_nil ()); + } + + + ::Components::EnterpriseComponent_var _ciao_ec = + this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (COMP::_nil ()); + + return this->_ciao_activate_component (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + } + + // CIAO-specific operations. + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + COMP * + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::_ciao_activate_component ( + ::Components::EnterpriseComponent_ptr ec + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + CORBA::Object_var hobj = + this->container_->get_home_objref (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (COMP::_nil ()); + + Components::CCMHome_var home = + Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (COMP::_nil ()); + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId (this->obj_id_); + + CORBA::Object_var objref = + this->container_->generate_reference ( + this->obj_id_, + this->repo_id_, + Container::Component + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + Dynamic_Component_Servant_Base *svt = + new Dynamic_Component_Servant + <COMP_SVNT, COMP_EXEC, COMP_EXEC_VAR, EXEC, EXEC_VAR, COMP> + (ec, home, this, this->container_); + + this->container_->add_servant_map (oid, svt); + + this->dynamic_servant_map_.bind (oid, svt); + + COMP_VAR ho = COMP::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK_RETURN (COMP::_nil ()); + + return ho._retn (); + } + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + void + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::update_component_map ( + PortableServer::ObjectId &oid) + { + Dynamic_Component_Servant_Base *servant; + if (this->dynamic_servant_map_.find (oid, servant) == 0) + { + servant->update_destroy_count (); + } + return; + } + + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + void + Swapping_Servant_Home_Impl<BASE_SKEL, + EXEC, + EXEC_VAR, + COMP, + COMP_VAR, + COMP_EXEC, + COMP_EXEC_VAR, + COMP_SVNT>::_ciao_passivate_component ( + COMP *comp + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + COMP_SVNT *servant = 0; + + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + } +} + +#endif /* CIAO_SWAPPING_SERVANT_IMPL_T_C */ diff --git a/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_T.h b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_T.h new file mode 100644 index 00000000000..6834c2050b9 --- /dev/null +++ b/TAO/CIAO/DAnCE/ciao/Swapping_Servant_Home_Impl_T.h @@ -0,0 +1,135 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Swapping_Servant_Impl_T.h + * + * $Id$ + * + * This file contains the declaration of a mixin base class for + * the generated home servant class. + * + */ +//============================================================================= + + +#ifndef CIAO_SWAPPING_SERVANT_HOME_IMPL_T_H +#define CIAO_SWAPPING_SERVANT_HOME_IMPL_T_H + +#include /**/ "ace/pre.h" + +#include "Home_Servant_Impl_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/Key_Adapters.h" +#include "ace/Hash_Map_Manager_T.h" +#include "Dynamic_Component_Servant_Base.h" + +namespace CIAO +{ + class Session_Container; + + /** + * @class Swapping_Servant_Impl + * + * @brief Mixin base class for generated home servant. + * + * This class implements operations + * common to all generated home servants. + */ + template <typename BASE_SKEL, + typename EXEC, + typename EXEC_VAR, + typename COMP, + typename COMP_VAR, + typename COMP_EXEC, + typename COMP_EXEC_VAR, + typename COMP_SVNT> + class Swapping_Servant_Home_Impl + : public virtual BASE_SKEL, + public virtual Home_Servant_Impl_Base, + public virtual PortableServer::RefCountServantBase + { + public: + Swapping_Servant_Home_Impl (EXEC * exe, + Session_Container * c, + const char* obj_id, const char* repo_id); + + virtual ~Swapping_Servant_Home_Impl (void); + + // Operations for CCMHome interface. + + virtual void + remove_component (Components::CCMObject_ptr comp + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)); + + // Operations for keyless home interface. + + virtual ::Components::CCMObject_ptr + create_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)); + + // Operations for implicit home interface. + + virtual COMP * + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CreateFailure)); + + virtual void + update_component_map (PortableServer::ObjectId &oid); + + protected: + // CIAO-specific operations. + + COMP * + _ciao_activate_component (::Components::EnterpriseComponent_ptr ec + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component (COMP *comp + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + EXEC_VAR executor_; + + ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, + COMP_SVNT *, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> + component_map_; + + typedef ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, + Dynamic_Component_Servant_Base *, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> DYNAMIC_SERVANT_MAP; + + typedef DYNAMIC_SERVANT_MAP::iterator DYNAMIC_SERVANT_MAP_ITERATOR; + DYNAMIC_SERVANT_MAP dynamic_servant_map_; + + const char* obj_id_; + const char* repo_id_; + }; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Swapping_Servant_Home_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Swapping_Servant_Home_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* CIAO_SWAPPING_SERVANT_HOME_IMPL_T_H */ diff --git a/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.cpp b/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.cpp index ade91a15e04..ca74c2a3c42 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.cpp +++ b/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.cpp @@ -8,6 +8,28 @@ #include "Receiver_exec.h" #include "CIAO_common.h" +Receiver_Impl::ReceiverSwap_exec_i::ReceiverSwap_exec_i () +{ +} + +Receiver_Impl::ReceiverSwap_exec_i::~ReceiverSwap_exec_i () +{ +} + +::Components::EnterpriseComponent_ptr +Receiver_Impl::ReceiverSwap_exec_i::incarnate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return new Receiver_Impl::Receiver_exec_i; +} + +::Components::EnterpriseComponent_ptr +Receiver_Impl::ReceiverSwap_exec_i::etherealize (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return new Receiver_Impl::Receiver_exec_i; +} + Receiver_Impl::Receiver_exec_i::Receiver_exec_i () { } @@ -95,6 +117,33 @@ Receiver_Impl::Receiver_exec_i::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) Components::CCMException)) { ACE_DEBUG ((LM_DEBUG, "Receiver_Impl::Receiver_exec_i::ccm_passivate\n")); + /* + CORBA::Object_var comp_object = + this->context_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + Hello::Receiver_var receiver = Hello::Receiver::_narrow (comp_object.in () + ACE_ENV_ARG_PARAMETER); + + ::Components::ConsumerDescriptions_var cons_desc = + receiver->get_all_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + ::Components::FacetDescriptions_var facet_desc = + receiver->get_all_facets (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::ULong cons_len = cons_desc->length (); + CORBA::ULong facet_len = facet_desc->length (); + for (CORBA::ULong i = 0; i < cons_len; ++i) + { + // ACE_DEBUG ((LM_DEBUG, "consumer name is %s\n", cons_desc[i]->name ())); + } + for (CORBA::ULong i = 0; i < facet_len; ++i) + { + // ACE_DEBUG ((LM_DEBUG, "facet name is %s\n", facet_desc[i]->name ())); + } + */ } void @@ -120,9 +169,16 @@ Receiver_Impl::ReceiverHome_exec_i::create (ACE_ENV_SINGLE_ARG_DECL) Components::CCMException)) { Components::EnterpriseComponent_ptr tmp; + + ACE_NEW_THROW_EX (tmp, + Receiver_Impl::ReceiverSwap_exec_i, + CORBA::NO_MEMORY ()); + /* ACE_NEW_THROW_EX (tmp, Receiver_Impl::Receiver_exec_i, CORBA::NO_MEMORY ()); + */ + return tmp; } diff --git a/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.h b/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.h index d60e59788b3..a86ff5970ae 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.h +++ b/TAO/CIAO/DAnCE/examples/Hello/Receiver/Receiver_exec.h @@ -10,6 +10,7 @@ #ifndef RECEIVER_EXEC_H #define RECEIVER_EXEC_H +#include "SwapExecC.h" #include "ReceiverEC.h" #include "Receiver_exec_export.h" #include "tao/LocalObject.h" @@ -23,6 +24,24 @@ namespace Receiver_Impl * Receiver executor implementation class. */ + class RECEIVER_EXEC_Export ReceiverSwap_exec_i : + public virtual CIAO::Swap_Exec, + public virtual TAO_Local_RefCounted_Object + { + public: + ReceiverSwap_exec_i (); + + ~ReceiverSwap_exec_i (); + + virtual ::Components::EnterpriseComponent_ptr + incarnate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::EnterpriseComponent_ptr + etherealize (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + }; + class RECEIVER_EXEC_Export Receiver_exec_i : public virtual Receiver_Exec, public virtual TAO_Local_RefCounted_Object diff --git a/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender.mpc b/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender.mpc index 421db5c00ce..cf456794089 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender.mpc +++ b/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender.mpc @@ -57,6 +57,38 @@ project(Hello_Base_Sender_DnC_exec) : ciao_component_dnc { } } +project(Hello_Base_Sender_DnC_exec_1) : ciao_component_dnc { + after += Hello_Base_Sender_DnC_svnt + sharedname = Sender_DnC_exec_1 + libs += Sender_DnC_stub Sender_DnC_svnt Hello_Base_DnC_stub Hello_Base_DnC_svnt + + idlflags += -Wb,export_macro=SENDER_EXEC_Export -Wb,export_include=Sender_exec_export.h + dynamicflags = SENDER_EXEC_BUILD_DLL + + IDL_Files { + } + + Source_Files { + Sender_exec_1.cpp + } +} + +project(Hello_Base_Sender_DnC_exec_2) : ciao_component_dnc { + after += Hello_Base_Sender_DnC_svnt + sharedname = Sender_DnC_exec_2 + libs += Sender_DnC_stub Sender_DnC_svnt Hello_Base_DnC_stub Hello_Base_DnC_svnt + + idlflags += -Wb,export_macro=SENDER_EXEC_Export -Wb,export_include=Sender_exec_export.h + dynamicflags = SENDER_EXEC_BUILD_DLL + + IDL_Files { + } + + Source_Files { + Sender_exec_2.cpp + } +} + project (Hello_DnC_Starter) : ciao_client_dnc, valuetype{ exename = starter after += Hello_Base_Sender_DnC_stub diff --git a/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.cpp b/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.cpp index 6fa52beb4de..1acce82d312 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.cpp +++ b/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.cpp @@ -2,6 +2,11 @@ #include "Sender_exec.h" +const char* first_exe_dll_name = "Sender_DnC_exec_1"; +const char* first_exe_entrypt = "createSenderExec_Impl"; +const char* second_exe_dll_name = "Sender_DnC_exec_2"; +const char* second_exe_entrypt = "createSenderExec_Impl"; + char* Sender_Impl::Message_Impl::get_message (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) @@ -30,10 +35,11 @@ Sender_Impl::Sender_exec_i::local_message (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) } Hello::CCM_ReadMessage_ptr -Sender_Impl::Sender_exec_i::get_push_message (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +Sender_Impl::Sender_exec_i::get_push_message +(ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "Sender_Impl::Sender_exec.i::get_push_message called\n ")); return ( new Message_Impl (*this) ); } @@ -48,7 +54,7 @@ Sender_Impl::Sender_exec_i::start (ACE_ENV_SINGLE_ARG_DECL) } void -Sender_Impl::Sender_exec_i::set_session_context +Sender_Impl::Sender_exec_i::set_session_context (Components::SessionContext_ptr ctx ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -66,7 +72,8 @@ Sender_Impl::Sender_exec_i::set_session_context } void -Sender_Impl::Sender_exec_i::ciao_preactivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +Sender_Impl::Sender_exec_i::ciao_preactivate +(ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException, Components::CCMException)) { @@ -84,8 +91,8 @@ Sender_Impl::Sender_exec_i::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) } void -Sender_Impl::Sender_exec_i::ciao_postactivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException, +Sender_Impl::Sender_exec_i::ciao_postactivate +(ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException, Components::CCMException)) { ACE_DEBUG ((LM_DEBUG, @@ -108,6 +115,7 @@ Sender_Impl::Sender_exec_i::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_DEBUG ((LM_DEBUG, "Sender_Impl::Sender_exec_i::ccm_remove\n")); } + Sender_Impl::SenderHome_exec_i::SenderHome_exec_i () { } @@ -116,13 +124,80 @@ Sender_Impl::SenderHome_exec_i::~SenderHome_exec_i () { } +Sender_Impl::SenderSwap_exec_i::SenderSwap_exec_i () + : count_ (0) +{ +} + +Sender_Impl::SenderSwap_exec_i::~SenderSwap_exec_i () +{ +} + +::Components::EnterpriseComponent_ptr +Sender_Impl::SenderSwap_exec_i::incarnate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // return new Sender_Impl::Sender_exec_i; + + ExecFactory first_exec_creator = 0; + ExecFactory second_exec_creator = 0; + ACE_DLL first_dll, second_dll; + + if (first_dll.open (first_exe_dll_name, + ACE_DEFAULT_SHLIB_MODE, 0) != 0) + { + ACE_DEBUG ((LM_DEBUG, "Could not open the DLL %s\n", first_exe_dll_name)); + return 0; + } + + if (second_dll.open (second_exe_dll_name, + ACE_DEFAULT_SHLIB_MODE, 0) != 0) + { + ACE_DEBUG ((LM_DEBUG, "Could not open the DLL %s\n", + second_exe_dll_name)); + return 0; + } + + if (first_exe_entrypt == 0 || second_exe_entrypt == 0) + { + ACE_DEBUG ((LM_DEBUG, "NIL entry points\n")); + return 0; + } + + if (this->count_ == 0) + { + first_exec_creator = (ExecFactory) first_dll.symbol (first_exe_entrypt); + Components::EnterpriseComponent_var first_executor = + first_exec_creator (this); + count_++; + return first_executor._retn (); + } + else if (count_ == 1) + { + second_exec_creator = (ExecFactory) + second_dll.symbol (second_exe_entrypt); + Components::EnterpriseComponent_var second_executor = + second_exec_creator (this); + --count_; + return second_executor._retn (); + } +} + +::Components::EnterpriseComponent_ptr +Sender_Impl::SenderSwap_exec_i::etherealize (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // return new Sender_Impl::Sender_exec_i; +} + ::Components::EnterpriseComponent_ptr Sender_Impl::SenderHome_exec_i::create (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException, Components::CCMException)) { - ACE_DEBUG ((LM_DEBUG, "%P|%t) creating SenderHome \n")); - return new Sender_Impl::Sender_exec_i; + ACE_DEBUG ((LM_DEBUG, "%P|%t) creating SenderHome \n")); + return new Sender_Impl::SenderSwap_exec_i; + //return new Sender_Impl::Sender_exec_i; } extern "C" SENDER_EXEC_Export ::Components::HomeExecutorBase_ptr diff --git a/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.h b/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.h index e8610a919c5..f095481ea86 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.h +++ b/TAO/CIAO/DAnCE/examples/Hello/Sender/Sender_exec.h @@ -10,18 +10,15 @@ #ifndef SENDER_EXEC_H #define SENDER_EXEC_H +#include "SwapExecC.h" #include "SenderEC.h" #include "Sender_exec_export.h" #include "tao/LocalObject.h" +#include "ace/DLL.h" +#include "ciao/CCM_EventC.h" namespace Sender_Impl { - /** - * @class Sender_exec_i - * - * Sender executor implementation class. - */ - class SENDER_EXEC_Export Sender_exec_i : public virtual Sender_Exec, public virtual TAO_Local_RefCounted_Object @@ -124,11 +121,50 @@ namespace Sender_Impl Sender_exec_i& component_; }; + class SenderSwap_exec_i; + + + typedef ::Components::EnterpriseComponent_ptr (*ExecFactory) (SenderSwap_exec_i *); + /** - * @class SenderHome_exec_i + * @class Sender_exec_i * - * Sender home executor implementation class. + * Sender executor implementation class. */ + + class SENDER_EXEC_Export SenderSwap_exec_i : + public virtual CIAO::Swap_Exec, + public virtual TAO_Local_RefCounted_Object + { + public: + SenderSwap_exec_i (); + + ~SenderSwap_exec_i (); + + virtual ::Components::EnterpriseComponent_ptr + incarnate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Components::EnterpriseComponent_ptr + etherealize (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void consumers (::Components::ConsumerDescriptions *p) + { + this->consumers_ = p; + } + + ::Components::ConsumerDescriptions *consumers (void) + { + return this->consumers_._retn (); + } + + protected: + int count_; + + ::Components::ConsumerDescriptions_var consumers_; + }; + class SENDER_EXEC_Export SenderHome_exec_i : public virtual SenderHome_Exec, public virtual TAO_Local_RefCounted_Object @@ -146,6 +182,8 @@ namespace Sender_Impl create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Components::CCMException)); + + }; } diff --git a/TAO/CIAO/DAnCE/examples/Hello/Sender/starter.cpp b/TAO/CIAO/DAnCE/examples/Hello/Sender/starter.cpp index 2351d71dadc..3fe54c93bdd 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/Sender/starter.cpp +++ b/TAO/CIAO/DAnCE/examples/Hello/Sender/starter.cpp @@ -79,10 +79,19 @@ main (int argc, char *argv[]) -1); } + char *return_message; sender->local_message (message); + return_message = sender->local_message (); + ACE_DEBUG ((LM_DEBUG, "the message is %s\n", return_message)); sender->start (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; + sender->remove (); + + ACE_DEBUG ((LM_DEBUG, "creating one more servant here\n")); + sender->start (ACE_ENV_SINGLE_ARG_PARAMETER); + sender->remove (); + ACE_TRY_CHECK; orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/CIAO/DAnCE/examples/Hello/descriptors/hello.dat b/TAO/CIAO/DAnCE/examples/Hello/descriptors/hello.dat index c92723678c9..0402b2fd2e0 100644 --- a/TAO/CIAO/DAnCE/examples/Hello/descriptors/hello.dat +++ b/TAO/CIAO/DAnCE/examples/Hello/descriptors/hello.dat @@ -1,3 +1,3 @@ -Sender corbaloc:iiop:localhost:30000/NodeManager -Receiver corbaloc:iiop:localhost:40000/NodeManager +Sender corbaloc:iiop:localhost:10000/NodeManager +Receiver corbaloc:iiop:localhost:20000/NodeManager diff --git a/TAO/CIAO/examples/Hello/Sender/New_Sender_svnt.h b/TAO/CIAO/examples/Hello/Sender/New_Sender_svnt.h index 2b836472b87..dc84c44f785 100644 --- a/TAO/CIAO/examples/Hello/Sender/New_Sender_svnt.h +++ b/TAO/CIAO/examples/Hello/Sender/New_Sender_svnt.h @@ -29,6 +29,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +// @@ Jai, is container base required? #include "ciao/Container_Base.h" #include "ciao/Swapping_Container.h" #include "ciao/Servant_Impl_T.h" @@ -91,6 +92,8 @@ namespace Sender_Impl namespace CIAO_GLUE_Hello { + // @@ Jai, this is the actual component servant. Where is the + // servant that actually deploys this servant? class SENDER_SVNT_Export Sender_Servant : public virtual CIAO::Servant_Impl< POA_Hello::Sender, @@ -201,7 +204,7 @@ namespace Sender_Impl ::Components::AlreadyConnected, ::Components::InvalidConnection)); - // CIAO specific operations on the servant + // CIAO specific operations on the servant CORBA::Object_ptr get_facet_executor (const char *name ACE_ENV_ARG_DECL_WITH_DEFAULTS) @@ -221,6 +224,7 @@ namespace Sender_Impl namespace CIAO_GLUE_Hello { + // @@ Jai, where is the home servant for the swapping servant? class SENDER_SVNT_Export SenderHome_Servant : public virtual CIAO::Swapping_Servant_Impl< POA_Hello::SenderHome, @@ -270,4 +274,3 @@ namespace Sender_Impl #include /**/ "ace/post.h" #endif /* CIAO_GLUE_SESSION_SENDER_SVNT_H */ - |