From f88445c51aa625a71b609d3773a245e62943d9c4 Mon Sep 17 00:00:00 2001 From: aky Date: Wed, 22 Jun 2011 18:42:10 +0000 Subject: Wed Jun 22 18:36:14 UTC 2011 Akshay V. Dabholkar --- CIAO/ChangeLog | 79 +++ ...ClientContainerInterceptorRegistration_Impl.cpp | 28 + .../ClientContainerInterceptorRegistration_Impl.h | 57 ++ CIAO/ciao/Containers/Generic/Generic_Container.cpp | 432 +++++++++++++++ CIAO/ciao/Containers/Generic/Generic_Container.h | 172 ++++++ CIAO/ciao/Containers/Generic/Generic_Container.idl | 87 +++ CIAO/ciao/Containers/Generic/Generic_Container.mpc | 73 +++ .../Containers/Generic/Generic_Container_export.h | 78 +++ .../Generic/Generic_Container_stub_export.h | 78 +++ .../Generic/Interceptor_Registration_T.cpp | 97 ++++ .../Generic/Interceptor_Registration_T.h | 90 ++++ ...ervantContainerInterceptorRegistration_Impl.cpp | 28 + .../ServantContainerInterceptorRegistration_Impl.h | 57 ++ ...ServerContainerInterceptorRegistration_Impl.cpp | 28 + .../ServerContainerInterceptorRegistration_Impl.h | 57 ++ .../StubContainerInterceptorRegistration_Impl.cpp | 28 + .../StubContainerInterceptorRegistration_Impl.h | 57 ++ CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl | 35 ++ .../FTComponentServer/CIAO_CS_Client_svnt_export.h | 58 ++ .../CIAO_ComponentInstallation_Impl.cpp | 120 +++++ .../CIAO_ComponentInstallation_Impl.h | 76 +++ .../FTComponentServer/CIAO_ComponentServer.idl | 68 +++ .../FTComponentServer/CIAO_ComponentServer.mpc | 94 ++++ .../ciao/FTComponentServer/CIAO_Container_Impl.cpp | 460 ++++++++++++++++ CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h | 115 ++++ .../FTComponentServer/CIAO_FTComponentServer.cpp | 590 +++++++++++++++++++++ .../FTComponentServer/CIAO_FTComponentServer.h | 78 +++ .../CIAO_FTComponentServer_Impl.cpp | 269 ++++++++++ .../CIAO_FTComponentServer_Impl.h | 78 +++ .../CIAO_FTComponentServer_stub_export.h | 58 ++ .../CIAO_FTComponentServer_svnt_export.h | 58 ++ CIAO/ciao/FTComponentServer/CIAO_Properties.idl | 29 + .../CIAO_ServerActivator_Impl.cpp | 530 ++++++++++++++++++ .../FTComponentServer/CIAO_ServerActivator_Impl.h | 194 +++++++ .../FTComponentServer/CIAO_ServerResources.idl | 268 ++++++++++ .../FTComponentServer/Configurator_Factory.cpp | 49 ++ CIAO/ciao/FTComponentServer/Configurator_Factory.h | 39 ++ .../Configurators/Basic_Config_Manager.cpp | 240 +++++++++ .../Configurators/Basic_Config_Manager.h | 79 +++ .../Configurators/Basic_Config_Manager.inl | 12 + .../Configurators/Basic_Config_Manager_export.h | 58 ++ .../Configurators/Basic_Configurator_export.h | 58 ++ .../ComponentServer_Configurator_export.h | 58 ++ .../Configurators/Config_Manager.cpp | 11 + .../Configurators/Config_Manager.h | 53 ++ .../Configurators/Configurators.mpc | 21 + .../Configurators/NA_Configurator_Export.h | 58 ++ .../NoOp/CIAO_FT_NoOp_Configurator.vcproj | 402 ++++++++++++++ .../Configurators/NoOp/FT_NoOp_Configurator.mpc | 12 + .../Configurators/NoOp/NoOp_Configurator.cpp | 46 ++ .../Configurators/NoOp/NoOp_Configurator.h | 66 +++ .../Configurators/NoOp/NoOp_Configurator_export.h | 58 ++ .../Configurators/RT/RTConfig_Manager.cpp | 513 ++++++++++++++++++ .../Configurators/RT/RTConfig_Manager.h | 138 +++++ .../Configurators/RT/RTConfig_Manager.inl | 8 + .../Configurators/RT/RTNA_Configurator_Export.h | 58 ++ .../Configurators/RTNodeApp_Configurator.cpp | 108 ++++ .../Configurators/RTNodeApp_Configurator.h | 78 +++ .../Configurators/Server_Configurator.cpp | 334 ++++++++++++ .../Configurators/Server_Configurator.h | 125 +++++ CIAO/ciao/FTComponentServer/Name_Helper_T.h | 196 +++++++ 61 files changed, 7582 insertions(+) create mode 100644 CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.cpp create mode 100644 CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h create mode 100644 CIAO/ciao/Containers/Generic/Generic_Container.cpp create mode 100644 CIAO/ciao/Containers/Generic/Generic_Container.h create mode 100644 CIAO/ciao/Containers/Generic/Generic_Container.idl create mode 100644 CIAO/ciao/Containers/Generic/Generic_Container.mpc create mode 100644 CIAO/ciao/Containers/Generic/Generic_Container_export.h create mode 100644 CIAO/ciao/Containers/Generic/Generic_Container_stub_export.h create mode 100644 CIAO/ciao/Containers/Generic/Interceptor_Registration_T.cpp create mode 100644 CIAO/ciao/Containers/Generic/Interceptor_Registration_T.h create mode 100644 CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.cpp create mode 100644 CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h create mode 100644 CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.cpp create mode 100644 CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h create mode 100644 CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.cpp create mode 100644 CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl create mode 100644 CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.cpp create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc create mode 100644 CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp create mode 100644 CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp create mode 100644 CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp create mode 100644 CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_Properties.idl create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h create mode 100644 CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl create mode 100644 CIAO/ciao/FTComponentServer/Configurator_Factory.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurator_Factory.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc create mode 100644 CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/NoOp/CIAO_FT_NoOp_Configurator.vcproj create mode 100644 CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc create mode 100644 CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl create mode 100644 CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp create mode 100644 CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h create mode 100644 CIAO/ciao/FTComponentServer/Name_Helper_T.h diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 40bfa7caa13..4e93fd9a915 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,82 @@ +Wed Jun 22 18:36:14 UTC 2011 Akshay V. Dabholkar + + * ciao/Containers/Generic: + + * ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h: + * ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.cpp: + * ciao/Containers/Generic/Generic_Container.h: + * ciao/Containers/Generic/Generic_Container.idl: + * ciao/Containers/Generic/Generic_Container.mpc: + * ciao/Containers/Generic/Generic_Container.cpp: + * ciao/Containers/Generic/Generic_Container_export.h: + * ciao/Containers/Generic/Generic_Container_stub_export.h: + * ciao/Containers/Generic/Interceptor_Registration_T.h: + * ciao/Containers/Generic/Interceptor_Registration_T.cpp: + * ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h: + * ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.cpp: + * ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h: + * ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.cpp: + * ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h: + * ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.cpp: + + * ciao/FTComponentServer: + + * ciao/FTComponentServer/CIAO_CS_Client.idl: + * ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h: + * ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.h: + * ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.cpp: + * ciao/FTComponentServer/CIAO_ComponentServer.idl: + * ciao/FTComponentServer/CIAO_ComponentServer.mpc: + * ciao/FTComponentServer/CIAO_Container_Impl.h: + * ciao/FTComponentServer/CIAO_Container_Impl.cpp: + * ciao/FTComponentServer/CIAO_FTComponentServer.h: + * ciao/FTComponentServer/CIAO_FTComponentServer.cpp: + * ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h: + * ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp: + * ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h: + * ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h: + * ciao/FTComponentServer/CIAO_Properties.idl: + * ciao/FTComponentServer/CIAO_ServerActivator_Impl.h: + * ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp: + * ciao/FTComponentServer/CIAO_ServerResources.idl: + * ciao/FTComponentServer/Configurator_Factory.h: + * ciao/FTComponentServer/Configurator_Factory.cpp: + * ciao/FTComponentServer/Configurators: + + * ciao/FTComponentServer/Configurators/Basic_Config_Manager.h: + * ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl: + * ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp: + * ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h: + * ciao/FTComponentServer/Configurators/Basic_Configurator_export.h: + * ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h: + * ciao/FTComponentServer/Configurators/Config_Manager.h: + * ciao/FTComponentServer/Configurators/Config_Manager.cpp: + * ciao/FTComponentServer/Configurators/Configurators.mpc: + * ciao/FTComponentServer/Configurators/NA_Configurator_Export.h: + * ciao/FTComponentServer/Configurators/NoOp: + + * ciao/FTComponentServer/Configurators/NoOp/CIAO_FT_NoOp_Configurator.vcproj: + * ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc: + * ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h: + * ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp: + * ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h: + + * ciao/FTComponentServer/Configurators/RT: + + * ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h: + * ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl: + * ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp: + * ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h: + + * ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h: + * ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp: + * ciao/FTComponentServer/Configurators/Server_Configurator.h: + * ciao/FTComponentServer/Configurators/Server_Configurator.cpp: + + * ciao/FTComponentServer/Name_Helper_T.h: + + CORFU merger + Mon Jun 20 15:38:24 UTC 2011 Johnny Willemsen * examples/DevGuideExamples/Messenger/Administrator_exec_i.h: diff --git a/CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.cpp b/CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.cpp new file mode 100644 index 00000000000..8bcdfdfc321 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.cpp @@ -0,0 +1,28 @@ +// $Id$ + +#include "ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h" + +namespace CIAO +{ + ClientContainerInterceptorRegistration_Impl::ClientContainerInterceptorRegistration_Impl (void) + { + } + + ClientContainerInterceptorRegistration_Impl::~ClientContainerInterceptorRegistration_Impl (void) + { + } + + ::Components::Cookie * + ClientContainerInterceptorRegistration_Impl::register_client_interceptor ( + ::Components::ContainerPortableInterceptor::ClientContainerInterceptor_ptr ci) + { + return this->register_interceptor(ci); + } + + ::Components::ContainerPortableInterceptor::ClientContainerInterceptor_ptr + ClientContainerInterceptorRegistration_Impl::unregister_client_interceptor ( + ::Components::Cookie * cookie) + { + return this->unregister_interceptor(cookie); + } +} diff --git a/CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h b/CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h new file mode 100644 index 00000000000..2b2531e9139 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h @@ -0,0 +1,57 @@ +/** + * @file ClientContainerInterceptorRegistration_Impl.h + * + * $Id$ + * + * @author Marcel Smit + */ +#if !defined CLIENTCONTAINERINTERCEPTORREGISTRATION_IMPL_H +#define CLIENTCONTAINERINTERCEPTORREGISTRATION_IMPL_H + +#include /**/ "ace/pre.h" + +#include "ciao/Containers/Generic/Generic_Container_export.h" + +#include "ccm/Extension/CCM_ClientContainerInterceptorC.h" +#include "ccm/Extension/CCM_ClientContainerInterceptorRegistrationC.h" +#include "ciao/Containers/Generic/Interceptor_Registration_T.h" + +namespace CIAO +{ + /** + * @class ClientContainerInterceptorRegistration_Impl + * + * @brief Implementation of the CCM_ClientContainerInterceptorRegistration interface + * + * Implementation of the registration process of Client Container + * Interceptors + * + * Part of COPI (Container Portable Interceptor) + */ + class GENERIC_CONTAINER_Export ClientContainerInterceptorRegistration_Impl + : public Interceptor_Registration_T< + ::Components::ContainerPortableInterceptor::ClientContainerInterceptorRegistration, + ::Components::ContainerPortableInterceptor::ClientContainerInterceptor> + { + public: + ClientContainerInterceptorRegistration_Impl (void); + virtual ~ClientContainerInterceptorRegistration_Impl (void); + + /// Registers a ClientContainerInterceptor. + /// Returns a cookie for this registration. + virtual ::Components::Cookie * + register_client_interceptor ( + ::Components::ContainerPortableInterceptor::ClientContainerInterceptor_ptr ci); + + /// Unregisters a ClientContainerInterceptor. + /// Throws an InvalidRegistration exception when the + /// ClientContainerInterceptor cannot be found. + /// Returns the ClientContainerInterceptor + virtual ::Components::ContainerPortableInterceptor::ClientContainerInterceptor_ptr + unregister_client_interceptor (::Components::Cookie * cookie); + }; +} + +#include /**/ "ace/post.h" + +#endif /* CLIENTCONTAINERINTERCEPTORREGISTRATION_IMPL_H */ diff --git a/CIAO/ciao/Containers/Generic/Generic_Container.cpp b/CIAO/ciao/Containers/Generic/Generic_Container.cpp new file mode 100644 index 00000000000..4aac2c2a35e --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Generic_Container.cpp @@ -0,0 +1,432 @@ +// $Id$ + +#include "Generic_Container.h" + +#include "ciao/Servants/Servant_Impl_Base.h" +#include "ciao/Logger/Log_Macros.h" + +#include "ciao/Containers/Generic/ClientContainerInterceptorRegistration_Impl.h" +#include "ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h" +#include "ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h" +#include "ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h" + +namespace CIAO +{ + /////////////////////////////////////////////////////////////// + + Generic_Container_i::Generic_Container_i ( + CORBA::ORB_ptr o, + PortableServer::POA_ptr poa) + : Container_i < ::CIAO::Generic_Container> (o, poa), + client_copi_registration_ (0), + servant_copi_registration_ (0), + server_copi_registration_ (0), + stub_copi_registration_ (0) + { + } + + Generic_Container_i::~Generic_Container_i (void) + { + } + + void + Generic_Container_i::init (const char *name) + { + CIAO_TRACE ("Generic_Container_i::init"); + + // Create the Portable Interceptor Registration objects + ACE_NEW_THROW_EX (this->client_copi_registration_, + ClientContainerInterceptorRegistration_Impl, + CORBA::NO_MEMORY ()); + ACE_NEW_THROW_EX (this->servant_copi_registration_, + ServantContainerInterceptorRegistration_Impl, + CORBA::NO_MEMORY ()); + ACE_NEW_THROW_EX (this->server_copi_registration_, + ServerContainerInterceptorRegistration_Impl, + CORBA::NO_MEMORY ()); + ACE_NEW_THROW_EX (this->stub_copi_registration_, + StubContainerInterceptorRegistration_Impl, + CORBA::NO_MEMORY ()); + + Container_i < ::CIAO::Generic_Container>::init (name); + } + + void + Generic_Container_i::fini (void) + { + CIAO_TRACE ("Generic_Container_i::fini"); + + ::CORBA::release (this->client_copi_registration_); + ::CORBA::release (this->servant_copi_registration_); + ::CORBA::release (this->server_copi_registration_); + ::CORBA::release (this->stub_copi_registration_); + + Container_i < ::CIAO::Generic_Container>::fini (); + } + + //@@ Apparently we need to be cautious when handling the exception + // thrown here. We should make sure that new DnC interfaces + // NodeApplication/NodeApplicationManager etc will cache the new + // exceptions--> rethrow of new exceptions is needed. + // --Tao + Components::CCMHome_ptr + Generic_Container_i::install_home (const char *primary_artifact, + const char *entry_point, + const char *servant_artifact, + const char *servant_entrypoint, + const char *name) + { + CIAO_TRACE ("Generic_Container_i::install_home"); + + ACE_DLL executor_dll; + ACE_DLL servant_dll; + + Container_i < ::CIAO::Generic_Container>::prepare_installation ("Generic Home", + primary_artifact, + entry_point, + servant_artifact, + servant_entrypoint, + name, + executor_dll, + servant_dll); + + void *void_ptr_executor = executor_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (entry_point)); + void *void_ptr_servant = servant_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (servant_entrypoint)); + + ptrdiff_t tmp_ptr = reinterpret_cast (void_ptr_executor); + HomeFactory hcreator = reinterpret_cast (tmp_ptr); + + tmp_ptr = reinterpret_cast (void_ptr_servant); + HomeServantFactory screator = reinterpret_cast (tmp_ptr); + + if (!hcreator) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_home " + "- Error: Entry point [%C] " + "invalid in dll [%C]\n", + entry_point, + primary_artifact)); + + throw Components::Deployment::ImplEntryPointNotFound (); + } + + if (!screator) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_home" + " - Error: Entry point [%C] " + "invalid in dll [%C]\n", + servant_entrypoint, + servant_artifact)); + + throw Components::Deployment::ImplEntryPointNotFound (); + } + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_home" + " - Loading home executor\n")); + + Components::HomeExecutorBase_var home_executor = + hcreator (); + + if (CORBA::is_nil (home_executor.in ())) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_home - " + "Home executor factory failed.\n")); + + throw Components::Deployment::InstallationFailure (); + } + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_home" + " - Loading home servant\n")); + + PortableServer::Servant home_servant = + screator (home_executor.in (), + this, + name); + + if (home_servant == 0) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_home - " + "Home servant factory failed.\n")); + + throw Components::Deployment::InstallationFailure (); + } + + PortableServer::ServantBase_var safe (home_servant); + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_home " + "- Installing home servant\n")); + + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref = + this->install_servant (home_servant, + Container_Types::HOME_t, + oid.out ()); + + Components::CCMHome_var homeref = + Components::CCMHome::_narrow (objref.in ()); + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_home - " + "Home successfully created with name\n")); + + return homeref._retn (); + } + + Components::CCMObject_ptr + Generic_Container_i::install_component (const char *primary_artifact, + const char *entry_point, + const char *servant_artifact, + const char *servant_entrypoint, + const char *name) + { + CIAO_TRACE ("Generic_Container_i::install_component"); + + ACE_DLL executor_dll; + ACE_DLL servant_dll; + + Container_i < ::CIAO::Generic_Container>::prepare_installation ("Generic Component", + primary_artifact, + entry_point, + servant_artifact, + servant_entrypoint, + name, + executor_dll, + servant_dll); + + void *void_ptr_executor = executor_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (entry_point)); + void *void_ptr_servant = servant_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (servant_entrypoint)); + + ptrdiff_t tmp_ptr = reinterpret_cast (void_ptr_executor); + ComponentFactory ccreator = reinterpret_cast (tmp_ptr); + + tmp_ptr = reinterpret_cast (void_ptr_servant); + ComponentServantFactory screator = reinterpret_cast (tmp_ptr); + + if (ccreator == 0) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_component " + "- Error: Entry point [%C] " + "invalid in dll [%C]\n", + entry_point, + primary_artifact)); + + throw Components::Deployment::ImplEntryPointNotFound (); + } + + if (screator == 0) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_component " + "- Error: Entry point [%C] " + "invalid in dll [%C]\n", + servant_entrypoint, + servant_artifact)); + + throw Components::Deployment::ImplEntryPointNotFound (); + } + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_component - " + "Loading component executor\n")); + + Components::EnterpriseComponent_var component_executor = + ccreator (); + + if (CORBA::is_nil (component_executor.in ())) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_component - " + "Component executor factory failed.\n")); + + throw Components::Deployment::InstallationFailure (); + } + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_component - " + "Loading component servant\n")); + + PortableServer::Servant component_servant = + screator (component_executor.in (), + this, + name); + + if (component_servant == 0) + { + CIAO_ERROR (1, + (LM_ERROR, + CLINFO + "Generic_Container_i::install_component - " + "Component servant factory failed.\n")); + + throw Components::Deployment::InstallationFailure (); + } + + PortableServer::ServantBase_var safe (component_servant); + + CIAO_DEBUG (9, + (LM_TRACE, + CLINFO + "Generic_Container_i::install_component - " + "Installing component servant\n")); + + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref = + this->install_servant (component_servant, + Container_Types::COMPONENT_t, + oid.out ()); + + Components::CCMObject_var componentref = + Components::CCMObject::_narrow (objref.in ()); + + CIAO_DEBUG (9, (LM_TRACE, CLINFO + "Generic_Container_i::install_component - " + "Component successfully created\n")); + + return componentref._retn (); + } + + + Components::Cookie * + Generic_Container_i::install_service_reference (const char * service_id, + CORBA::Object_ptr objref) + { + CIAO_TRACE ("Generic_Container_i::install_service_reference"); + if (this->installed_services_.find(service_id) != + this->installed_services_.end()) + { + throw Components::CCMException (::Components::SERVICE_INSTALLATION_ERROR); + } + + //first create a cookie out of the given object reference. + Components::Cookie_var key_cookie; + ACE_NEW_THROW_EX (key_cookie, + CIAO::Cookie_Impl (reinterpret_cast (objref)), + CORBA::NO_MEMORY ()); + //create a pair of cookie and object reference + std::pair ck_obj; + ck_obj = std::make_pair(key_cookie.in (), CORBA::Object::_duplicate(objref)); + this->installed_services_[service_id] = ck_obj; + + return key_cookie; + } + + CORBA::Object_ptr + Generic_Container_i::uninstall_service_reference (Components::Cookie * ck) + { + CIAO_TRACE ("Generic_Container_i::uninstall_service_reference"); + for (InstalledServices::iterator it = this->installed_services_.begin (); + it != this->installed_services_.end (); + ++it) + { + if (it->second.first == ck) + { + CORBA::Object_ptr obj = it->second.second; + this->installed_services_.erase (it); + return CORBA::Object::_duplicate (obj); + } + } + throw Components::CCMException (::Components::SERVICE_INSTALLATION_ERROR); + } + + CORBA::Object_ptr + Generic_Container_i::resolve_service_reference (const char *service_id) + { + CIAO_TRACE ("Generic_Container_i::resolve_service_reference"); + //search + InstalledServices::iterator it = this->installed_services_.find (service_id); + if (it != this->installed_services_.end ()) + { + return CORBA::Object::_duplicate(it->second.second); + } + // not found. Calling base. + return Container_i< CIAO::Generic_Container >::resolve_service_reference (service_id); + } + + Components::ContainerPortableInterceptor::ClientContainerInterceptorRegistration_ptr + Generic_Container_i::get_client_interceptor_registration (void) + { + CIAO_TRACE ("Generic_Container_i::get_client_interceptor_registration"); + + if (!this->client_copi_registration_) + { + throw Components::CCMException (::Components::REGISTRATION_ERROR); + } + return ::Components::ContainerPortableInterceptor::ClientContainerInterceptorRegistration::_duplicate ( + this->client_copi_registration_); + } + + Components::ContainerPortableInterceptor::ServantContainerInterceptorRegistration_ptr + Generic_Container_i::get_servant_interceptor_registration (void) + { + CIAO_TRACE ("Generic_Container_i::get_servant_interceptor_registration"); + + if (!this->servant_copi_registration_) + { + throw Components::CCMException (::Components::REGISTRATION_ERROR); + } + return ::Components::ContainerPortableInterceptor::ServantContainerInterceptorRegistration::_duplicate ( + this->servant_copi_registration_); + } + + Components::ContainerPortableInterceptor::ServerContainerInterceptorRegistration_ptr + Generic_Container_i::get_server_interceptor_registration (void) + { + CIAO_TRACE ("Generic_Container_i::get_server_interceptor_registration"); + + if (!this->server_copi_registration_) + { + throw Components::CCMException (::Components::REGISTRATION_ERROR); + } + return ::Components::ContainerPortableInterceptor::ServerContainerInterceptorRegistration::_duplicate ( + this->server_copi_registration_); + } + + Components::ContainerPortableInterceptor::StubContainerInterceptorRegistration_ptr + Generic_Container_i::get_stub_interceptor_registration (void) + { + CIAO_TRACE ("Generic_Container_i::get_stub_interceptor_registration"); + + if (!this->stub_copi_registration_) + { + throw Components::CCMException (::Components::REGISTRATION_ERROR); + } + return ::Components::ContainerPortableInterceptor::StubContainerInterceptorRegistration::_duplicate ( + this->stub_copi_registration_); + } +} diff --git a/CIAO/ciao/Containers/Generic/Generic_Container.h b/CIAO/ciao/Containers/Generic/Generic_Container.h new file mode 100644 index 00000000000..56c5db305c0 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Generic_Container.h @@ -0,0 +1,172 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Generic_Container.h + * + * $Id$ + * + * Header file for CIAO's container implementations + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef CIAO_GENERIC_CONTAINER_H +#define CIAO_GENERIC_CONTAINER_H + +#include /**/ "ace/pre.h" + +#include "ciao/Containers/Generic/Generic_Container_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/Servant_Base.h" +#include "ciao/Containers/Container_Base_T.h" +#include "ciao/Containers/Generic/Generic_ContainerC.h" +#include "ccm/CCM_HomeExecutorBaseC.h" +#include "ccm/CCM_EnterpriseComponentC.h" + +#include + +namespace CIAO +{ + class ClientContainerInterceptorRegistration_Impl; + class ServantContainerInterceptorRegistration_Impl; + class ServerContainerInterceptorRegistration_Impl; + class StubContainerInterceptorRegistration_Impl; + + class Servant_Activator; + + typedef ::Components::HomeExecutorBase_ptr (*HomeFactory) (void); + typedef ::PortableServer::Servant (*HomeServantFactory) (::Components::HomeExecutorBase_ptr p, + ::CIAO::Generic_Container_ptr c, + const char *ins_name); + typedef ::Components::EnterpriseComponent_ptr (*ComponentFactory) (void); + typedef ::PortableServer::Servant (*ComponentServantFactory) (::Components::EnterpriseComponent_ptr, + ::CIAO::Generic_Container_ptr, + const char *); + + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + HOMECREATOR_FUNCPTR_MAP; + + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + HOMESERVANTCREATOR_FUNCPTR_MAP; + + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + COMPONENTCREATOR_FUNCPTR_MAP; + + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + COMPONENTSERVANTCREATOR_FUNCPTR_MAP; + + + class GENERIC_CONTAINER_Export Generic_Container_i : + public Container_i < ::CIAO::Generic_Container> + { + public: + Generic_Container_i (CORBA::ORB_ptr o, + PortableServer::POA_ptr poa); + + virtual ~Generic_Container_i (void); + + /// Initialize the container with a name. + virtual void init (const char *name); + + virtual void fini (void); + + /** + * @brief Simply installing a home executor into the component. + * + * This operation install a home executor into the component. It + * requires the name of the DLLs to executor and the servant glue + * code, and the entry points to the respective DLLs. Currently, + * we don't try to manage the lifetime of DLL objects, but we + * should at some later point. + * + * @retval Home objref of the installed home. + */ + /// Install a new home + virtual Components::CCMHome_ptr install_home (const char *primary_artifact, + const char *entry_point, + const char *servant_artifact, + const char *servant_entrypoint, + const char *name); + + /// Install a new component + virtual Components::CCMObject_ptr install_component (const char *primary_artifact, + const char *entry_point, + const char *servant_artifact, + const char *servant_entrypoint, + const char *name); + + // @{ + /// Inherited from extension context. + Components::Cookie * install_service_reference (const char * service_id, + CORBA::Object_ptr objref); + + CORBA::Object_ptr uninstall_service_reference (Components::Cookie * ck); + + CORBA::Object_ptr resolve_service_reference (const char *service_id); + // @} + + // @{ + /** + * Getters for the Containter Portable Interceptor registration + * Objects. + */ + Components::ContainerPortableInterceptor::ClientContainerInterceptorRegistration_ptr + get_client_interceptor_registration (void); + + Components::ContainerPortableInterceptor::ServantContainerInterceptorRegistration_ptr + get_servant_interceptor_registration (void); + + Components::ContainerPortableInterceptor::ServerContainerInterceptorRegistration_ptr + get_server_interceptor_registration (void); + + Components::ContainerPortableInterceptor::StubContainerInterceptorRegistration_ptr + get_stub_interceptor_registration (void); + // @} + + private: + /// Not allowed to be + Generic_Container_i (void); + + /// Administration of installed CCM services + typedef std::map + > InstalledServices; + InstalledServices installed_services_; + + // @{ + /// Caching of the COPI registration objects + /// When a component want to register a Portable Interceptor, it'll + /// need the registration object. + ClientContainerInterceptorRegistration_Impl *client_copi_registration_; + ServantContainerInterceptorRegistration_Impl *servant_copi_registration_; + ServerContainerInterceptorRegistration_Impl *server_copi_registration_; + StubContainerInterceptorRegistration_Impl *stub_copi_registration_; + // @} + }; +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_GENERIC_CONTAINER_H */ diff --git a/CIAO/ciao/Containers/Generic/Generic_Container.idl b/CIAO/ciao/Containers/Generic/Generic_Container.idl new file mode 100644 index 00000000000..07ff8c5c146 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Generic_Container.idl @@ -0,0 +1,87 @@ +/** + * @file Generic_Container.idl + * @author Johnny Willemsen + * $Id$ + * Extends the basic container interface for extension capabilities. + */ + +#include "ciao/Containers/Container_Base.idl" +#include "ccm/Extension/CCM_ClientContainerInterceptorRegistration.idl" +#include "ccm/Extension/CCM_ServantContainerInterceptorRegistration.idl" +#include "ccm/Extension/CCM_ServerContainerInterceptorRegistration.idl" +#include "ccm/Extension/CCM_StubContainerInterceptorRegistration.idl" + +module CIAO +{ + local interface Generic_Container : Container + { + Components::Cookie install_service_reference(in string service_id, in Object objref) + raises (Components::CCMException); + Object uninstall_service_reference(in Components::Cookie ck) + raises (Components::CCMException); + + Components::ContainerPortableInterceptor::ClientContainerInterceptorRegistration + get_client_interceptor_registration () + raises (Components::CCMException); + Components::ContainerPortableInterceptor::ServerContainerInterceptorRegistration + get_server_interceptor_registration () + raises (Components::CCMException); + Components::ContainerPortableInterceptor::StubContainerInterceptorRegistration + get_stub_interceptor_registration() + raises (Components::CCMException); + Components::ContainerPortableInterceptor::ServantContainerInterceptorRegistration + get_servant_interceptor_registration() + raises (Components::CCMException); + }; + + local interface InstanceManager + { + readonly attribute string instance_type; + + readonly attribute ::CORBA::StringSeq dependencies; + + void configure (/*in ::Deployment::Properties config*/); + + void install_instance (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long instanceRef, + out any instance_reference); + /*raises (Deployment::StartError, + Deployment::InvalidProperty, + Deployment::InvalidNodeExecParameter, + Deployment::InvalidComponentExecParameter);*/ + + + void connect_instance (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long connectionRef, + in any provided_reference); + //raises (Deployment::StartError, + // Deployment::InvalidConnection); + + void disconnect_instance (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long connectionRef); + //raises (::Deployment::StopError); + + void instance_configured (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long instanceRef); + //raises (Deployment::StartError); + + void activate_instance (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long instanceRef, + in any instance_re:Dference); + //raises (Deployment::StartError); + + void passivate_instance (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long instanceRef, + in any instance_reference); + //raises (Deployment::StopError); + + void remove_instance (/*in ::Deployment::DeploymentPlan plan,*/ + in unsigned long instanceRef, + in any instance_reference); + //raises (::Deployment::StopError); + + /// Instruct the handler to release any resources prior to deallocation. + void close (); + }; + +}; diff --git a/CIAO/ciao/Containers/Generic/Generic_Container.mpc b/CIAO/ciao/Containers/Generic/Generic_Container.mpc new file mode 100644 index 00000000000..e9f442e6f28 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Generic_Container.mpc @@ -0,0 +1,73 @@ +// -*- MPC -*- +// $Id$ + +project(CIAO_Generic_Container_idl) : install, ciaoidldefaults { + custom_only = 1 + idlflags += -Wb,stub_export_include=Generic_Container_stub_export.h \ + -Wb,stub_export_macro=GENERIC_CONTAINER_STUB_Export \ + -Wb,skel_export_include=Generic_Container_export.h \ + -Wb,skel_export_macro=GENERIC_CONTAINER_Export \ + -Gxhst -SS -Sci -Gxhsk + IDL_Files { + Generic_Container.idl + } + specific { + install_dir = ciao/Containers/Generic + } +} + +project(CIAO_Generic_Container_stub) : install, ccm_stub, ciao_lib, ciao_container_base_stub, utils, ciao_base, \ + ciao_servant_activator_stub { + after += CIAO_Generic_Container_idl + dynamicflags += GENERIC_CONTAINER_STUB_BUILD_DLL + + IDL_Files { + } + Source_Files { + Generic_ContainerC.cpp + } + Inline_Files { + } + Header_Files { + Generic_ContainerC.h + Generic_ContainerS.h + Generic_Container_stub_export.h + } + specific { + install_dir = ciao/Containers/Generic + } +} + +project(CIAO_Generic_Container) : install, ccm_svnt, ciao_lib, ciao_extension_container_stub, utils, \ + ciao_base, ciao_servant_activator, \ + ciao_servant, ccm_extension_stub, portableserver { + after += CIAO_Generic_Container_idl + dynamicflags += GENERIC_CONTAINER_BUILD_DLL + + IDL_Files { + } + Source_Files { + Generic_Container.cpp + ClientContainerInterceptorRegistration_Impl.cpp + ServantContainerInterceptorRegistration_Impl.cpp + ServerContainerInterceptorRegistration_Impl.cpp + StubContainerInterceptorRegistration_Impl.cpp + } + Inline_Files { + } + Header_Files { + Generic_Container.h + Generic_Container_export.h + ClientContainerInterceptorRegistration_Impl.h + ServantContainerInterceptorRegistration_Impl.h + ServerContainerInterceptorRegistration_Impl.h + StubContainerInterceptorRegistration_Impl.h + Interceptor_Registration_T.h + } + Template_Files { + Interceptor_Registration_T.cpp + } + specific { + install_dir = ciao/Containers/Generic + } +} diff --git a/CIAO/ciao/Containers/Generic/Generic_Container_export.h b/CIAO/ciao/Containers/Generic/Generic_Container_export.h new file mode 100644 index 00000000000..44056987cfd --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Generic_Container_export.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +// $Id$ + +/** + * Code generated by the The ACE ORB (TAO) IDL Compiler v2.0.2 + * TAO and the TAO IDL Compiler have been developed by: + * Center for Distributed Object Computing + * Washington University + * St. Louis, MO + * USA + * http://www.cs.wustl.edu/~schmidt/doc-center.html + * and + * Distributed Object Computing Laboratory + * University of California at Irvine + * Irvine, CA + * USA + * and + * Institute for Software Integrated Systems + * Vanderbilt University + * Nashville, TN + * USA + * http://www.isis.vanderbilt.edu/ + * + * Information about TAO is available at: + * http://www.cs.wustl.edu/~schmidt/TAO.html + **/ + +#ifndef GENERIC_CONTAINER_EXPORT_H +#define GENERIC_CONTAINER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (GENERIC_CONTAINER_HAS_DLL) +# define GENERIC_CONTAINER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && GENERIC_CONTAINER_HAS_DLL */ + +#if !defined (GENERIC_CONTAINER_HAS_DLL) +# define GENERIC_CONTAINER_HAS_DLL 1 +#endif /* ! GENERIC_CONTAINER_HAS_DLL */ + +#if defined (GENERIC_CONTAINER_HAS_DLL) && (GENERIC_CONTAINER_HAS_DLL == 1) +# if defined (GENERIC_CONTAINER_BUILD_DLL) +# define GENERIC_CONTAINER_Export ACE_Proper_Export_Flag +# define GENERIC_CONTAINER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define GENERIC_CONTAINER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* GENERIC_CONTAINER_BUILD_DLL */ +# define GENERIC_CONTAINER_Export ACE_Proper_Import_Flag +# define GENERIC_CONTAINER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define GENERIC_CONTAINER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* GENERIC_CONTAINER_BUILD_DLL */ +#else /* GENERIC_CONTAINER_HAS_DLL == 1 */ +# define GENERIC_CONTAINER_Export +# define GENERIC_CONTAINER_SINGLETON_DECLARATION(T) +# define GENERIC_CONTAINER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* GENERIC_CONTAINER_HAS_DLL == 1 */ + +// Set GENERIC_CONTAINER_NTRACE = 0 to turn on library-specific +// tracing even if tracing is turned off for ACE. +#if !defined (GENERIC_CONTAINER_NTRACE) +# if (ACE_NTRACE == 1) +# define GENERIC_CONTAINER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define GENERIC_CONTAINER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !GENERIC_CONTAINER_NTRACE */ + +#if (GENERIC_CONTAINER_NTRACE == 1) +# define GENERIC_CONTAINER_TRACE(X) +#else /* (GENERIC_CONTAINER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define GENERIC_CONTAINER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (GENERIC_CONTAINER_NTRACE == 1) */ + +#endif /* GENERIC_CONTAINER_EXPORT_H */ + diff --git a/CIAO/ciao/Containers/Generic/Generic_Container_stub_export.h b/CIAO/ciao/Containers/Generic/Generic_Container_stub_export.h new file mode 100644 index 00000000000..6d2d79e7a5c --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Generic_Container_stub_export.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +// $Id$ + +/** + * Code generated by the The ACE ORB (TAO) IDL Compiler v2.0.2 + * TAO and the TAO IDL Compiler have been developed by: + * Center for Distributed Object Computing + * Washington University + * St. Louis, MO + * USA + * http://www.cs.wustl.edu/~schmidt/doc-center.html + * and + * Distributed Object Computing Laboratory + * University of California at Irvine + * Irvine, CA + * USA + * and + * Institute for Software Integrated Systems + * Vanderbilt University + * Nashville, TN + * USA + * http://www.isis.vanderbilt.edu/ + * + * Information about TAO is available at: + * http://www.cs.wustl.edu/~schmidt/TAO.html + **/ + +#ifndef GENERIC_CONTAINER_STUB_EXPORT_H +#define GENERIC_CONTAINER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (GENERIC_CONTAINER_STUB_HAS_DLL) +# define GENERIC_CONTAINER_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && GENERIC_CONTAINER_STUB_HAS_DLL */ + +#if !defined (GENERIC_CONTAINER_STUB_HAS_DLL) +# define GENERIC_CONTAINER_STUB_HAS_DLL 1 +#endif /* ! GENERIC_CONTAINER_STUB_HAS_DLL */ + +#if defined (GENERIC_CONTAINER_STUB_HAS_DLL) && (GENERIC_CONTAINER_STUB_HAS_DLL == 1) +# if defined (GENERIC_CONTAINER_STUB_BUILD_DLL) +# define GENERIC_CONTAINER_STUB_Export ACE_Proper_Export_Flag +# define GENERIC_CONTAINER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define GENERIC_CONTAINER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* GENERIC_CONTAINER_STUB_BUILD_DLL */ +# define GENERIC_CONTAINER_STUB_Export ACE_Proper_Import_Flag +# define GENERIC_CONTAINER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define GENERIC_CONTAINER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* GENERIC_CONTAINER_STUB_BUILD_DLL */ +#else /* GENERIC_CONTAINER_STUB_HAS_DLL == 1 */ +# define GENERIC_CONTAINER_STUB_Export +# define GENERIC_CONTAINER_STUB_SINGLETON_DECLARATION(T) +# define GENERIC_CONTAINER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* GENERIC_CONTAINER_STUB_HAS_DLL == 1 */ + +// Set GENERIC_CONTAINER_STUB_NTRACE = 0 to turn on library-specific +// tracing even if tracing is turned off for ACE. +#if !defined (GENERIC_CONTAINER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define GENERIC_CONTAINER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define GENERIC_CONTAINER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !GENERIC_CONTAINER_STUB_NTRACE */ + +#if (GENERIC_CONTAINER_STUB_NTRACE == 1) +# define GENERIC_CONTAINER_STUB_TRACE(X) +#else /* (GENERIC_CONTAINER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define GENERIC_CONTAINER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (GENERIC_CONTAINER_STUB_NTRACE == 1) */ + +#endif /* GENERIC_CONTAINER_STUB_EXPORT_H */ + diff --git a/CIAO/ciao/Containers/Generic/Interceptor_Registration_T.cpp b/CIAO/ciao/Containers/Generic/Interceptor_Registration_T.cpp new file mode 100644 index 00000000000..7fc1a209bc0 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Interceptor_Registration_T.cpp @@ -0,0 +1,97 @@ +// $Id$ + +#include "ciao/Valuetype_Factories/Cookies.h" + +#include +#include +#include +#include + +namespace CIAO +{ + template + Interceptor_Registration_T::Interceptor_Registration_T (void) + { + } + + template + Interceptor_Registration_T::~Interceptor_Registration_T (void) + { + } + + template + size_t + Interceptor_Registration_T::size (void) const + { + return this->interceptors_.size (); + } + + template + typename Interceptor_Registration_T::InterceptorType_ptr_type + Interceptor_Registration_T::interceptor (size_t index) + { + if (index > this->interceptors_.size ()) + { + return COPITYPE::_nil (); + } + typedef std::pair< ::CORBA::UShort, InterceptorCookie > data_t; + + typedef std::vector DataInVector; + DataInVector vec (this->interceptors_.begin(), this->interceptors_.end()); + return COPITYPE::_duplicate (vec.at (index).second.second); + } + + template + typename Interceptor_Registration_T::InterceptorType_ptr_type + Interceptor_Registration_T::interceptor (::Components::Cookie * ck) + { + typename RegisteredInterceptors::iterator it; + for (it = this->interceptors_.begin (); + it != this->interceptors_.end (); + ++it) + { + if (it->second.first.in () == ck) + { + return COPITYPE::_duplicate (it->second.second); + } + } + return COPITYPE::_nil (); + } + + template + ::Components::Cookie * + Interceptor_Registration_T::register_interceptor ( + InterceptorType_ptr_type ict) + { + ::Components::Cookie_var key_cookie; + ACE_NEW_THROW_EX (key_cookie, + Cookie_Impl (reinterpret_cast (ict)), + CORBA::NO_MEMORY ()); + + this->interceptors_.insert ( + std::pair < ::CORBA::UShort, InterceptorCookie > ( + ict->priority (), + InterceptorCookie (key_cookie.in (), ict))); + return key_cookie._retn (); + } + + template + typename Interceptor_Registration_T::InterceptorType_ptr_type + Interceptor_Registration_T::unregister_interceptor ( + ::Components::Cookie *ck) + { + typename RegisteredInterceptors::iterator it; + for (it = this->interceptors_.begin (); + it != this->interceptors_.end (); + ++it) + { + if (it->second.first.in () == ck) + { + InterceptorType_ptr_type interceptor = it->second.second; + this->interceptors_.erase (it); + return COPITYPE::_duplicate (interceptor); + } + } + throw ::Components::ContainerPortableInterceptor::InvalidRegistration (); + } +} diff --git a/CIAO/ciao/Containers/Generic/Interceptor_Registration_T.h b/CIAO/ciao/Containers/Generic/Interceptor_Registration_T.h new file mode 100644 index 00000000000..4eb3ce801d6 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/Interceptor_Registration_T.h @@ -0,0 +1,90 @@ +// -*- C++ -*- + +/** + * @file Interceptor_Registration_T.h + * + * $Id$ + * + * @author Marcel Smit + */ + +#ifndef CIAO_INTERCEPTOR_REGISTRATION_H +#define CIAO_INTERCEPTOR_REGISTRATION_H + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include + +struct priority_compare { + bool operator() (const ::CORBA::UShort& lhs, const ::CORBA::UShort& rhs) const + {return lhs>rhs;} +}; + +namespace CIAO +{ + /** + * @class Interceptor_Registration + * + * @brief Template for Container Portable Interceptor registrations. + * + * Template for the various Container Portable Interceptor lists used + * internally by CIAO. The following Interceptor Types are known: + * - ClientContainerInterceptor + * - ServantContainerInterceptor + * - ServerContainerInterceptor + * - StubContainerInterceptor + * + * Part of COPI (Container Portable Interceptor) + */ + template + class Interceptor_Registration_T + : public BASE + { + protected : + /// Constructor. + Interceptor_Registration_T (void); + ~Interceptor_Registration_T (void); + + /// Define the traits for the underlying portable interceptor array. + typedef typename COPITYPE::_ptr_type InterceptorType_ptr_type; + + /// Return the Cookie of a new registered interceptor. + ::Components::Cookie *register_interceptor ( + InterceptorType_ptr_type ict); + + /// Removes a registered interceptor from the list. The registered + /// interceptor is indicated by a cookie. If the passed cookie + /// cannot be found in the list, a InvalidRegistration exception + /// will be thrown. + /// Returns the interceptor found. + InterceptorType_ptr_type unregister_interceptor ( + ::Components::Cookie *ck); + + public: + /// List accessors. + size_t size (void) const; + InterceptorType_ptr_type interceptor (size_t index); + + /// Return the interceptor with the given cookie. + InterceptorType_ptr_type interceptor (::Components::Cookie *ck); + + private: + /// Dynamic array of registered interceptors. + typedef std::pair< ::Components::Cookie_var, + InterceptorType_ptr_type> + InterceptorCookie; + + typedef std::multimap< ::CORBA::UShort, + InterceptorCookie, + priority_compare > + RegisteredInterceptors; + + RegisteredInterceptors interceptors_; + }; +} + +#include "ciao/Containers/Generic/Interceptor_Registration_T.cpp" + +#endif /* CIAO_INTERCEPTOR_REGISTRATION_H */ diff --git a/CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.cpp b/CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.cpp new file mode 100644 index 00000000000..ca8dd16cc39 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.cpp @@ -0,0 +1,28 @@ +// $Id$ + +#include "ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h" + +namespace CIAO +{ + ServantContainerInterceptorRegistration_Impl::ServantContainerInterceptorRegistration_Impl (void) + { + } + + ServantContainerInterceptorRegistration_Impl::~ServantContainerInterceptorRegistration_Impl (void) + { + } + + ::Components::Cookie * + ServantContainerInterceptorRegistration_Impl::register_servant_interceptor ( + ::Components::ContainerPortableInterceptor::ServantContainerInterceptor_ptr ci) + { + return this->register_interceptor(ci); + } + + ::Components::ContainerPortableInterceptor::ServantContainerInterceptor_ptr + ServantContainerInterceptorRegistration_Impl::unregister_servant_interceptor ( + ::Components::Cookie * cookie) + { + return this->unregister_interceptor(cookie); + } +} diff --git a/CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h b/CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h new file mode 100644 index 00000000000..7620dbb25f5 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/ServantContainerInterceptorRegistration_Impl.h @@ -0,0 +1,57 @@ +/** + * @file ServantContainerInterceptorRegistration_Impl.h + * + * $Id$ + * + * @author Marcel Smit + */ +#if !defined SERVANTCONTAINERINTERCEPTORREGISTRATION_IMPL_H +#define SERVANTCONTAINERINTERCEPTORREGISTRATION_IMPL_H + +#include /**/ "ace/pre.h" + +#include "ciao/Containers/Generic/Generic_Container_export.h" + +#include "ccm/Extension/CCM_ServantContainerInterceptorC.h" +#include "ccm/Extension/CCM_ServantContainerInterceptorRegistrationC.h" +#include "ciao/Containers/Generic/Interceptor_Registration_T.h" + +namespace CIAO +{ + /** + * @class ServantContainerInterceptorRegistration_Impl + * + * @brief Implementation of the CCM_ServantContainerInterceptorRegistration interface + * + * Implementation of the registration process of Servant Container + * Interceptors + * + * Part of COPI (Container Portable Interceptor) + */ + class GENERIC_CONTAINER_Export ServantContainerInterceptorRegistration_Impl + : public Interceptor_Registration_T< + ::Components::ContainerPortableInterceptor::ServantContainerInterceptorRegistration, + ::Components::ContainerPortableInterceptor::ServantContainerInterceptor> + { + public: + ServantContainerInterceptorRegistration_Impl (void); + virtual ~ServantContainerInterceptorRegistration_Impl (void); + + /// Registers a ServantContainerInterceptor. + /// Returns a cookie for this registration. + virtual ::Components::Cookie * + register_servant_interceptor ( + ::Components::ContainerPortableInterceptor::ServantContainerInterceptor_ptr ci); + + /// Unregisters a ServantContainerInterceptor. + /// Throws an InvalidRegistration exception when the + /// ServantContainerInterceptor cannot be found. + /// Returns the ServantContainerInterceptor + virtual ::Components::ContainerPortableInterceptor::ServantContainerInterceptor_ptr + unregister_servant_interceptor (::Components::Cookie * cookie); + }; +} + +#include /**/ "ace/post.h" + +#endif /* CCM_SERVANTCONTAINERINTERCEPTORREGISTRATION_IMPL_H */ diff --git a/CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.cpp b/CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.cpp new file mode 100644 index 00000000000..0c21bbebb1e --- /dev/null +++ b/CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.cpp @@ -0,0 +1,28 @@ +// $Id$ + +#include "ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h" + +namespace CIAO +{ + ServerContainerInterceptorRegistration_Impl::ServerContainerInterceptorRegistration_Impl (void) + { + } + + ServerContainerInterceptorRegistration_Impl::~ServerContainerInterceptorRegistration_Impl (void) + { + } + + ::Components::Cookie * + ServerContainerInterceptorRegistration_Impl::register_server_interceptor ( + ::Components::ContainerPortableInterceptor::ServerContainerInterceptor_ptr ci) + { + return this->register_interceptor(ci); + } + + ::Components::ContainerPortableInterceptor::ServerContainerInterceptor_ptr + ServerContainerInterceptorRegistration_Impl::unregister_server_interceptor ( + ::Components::Cookie * cookie) + { + return this->unregister_interceptor(cookie); + } +} diff --git a/CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h b/CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h new file mode 100644 index 00000000000..9a9b6aea1d8 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/ServerContainerInterceptorRegistration_Impl.h @@ -0,0 +1,57 @@ +/** + * @file ServerContainerInterceptorRegistration_Impl.h + * + * $Id$ + * + * @author Marcel Smit + */ +#if !defined SERVERCONTAINERINTERCEPTORREGISTRATION_IMPL_H +#define CCM_SERVERCONTAINERINTERCEPTORREGISTRATION_IMPL_H + +#include /**/ "ace/pre.h" + +#include "ciao/Containers/Generic/Generic_Container_export.h" + +#include "ccm/Extension/CCM_ServerContainerInterceptorC.h" +#include "ccm/Extension/CCM_ServerContainerInterceptorRegistrationC.h" +#include "ciao/Containers/Generic/Interceptor_Registration_T.h" + +namespace CIAO +{ + /** + * @class ServerContainerInterceptorRegistration_Impl + * + * @brief Implementation of the CCM_ServerContainerInterceptorRegistration interface + * + * Implementation of the registration process of Server Container + * Interceptors + * + * Part of COPI (Container Portable Interceptor) + */ + class GENERIC_CONTAINER_Export ServerContainerInterceptorRegistration_Impl + : public Interceptor_Registration_T< + ::Components::ContainerPortableInterceptor::ServerContainerInterceptorRegistration, + ::Components::ContainerPortableInterceptor::ServerContainerInterceptor> + { + public: + ServerContainerInterceptorRegistration_Impl (void); + virtual ~ServerContainerInterceptorRegistration_Impl (void); + + /// Registers a ServerContainerInterceptor. + /// Return a cookie for this registration. + virtual ::Components::Cookie * + register_server_interceptor ( + ::Components::ContainerPortableInterceptor::ServerContainerInterceptor_ptr ci); + + /// Unregisters a ServerContainerInterceptor. + /// Throws an InvalidRegistration exception when the + /// ServerContainerInterceptor cannot be found. + /// Returns the ServerContainerInterceptor + virtual ::Components::ContainerPortableInterceptor::ServerContainerInterceptor_ptr + unregister_server_interceptor (::Components::Cookie * cookie); + }; +} + +#include /**/ "ace/post.h" + +#endif /* CCM_SERVERCONTAINERINTERCEPTORREGISTRATION_IMPL_H */ diff --git a/CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.cpp b/CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.cpp new file mode 100644 index 00000000000..4cab9831382 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.cpp @@ -0,0 +1,28 @@ +// $Id$ + +#include "ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h" + +namespace CIAO +{ + StubContainerInterceptorRegistration_Impl::StubContainerInterceptorRegistration_Impl (void) + { + } + + StubContainerInterceptorRegistration_Impl::~StubContainerInterceptorRegistration_Impl (void) + { + } + + ::Components::Cookie * + StubContainerInterceptorRegistration_Impl::register_stub_interceptor ( + ::Components::ContainerPortableInterceptor::StubContainerInterceptor_ptr ci) + { + return this->register_interceptor(ci); + } + + ::Components::ContainerPortableInterceptor::StubContainerInterceptor_ptr + StubContainerInterceptorRegistration_Impl::unregister_stub_interceptor ( + ::Components::Cookie * cookie) + { + return this->unregister_interceptor(cookie); + } +} diff --git a/CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h b/CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h new file mode 100644 index 00000000000..11ce78b1731 --- /dev/null +++ b/CIAO/ciao/Containers/Generic/StubContainerInterceptorRegistration_Impl.h @@ -0,0 +1,57 @@ +/** + * @file StubContainerInterceptorRegistration_Impl.h + * + * $Id$ + * + * @author Marcel Smit + */ +#if !defined STUBCONTAINERINTERCEPTORREGISTRATION_IMPL_H +#define STUBCONTAINERINTERCEPTORREGISTRATION_IMPL_H + +#include /**/ "ace/pre.h" + +#include "ciao/Containers/Generic/Generic_Container_export.h" + +#include "ccm/Extension/CCM_StubContainerInterceptorC.h" +#include "ccm/Extension/CCM_StubContainerInterceptorRegistrationC.h" +#include "ciao/Containers/Generic/Interceptor_Registration_T.h" + +namespace CIAO +{ + /** + * @class StubContainerInterceptorRegistration_Impl + * + * @brief Implementation of the CCM_ServerContainerInterceptorRegistration interface + * + * Implementation of the registration process of Server Container + * Interceptors + * + * Part of COPI (Container Portable Interceptor) + */ + class GENERIC_CONTAINER_Export StubContainerInterceptorRegistration_Impl + : public Interceptor_Registration_T< + ::Components::ContainerPortableInterceptor::StubContainerInterceptorRegistration, + ::Components::ContainerPortableInterceptor::StubContainerInterceptor> + { + public: + StubContainerInterceptorRegistration_Impl (void); + virtual ~StubContainerInterceptorRegistration_Impl (void); + + /// Registers a StubContainerInterceptor. + /// Returns a cookie for this registration. + virtual ::Components::Cookie * + register_stub_interceptor ( + ::Components::ContainerPortableInterceptor::StubContainerInterceptor_ptr ci); + + /// Unregisters a StubContainerInterceptor. + /// Throws an InvalidRegistration exception when the + /// StubContainerInterceptor cannot be found. + /// Returns the StubContainerInterceptor + virtual ::Components::ContainerPortableInterceptor::StubContainerInterceptor_ptr + unregister_stub_interceptor (::Components::Cookie * cookie); + }; +} + +#include /**/ "ace/post.h" + +#endif /* STUBCONTAINERINTERCEPTORREGISTRATION_IMPL_H */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl b/CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl new file mode 100644 index 00000000000..883c87450d3 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl @@ -0,0 +1,35 @@ +/** + * @file CIAO_CS_Client.idl + * @author William R. Otte + * + * A couple CIAO-specific extensions to the component server client + * interfaces. + */ + +#ifndef CIAO_COMPONENTSERVER_IDL_ +#define CIAO_COMPONENTSERVER_IDL_ + +#include + +module CIAO +{ + module Deployment + { + interface ServerActivator : ::Components::Deployment::ServerActivator + { + /// Used by spawned component servers to notify the server + /// activator of their object reference and retrieve + /// configuration information. + void component_server_callback (in ::Components::Deployment::ComponentServer serverref, + in string server_UUID, + out ::Components::ConfigValues config); + + void configuration_complete (in string server_UUID); + }; + }; +}; + + +#endif + + diff --git a/CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h b/CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h new file mode 100644 index 00000000000..32a2ea33fd5 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_CS_Client_svnt +// ------------------------------ +#ifndef CIAO_CS_CLIENT_SVNT_EXPORT_H +#define CIAO_CS_CLIENT_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) +# define CIAO_CS_CLIENT_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_CS_CLIENT_SVNT_HAS_DLL */ + +#if !defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) +# define CIAO_CS_CLIENT_SVNT_HAS_DLL 1 +#endif /* ! CIAO_CS_CLIENT_SVNT_HAS_DLL */ + +#if defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) && (CIAO_CS_CLIENT_SVNT_HAS_DLL == 1) +# if defined (CIAO_CS_CLIENT_SVNT_BUILD_DLL) +# define CIAO_CS_Client_svnt_Export ACE_Proper_Export_Flag +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_CS_CLIENT_SVNT_BUILD_DLL */ +# define CIAO_CS_Client_svnt_Export ACE_Proper_Import_Flag +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_CS_CLIENT_SVNT_BUILD_DLL */ +#else /* CIAO_CS_CLIENT_SVNT_HAS_DLL == 1 */ +# define CIAO_CS_Client_svnt_Export +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_CS_CLIENT_SVNT_HAS_DLL == 1 */ + +// Set CIAO_CS_CLIENT_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_CS_CLIENT_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_CS_CLIENT_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_CS_CLIENT_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_CS_CLIENT_SVNT_NTRACE */ + +#if (CIAO_CS_CLIENT_SVNT_NTRACE == 1) +# define CIAO_CS_CLIENT_SVNT_TRACE(X) +#else /* (CIAO_CS_CLIENT_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_CS_CLIENT_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_CS_CLIENT_SVNT_NTRACE == 1) */ + +#endif /* CIAO_CS_CLIENT_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.cpp new file mode 100644 index 00000000000..5492df95404 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.cpp @@ -0,0 +1,120 @@ +// $Id$ + +#include "ComponentInstallation_Impl.h" +#include "DAnCE/Logger/Log_Macros.h" + +using namespace DAnCE; + +ComponentInstallation_Impl::ComponentInstallation_Impl() +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::ComponentInstallation_Impl - started\n")); + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::ComponentInstallation_Impl - finished\n")); +} + +ComponentInstallation_Impl::~ComponentInstallation_Impl() +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::~ComponentInstallation_Impl - started\n")); + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::~ComponentInstallation_Impl - finished\n")); +} + +void +ComponentInstallation_Impl::install (const char * implUUID, const char * component_loc) +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::install - started\n")); + + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::install - implUUID %s, component_loc %s\n", implUUID, component_loc)); + if (0 != this->locations_.find (implUUID)) + { + ACE_CString location = component_loc; + this->locations_.bind (implUUID, location); + } + else + { + // I don't certaint that we should throw exception here + //throw ::Components::Deployment::InstallationFailure(); + } + + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::install - finished\n")); +} + + +void +ComponentInstallation_Impl::replace (const char * , const char *) +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::replace - started\n")); + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::replace - finished\n")); +} + +void +ComponentInstallation_Impl::remove (const char *) +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::remove - started\n")); + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::remove - finished\n")); +} + +char * +ComponentInstallation_Impl::get_implementation (const char * implUUID) +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::get_implementation - started\n")); + + ACE_CString s; + if (0 == this->locations_.find (implUUID, s)) + { + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::get_implementation - ComponentInstallation_Impl::get_implementation for UUID %s, location %s\n", implUUID, s.c_str())); + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::get_implementation - finished\n")); + return CORBA::string_dup (s.c_str()); + } + else + { + DANCE_ERROR ( (LM_ERROR, "[%M] ComponentInstallation_Impl::get_implementation - cannot find location for specified implementation UUID\n")); + throw ::Components::Deployment::UnknownImplId(); + return 0; + } +} + + +char * +ComponentInstallation_Impl::get_valuetypefactory_location ( + const char * implUUID, + const char * repid +) +{ + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::get_valuetypefactory_location - started\n")); + ACE_CString key = ComponentInstallation_Impl::valuefactory_key (implUUID, repid); + ACE_CString s; + if (0 == this->locations_.find (implUUID, s)) + { + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::get_valuetypefactory_location - UUID:\"%s\" repid:\"%s\" -> location:\"%s\"\n", implUUID, repid, s.c_str())); + return CORBA::string_dup (s.c_str()); + } + else + { + DANCE_ERROR ( (LM_ERROR, "[%M] ComponentInstallation_Impl::get_valuetypefactory_location - cannot find location for specified implementation UUID and repid.\n")); + throw ::Components::Deployment::InstallationFailure(); + return 0; + } + DANCE_DEBUG ( (LM_DEBUG, "[%M] ComponentInstallation_Impl::get_valuetypefactory_location - finished\n")); + return 0; +} + + +void +ComponentInstallation_Impl::install_valuetypefactory_location ( + const char * implUUID, + const char * repid, + const char * loc +) +{ + ACE_CString key = ComponentInstallation_Impl::valuefactory_key (implUUID, repid); + if (0 != this->locations_.find (key)) + { + ACE_CString location = loc; + this->locations_.bind (implUUID, location); + } + else + { + // I don't certaint that we should throw exception here + //throw ::Components::Deployment::InstallationFailure(); + } +} + diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.h new file mode 100644 index 00000000000..c291adcb346 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentInstallation_Impl.h @@ -0,0 +1,76 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CIAO_ComponentInstallation_Impl.h + * + * $Id$ + * + * @Brief Return location of component artifact + * + * @author Erwin Gottlieb + */ +//============================================================================= + +#ifndef COMPONENTINSTALLATION_IMPL_H_ +#define COMPONENTINSTALLATION_IMPL_H_ + +#include "ace/Map_Manager.h" +#include "ccm/CCM_ComponentC.h" + +#include "Cdmw/CDMW_DeploymentS.h" +#include "tao/ORB.h" +#include "NodeApplication_Export.h" + +namespace DAnCE + { + + class NodeApplication_Export ComponentInstallation_Impl + : public virtual POA_CdmwDeployment::ComponentInstallation + { + public: + ComponentInstallation_Impl(); + + virtual ~ComponentInstallation_Impl(); + + virtual void install ( + const char * implUUID, + const char * component_loc + ); + + virtual void replace ( + const char * implUUID, + const char * component_loc + ); + + virtual void remove ( + const char * implUUID + ); + + virtual char * get_implementation ( + const char * implUUID + ); + + virtual char * get_valuetypefactory_location ( + const char * implUUID, + const char * repid + ); + + void install_valuetypefactory_location ( + const char * implUUID, + const char * repid, + const char * loc + ); + + private: + typedef ACE_Map_Manager< ACE_CString, ACE_CString, ACE_Null_Mutex > TLocations; + TLocations locations_; + + static ACE_CString valuefactory_key (const char* uuid, const char* repid) + { + return ACE_CString (repid) + "@" + uuid; + }; + }; + +}; +#endif /*COMPONENTINSTALLATION_IMPL_H_*/ diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl new file mode 100644 index 00000000000..69c1bdc1e00 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl @@ -0,0 +1,68 @@ +/** + * @file CIAO_ComponentServer.idl + * @author William R. Otte + * + * $Id$ + * + * A couple CIAO-specific extensions to the component server + * interfaces. + */ + +#ifndef CIAO_COMPONENTSERVER_IDL_ +#define CIAO_COMPONENTSERVER_IDL_ + +#include +#include + +module CIAO +{ + module Deployment + { + interface ComponentServer : ::Components::Deployment::ComponentServer + { + oneway void shutdown (); + }; + + exception InvalidComponent + { + }; + + /** + * @interface CIAO_Container + * @brief CIAO specific extensions to the component server interface. + */ + interface Container : Components::Deployment::Container + { + /// Instruct the container to install a component without + /// an explicit home. + ::Components::CCMObject install_component (in ::Components::Deployment::UUID id, + in string entrypt, + in ::Components::ConfigValues config) + raises (::Components::Deployment::UnknownImplId, + ::Components::Deployment::ImplEntryPointNotFound, + ::Components::Deployment::InstallationFailure, + ::Components::Deployment::InvalidConfiguration); + + /// Activate component with specified ID, if no ID provided, + /// activates all components. + void activate_component (in ::Components::CCMObject comp) + raises (InvalidComponent); + + /// Passivate component with specified ID, if no ID provided, + /// passivates all components. + void passivate_component (in ::Components::CCMObject comp) + raises (InvalidComponent); + + /// Instruct the container to remove a component installed + /// without an explicit home. If the component was installed + /// with an explicit home, this operation will fail. + void remove_component (in ::Components::CCMObject cref) + raises (::Components::RemoveFailure); + + /// Returns a sequence of all homeless components. + ::Components::CCMObjectSeq get_components (); + }; + }; +}; + +#endif /* CIAO_COMPONENTSERVER_IDL_ */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc new file mode 100644 index 00000000000..62e17d7d7ad --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc @@ -0,0 +1,94 @@ +project(CIAO_FTComponentServer_IDL) : ciaoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_FTComponentServer_stub_Export + idlflags += -Wb,stub_export_include=CIAO_FTComponentServer_stub_export.h + idlflags += -Wb,skel_export_macro=CIAO_FTComponentServer_svnt_Export + idlflags += -Wb,skel_export_include=CIAO_FTComponentServer_svnt_export.h + + custom_only=1 + + IDL_Files { + CIAO_ComponentServer.idl + CIAO_ServerResources.idl + } +} + +project(CIAO_FTCS_Client_IDL) : ciaoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_FTComponentServer_stub_Export + idlflags += -Wb,stub_export_include=CIAO_FTComponentServer_stub_export.h + idlflags += -Wb,skel_export_macro=CIAO_CS_Client_svnt_Export + idlflags += -Wb,skel_export_include=CIAO_CS_Client_svnt_export.h + + custom_only=1 + + IDL_Files { + CIAO_CS_Client.idl + CIAO_Properties.idl + } +} + +project(CIAO_FTComponentServer_stub) : ccm_componentserver_stub, ciaolib_with_idl, ciao_output, \ + messaging, anytypecode, ciao_lib { + after += CIAO_FTComponentServer_IDL CIAO_FTCS_Client_IDL + dynamicflags = CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL + + IDL_Files { + } + Source_Files { + CIAO_ComponentServerC.cpp + CIAO_CS_ClientC.cpp + CIAO_ServerResourcesC.cpp + CIAO_PropertiesC.cpp + } + Header_Files { + CIAO_FTComponentServer_stub_export.h + } +} + +project(CIAO_FTCS_Client_svnt) : ccm_svnt, ccm_componentserver_svnt, ciao_ft_componentserver_stub, portableserver, ciao_client, ciao_lib { + dynamicflags = CIAO_CS_CLIENT_SVNT_BUILD_DLL + after += CIAO_FTCS_Client_IDL CIAO_FTComponentServer_stub + + IDL_Files { + } + Source_Files { + CIAO_ServerActivator_Impl.cpp + CIAO_CS_ClientS.cpp + } + Header_Files { + CIAO_ServerActivator_Impl.h + CIAO_CS_ClientS.h + CIAO_CS_Client_svnt_export.h + } +} + +project(CIAO_FTComponentServer_svnt) : ccm_componentserver_svnt, ciao_ft_componentserver_stub, portableserver, ciao_ft_componentserver_configurator, ciao_ft_session_container, naming, ciao_server { + + dynamicflags = CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL + + IDL_Files { + } + Source_Files { + CIAO_FTComponentServer_Impl.cpp + CIAO_ComponentServerS.cpp + CIAO_ServerResourcesS.cpp + CIAO_Container_Impl.cpp + Configurator_Factory.cpp + } + Header_Files { + CIAO_FTComponentServer_svnt_export.h + } +} + +project(CIAO_FTComponentServer_exe) : ccm_componentserver_svnt, portableserver, ciao_ft_componentserver_svnt, messaging, anytypecode, ciao_server, ciaoexe, ciao_ft_session_container, pi_server, iorinterceptor {// , rtcorba + exename = ciao_ft_componentserver + libs += CIAO_FT_Basic_Configurator CIAO_Logger LWFT_StateSyncAgent LWFT_ReplicationManager LWFT_Client LWFT_Server + after += CIAO_FT_Basic_Configurator CIAO_Logger + macros += CIAO_BUILD_COMPONENTSERVER_EXE + includes += $(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + + Source_Files { + CIAO_FTComponentServer.cpp + } + IDL_Files { + } +} diff --git a/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp new file mode 100644 index 00000000000..5a08aaea716 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp @@ -0,0 +1,460 @@ +// $Id$ +#include "CIAO_Container_Impl.h" + +#include "ace/Log_Msg.h" +#include "ccm/CCM_HomeC.h" +#include "ciao/CIAO_common.h" +#include "ciao/Server_init.h" +#include "ciao/Client_init.h" +#include "CIAO_PropertiesC.h" + +namespace CIAO +{ + namespace Deployment + { + // Constructor + CIAO_Container_i::CIAO_Container_i (const Components::ConfigValues &config, + const Static_Config_EntryPoints_Maps *static_entrypts, + const char *name, + const CORBA::PolicyList *policies, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + config_ (config.length ()), + static_entrypts_maps_ (static_entrypts) + { + CIAO_TRACE("CIAO_Container_i::CIAO_Container_i"); + + for (CORBA::ULong i = 0; i < config.length (); ++i) + { + this->config_[i] = config[i]; + } + + try + { + if (this->static_entrypts_maps_ == 0) + { + CIAO_DEBUG((LM_DEBUG, CLINFO "CIAO_Container_i: creating FT Session container with dynamic linkage\n")); + this->container_ = new CIAO::FT_Session_Container (this->orb_.in (), this, false, + 0, name, policies); + } + else + { + CIAO_DEBUG((LM_DEBUG, CLINFO "CIAO_Container_i: creating FT Session container with static linkage\n")); + this->container_ = new CIAO::FT_Session_Container (this->orb_.in (), this, true, + this->static_entrypts_maps_, + name, policies); + } + } + catch (...) + { + CIAO_ERROR((LM_ERROR, CLINFO "CIAO_Container_i::CIAO_Container_i - " + "Caught exception while allocating container implementation\n")); + throw; + } + } + + + // Destructor + CIAO_Container_i::~CIAO_Container_i (void) + { + CIAO_TRACE("CIAO_Container_i::~CIAO_Container_i"); + } + + ::Components::CCMObject_ptr + CIAO_Container_i::install_component (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_Container_i::install_component"); + + const char *tmp; + CORBA::String_var name; + + CIAO::Utility::CONFIGVALUE_MAP cm; + CIAO::Utility::build_config_values_map (cm, config); + CORBA::Any val; + + if (cm.find (OBJECT_ID, val) == 0) + { + val >>= tmp; + name = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found ObjectId %C\n", name.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Found no ObjectId property, using component id instead\n")); + name = id; + } + + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_component - " + "No home ID provided\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + Components::CCMObject_var comp; + + if (this->component_map_.find (name.in (), comp) == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_component - " + "Component with id %C already installed, aborting\n", + name.in ())); + throw Components::CreateFailure (); + } + + if (entrypt == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_component - " + "No executor entrypoint found.\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::install_component - " + "Attempting to install home with id [%C]\n", + name.in ())); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Extracting ConfigValues from sequence of length [%u]\n", + config.length ())); + + CORBA::String_var exec_art, svnt_art, svnt_entry; + + if (cm.find (SVNT_ENTRYPT, val) == 0) + { + val >>= tmp; + svnt_entry = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found Servant entrypoint %C\n", svnt_entry.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Error: No Servant entrypoint porovided, aborting installation\n")); + throw Components::InvalidConfiguration (); + } + + if (cm.find (SVNT_ARTIFACT, val) == 0) + { + val >>= tmp; + svnt_art = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found Servant artifact %C\n", svnt_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Error: No Servant artifact porovided, aborting installation\n")); + throw Components::InvalidConfiguration (); + } + + + if (cm.find (EXEC_ARTIFACT, val) == 0) + { + val >>= tmp; + exec_art = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found executor artifact: %C\n", exec_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Error: No Executor artifact porovided, aborting installation\n")); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Extraction resulted in map of [%u] values\n", cm.current_size ())); + + comp = this->container_->install_component (exec_art, + entrypt, + svnt_art, + svnt_entry, + name.in ()); + + if (this->component_map_.bind (name.in (), + Components::CCMObject::_duplicate (comp.in ())) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Unable to bind componnet into component map\n")); + } + + + return comp._retn (); + } + + void + CIAO_Container_i::remove_component (::Components::CCMObject_ptr /*cref*/) + { + CIAO_TRACE("CIAO_Container_i::remove_component"); + throw CORBA::NO_IMPLEMENT (); + } + + ::Components::CCMObjectSeq * + CIAO_Container_i::get_components (void) + { + CIAO_TRACE("CIAO_Container_i::get_components"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::ConfigValues * + CIAO_Container_i::configuration (void) + { + CIAO_TRACE("CIAO_Container_i::configuration"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::Deployment::ComponentServer_ptr + CIAO_Container_i::get_component_server (void) + { + CIAO_TRACE("CIAO_Container_i::get_component_server"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::CCMHome_ptr + CIAO_Container_i::install_home (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_Container_i::install_home"); + + if (id == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "No home ID provided\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + Components::CCMHome_var home; + + if (this->home_map_.find (id, home) == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "Home with id %C already installed, aborting\n", + id)); + throw Components::CreateFailure (); + } + + if (entrypt == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "No executor entrypoint found.\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::install_home - " + "Attempting to install home with id [%C]\n", id)); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Extracting ConfigValues from sequence of length [%u]\n", + config.length ())); + + CIAO::Utility::CONFIGVALUE_MAP cm; + CIAO::Utility::build_config_values_map (cm, config); + CORBA::Any val; + + const char *tmp = 0; + CORBA::String_var exec_art, svnt_art, svnt_entry; + if (cm.find (SVNT_ENTRYPT, val) == 0) + { + val >>= tmp; + svnt_entry = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found Servant entrypoint %C\n", svnt_entry.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Servant entrypoint porovided, aborting installation\n")); + throw Components::InvalidConfiguration (); + } + + if (cm.find (SVNT_ARTIFACT, val) == 0) + { + val >>= tmp; + svnt_art = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found Servant artifact %C\n", svnt_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Servant artifact porovided, aborting installation\n")); + throw Components::InvalidConfiguration (); + } + + + if (cm.find (EXEC_ARTIFACT, val) == 0) + { + val >>= tmp; + exec_art = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found executor artifact: %C\n", exec_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Executor artifact porovided, aborting installation\n")); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Extraction resulted in map of [%u] values\n", cm.current_size ())); + + + // extract config values here... + + //CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_Container_i::install_home - ", + //"Executor entrypoint [%C], servant entrypoint [%C], servant library [%C]\n", + //entrypt, svnt_entrypt.in (), svnt_library.in ())); + + home = this->container_->install_home (exec_art, + entrypt, + svnt_art, + svnt_entry, + id); + + if (this->home_map_.bind (id, + Components::CCMHome::_duplicate (home.in ())) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Unable to bind home into home map\n")); + } + + return home._retn (); + } + + void + CIAO_Container_i::remove_home (::Components::CCMHome_ptr href) + { + CIAO_TRACE("CIAO_Container_i::remove_home"); + + ::Components::CCMHome_var home (href); + + Home_Iterator i = this->home_map_.begin (); + while (!i.done ()) + { + if (i->item ()->_is_equivalent (home.in ())) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " + "Successfully found matching home\n")); + break; + } + i.advance (); + } + + if (i.done ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::remove_home - " + "Unable to find matching home managed by this container, throwing RemoveFailure\n")); + throw Components::RemoveFailure (); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " + "Invoking remove on the container impl for home %C.\n", + i->key ().c_str ())); + this->container_->uninstall_home (home.in ()); + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::remove_home - " + "Successfully removed home %C\n", + i->key ().c_str ())); + + if (this->home_map_.unbind (i->key ()) != 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::remove_home - " + "Unable to unbind removed home with id %C from home map\n", + i->key ().c_str ())); + } + } + + ::Components::CCMHomes * + CIAO_Container_i::get_homes (void) + { + CIAO_TRACE("CIAO_Container_i::get_homes"); + + ::Components::CCMHomes *tmp_homes = 0; + + ACE_NEW_THROW_EX (tmp_homes, + ::Components::CCMHomes (this->home_map_.current_size ()), + CORBA::NO_MEMORY ()); + + ::Components::CCMHomes_var retval (tmp_homes); + retval->length (this->home_map_.current_size ()); + Home_Iterator i = this->home_map_.begin (); + CORBA::ULong pos = 0; + while (!i.done ()) + { + retval[pos++] = ::Components::CCMHome::_duplicate (i->item ().in ()); + i.advance (); + } + + return retval._retn (); + } + + void + CIAO_Container_i::remove (void) + { + CIAO_TRACE("CIAO_Container_i::remove"); + + if (this->home_map_.current_size () != 0 || + this->component_map_.current_size () != 0) + { + CIAO_ERROR ((LM_WARNING, CLINFO "CIAO_Container_i::remove - " + "Attempting to remove container that still has %u homes and %u components installed\n", + this->home_map_.current_size (), + this->component_map_.current_size ())); + } + + //this->container_->_remove_ref (); + } + + void + CIAO_Container_i::activate_component (::Components::CCMObject_ptr comp) + { + CIAO_TRACE ("CIAO_Container_i::activate_component"); + + this->container_->activate_component (comp); + } + + + void + CIAO_Container_i::passivate_component (::Components::CCMObject_ptr comp) + { + CIAO_TRACE ("CIAO_Container_i::passivate_component"); + + this->container_->passivate_component (comp); + } + + + PortableServer::POA_ptr + CIAO_Container_i::_default_POA (void) + { + CIAO_TRACE ("CIAO_Container_i::_default_POA"); + return PortableServer::POA::_duplicate (this->poa_.in ()); + } + } +} diff --git a/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h new file mode 100644 index 00000000000..87c9977cdb1 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h @@ -0,0 +1,115 @@ +// $Id$ +/** + * @file CIAO_Container_Impl.h + * @author William R. Otte + */ + +#ifndef CIAO_CONTAINER_H_ +#define CIAO_CONTAINER_H_ + +#include "CIAO_ComponentServerS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ciao/Containers/FTSession/FT_Session_Container.h" + +#include "CIAO_FTComponentServer_svnt_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @class CIAO_Container + * @brief Implements external interface for CIAO container. + */ + class CIAO_FTComponentServer_svnt_Export CIAO_Container_i + : public virtual POA_CIAO::Deployment::Container + { + public: + /// Constructor + CIAO_Container_i (const Components::ConfigValues &config, + const Static_Config_EntryPoints_Maps *, + const char *, + const CORBA::PolicyList *, + CORBA::ORB_ptr, + PortableServer::POA_ptr); + + /// Destructor + virtual ~CIAO_Container_i (void); + + virtual ::Components::CCMObject_ptr install_component ( + const char * id, + const char * entrypt, + const ::Components::ConfigValues & config); + + virtual void remove_component (::Components::CCMObject_ptr cref); + + virtual ::Components::CCMObjectSeq * get_components (void); + + virtual ::Components::ConfigValues * configuration (void); + + virtual + ::Components::Deployment::ComponentServer_ptr get_component_server (void); + + virtual ::Components::CCMHome_ptr install_home (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config); + + virtual void remove_home (::Components::CCMHome_ptr href); + + virtual ::Components::CCMHomes * get_homes (void); + + virtual void remove (void); + + virtual void activate_component (::Components::CCMObject_ptr comp); + + virtual void passivate_component (::Components::CCMObject_ptr comp); + + virtual PortableServer::POA_ptr _default_POA (void); + + private: + /// Keep a pointer to the managing ORB serving this servant. + CORBA::ORB_var orb_; + + PortableServer::POA_var poa_; + + CIAO::Container_var container_; + + Components::ConfigValues config_; + + const Static_Config_EntryPoints_Maps* static_entrypts_maps_; + + /// To store all created CCMHome object + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> CCMHome_Map; + + typedef CCMHome_Map::iterator Home_Iterator; + CCMHome_Map home_map_; + + /// To store all created Component object. + // @@Gan, see how this caching is duplicated.. + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> CCMComponent_Map; + + typedef CCMComponent_Map::iterator Component_Iterator; + CCMComponent_Map component_map_; + + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> CCMNaming_Map; + CCMNaming_Map naming_map_; + }; + } +} +#endif /* CIAO_CONTAINER_H_ */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp new file mode 100644 index 00000000000..8dcef805233 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp @@ -0,0 +1,590 @@ +/** + * @file CIAO_ComponentServer.cpp + * @author William R. Otte + * + * Implementation and main for CIAO_ComponentServer. + */ + +#include "CIAO_FTComponentServer.h" + +#include +#include "ace/OS_NS_string.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" +#include "ace/Sched_Params.h" +#include "ace/Trace.h" +#include "ace/Env_Value_T.h" +#include "tao/ORB.h" +#include "tao/Object.h" +#include "tao/CORBA_methods.h" +#include "tao/PortableServer/PortableServer.h" +#include "tao/ORB_Core.h" +#include "tao/ORBInitializer_Registry.h" +#include "orbsvcs/orbsvcs/LWFT/StateSynchronizationAgent_i.h" +#include "orbsvcs/orbsvcs/LWFT/LWFT_Server_Init.h" +#include "orbsvcs/orbsvcs/LWFT/LWFT_Client_Init.h" +#include "orbsvcs/orbsvcs/LWFT/AppOptions.h" +#include "orbsvcs/orbsvcs/LWFT/AppSideMonitor_Thread.h" +#include "orbsvcs/orbsvcs/LWFT/ReplicationManagerC.h" +#include "ciao/CIAO_common.h" +#include "ciao/Logger/Logger_Service.h" +#include "ciao/Logger/Log_Macros.h" +#include "ciao/Server_init.h" + +#include "Name_Helper_T.h" +#include "CIAO_FTComponentServer_Impl.h" +#include "CIAO_CS_ClientC.h" +#include "Configurator_Factory.h" +#include "Configurators/Server_Configurator.h" + +#ifdef CIAO_BUILD_COMPONENTSERVER_EXE + +int ACE_TMAIN (int argc, ACE_TCHAR **argv) +{ + // Tracing disabled by default + CIAO_DISABLE_TRACE (); + + CIAO_TRACE ("CIAO_ComponentServer::ACE_TMAIN"); + + try + { + CIAO::Deployment::ComponentServer_Task cs (argc, argv); + cs.run (); + return 0; + } + catch (CIAO::Deployment::ComponentServer_Task::Error &e) + { + CIAO_DEBUG ((LM_ALERT, CLINFO "CIAO_ComponentServer main: Caught ComponentServer exception: %s\n", + e.err_.c_str ())); + } + catch (...) + { + CIAO_DEBUG ((LM_ALERT, CLINFO "CIAO_ComponentServer main: Caught unknown exception.\n")); + } + + return -1; +} + +#endif /* CIAO_BUILD_COMPONENTSERVER_EXE */ + +bool +write_IOR (const char * ior_file_name, const char* ior) +{ + FILE* ior_output_file_ = + ACE_OS::fopen (ior_file_name, "w"); + + if (ior_output_file_) + { + ACE_OS::fprintf (ior_output_file_, + "%s", + ior); + ACE_OS::fclose (ior_output_file_); + return true; + } + return false; +} + +namespace CIAO +{ + namespace Deployment + { + ComponentServer_Task::ComponentServer_Task (int argc, ACE_TCHAR **argv) + : orb_ (0), + uuid_ (""), + callback_ior_str_ ("") + { + CIAO_TRACE ("CIAO_ComponentServer_Task::CIAO_ComponentServer_Task ()"); + + Logger_Service + *clf = ACE_Dynamic_Service::instance ("CIAO_Logger_Backend_Factory"); + + if (!clf) + clf = new Logger_Service; + + this->logger_.reset (clf); + + this->logger_->init (argc, argv); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "Creating server object\n")); + Configurator_Factory cf; + this->configurator_.reset (cf (argc, argv)); + + if (!this->configurator_->create_config_managers ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "ComponentServer_Task::ComponentServer_Task - " + "Error configuring ComponentServer configurator, exiting.\n")); + throw Error ("Unable to load ComponentServer configurator."); + } + + this->configurator_->pre_orb_initialize (); + + LWFT_Client_Init initializer; + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "Creating ORB\n")); + this->orb_ = initializer.init (argc, argv); + + AppOptions::instance ()->parse_args (argc, argv); + AppOptions::instance ()->process_id (this->get_process_id ()); + AppOptions::instance ()->orb (CORBA::ORB::_duplicate (orb_.in ())); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task - " + "starting AppSideMonitor thread.\n")); + + int result = AppSideMonitor_Thread::instance ()->activate ();; + + if (result != 0) + { + CIAO_DEBUG ((LM_ERROR, + CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "AppSideMonitor_Thread::activate () returned %d\n", + result)); + } + + this->configurator_->post_orb_initialize (this->orb_.in ()); + + this->parse_args (argc, argv); + this->configure_logging_backend (); + + CIAO::Server_init (this->orb_.in ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "CIAO_ComponentServer object created.\n")); + } + + int + ComponentServer_Task::svc (void) + { + try + { + CIAO_TRACE ("ComponentServer_Task::svc"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Activating the root POA\n")); + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (object.in ()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + poa_manager->activate (); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Creating state synchronization servant\n")); + + // start up SSA + StateSynchronizationAgent_i* ssa_servant = 0; + ACE_NEW_NORETURN (ssa_servant, StateSynchronizationAgent_i ( + this->get_hostname (), // this has to be replaced by the + this->get_process_id ())); // real hostname and process id + + if (ssa_servant == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating ssa servant.")); + throw Error ("Out of memory whilst allocating ssa servant."); + } + + PortableServer::ServantBase_var safe_ssa (ssa_servant); + + // activate servant here + StateSynchronizationAgent_var ssa (ssa_servant->_this ()); + + Name_Helper_T nsh (orb_); + nsh.bind (this->get_obj_path () + "/StateSynchronizationAgent", ssa.in ()); + + // register ssa with the replication manager + Name_Helper_T rmh (orb_.in ()); + + ReplicationManager_var rm = rmh.resolve ("ReplicationManager"); + + rm->register_state_synchronization_agent (this->get_hostname ().c_str (), + this->get_process_id ().c_str (), + ssa); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Creating server implementation object\n")); + CIAO::Deployment::CIAO_ComponentServer_i *ci_srv = 0; + ACE_NEW_NORETURN (ci_srv, CIAO_ComponentServer_i (this->uuid_, this->orb_.in (), root_poa.in ())); + + if (ci_srv == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating servant.")); + throw Error ("Out of memory whilst allocating servant."); + } + + PortableServer::ServantBase_var safe (ci_srv); + + ComponentServer_var cs (ci_srv->_this ()); + + if (this->output_file_ != "") + { + CORBA::String_var ior = this->orb_->object_to_string (cs.in ()); + write_IOR (this->output_file_.c_str (), ior.in ()); + } + + if (this->callback_ior_str_ != "") + { + CIAO_DEBUG ((LM_TRACE, CLINFO " resolving callback IOR\n")); + CORBA::Object_ptr obj = this->orb_->string_to_object (this->callback_ior_str_.c_str ()); + ServerActivator_var sa (ServerActivator::_narrow (obj)); + + if (CORBA::is_nil (sa.in ())) + { + CIAO_DEBUG ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Failed to narrow callback IOR\n")); + throw Error ("Failed to narrow callback IOR"); + } + + Components::ConfigValues_var config; + { + Components::ConfigValues *cf; + ACE_NEW_NORETURN (cf, Components::ConfigValues (0)); + + if (cf == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating config values\n")); + } + else config = cf; + } + + // Make callback. + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Making callback on my ServerActivator\n")); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Calling back to ServerActivator\n")); + + try + { + // Callback to NodeApplication to get configuration + sa->component_server_callback (cs.in (), + this->uuid_.c_str (), + config.out ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Configuration received\n")); + // @@WO: Probably need to do something with these config values. + + ci_srv->init (sa.in (), config._retn ()); + + CIAO_DEBUG ((LM_NOTICE, CLINFO "ComponentServer_Task::svc - " + "Configuration complete for component server %s\n", + this->uuid_.c_str ())); + + sa->configuration_complete (this->uuid_.c_str ()); + } + catch (CORBA::BAD_PARAM &) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "The Callback IOR provided pointed to the wrong ServerActivator\n")); + throw Error ("Bad callback IOR"); + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Caught exception while calling back\n")); + throw Error ("Caught exception while calling back"); + } + } + else + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Initializing ComponentServer without ServantActivator callback\n")); + ci_srv->init (0, 0); + } + + this->orb_->run (); + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "ORB Event loop completed.\n")); + + root_poa->destroy (1, 1); + + this->orb_->destroy (); + return 0; + } + catch (CORBA::Exception & ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "caught: %s.\n", ex._info ().c_str ())); + } + catch (Name_Helper_Exception & ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Name helper exception: %s\n", ex.what ())); + } + + return -1; + } + + void + ComponentServer_Task::run (void) + { + CIAO_TRACE ("ComponentServer_Task::run"); + + if (this->configurator_->rt_support ()) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB with RT support\n")); + + this->check_supported_priorities (); + + // spawn a thread + // Task activation flags. + long flags = + THR_NEW_LWP | + THR_JOINABLE | + this->orb_->orb_core ()->orb_params ()->thread_creation_flags (); + + // Activate task. + int result = + this->activate (flags); + if (result == -1) + { + if (errno == EPERM) + { + CIAO_ERROR ((LM_EMERGENCY, CLINFO + "ComponentServer_Task::run - Cannot create thread with scheduling policy %s\n" + "because the user does not have the appropriate privileges, terminating program. " + "Check svc.conf options and/or run as root\n", + sched_policy_name (this->orb_->orb_core ()->orb_params ()->ace_sched_policy ()))); + throw Error ("Unable to start RT support due to permissions problem."); + } + else + throw Error ("Unknown error while spawning ORB thread."); + } + + // Wait for task to exit. + result = + this->wait (); + + if (result != -1) + throw Error ("Unknown error waiting for ORB thread to complete"); + + CIAO_DEBUG ((LM_INFO, CLINFO "ComponentServer_Task::run - ORB thread completed, terminating ComponentServer %s\n", + this->uuid_.c_str ())); + } + else + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB without RT support\n")); + this->svc (); + CIAO_DEBUG ((LM_INFO, CLINFO "ComponentServer_Task::run - ORB has shutdown, terminating ComponentServer \n")); + } + } + + void + ComponentServer_Task::parse_args (int argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("ComponentServer_Task::parse_args"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::parse_args - parsing arguments...\n")); + + ACE_Get_Opt opts (argc, argv, "hu:c:", 1, 0, + ACE_Get_Opt::RETURN_IN_ORDER); + opts.long_option ("uuid", 'u', ACE_Get_Opt::ARG_REQUIRED); + opts.long_option ("callback-ior", 'c', ACE_Get_Opt::ARG_REQUIRED); + opts.long_option ("help", 'h'); + opts.long_option ("log-level",'l', ACE_Get_Opt::ARG_REQUIRED); + opts.long_option ("trace",'t', ACE_Get_Opt::NO_ARG); + opts.long_option ("output-ior",'o', ACE_Get_Opt::ARG_REQUIRED); + + //int j; + char c; + ACE_CString s; + + while ((c = opts ()) != -1) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::parse_args - " + "Found option: \"%s\" with argument \"%s\"\n", + opts.last_option (), opts.opt_arg ())); + + switch (c) + { + case 'u': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "uuid is %s\n", + opts.opt_arg ())); + this->uuid_ = opts.opt_arg (); + break; + + case 'c': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "callback ior is %s\n", + opts.opt_arg ())); + this->callback_ior_str_ = opts.opt_arg (); + break; + + case 'l': + { + continue; // no-op, already taken care of + } + + case 't': + continue; // already taken care of + + case 'o': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "IOR Output file: %s\n", + opts.opt_arg ())); + this->output_file_ = opts.opt_arg (); + break; + + case 'h': + this->usage (); + throw Error ("Command line help requested, bailing out...."); + + default: + CIAO_ERROR ((LM_ERROR, CLINFO " Unknown option: %s\n", + opts.last_option ())); + this->usage (); + ACE_CString err ("Unknown option "); + err += opts.last_option (); + throw Error (err); + } + } + + // check required options. + if (this->uuid_ == "") + throw Error ("Option required: -u|--uuid"); + if (this->callback_ior_str_ == "") + CIAO_ERROR ((LM_WARNING, CLINFO + "ComponentServer_Task::parse_args - Starting ComponentServer without a callback IOR\n")); + } + + void + ComponentServer_Task::usage (void) + { + CIAO_TRACE ("ComponentServer_Task::usage"); + // Shouldn't be subject to CIAO's logging policy + ACE_ERROR ((LM_EMERGENCY, "Usage: CIAO_ComponentServer \n" + "Options: \n" + "\t-h|--help\t\t\t\tShow help\n" + "\t-l|--log-level \t\t\tSets log level (default 5). 1 - most detailed.\n" + "\t-u|--uuid \t\t\tSets UUID of spawned component server (required)\n" + "\t-c|--callback-ior \t\tSets callback url for the spawning ServerActivator.\n" + "\t-o|--output-ior \t\tOutputs the IOR of the component server object to file\n" + )); + + } + + const char * + ComponentServer_Task::sched_policy_name (int sched_policy) + { + const char *name = 0; + + switch (sched_policy) + { + case ACE_SCHED_OTHER: + name = "SCHED_OTHER"; + break; + case ACE_SCHED_RR: + name = "SCHED_RR"; + break; + case ACE_SCHED_FIFO: + name = "SCHED_FIFO"; + break; + } + + return name; + } + + /// The following check is taken from $(TAO_ROOT)/tests/RTCORBA/ + void + ComponentServer_Task::check_supported_priorities (void) + { + CIAO_TRACE ("ComponentServer_Task::check_supported_priorities"); + + int const sched_policy = + this->orb_->orb_core ()->orb_params ()->ace_sched_policy (); + + // Check that we have sufficient priority range to run, + // i.e., more than 1 priority level. + int const max_priority = + ACE_Sched_Params::priority_max (sched_policy); + int const min_priority = + ACE_Sched_Params::priority_min (sched_policy); + + if (max_priority == min_priority) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::check_supported_priorities - " + " Not enough priority levels with the %s scheduling policy\n" + "on this platform to run, terminating ....\n" + "Check svc.conf options\n", + sched_policy_name (sched_policy))); + + throw Error ("Bad scheduling policy."); + } + } + + void + ComponentServer_Task::configure_logging_backend (void) + { + Logger_Service + *clf = ACE_Dynamic_Service::instance ("CIAO_Logger_Backend_Factory"); + if (clf) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::configure_logging_backend - " + "Replacing logger backend\n")); + ACE_Log_Msg_Backend * backend = clf->get_logger_backend(this->orb_); + backend->open(0); + ACE_Log_Msg::msg_backend (backend); + ACE_Log_Msg * ace = ACE_Log_Msg::instance(); + ace->clr_flags(ace->flags()); + ace->set_flags(ACE_Log_Msg::CUSTOM); + } + } + + std::string + ComponentServer_Task::get_hostname () + { + char hostname [100]; + gethostname (hostname, sizeof (hostname)); + + return std::string (hostname);; + } + + std::string + ComponentServer_Task::get_process_id () + { + pid_t pid = ACE_OS::getpid (); + std::stringstream ss; + ss << pid; + + return ss.str (); + } + + std::string + ComponentServer_Task::get_obj_path () + { + std::string path; + path += ("FLARe/"); + std::string hostname = this->get_hostname (); + + // replace all dots in the hostname with escaped dots for + //to_name conversion. + for (size_t pos = hostname.find ('.', 0); + pos < hostname.length (); + pos = hostname.find ('.', pos)) + { + hostname.replace (pos, 1, "\\."); + pos += 2; + } + + path += hostname; + path += "/"; + path += this->get_process_id (); + + return path; + } + + } +} + + diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h new file mode 100644 index 00000000000..24a8ca4f484 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h @@ -0,0 +1,78 @@ +/** + * @file CIAO_ComponentServer.h + * @author William R. Otte + * + * Defines interface for the bootstrap element of the CIAO Component + * Server. + */ + +#ifndef CIAO_COMPONENTSERVER_H_ +#define CIAO_COMPONENTSERVER_H_ + +#include "ace/String_Base.h" +#include "ace/Task.h" +#include "tao/ORB.h" +#include "ciao/Logger/Logger_Service.h" +#include "orbsvcs/CosNamingC.h" + +class StateSynchronizationAgent; + +namespace CIAO +{ + namespace Deployment + { + class ComponentServer_Configurator; + + + class ComponentServer_Task : ACE_Task_Base + { + public: + ComponentServer_Task (int argc, ACE_TCHAR **argv); + + int svc (void); + + struct Error + { + Error (const ACE_CString &err) : err_(err) {} + + ACE_CString err_; + }; + + void run (void); + + private: + void parse_args (int argc, ACE_TCHAR **argv); + + void get_log_level (int argc, ACE_TCHAR **argv); + + void set_log_level (void); + + void configure_logging_backend (void); + + void usage (void); + + const char * sched_policy_name (int sched_policy); + + void check_supported_priorities (void); + + /// helper functions for naming service operations + std::string get_hostname (); + + std::string get_process_id (); + + std::string get_obj_path (); + + CORBA::ORB_var orb_; + + auto_ptr logger_; + + ACE_CString uuid_; + ACE_CString callback_ior_str_; + ACE_CString output_file_; + auto_ptr configurator_; + + }; + } +} + +#endif diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp new file mode 100644 index 00000000000..bd0cd957d99 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp @@ -0,0 +1,269 @@ +#include "CIAO_FTComponentServer_Impl.h" + +#include "ciao/CIAO_common.h" + +#include "CIAO_CS_ClientC.h" +#include "CIAO_Container_Impl.h" +//#include "tao/RTCORBA/RTCORBA.h" + +const size_t CS_DEFAULT_PRIORITY = 0; + +namespace CIAO +{ + namespace Deployment + { + CIAO_ComponentServer_i::CIAO_ComponentServer_i (const ACE_CString &uuid, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : uuid_ (uuid), + orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + containers_ () + { + CIAO_TRACE("CIAO_ComponentServer_i::CIAO_ComponentServer_i"); + } + + // Destructor + CIAO_ComponentServer_i::~CIAO_ComponentServer_i (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::~CIAO_ComponentServer_i"); + } + + + void + CIAO_ComponentServer_i::shutdown (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::shutdown"); + + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ComponentServer_i::shutdown - ORB shutdown request received at %s.\n", + this->uuid_.c_str ())); + + if (!this->containers_.is_empty ()) + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::shutdown - ComponentServer %s still containers!\n", + this->uuid_.c_str ())); + + this->orb_->shutdown (); + } + + + ::Components::ConfigValues * + CIAO_ComponentServer_i::configuration (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::configuration"); + return this->config_values_.out (); + } + + + ::Components::Deployment::ServerActivator_ptr + CIAO_ComponentServer_i::get_server_activator (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::get_server_activator"); + return this->serv_act_.in (); + } + + + ::Components::Deployment::Container_ptr + CIAO_ComponentServer_i::create_container (const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_ComponentServer_i::create_container"); + + try + { + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_ComponentServer_i::create_container - Request received with %u config values\n", + config.length ())); + + CORBA::PolicyList policies (0); + + // get RT ORB and set client_propagated priority + /* + CORBA::Object_var obj = orb_->resolve_initial_references ("RTORB"); + RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (obj); + + CORBA::PolicyList policies (1); + + if (!CORBA::is_nil (rtorb)) + { + policies.length (1); + policies[0] = RTCORBA::PriorityModelPolicy::_duplicate (rtorb->create_priority_model_policy ( + RTCORBA::CLIENT_PROPAGATED, + CS_DEFAULT_PRIORITY)); + } + */ + const char *name = 0; + + CIAO_Container_i *cont = 0; + ACE_NEW_THROW_EX (cont, + CIAO_Container_i (config, 0, name, &policies, this->orb_.in (), this->poa_.in ()), + CORBA::NO_MEMORY ()); + + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ComponentServer_i::create_container - " + "Container servant successfully allocated.\n")); + + PortableServer::ServantBase_var safe_config = cont; + CIAO::Deployment::Container_var cont_var = cont->_this (); + + this->containers_.insert (CIAO::Deployment::Container::_duplicate(cont_var.in ())); + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_ComponentServer_i::create_container - Container successfully activated and stored," + "now manage %u containers\n", + this->containers_.size ())); + + return cont_var._retn (); + } + catch (CORBA::NO_MEMORY &) + { + CIAO_ERROR ((LM_CRITICAL, CLINFO "CIAO_ComponentServer_Impl: Out of memory exception whilst creating container.\n")); + throw; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, "CIAO_ComponentServer_Impl: Caught unknown exception\n")); + } + + throw Components::CreateFailure (); + } + + + + void + CIAO_ComponentServer_i::remove_container (::Components::Deployment::Container_ptr cref) + { + CIAO_TRACE("CIAO_ComponentServer_i::remove_container"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - remove request received.\n")); + + if (CORBA::is_nil (cref)) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Error: Received nil container reference\n")); + throw Components::RemoveFailure (); + } + + + if (this->containers_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Error: I don't manage any containers!\n")); + throw Components::RemoveFailure (); + } + + + try + { + CONTAINERS::ITERATOR i (this->containers_.begin ()); + + // @@ TODO: artifact from when this was a sequence, should probably use .find, + // which will work properly with the new parameterized set class. + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + if (CORBA::is_nil (*i)) + { + ACE_ERROR ((LM_WARNING, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Managed container reference is nil, skipping.\n")); + continue; + } + + if ((*i)->_is_equivalent (cref)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Found container, invoking remove....\n")); + cref->remove (); + if (this->containers_.remove (*i) != 0) + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - Unable to remove " + "container reference from internal structure....\n")); + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Remove completed, destroying object, " + "now manage %u containers\n", this->containers_.size ())); + return; + } + } + } + catch (CORBA::Exception &ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - " + "Caught CORBA exception whilst removing container: %s\n", + ex._info ().c_str ())); + } + + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - Error: Unknown exception caught while removing a container.\n")); + } + throw Components::RemoveFailure (); + } + + + ::Components::Deployment::Containers * + CIAO_ComponentServer_i::get_containers (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::get_containers"); + + ::Components::Deployment::Containers *tmp(0); + // tmp = new ::Components::Deployment::Containers (); + ACE_NEW_THROW_EX (tmp, + ::Components::Deployment::Containers (this->containers_.size ()), + CORBA::NO_MEMORY ()); + + ::Components::Deployment::Containers_var retval (tmp); + CORBA::ULong pos (0); + retval->length (this->containers_.size ()); + + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + retval[pos++] = ::CIAO::Deployment::Container::_duplicate (*i); + } + + return retval._retn (); + } + + + void + CIAO_ComponentServer_i::remove (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::remove"); + + bool successful = true; + + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + try + { + (*i)->remove (); + } + catch (CORBA::Exception &ex) + { + successful = false; + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove - " + "Intercepted CORBA exception while trying to remove a container:%s\n", + ex._info ().c_str ())); + } + catch (...) + { + successful = false; + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove - " + "Intercepted exception while trying to remove a container\n")); + } + } + + this->containers_.reset (); + + if (!successful) + throw ::Components::RemoveFailure (); + } + + void + CIAO_ComponentServer_i::init (::Components::Deployment::ServerActivator_ptr sa, + Components::ConfigValues *cvs) + { + this->serv_act_ = ::Components::Deployment::ServerActivator::_duplicate(sa); + this->config_values_ = cvs; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h new file mode 100644 index 00000000000..63ed835a644 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h @@ -0,0 +1,78 @@ +/** + * @file CIAO_ComponentServer.h + * @author William R. Otte + */ + +#ifndef CIAO_COMPONENTSERVER_IMPL_H_ +#define CIAO_COMPONENTSERVER_IMPL_H_ + +#include "ciao/ComponentServer/CIAO_ComponentServerS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/String_Base.h" +#include "ace/Unbounded_Set_Ex.h" + +namespace CIAO +{ + namespace Deployment + { + class CIAO_ComponentServer_svnt_Export CIAO_ComponentServer_i + : public virtual POA_CIAO::Deployment::ComponentServer + { + public: + // Constructor + CIAO_ComponentServer_i (const ACE_CString &uuid, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa); + + // Destructor + virtual ~CIAO_ComponentServer_i (void); + + virtual void shutdown (void); + + virtual ::Components::ConfigValues * configuration (void); + + virtual + ::Components::Deployment::ServerActivator_ptr get_server_activator (void); + + virtual + ::Components::Deployment::Container_ptr create_container (const ::Components::ConfigValues & config); + + virtual + void remove_container (::Components::Deployment::Container_ptr cref); + + virtual + ::Components::Deployment::Containers * get_containers (void); + + virtual + void remove (void); + + void init (::Components::Deployment::ServerActivator_ptr sa, + Components::ConfigValues *cvs); + + private: + ACE_CString uuid_; + CORBA::ORB_var orb_; + PortableServer::POA_var poa_; + ::Components::Deployment::ServerActivator_var serv_act_; + Components::ConfigValues_var config_values_; + + template + struct _is_equivalent + { + bool operator() (const T &a, const T &b) const + { + return a->_is_equivalent (const_cast (b)); + } + }; + + typedef ACE_Unbounded_Set_Ex > CONTAINERS; + + CONTAINERS containers_; + }; + } +} + +#endif diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h new file mode 100644 index 00000000000..8f5dddc8c9e --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_FTComponentServer_stub +// ------------------------------ +#ifndef CIAO_FTCOMPONENTSERVER_STUB_EXPORT_H +#define CIAO_FTCOMPONENTSERVER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL */ + +#if !defined (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL 1 +#endif /* ! CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL */ + +#if defined (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL) && (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL == 1) +# if defined (CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL) +# define CIAO_FTComponentServer_stub_Export ACE_Proper_Export_Flag +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL */ +# define CIAO_FTComponentServer_stub_Export ACE_Proper_Import_Flag +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL */ +#else /* CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL == 1 */ +# define CIAO_FTComponentServer_stub_Export +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL == 1 */ + +// Set CIAO_FTCOMPONENTSERVER_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_FTCOMPONENTSERVER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_FTCOMPONENTSERVER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_FTCOMPONENTSERVER_STUB_NTRACE */ + +#if (CIAO_FTCOMPONENTSERVER_STUB_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_STUB_TRACE(X) +#else /* (CIAO_FTCOMPONENTSERVER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_FTCOMPONENTSERVER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_FTCOMPONENTSERVER_STUB_NTRACE == 1) */ + +#endif /* CIAO_FTCOMPONENTSERVER_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h new file mode 100644 index 00000000000..ecd2a4ba8e4 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_FTComponentServer_svnt +// ------------------------------ +#ifndef CIAO_FTCOMPONENTSERVER_SVNT_EXPORT_H +#define CIAO_FTCOMPONENTSERVER_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL */ + +#if !defined (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL 1 +#endif /* ! CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL */ + +#if defined (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL) && (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL == 1) +# if defined (CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL) +# define CIAO_FTComponentServer_svnt_Export ACE_Proper_Export_Flag +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL */ +# define CIAO_FTComponentServer_svnt_Export ACE_Proper_Import_Flag +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL */ +#else /* CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL == 1 */ +# define CIAO_FTComponentServer_svnt_Export +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL == 1 */ + +// Set CIAO_FTCOMPONENTSERVER_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_FTCOMPONENTSERVER_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_FTCOMPONENTSERVER_SVNT_NTRACE */ + +#if (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_SVNT_TRACE(X) +#else /* (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_FTCOMPONENTSERVER_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE == 1) */ + +#endif /* CIAO_FTCOMPONENTSERVER_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CIAO_Properties.idl b/CIAO/ciao/FTComponentServer/CIAO_Properties.idl new file mode 100644 index 00000000000..6f0cf0e47e1 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_Properties.idl @@ -0,0 +1,29 @@ +/** + * @file CIAO_Properties.idl + * @author William R. Otte + * $Id$ + * Standardizes names of configvalues used by CIAO. + */ + +#ifndef CIAO_PROPERTIES_IDL +#define CIAO_PROPERTIES_IDL + +module CIAO +{ + module Deployment + { + const string SVNT_ENTRYPT = "edu.vanderbilt.dre.CIAO.ServantEntrypoint"; + const string SVNT_ARTIFACT = "edu.vanderbilt.dre.CIAO.ServantArtifact"; + const string EXEC_ARTIFACT = "edu.vanderbilt.dre.CIAO.ExecutorArtifact"; + const string SERVER_RESOURCES = "edu.vanderbilt.dre.CIAO.ServerResources"; + const string SERVER_UUID = "edu.vanderbilt.dre.CIAO.ServerUUID"; + const string SERVER_EXECUTABLE = "edu.vanderbilt.dre.CIAO.ComponentServerExecutable"; + const string SERVER_ARGUMENTS = "edu.vanderbilt.dre.CIAO.ComponentServerArgs"; + const string SERVER_TIMEOUT = "edu.vanderbilt.dre.CIAO.ServerTimeout"; + const string SERVER_MULTITHREAD = "edu.vanderbilt.dre.CIAO.Multithreaded"; + const string REGISTER_NAMING = "edu.vanderbilt.dre.CIAO.RegisterNaming"; + const string OBJECT_ID = "edu.vanderbilt.dre.CIAO.ObjectId"; + + }; +}; +#endif /* CIAO_PROPERTIES_IDL */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp new file mode 100644 index 00000000000..cb4e5c5a9a0 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp @@ -0,0 +1,530 @@ +// $Id$ +#include "CIAO_ServerActivator_Impl.h" + +#include "ace/Log_Msg.h" +#include "ace/UUID.h" +#include "ciao/CIAO_common.h" +#include "ciao/Client_init.h" +#include "ciao/CIAO_FailureReasonsC.h" + +#include "CIAO_ServerResourcesC.h" +#include "CIAO_ComponentServerC.h" +#include "CIAO_PropertiesC.h" + +namespace CIAO +{ + namespace Deployment + { + CIAO_ServerActivator_i::CIAO_ServerActivator_i (CORBA::ULong def_spawn_delay, + const char * default_cs_path, + const char * cs_args, + bool multithreaded, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : spawn_delay_ (def_spawn_delay), + multithreaded_ (multithreaded), + orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + cs_path_ (default_cs_path), + cs_args_ (cs_args), + mutex_ (), + condition_ (mutex_) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::CIAO_ServerActivator_i"); + } + + CIAO_ServerActivator_i::~CIAO_ServerActivator_i(void) + { + } + + void + CIAO_ServerActivator_i::component_server_callback (::Components::Deployment::ComponentServer_ptr serverref, + const char * server_UUID, + ::Components::ConfigValues_out config) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::component_server_callback"); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C\n", + server_UUID)); + + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, but I don't manage any.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + //SERVER_INFOS::iterator i (this->server_infos_.begin ()); + //i.first (); + Server_Info *info = 0; + + for (SERVER_INFOS::iterator i (this->server_infos_.begin ()); + !i.done (); ++i) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Comparing %C with %C\n", (*i)->uuid_.c_str (), server_UUID)); + if ((*i)->uuid_ == server_UUID) + { + info = (*i).get (); + } + } + + if (info == 0) + { CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, which doesn't belong to me.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + if (info->activated_) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, which has already been configured.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + if (!CORBA::is_nil (info->ref_)) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, which has already called back.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C\n", + server_UUID)); + + info->ref_ = ::Components::Deployment::ComponentServer::_duplicate (serverref); + + this->create_component_server_config_values (*info, config); + + // @@TODO: May want to print out configvalues here. + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Generated %u ConfigValues for ComponentServer %C\n", + config->length (), server_UUID)); + } + + void + CIAO_ServerActivator_i::configuration_complete (const char *server_UUID) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::configuration_complete"); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C\n", + server_UUID)); + + try + { + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received callback from ComponentServer %C, but I don't manage any.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + Server_Info *info = 0; + + for (SERVER_INFOS::ITERATOR j (this->server_infos_); + !j.done (); ++j) + { + if ((*j)->uuid_ == server_UUID) + { + info = (*j).get (); + } + } + + if (info == 0) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C, which doesn't belong to me.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + if (info->activated_) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C, which has already been completed.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + if (CORBA::is_nil (info->ref_.in ())) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C, which has not called back.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + info->activated_ = true; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Caught unknown exception while processing configuration_complete\n")); + throw; + } + } + + ::Components::Deployment::ComponentServer_ptr + CIAO_ServerActivator_i::create_component_server (const ::Components::ConfigValues & config) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::create_component_server"); + + Safe_Server_Info server (new Server_Info (config.length () + 1)); + + CIAO::Utility::build_config_values_map (*server->cmap_, config); + + ACE_CString cmd_options = this->construct_command_line (*server); + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::create_component_server - ComponentServer arguments: %C\n", + cmd_options.c_str ())); + + server_infos_.insert_tail (server); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::create_component_server - " + "Attempting to spawn ComponentServer with UUID %C\n", + server->uuid_.c_str ())); + // Now we need to get a copy of the one that was inserted... + pid_t pid = this->spawn_component_server (*server, cmd_options); + ACE_UNUSED_ARG (pid); + + ACE_Time_Value timeout (this->spawn_delay_); + + CORBA::Any val; + + if (server->cmap_->find (SERVER_TIMEOUT, val) == 0) + { + CORBA::ULong t; + if (val >>= t) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::create_component_server - " + "Using provided non-default server timeout of %u\n", t)); + timeout = ACE_Time_Value (t); + } + else + { + CIAO_ERROR ((LM_WARNING, CLINFO "CIAO_ServerActivator_i::create_component_server - " + "Failed to extract provided non-default server timeout from property '%C', " + "falling back to default timeout of %u\n", + this->spawn_delay_)); + } + } + + if (this->multithreaded_) + this->multi_threaded_wait_for_callback (*server, timeout/*, pid*/); + else + this->single_threaded_wait_for_callback (*server, timeout/*, pid*/); + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::create_component_server - " + "ComponentServer %C successfully spawned and configured!\n", + server->uuid_.c_str ())); + + return ::Components::Deployment::ComponentServer::_duplicate (server->ref_.in ()); + } + + ACE_CString + CIAO_ServerActivator_i::construct_command_line (Server_Info &server) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::construct_command_line"); + // Build our command line to launch the compoent server + ACE_CString cmd_options (this->cs_args_); + + CORBA::Any val; + + if (server.cmap_->find (SERVER_UUID, val) == 0) + { + // Nodeapplication has requested a custom uuid + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using provided UUID\n")); + const char *uuid = 0; + val >>= uuid; + server.uuid_ = uuid; + } + else + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using generated UUID\n")); + ACE_Utils::UUID uuid; + ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid); + server.uuid_ = *uuid.to_string (); + } + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Creating component server " + " with UUID %C\n", server.uuid_.c_str ())); + + cmd_options += " -u "; + cmd_options += server.uuid_; + + if (server.cmap_->find (SERVER_RESOURCES, val) == 0) + { + // There may be command line arguments specified in the plan + ServerResource_var sr; + val >>= sr; + + // If command line options are specified through RTCCM descriptors, + // then we should honor these command line options as well. + for (CORBA::ULong arg_i = 0; + arg_i < sr->args.length (); + ++arg_i) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Adding argument %C from ServerResource\n ", + sr->args[arg_i].in ())); + cmd_options += " "; // space between command line args + cmd_options += sr->args[arg_i]; + } + + // If service configuration file is specified through RTCCM + // descriptors, then we should honor it as well. + if (ACE_OS::strcmp (sr->svcconf.in (), + "") != 0) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using SvcConf file %C\n ", + sr->svcconf.in ())); + cmd_options += " -ORBSvcConf "; + cmd_options += sr->svcconf; + } + } + + return cmd_options; + } + + pid_t + CIAO_ServerActivator_i::spawn_component_server (const Server_Info &si, + const ACE_CString &cmd_line) + { + CIAO_TRACE ("CIAO_ServerActivator_i::spawn_component_server"); + + ACE_Process_Options options; + + // Get my object reference + CORBA::Object_var obj = this->poa_->servant_to_reference (this); + CORBA::String_var ior = this->orb_->object_to_string (obj.in ()); + CORBA::Any val; + + const char *path = this->cs_path_.c_str (); + + if (si.cmap_->find (SERVER_EXECUTABLE, val) == 0) + { + val >>= path; + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " + "Using provided component server executable:%C\n", path)); + } + else + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " + "Using default component server execuable\n")); + } + + options.command_line ("%s %s -c %s", + path, + cmd_line.c_str (), + ior.in ()); + + options.avoid_zombies (0); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::spawn_component_server - Spawning process, command line is %C\n", + options.command_line_buf ())); + + pid_t const pid = this->process_manager_.spawn (options, + &this->child_handler_); + + if (pid == ACE_INVALID_PID) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "Failed to spawn a ComponentServer process\n")); + throw Components::CreateFailure (CIAO::SERVER_SPAWN_FAILURE); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::spawn_component_server - Process successfully spawned with pid %u\n", + pid)); + return pid; + } + + void + CIAO_ServerActivator_i:: + single_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::single_threaded_wait_for_callback"); + // Below code is broken for thread-per-connection concurrency model, + // since the main thread is running ORB event loop and will spawn + // a different thread to handle the call , + // the operation will not be invoked and finally + // a timeout will occur. For a similar reason, it won't work + // for thread-pool concurrency model. + while (true) + { + this->orb_->perform_work (timeout); + + if (timeout == ACE_Time_Value::zero) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::single_threaded_wait_for_callback - " + "Timed out while waiting for ComponentServer %C to call back.\n", + si.uuid_.c_str ())); + throw ::Components::CreateFailure (CIAO::CALLBACK_TIMEOUT_EXCEEDED); + } + + if (si.activated_) + { + break; + } + } + } + + void + CIAO_ServerActivator_i:: + multi_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::multi_threaded_wait_for_callback"); + + // Wait for a conditional variable + ACE_GUARD_THROW_EX ( ACE_SYNCH_MUTEX, + guard, + this->mutex_, + CORBA::NO_RESOURCES ()); + + while (! si.activated_ ) + if (this->condition_.wait (&timeout) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::multi_threaded_wait_for_callback - " + "Timed out while waiting for ComponentServer %C to call back.\n", + si.uuid_.c_str ())); + throw Components::CreateFailure (CIAO::CALLBACK_TIMEOUT_EXCEEDED); + } + } + + void + CIAO_ServerActivator_i::remove_component_server (::Components::Deployment::ComponentServer_ptr server) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::remove_component_server"); + + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "I don't manage any ComponentServers.\n")); + throw CORBA::BAD_PARAM (); + } + + Server_Info *info = 0; + + for (SERVER_INFOS::ITERATOR i (this->server_infos_); + !i.done (); ++i) + { + if ((*i)->ref_->_is_equivalent (server)) + { + info = (*i).get (); + } + } + + if (info == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Failed to find equivalent ComponentServer under my management.\n")); + throw ::Components::RemoveFailure (); + } + + try + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Calling remove () on ComponentServer %C\n", + info->uuid_.c_str ())); + server->remove (); + } + catch (::Components::RemoveFailure &) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Received RemoveFailure exception from ComponentServer %C\n", + info->uuid_.c_str ())); + } + + // If this is a CIAO component server, call shutdown + CIAO::Deployment::ComponentServer_var ccs = + CIAO::Deployment::ComponentServer::_narrow (server); + if (!CORBA::is_nil (ccs)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Calling shutdown () on ComponentServer %C\n", + info->uuid_.c_str ())); + ccs->shutdown (); + } + else + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "ComponentServer %C is not a CIAO_ComponentServer, not calling shutdown.\n", + info->uuid_.c_str ())); + + CIAO_DEBUG ((LM_INFO, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "ComponentServer %C successfully shut down.\n", + info->uuid_.c_str ())); + } + + ::Components::Deployment::ComponentServers * + CIAO_ServerActivator_i::get_component_servers (void) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::get_component_servers"); + + ::Components::Deployment::ComponentServers_var retval = new + Components::Deployment::ComponentServers (this->server_infos_.size ()); + + CORBA::ULong pos = 0; + + for (SERVER_INFOS::ITERATOR i (this->server_infos_); + !i.done (); ++i) + { + retval[pos++] = + ::Components::Deployment::ComponentServer::_duplicate ((*i)->ref_); + } + + return retval._retn (); + } + + void + CIAO_ServerActivator_i::create_component_server_config_values ( + const Server_Info &, + Components::ConfigValues_out &config) + { + ACE_NEW_THROW_EX (config, + Components::ConfigValues (0), + CORBA::NO_MEMORY ()); + } + } +} + diff --git a/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h new file mode 100644 index 00000000000..83a41b813ff --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h @@ -0,0 +1,194 @@ +// $Id$ +/** + * @file CIAO_ServerActivator.h + * @author William R. Otte + */ + +#ifndef CIAO_SERVERACTIVATOR_H_ +#define CIAO_SERVERACTIVATOR_H_ + +#include "ace/Process_Manager.h" +#include "ace/Event_Handler.h" +#include "ace/Condition_T.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Unbounded_Set_Ex.h" +#include "ace/Synch_Traits.h" +#include "tao/PortableServer/PortableServer.h" +#include "tao/orbconf.h" +#include "ciao/Client_init.h" +#include "ciao/FTComponentServer/CIAO_CS_ClientS.h" +#include "ciao/FTComponentServer/CIAO_ComponentServerC.h" +#include "ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace CIAO +{ + namespace Deployment + { + //namespace + //{ + /** + * @class Child_Handler + * @brief The signal handler class for the SIGCHLD handling to avoid + * zombies + */ + class Child_Handler : public virtual ACE_Event_Handler + { + public: + virtual int handle_signal (int, + siginfo_t *, + ucontext_t *) + { + // @@ Note that this code is not portable to all OS platforms + // since it uses print statements within signal handler context. + ACE_exitcode status; + // makes a claal to the underlying os system call + // -1 to wait for any child process + // and WNOHANG so that it retuurns immediately + ACE_OS::waitpid (-1 ,&status, WNOHANG, 0); + + return 0; + } + }; + // } + + + /** + * @author William R. Otte + * @brief Default server activator for CIAO component servers. + * + * Implements the default component server activation strategy + * which is to spawn new processes. This is not thread-safe, + * nor is it intended to be. Containers are reated serially, + * so there will be only one actor *modifying* data at a particular + * point in time. + */ + class CIAO_CS_Client_svnt_Export CIAO_ServerActivator_i + : public virtual POA_CIAO::Deployment::ServerActivator + { + public: + // Constructor + CIAO_ServerActivator_i (CORBA::ULong def_spawn_delay, + const char * default_cs_path, + const char * cs_args, + bool multithreaded, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa_); + + + // Destructor + virtual ~CIAO_ServerActivator_i (void); + + virtual + void component_server_callback ( + ::Components::Deployment::ComponentServer_ptr serverref, + const char * server_UUID, + ::Components::ConfigValues_out config); + + virtual void configuration_complete (const char *server_UUID); + + virtual + ::Components::Deployment::ComponentServer_ptr + create_component_server (const ::Components::ConfigValues & config); + + virtual + void remove_component_server ( + ::Components::Deployment::ComponentServer_ptr server); + + virtual + ::Components::Deployment::ComponentServers * get_component_servers (void); + + private: + struct Server_Info; + + /// Builds command line options based on configuration information. + /// May modify the uuid of the component server. + ACE_CString construct_command_line (Server_Info &si); + + /// Spawns the component server process, but does not wait for it + /// to call back. + pid_t spawn_component_server (const Server_Info &si, + const ACE_CString &cmd_line); + + /// This method is only applicable when our program is configured as + /// singled threaded . Internally it uses a blocking + /// call to wait for NA object to call back + void single_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout); + + /// This method is only applicable when our program is configured as + /// multiple threaded. Internally it waits on a conditional variable + /// that could be modified by the callback servant which runs in + /// another thread + void multi_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout); + + void create_component_server_config_values (const Server_Info &info, + Components::ConfigValues_out &config); + + struct Server_Info + { + Server_Info (size_t cmap_size_hint = 128) + : cmap_ (new CIAO::Utility::CONFIGVALUE_MAP (cmap_size_hint)), + ref_ (Components::Deployment::ComponentServer::_nil ()), + pid_ (ACE_INVALID_PID), + activated_ (false) {} + + typedef ACE_Refcounted_Auto_Ptr CONFIGVALUE_MAP_PTR; + + ACE_CString uuid_; + CONFIGVALUE_MAP_PTR cmap_; + Components::Deployment::ComponentServer_var ref_; + pid_t pid_; + bool activated_; + }; + + typedef ACE_Refcounted_Auto_Ptr Safe_Server_Info; + + struct _server_info + { + bool operator() (const Safe_Server_Info &a, const Safe_Server_Info &b) const + { + return a->uuid_ == b->uuid_; + } + }; + + // Presumably, there won't be too many component servers per node application + typedef ACE_Unbounded_Set_Ex SERVER_INFOS; + + /// Default args to pass to all componentservers. + ACE_CString default_args_; + + SERVER_INFOS server_infos_; + + ACE_Process_Manager process_manager_; + + Child_Handler child_handler_; + + CORBA::ULong spawn_delay_; + + /////*******NEW + bool multithreaded_; + + CORBA::ORB_var orb_; + + PortableServer::POA_var poa_; + + ACE_CString cs_path_; + + ACE_CString cs_args_; + + ACE_Thread_Mutex mutex_; + + ACE_Condition condition_; + }; + + + } +} +#endif /* CIAO_SERVERACTIVATOR_H_ */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl b/CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl new file mode 100644 index 00000000000..5c00205a39b --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl @@ -0,0 +1,268 @@ +// $Id$ + +/** + * @file CIAO_ServerResources.idl + * + * @brief A collection of IDL data types for + * + * @author Nanbor Wang + */ + +#if !defined (CIAO_SERVERRESOURCES_IDL) +#define CIAO_SERVERRESOURCES_IDL + +#include + +module CIAO +{ + module Deployment + { + /** + * @brief A single command line argument corresponds to a string as + * in the case of "argv". + */ + typedef string CommandlineArg; + /** + * @brief A list of command line arguments which a + * NodeApplicationManager will use to start up the NodeApplication + * this list is associated to. The command line arguments will be + * appended to the command line in order. + */ + typedef sequence CommandlineArgs; + + /** + * @brief A string containing the filename of the svc.conf file the + * NodeApplication uses. The current approach of specifying + * svc.conf filename directly some harder problems such as + * distribution of svc.conf files and the relative/absolute path to + * the svc.conf file (the ServerResrouces xml document will have to + * assume the svc.conf file will be available at specific location.) + */ + typedef string SvcconfURI; + + /** + * @brief enumeration of ORB Resource Types (ORT) supported in RT + * extension. + */ + enum ORBResourceType + { + ORT_THREADPOOL, + ORT_THREADPOOLWITHLANES, + ORT_CONNECTIONBANDS + }; + + typedef short Priority; + + /** + * @brief Define a threadpool resource that an ORB must provide + */ + struct ORS_Threadpool + { + string Id; + unsigned long stacksize; + unsigned long static_threads; + unsigned long dynamic_threads; + Priority default_priority; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence ORS_ThreadpoolSeq; + + /** + * @brief Defines the configuration of a threadpool lane. We need + * to redefine it here to avoid dependency to RTCORBA library. + */ + struct ORS_ThreadpoolLane + { + Priority lane_priority; + unsigned long static_threads; + unsigned long dynamic_threads; + }; + + /** + * @brief Defines a set of threadpool lanes. We need + * to redefine it here to avoid dependency to RTCORBA library. + */ + typedef sequence ORS_ThreadpoolLanes; + + /** + * @brief Defines a Threadpool with Lanes resource that an ORB + * must provide. + */ + struct ORS_ThreadpoolWithLanes + { + string Id; + unsigned long stacksize; + ORS_ThreadpoolLanes threadpool_lanes; + boolean allow_borrowing; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence ORS_ThreadpoolWithLanesSeq; + + /** + * @brief Define a priority band for BandedConnection policies. + */ + struct ORS_PriorityBand + { + Priority low; + Priority high; + }; + /** + * @brief Define a list of priority bands for BandedConnection + * policies. + */ + typedef sequence ORS_PriorityBands; + + /** + * @brief Define the information needed to create a + * BandedConnection policy. This info can be referred to via its + * name (Id). + */ + struct ORS_ConnectionBands + { + string Id; + ORS_PriorityBands bands; + }; + + typedef sequence ORS_ConnectionBandsSeq; + + /** + * @brief Collection of resources managed by the NodeApplication + * ORB. + */ + struct ORBResource + { + ORS_ThreadpoolSeq threadpool_list; + + ORS_ThreadpoolWithLanesSeq threadpool_with_lanes_list; + + ORS_ConnectionBandsSeq connection_bands_list; + }; + + typedef sequence ORBResources; + + // ================================================================= + + /** + * @brief PolicyType supported by DAnCE extension. Again, we are + * redefining these value to avoid dependencies to various ORB + * modules such as RTCORBA and DiffServ policy libraries. + * @JW This is a bad thing to redefine. Maybe we have to make a seperate + * IDL lib for these libraries, but redefinition is really a bad thing + */ + const CORBA::PolicyType PRIORITY_MODEL_POLICY_TYPE = 40; + const CORBA::PolicyType THREADPOOL_POLICY_TYPE = 41; + const CORBA::PolicyType PRIORITY_BANDED_CONNECTION_POLICY_TYPE = 45; + const CORBA::PolicyType CLIENT_NETWORK_PRIORITY_TYPE = 86; + const CORBA::PolicyType NETWORK_PRIORITY_TYPE = 87; + + enum PriorityModel + { + CLIENT_PROPAGATED, + SERVER_DECLARED + }; + + enum NWPriorityModel + { + CLIENT_PROPAGATED_NWPRIORITY, + SERVER_DECLARED_NWPRIORITY + }; + + /** + * @brief Defines data required for creating a PriorityModel Policy + */ + struct PriorityModelPolicyDef + { + PriorityModel priority_model; + Priority server_priority; + }; + + /** + * @brief Defines data required for creating a server side DiffServ policy + */ + struct NWPriorityModelPolicyDef + { + NWPriorityModel nw_priority_model; + long request_dscp; + long reply_dscp; + }; + + /** + * @brief Defines data required for creating a client side DiffServ policy + */ + struct CNWPriorityModelPolicyDef + { + long request_dscp; + long reply_dscp; + }; + + /** + * @brief Define data required for creating a Threadpool policy + */ + struct ThreadpoolPolicyDef + { + // Threadpool name defined in ORBResource + string Id; + }; + + /** + * @brief Define data required for creating a PriorityBandedConnection + * policy + */ + struct PriorityBandedConnectionPolicyDef + { + string Id; // PriorityBands name defined in + // ORBResource + }; + + union PolicyDef switch (CORBA::PolicyType) + { + case PRIORITY_MODEL_POLICY_TYPE: PriorityModelPolicyDef PriorityModelDef; + case THREADPOOL_POLICY_TYPE: ThreadpoolPolicyDef ThreadpoolDef; + case PRIORITY_BANDED_CONNECTION_POLICY_TYPE: PriorityBandedConnectionPolicyDef PriorityBandedConnectionDef; + case CLIENT_NETWORK_PRIORITY_TYPE: CNWPriorityModelPolicyDef CNWPriorityModelDef; + case NETWORK_PRIORITY_TYPE: NWPriorityModelPolicyDef NWPriorityModelDef; + }; + + /** + * @brief Define a set of policy definitions. + */ + typedef sequence PolicyDefs; + + /** + * @brief A policy set is named. + */ + struct PolicySet + { + string Id; // Name of this policy set + PolicyDefs policies; + }; + + /** + * @brief A list of all policy sets. + */ + typedef sequence PolicySets; + + struct ORBConfigs + { + ORBResources orb_resources; + PolicySets policy_set; + }; + + struct ServerResource + { + string Id; + + CommandlineArgs args; + SvcconfURI svcconf; + ORBConfigs orb_config; + }; + }; +}; + +#endif /* CIAO_SERVERRESOURCES_IDL */ diff --git a/CIAO/ciao/FTComponentServer/Configurator_Factory.cpp b/CIAO/ciao/FTComponentServer/Configurator_Factory.cpp new file mode 100644 index 00000000000..2db7cec6ef3 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurator_Factory.cpp @@ -0,0 +1,49 @@ +#include "Configurator_Factory.h" +// $Id$ +#include "ace/Arg_Shifter.h" +#include "ciao/CIAO_common.h" +#include "Configurators/Server_Configurator.h" + +namespace CIAO +{ + namespace Deployment + { + ComponentServer_Configurator * + Configurator_Factory::operator() (int &argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("Configurator_Factory::operator()"); + bool const rt = this->parse_args (argc, argv); + + ComponentServer_Configurator *ptr = 0; + ACE_NEW_THROW_EX (ptr, + ComponentServer_Configurator (rt), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return ptr; + } + + bool + Configurator_Factory::parse_args (int &argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("Configurator_Factory::parse_args"); + ACE_Arg_Shifter shifter (argc, argv); + bool retval = false; + + while (shifter.is_anything_left ()) + { + if (shifter.cur_arg_strncasecmp (ACE_TEXT("-r")) == 0) + { + retval = true; + shifter.consume_arg (); + } + else + { + shifter.ignore_arg (); + } + } + + return retval; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurator_Factory.h b/CIAO/ciao/FTComponentServer/Configurator_Factory.h new file mode 100644 index 00000000000..5f62473a5da --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurator_Factory.h @@ -0,0 +1,39 @@ +// $Id$ +/** + * @file Configurator_Factory.h + * @author William R. Otte + * @author Nanbor Wang <> + * + * Factory for creating configurators, based on old NodeApplication_Options + * class + */ + +#ifndef CIAO_CONFIGURATOR_FACTORY_H +#define CIAO_CONFIGURATOR_FACTORY_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "CIAO_FTComponentServer_svnt_export.h" + +namespace CIAO +{ + namespace Deployment + { + class ComponentServer_Configurator; + + class CIAO_FTComponentServer_svnt_Export Configurator_Factory + { + public: + ComponentServer_Configurator * operator () (int &argc, ACE_TCHAR **argv); + + private: + bool parse_args (int &argc, ACE_TCHAR **argv); + }; + } +} +#include /**/ "ace/post.h" + +#endif diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp new file mode 100644 index 00000000000..a34353fe5c7 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp @@ -0,0 +1,240 @@ +// $Id$ + +#include "Basic_Config_Manager.h" +#include "ciao/CIAO_common.h" +#include "ace/SString.h" +#include "tao/SystemException.h" +#include "tao/DiffServPolicy/DiffServPolicy.h" +#include "tao/DiffServPolicy/Client_Network_Priority_Policy.h" +#include "tao/DiffServPolicy/Server_Network_Priority_Policy.h" + +namespace CIAO +{ + namespace Deployment + { + + void + Basic_Config_Manager::init (CORBA::ORB_ptr orb) + { + this->orb_ = CORBA::ORB::_duplicate (orb); + } + + int + Basic_Config_Manager::pre_orb_initialize (void) + { + return 0; + } + + int + Basic_Config_Manager::post_orb_initialize (CORBA::ORB_ptr) + { + return 0; + } + + void + Basic_Config_Manager::init_resources + (const ServerResource &server_resource) + { + CIAO_DEBUG ((LM_DEBUG,"Basic_Config_Manager::init_resources\n")); + + if (CORBA::is_nil (this->orb_.in())) + { + CIAO_ERROR ((LM_ERROR, + "Basic_Config_Manager has not been properly initialized\n")); + throw CORBA::INTERNAL (); + } + + const PolicySets &sets = server_resource.orb_config.policy_set; + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong np = sets[i].policies.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + CORBA::ULong index = 0; + CORBA::ULong array_index = np; + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + CORBA::Policy_var temp_policy = + this->create_single_policy (sets[i].policies[pc]); + + if (CORBA::is_nil (temp_policy.in ())) + { + array_index = array_index - 1; + policy_list->length (array_index); + } + else + { + policy_list[index] = temp_policy; + index = index + 1; + } + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (array_index != 0) + { + if (this->policy_map_.bind (sets[i].Id.in (), + policy_list) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding Policy_Set with name: %s\n", + sets[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "Basic_Config_Manager::init_resource" + " added policy set : %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "Basic_Config_Manager::init_resource" + " added policy set : %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + } + + bool + Basic_Config_Manager::policy_exists (const char *name) + { + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in " + "Basic_Config_Manager::policy_exists\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + return false; + } + + return true; + } + + CORBA::PolicyList * + Basic_Config_Manager::find_policies_by_name (const char *name) + { + if (name == 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Invalid name string found in find_policies_by_name\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + CORBA::PolicyList_var retv; + + if (this->policy_map_.find (name, entry) != 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Unable to find a PolicyList named %s\n", + name)); + retv = 0; + } + else + { + retv = new CORBA::PolicyList (entry->int_id_.in ()); + } + return retv._retn (); + } + + CORBA::Policy_ptr + Basic_Config_Manager::create_single_policy + (const PolicyDef &policy_def) + { + CORBA::Policy_var retv; + + switch (policy_def._d ()) + { + case TAO::NETWORK_PRIORITY_TYPE: + { + const NWPriorityModelPolicyDef &nw_tmp + = policy_def.NWPriorityModelDef (); + retv = this->orb_->_create_policy (TAO::NETWORK_PRIORITY_TYPE); + + TAO::NetworkPriorityPolicy_var nw_priority = + TAO::NetworkPriorityPolicy::_narrow (retv.in ()); + + nw_priority->network_priority_model ( + (TAO::NetworkPriorityModel) nw_tmp.nw_priority_model); + + nw_priority->request_diffserv_codepoint ( + (TAO::DiffservCodepoint) nw_tmp.request_dscp); + + nw_priority->reply_diffserv_codepoint ( + (TAO::DiffservCodepoint) nw_tmp.reply_dscp); + + retv = nw_priority._retn (); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "NAConfigManager::Create NetworkPriority policy: %d\n", + nw_tmp.nw_priority_model)); + } + break; + + case TAO::CLIENT_NETWORK_PRIORITY_TYPE: + { + const CNWPriorityModelPolicyDef &cnw_tmp + = policy_def.CNWPriorityModelDef (); + retv = this->orb_->_create_policy (TAO::CLIENT_NETWORK_PRIORITY_TYPE); + + TAO::NetworkPriorityPolicy_var cnw_priority = + TAO::NetworkPriorityPolicy::_narrow (retv.in ()); + + cnw_priority->request_diffserv_codepoint ( + (TAO::DiffservCodepoint) cnw_tmp.request_dscp); + + cnw_priority->reply_diffserv_codepoint ( + (TAO::DiffservCodepoint) cnw_tmp.reply_dscp); + + retv = cnw_priority._retn (); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "NAConfigManager::Create NetworkPriority policy \n")); + } + break; + + default: + retv = 0; + } + + return retv._retn (); + } + + } +} + +using CIAO::Deployment::Config_Manager; +using CIAO::Deployment::Basic_Config_Manager; + +extern "C" Basic_Config_Manager_Export Config_Manager *create_basic_config_manager (void); + +extern "C" +{ + Config_Manager * + create_basic_config_manager (void) + { + Basic_Config_Manager *config; + ACE_NEW_RETURN (config, Basic_Config_Manager, 0); + return config; + } +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h new file mode 100644 index 00000000000..0f1f0b03b64 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h @@ -0,0 +1,79 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Basic_Config_Manager.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_NACONFIG_MANAGER_H +#define CIAO_NACONFIG_MANAGER_H +#include /**/ + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/SString.h" +#include "ace/Hash_Map_Manager_T.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +#include "Config_Manager.h" +#include "Basic_Config_Manager_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + */ + class Basic_Config_Manager_Export Basic_Config_Manager + : public Config_Manager + { + public: + virtual ~Basic_Config_Manager (void) {} + + virtual int pre_orb_initialize (void); + + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + virtual void init (CORBA::ORB_ptr orb); + + /// Initializing the NAResource_Config_Manager + virtual void init_resources (const ServerResource &info); + + /// Query a policy set by name + virtual CORBA::PolicyList *find_policies_by_name (const char *name); + + virtual bool policy_exists (const char *name); + + private: + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + CORBA::Policy_ptr create_single_policy + (const PolicyDef &policy_def); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; + }; +} + } + +#include /**/ "ace/post.h" +#endif /* CIAO_NACONFIG_MANAGER_H */ + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl new file mode 100644 index 00000000000..67203a91ff8 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl @@ -0,0 +1,12 @@ +// $Id$ + +ACE_INLINE +CIAO::NAResource_Config_Manager::NAResource_Config_Manager () +{ +} + +ACE_INLINE +CIAO::NAResource_Config_Manager::~NAResource_Config_Manager () +{ +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h new file mode 100644 index 00000000000..51cb9778168 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Basic_Config_Manager +// ------------------------------ +#ifndef BASIC_CONFIG_MANAGER_EXPORT_H +#define BASIC_CONFIG_MANAGER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BASIC_CONFIG_MANAGER_HAS_DLL) +# define BASIC_CONFIG_MANAGER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BASIC_CONFIG_MANAGER_HAS_DLL */ + +#if !defined (BASIC_CONFIG_MANAGER_HAS_DLL) +# define BASIC_CONFIG_MANAGER_HAS_DLL 1 +#endif /* ! BASIC_CONFIG_MANAGER_HAS_DLL */ + +#if defined (BASIC_CONFIG_MANAGER_HAS_DLL) && (BASIC_CONFIG_MANAGER_HAS_DLL == 1) +# if defined (BASIC_CONFIG_MANAGER_BUILD_DLL) +# define Basic_Config_Manager_Export ACE_Proper_Export_Flag +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BASIC_CONFIG_MANAGER_BUILD_DLL */ +# define Basic_Config_Manager_Export ACE_Proper_Import_Flag +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BASIC_CONFIG_MANAGER_BUILD_DLL */ +#else /* BASIC_CONFIG_MANAGER_HAS_DLL == 1 */ +# define Basic_Config_Manager_Export +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BASIC_CONFIG_MANAGER_HAS_DLL == 1 */ + +// Set BASIC_CONFIG_MANAGER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BASIC_CONFIG_MANAGER_NTRACE) +# if (ACE_NTRACE == 1) +# define BASIC_CONFIG_MANAGER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BASIC_CONFIG_MANAGER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BASIC_CONFIG_MANAGER_NTRACE */ + +#if (BASIC_CONFIG_MANAGER_NTRACE == 1) +# define BASIC_CONFIG_MANAGER_TRACE(X) +#else /* (BASIC_CONFIG_MANAGER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BASIC_CONFIG_MANAGER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BASIC_CONFIG_MANAGER_NTRACE == 1) */ + +#endif /* BASIC_CONFIG_MANAGER_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h b/CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h new file mode 100644 index 00000000000..098b4c87f0d --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Basic_Configurator +// ------------------------------ +#ifndef BASIC_CONFIGURATOR_EXPORT_H +#define BASIC_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BASIC_CONFIGURATOR_HAS_DLL) +# define BASIC_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BASIC_CONFIGURATOR_HAS_DLL */ + +#if !defined (BASIC_CONFIGURATOR_HAS_DLL) +# define BASIC_CONFIGURATOR_HAS_DLL 1 +#endif /* ! BASIC_CONFIGURATOR_HAS_DLL */ + +#if defined (BASIC_CONFIGURATOR_HAS_DLL) && (BASIC_CONFIGURATOR_HAS_DLL == 1) +# if defined (BASIC_CONFIGURATOR_BUILD_DLL) +# define Basic_Configurator_Export ACE_Proper_Export_Flag +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BASIC_CONFIGURATOR_BUILD_DLL */ +# define Basic_Configurator_Export ACE_Proper_Import_Flag +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BASIC_CONFIGURATOR_BUILD_DLL */ +#else /* BASIC_CONFIGURATOR_HAS_DLL == 1 */ +# define Basic_Configurator_Export +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BASIC_CONFIGURATOR_HAS_DLL == 1 */ + +// Set BASIC_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BASIC_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define BASIC_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BASIC_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BASIC_CONFIGURATOR_NTRACE */ + +#if (BASIC_CONFIGURATOR_NTRACE == 1) +# define BASIC_CONFIGURATOR_TRACE(X) +#else /* (BASIC_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BASIC_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BASIC_CONFIGURATOR_NTRACE == 1) */ + +#endif /* BASIC_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h b/CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h new file mode 100644 index 00000000000..9793cd0ed44 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ComponentServer_Configurator +// ------------------------------ +#ifndef COMPONENTSERVER_CONFIGURATOR_EXPORT_H +#define COMPONENTSERVER_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) +# define COMPONENTSERVER_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && COMPONENTSERVER_CONFIGURATOR_HAS_DLL */ + +#if !defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) +# define COMPONENTSERVER_CONFIGURATOR_HAS_DLL 1 +#endif /* ! COMPONENTSERVER_CONFIGURATOR_HAS_DLL */ + +#if defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) && (COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1) +# if defined (COMPONENTSERVER_CONFIGURATOR_BUILD_DLL) +# define ComponentServer_Configurator_Export ACE_Proper_Export_Flag +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* COMPONENTSERVER_CONFIGURATOR_BUILD_DLL */ +# define ComponentServer_Configurator_Export ACE_Proper_Import_Flag +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* COMPONENTSERVER_CONFIGURATOR_BUILD_DLL */ +#else /* COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1 */ +# define ComponentServer_Configurator_Export +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1 */ + +// Set COMPONENTSERVER_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (COMPONENTSERVER_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define COMPONENTSERVER_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define COMPONENTSERVER_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !COMPONENTSERVER_CONFIGURATOR_NTRACE */ + +#if (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) +# define COMPONENTSERVER_CONFIGURATOR_TRACE(X) +#else /* (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define COMPONENTSERVER_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) */ + +#endif /* COMPONENTSERVER_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp new file mode 100644 index 00000000000..47ee45a81a4 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp @@ -0,0 +1,11 @@ +#include "Config_Manager.h" + +namespace CIAO +{ + namespace Deployment + { + Config_Manager::~Config_Manager (void) + { + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h new file mode 100644 index 00000000000..2ce46aa980f --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h @@ -0,0 +1,53 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Config_Manager.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_CONFIG_MANAGER_H +#define CIAO_CONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +namespace CIAO +{ + namespace Deployment + { + /** + */ + class Config_Manager + { + public: + virtual ~Config_Manager (void) {}; + + virtual int pre_orb_initialize (void) = 0; + + virtual int post_orb_initialize (CORBA::ORB_ptr o) = 0; + + virtual void init_resources (const ServerResource &info) = 0; + + virtual void init (CORBA::ORB_ptr orb) = 0; + + virtual CORBA::PolicyList *find_policies_by_name (const char *name)= 0; + + virtual bool policy_exists (const char *name) = 0; + }; + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_MANAGER_H */ + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc b/CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc new file mode 100644 index 00000000000..dc072ddb6dc --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc @@ -0,0 +1,21 @@ +project(CIAO_FT_Basic_Configurator) : ccm_stub, ciao_ft_componentserver_stub, ciao_lib { + dynamicflags += COMPONENTSERVER_CONFIGURATOR_BUILD_DLL + Source_Files { + Server_Configurator.cpp + } + Header_Files { + Server_Configurator.h + } +} + +project(CIAO_FT_Basic_Config_Manager) : ciao_lib, ciao_config_manager, ciao_ft_componentserver_stub, \ + diffservpolicy { + dynamicflags += BASIC_CONFIG_MANAGER_BUILD_DLL + Source_Files { + Basic_Config_Manager.cpp + } + Header_Files { + Basic_Config_Manager.h + } +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h b/CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h new file mode 100644 index 00000000000..2e30fd59cc1 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_NA_Configurator +// ------------------------------ +#ifndef CIAO_NA_CONFIGURATOR_EXPORT_H +#define CIAO_NA_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_NA_CONFIGURATOR_HAS_DLL) +# define CIAO_NA_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_NA_CONFIGURATOR_HAS_DLL */ + +#if !defined (CIAO_NA_CONFIGURATOR_HAS_DLL) +# define CIAO_NA_CONFIGURATOR_HAS_DLL 1 +#endif /* ! CIAO_NA_CONFIGURATOR_HAS_DLL */ + +#if defined (CIAO_NA_CONFIGURATOR_HAS_DLL) && (CIAO_NA_CONFIGURATOR_HAS_DLL == 1) +# if defined (CIAO_NA_CONFIGURATOR_BUILD_DLL) +# define CIAO_NA_Configurator_Export ACE_Proper_Export_Flag +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_NA_CONFIGURATOR_BUILD_DLL */ +# define CIAO_NA_Configurator_Export ACE_Proper_Import_Flag +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_NA_CONFIGURATOR_BUILD_DLL */ +#else /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */ +# define CIAO_NA_Configurator_Export +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */ + +// Set CIAO_NA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_NA_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_NA_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_NA_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_NA_CONFIGURATOR_NTRACE */ + +#if (CIAO_NA_CONFIGURATOR_NTRACE == 1) +# define CIAO_NA_CONFIGURATOR_TRACE(X) +#else /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_NA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */ + +#endif /* CIAO_NA_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/CIAO_FT_NoOp_Configurator.vcproj b/CIAO/ciao/FTComponentServer/Configurators/NoOp/CIAO_FT_NoOp_Configurator.vcproj new file mode 100644 index 00000000000..8e239e4c5c3 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/CIAO_FT_NoOp_Configurator.vcproj @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc b/CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc new file mode 100644 index 00000000000..50cb9d50665 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc @@ -0,0 +1,12 @@ +project(CIAO_FT_NoOp_Configurator) : ccm_stub, ciao_ft_componentserver_stub, ciao_ft_componentserver_configurator, ciao_lib { + + Source_Files { + NoOp_Configurator.cpp + } + + Header_Files { + NoOp_Configurator.h + } +} + + diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp new file mode 100644 index 00000000000..e4c377e436a --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "NoOp_Configurator.h" + +namespace CIAO +{ + namespace Deployment + { + + NoOp_Configurator::~NoOp_Configurator (void) + { + // Not much to do. + } + + int + NoOp_Configurator::pre_orb_initialize () + { + return 0; + } + + int + NoOp_Configurator::post_orb_initialize (CORBA::ORB_ptr) + { + return 0; + } + + int + NoOp_Configurator::init_resource_manager + (const ::Components::ConfigValues & /*properties*/) + { + // @@ Currently do thing. We should go over the resource struct in + // the future and throw exceptions if there are + // un-recognizable/supported stuff in it. + return 0; + } + + CORBA::PolicyList * + NoOp_Configurator::find_container_policies + (const ::Components::ConfigValues & /*properties*/) + { + // Not much to do. + + return 0; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h new file mode 100644 index 00000000000..d84715d5bca --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h @@ -0,0 +1,66 @@ +/** $Id$ + * @file NoOp_Configurator.h + * @brief This file contains the noop configurator. + */ + +#ifndef NOOP_CONFIGURATOR_H +#define NOOP_CONFIGURATOR_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include + +#include "ciao/ComponentServer/Configurators/Server_Configurator.h" +#include "NoOp_Configurator_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @class NoOP_Configurator + * + * @brief The NoOp_Configurator doesn't do anything. + */ + class NoOp_Configurator_Export NoOp_Configurator + : public ComponentServer_Configurator + { + public: + /// Default destructor. + virtual ~NoOp_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "post_orb_initialize" is called after NodeApplication + * get a hold at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by NodeApplication when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Components::ConfigValues &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Components::ConfigValues &properties); + }; + } +} + +#include /**/ "ace/post.h" +#endif /* NOOP_CONFIGURATOR_H */ diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h new file mode 100644 index 00000000000..b6b3a9ec841 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl NoOp_Configurator +// ------------------------------ +#ifndef NOOP_CONFIGURATOR_EXPORT_H +#define NOOP_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (NOOP_CONFIGURATOR_HAS_DLL) +# define NOOP_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && NOOP_CONFIGURATOR_HAS_DLL */ + +#if !defined (NOOP_CONFIGURATOR_HAS_DLL) +# define NOOP_CONFIGURATOR_HAS_DLL 1 +#endif /* ! NOOP_CONFIGURATOR_HAS_DLL */ + +#if defined (NOOP_CONFIGURATOR_HAS_DLL) && (NOOP_CONFIGURATOR_HAS_DLL == 1) +# if defined (NOOP_CONFIGURATOR_BUILD_DLL) +# define NoOp_Configurator_Export ACE_Proper_Export_Flag +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* NOOP_CONFIGURATOR_BUILD_DLL */ +# define NoOp_Configurator_Export ACE_Proper_Import_Flag +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* NOOP_CONFIGURATOR_BUILD_DLL */ +#else /* NOOP_CONFIGURATOR_HAS_DLL == 1 */ +# define NoOp_Configurator_Export +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* NOOP_CONFIGURATOR_HAS_DLL == 1 */ + +// Set NOOP_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (NOOP_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define NOOP_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define NOOP_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !NOOP_CONFIGURATOR_NTRACE */ + +#if (NOOP_CONFIGURATOR_NTRACE == 1) +# define NOOP_CONFIGURATOR_TRACE(X) +#else /* (NOOP_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define NOOP_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (NOOP_CONFIGURATOR_NTRACE == 1) */ + +#endif /* NOOP_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp new file mode 100644 index 00000000000..4ec837c06fe --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp @@ -0,0 +1,513 @@ +// $Id$ + +#include "RTConfig_Manager.h" +#include "ciao/CIAO_common.h" +#include "ace/SString.h" + +#if !defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +void +CIAO::Deployment::RTResource_Config_Manager::init (CORBA::ORB_ptr orb) +{ + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB"); + this->rtorb_ = RTCORBA::RTORB::_narrow (object.in ()); +} + +int +CIAO::Deployment::RTResource_Config_Manager::pre_orb_initialize (void) +{ + return 0; +} + +int +CIAO::Deployment::RTResource_Config_Manager::post_orb_initialize (CORBA::ORB_ptr) +{ + return 0; +} + +void +CIAO::Deployment::RTResource_Config_Manager::print_resources +(const ServerResource &server_resource) +{ + const ORBResource &orb_resource + = server_resource.orb_config.orb_resources[0]; + + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < orb_resource.threadpool_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource threadpool: %s\n" + "\tStack size: %d\n" + "\tStatic: %d\n" + "\tDynamic %d\n" + "\tDefault Prio: %d\n" + "\tBuffering %s\n" + "\tMax Buffered: %d\n" + "\tBuffer Size %d\n", + orb_resource.threadpool_list[i].Id.in (), + orb_resource.threadpool_list[i].stacksize, + orb_resource.threadpool_list[i].static_threads, + orb_resource.threadpool_list[i].dynamic_threads, + orb_resource.threadpool_list[i].default_priority, + (orb_resource.threadpool_list[i].allow_request_buffering ? "Y" : "N"), + orb_resource.threadpool_list[i].max_buffered_requests, + orb_resource.threadpool_list[i].max_request_buffer_size)); + } + + for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource threadpool_with %d, lanes: %s\n", + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (), + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + + for (CORBA::ULong l = 0; + l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (); + ++l) + { + CIAO_DEBUG ((LM_DEBUG, + "\tLane %d:\n" + "\t\tPriority: %d\n" + "\t\tStatic: %d\n" + "\t\tDynamic: %d\n", + l, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads)); + } + CIAO_DEBUG ((LM_DEBUG, + "\tStack size: %d\n" + "\tBorrowing: %s\n" + "\tBuffering %s\n" + "\tMax Buffered: %d\n" + "\tBuffer Size %d\n", + orb_resource.threadpool_with_lanes_list[i].stacksize, + (orb_resource.threadpool_with_lanes_list[i].allow_borrowing ? "Y" : "N"), + (orb_resource.threadpool_with_lanes_list[i].allow_request_buffering ? "Y" : "N"), + orb_resource.threadpool_with_lanes_list[i].max_buffered_requests, + orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size)); + } + + for (i = 0; i < orb_resource.connection_bands_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource connection %d bands: %s\n", + orb_resource.connection_bands_list[i].bands.length (), + orb_resource.connection_bands_list[i].Id.in ())); + + for (CORBA::ULong l = 0; + l < orb_resource.connection_bands_list[i].bands.length (); + ++l) + { + CIAO_DEBUG ((LM_DEBUG, + "\tBand %d Prio: %d -- %d\n", + l, + orb_resource.connection_bands_list[i].bands[l].low, + orb_resource.connection_bands_list[i].bands[l].high)); + } + } +} + +void +CIAO::Deployment::RTResource_Config_Manager::init_resources +(const ServerResource &server_resource) +{ + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource.\n")); + + if (CORBA::is_nil (this->rtorb_.in())) + { + CIAO_ERROR ((LM_ERROR, + "RTResource_Config_Manager has not been properly initialized.\n")); + throw CORBA::INTERNAL (); + } + + this->print_resources (server_resource); + // return; + + const ORBResource &orb_resource + = server_resource.orb_config.orb_resources[0]; + + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < orb_resource.threadpool_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource threadpool: %s\n", + orb_resource.threadpool_list[i].Id.in ())); + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool + (orb_resource.threadpool_list[i].stacksize, + orb_resource.threadpool_list[i].static_threads, + orb_resource.threadpool_list[i].dynamic_threads, + orb_resource.threadpool_list[i].default_priority, + orb_resource.threadpool_list[i].allow_request_buffering, + orb_resource.threadpool_list[i].max_buffered_requests, + orb_resource.threadpool_list[i].max_request_buffer_size); + // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + if (this->threadpool_map_.bind (orb_resource.threadpool_list[i].Id.in (), + thr_id) != 0) + { + CIAO_ERROR ((LM_ERROR, "Error binding thread pool Id: %s to map when initializing RTNodeApplication resources.\n", orb_resource.threadpool_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added thread pool: %s\n", + orb_resource.threadpool_list[i].Id.in ())); + } + } + + for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource threadpool_with %d, lanes: %s\n", + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (), + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + + // Duplicate RTCORBA lanes + RTCORBA::ThreadpoolLanes lanes + (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ()); + lanes.length (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ()); + + for (CORBA::ULong l = 0; + l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (); + ++l) + { + lanes[l].lane_priority + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority; + lanes[l].static_threads + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads; + lanes[l].dynamic_threads + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads; + } + + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool_with_lanes + (orb_resource.threadpool_with_lanes_list[i].stacksize, + lanes, + orb_resource.threadpool_with_lanes_list[i].allow_borrowing, + orb_resource.threadpool_with_lanes_list[i].allow_request_buffering, + orb_resource.threadpool_with_lanes_list[i].max_buffered_requests, + orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size); + // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + + if (this->threadpool_map_.bind (orb_resource.threadpool_with_lanes_list[i].Id.in (), + thr_id) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding thread pool name: %s to map when " + "initializing RTNodeApplication resources.\n", + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added thread pool with lanes: %s\n", + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + } + } + + for (i = 0; i < orb_resource.connection_bands_list.length (); ++i) + { + RTCORBA::PriorityBands + safebands(orb_resource.connection_bands_list[i].bands.length ()); + safebands.length (orb_resource.connection_bands_list[i].bands.length ()); + + for (CORBA::ULong l = 0; + l < orb_resource.connection_bands_list[i].bands.length (); + ++l) + { + safebands[l].low = orb_resource.connection_bands_list[i].bands[l].low; + safebands[l].high = orb_resource.connection_bands_list[i].bands[l].high; + } + + if (this->priority_bands_map_.bind (orb_resource.connection_bands_list[i].Id.in (), + safebands) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding priority bands name: %s to map " + "when initializing RTNodeApplication resources.\n", + orb_resource.connection_bands_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added connection bands: %s\n", + orb_resource.connection_bands_list[i].Id.in ())); + } + } + + // now initialize the policy set part of it. + // server_resource.orb_config.policy_set + const PolicySets &sets = server_resource.orb_config.policy_set; + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong const np = sets[i].policies.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + CORBA::ULong index = 0; + CORBA::ULong array_index = np; + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + CORBA::Policy_var temp_policy = + this->create_single_policy (sets[i].policies[pc]); + if (CORBA::is_nil (temp_policy.in ())) + { + array_index = array_index - 1; + policy_list->length (array_index); + } + else + { + policy_list[index] = CORBA::Policy::_duplicate (temp_policy.in ()); + index = index + 1; + } + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (array_index != 0) + { + if (this->policy_map_.bind (sets[i].Id.in (), + policy_list._retn ()) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding Policy_Set with name: %s\n", + sets[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource " + "added policy set: %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource " + "added policy set: %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } +} + +void +CIAO::Deployment::RTResource_Config_Manager::fini () +{ + TP_MAP::ITERATOR iter = this->threadpool_map_.begin (); + TP_MAP::ITERATOR end = this->threadpool_map_.end (); + + for (; iter != end; ++iter) + { + this->rtorb_->destroy_threadpool ((*iter).int_id_); + } + +} + +RTCORBA::ThreadpoolId +CIAO::Deployment::RTResource_Config_Manager::find_threadpool_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_threadpool_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + + RTCORBA::ThreadpoolId ret_id = 0; // return id + + if (this->threadpool_map_.find (name, ret_id) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a threadpool named %s\n", + name)); + throw CORBA::INTERNAL (); + } + + return ret_id; +} + +RTCORBA::PriorityBands * +CIAO::Deployment::RTResource_Config_Manager::find_priority_bands_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_priority_bands_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + PB_MAP::ENTRY *entry = 0; + + if (this->priority_bands_map_.find (name, entry) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a connection bands named %s\n", + name)); + throw CORBA::INTERNAL (); + } + + RTCORBA::PriorityBands_var retv = new RTCORBA::PriorityBands; + (*retv.ptr ()) = (*entry->int_id_.ptr ()); + return retv._retn (); +} + +bool +CIAO::Deployment::RTResource_Config_Manager::policy_exists (const char *name) +{ + if (name == 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Invalid name string found in " + "CIAO::Deployment::NAResource_Config_Manager::policy_exists\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + return false; + } + + return true; +} + +CORBA::PolicyList * +CIAO::Deployment::RTResource_Config_Manager::find_policies_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_policies_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + + CIAO_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name: %s\n", + name)); + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a PolicyList named %s\n", + name)); + throw CORBA::INTERNAL (); + } + + // duplicate the sequence PolicyList. + CORBA::PolicyList_var retv = + new CORBA::PolicyList (entry->int_id_.in ()); + + CIAO_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name ok.\n")); + + return retv._retn (); +} + +CORBA::Policy_ptr +CIAO::Deployment::RTResource_Config_Manager::create_single_policy +(const PolicyDef &policy_def) +{ + // if (CIAO::Deployment::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::create_single_policy: %d\n", + policy_def._d ())); + + CORBA::Policy_var retv; + + switch (policy_def._d ()) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE: + { + const PriorityModelPolicyDef &tmp + = policy_def.PriorityModelDef (); + + retv = this->rtorb_->create_priority_model_policy ((RTCORBA::PriorityModel) tmp.priority_model, + tmp.server_priority); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "Create PriorityModel policy: %d - %d\n", + tmp.priority_model, tmp.server_priority)); + } + break; + + case RTCORBA::THREADPOOL_POLICY_TYPE: + { + RTCORBA::ThreadpoolId tpid = + this->find_threadpool_by_name (policy_def.ThreadpoolDef().Id.in ()); + + retv = this->rtorb_->create_threadpool_policy (tpid); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "Create Threadpool policy: %s, TPid: %d\n", + policy_def.ThreadpoolDef().Id.in (), tpid)); + } + break; + + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE: + { + RTCORBA::PriorityBands_var bands = + this->find_priority_bands_by_name (policy_def.PriorityBandedConnectionDef().Id.in ()); + + retv = + this->rtorb_->create_priority_banded_connection_policy (bands.in ()); + + if (! CORBA::is_nil (retv.in ())) + { + CIAO_DEBUG ((LM_DEBUG, + "Created Banded Connection policy: %s\n", + policy_def.PriorityBandedConnectionDef().Id.in ())); + } + } + break; + + default: + retv = 0; + } + + return retv._retn (); +} + +CIAO::Deployment::RTResource_Config_Manager::~RTResource_Config_Manager () +{ + this->fini (); +} + +extern "C" CIAO_RTNA_Configurator_Export CIAO::Deployment::Config_Manager +*create_rt_config_manager (void); + +CIAO::Deployment::Config_Manager * +create_rt_config_manager (void) +{ + CIAO::Deployment::RTResource_Config_Manager *config; + ACE_NEW_RETURN (config, CIAO::Deployment::RTResource_Config_Manager, 0); + return config; +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h new file mode 100644 index 00000000000..fbbea84d706 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h @@ -0,0 +1,138 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RTConfig_Manager.h + * + * $Id$ + * + * This file contains classes that manage name to configuration + * mapping info in a RTComponentServer. + * + * @author Nanbor Wang + */ +//============================================================================= + + +#ifndef CIAO_RTCONFIG_MANAGER_H +#define CIAO_RTCONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/SString.h" +#include "ace/Hash_Map_Manager_T.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +#include "ciao/ComponentServer/Configurators/Config_Manager.h" +#include "RTNA_Configurator_Export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @brief RTResource_Config_Manager maintains a collection of + * RTCORBA related resources. + * + * This class is responsible to create and manage a list of RTCORBA + * related resources that are global to an RT ComponentServer. The + * information required to create and configure these resources are + * passed in via the @a info argument in the @c init method. These + * resources are identified by names and can be used to associate + * these resources with related RTPolicies. These resources are + * destoryed along with this class. + * + * Currently, the only resources supported (and managed) by this + * class are Threadpool and Threadpool_with_Lanes. + */ + class RTResource_Config_Manager : public Config_Manager + { + public: + RTResource_Config_Manager (void); + ~RTResource_Config_Manager (void); + + virtual void init (CORBA::ORB_ptr orb); + + virtual int pre_orb_initialize (void); + + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /// Initializing the RTResource_Config_Manager + virtual void init_resources (const ServerResource &info); + + /// Finalizing the RTResource_Config_Manager and the resources it + /// manages. + void fini (); + + /// Query a policy set by name + virtual CORBA::PolicyList *find_policies_by_name (const char *name); + + virtual bool policy_exists (const char *name); + + protected: + void print_resources (const ServerResource &info); + + /// Query a thread pool by name. + RTCORBA::ThreadpoolId find_threadpool_by_name (const char *name); + + + /// Query a priority bands info by name. + RTCORBA::PriorityBands *find_priority_bands_by_name (const char *name); + + private: + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + // Cached an RTORB reference. + RTCORBA::RTORB_var rtorb_; + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> TP_MAP; + + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> PB_MAP; + + /// Internal TP name to id map. + TP_MAP threadpool_map_; + + /// Internal PB name to priority bands map. + PB_MAP priority_bands_map_; + + /// create a single policy + CORBA::Policy_ptr create_single_policy + (const PolicyDef &policy_def); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; +}; +} +} + +#if defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* CIAO_RTCONFIG_MANAGER_H */ + diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl new file mode 100644 index 00000000000..08aaef9f6ad --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl @@ -0,0 +1,8 @@ +// $Id$ + + +ACE_INLINE +CIAO::Deployment::RTResource_Config_Manager::RTResource_Config_Manager () +{ +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h b/CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h new file mode 100644 index 00000000000..689a871c7e5 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_RTNA_Configurator +// ------------------------------ +#ifndef CIAO_RTNA_CONFIGURATOR_EXPORT_H +#define CIAO_RTNA_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) +# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_RTNA_CONFIGURATOR_HAS_DLL */ + +#if !defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) +# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 1 +#endif /* ! CIAO_RTNA_CONFIGURATOR_HAS_DLL */ + +#if defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) && (CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1) +# if defined (CIAO_RTNA_CONFIGURATOR_BUILD_DLL) +# define CIAO_RTNA_Configurator_Export ACE_Proper_Export_Flag +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */ +# define CIAO_RTNA_Configurator_Export ACE_Proper_Import_Flag +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */ +#else /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */ +# define CIAO_RTNA_Configurator_Export +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */ + +// Set CIAO_RTNA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_RTNA_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_RTNA_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_RTNA_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_RTNA_CONFIGURATOR_NTRACE */ + +#if (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) +# define CIAO_RTNA_CONFIGURATOR_TRACE(X) +#else /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_RTNA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */ + +#endif /* CIAO_RTNA_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp new file mode 100644 index 00000000000..5f199f366aa --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp @@ -0,0 +1,108 @@ +// $Id$ + +#include "RTNodeApp_Configurator.h" +#include "DAnCE/Deployment/CIAO_ServerResourcesC.h" +#include "tao/RTPortableServer/RTPortableServer.h" + +CIAO::RTNodeApp_Configurator::~RTNodeApp_Configurator () +{ +} + +int +CIAO::RTNodeApp_Configurator::pre_orb_initialize () +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::pre_orb_init\n")); + + return 0; +} + +int +CIAO::RTNodeApp_Configurator::post_orb_initialize (CORBA::ORB_ptr o) +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::post_orb_init\n")); + + this->orb_ = CORBA::ORB::_duplicate (o); + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RTORB"); + + this->rtorb_ = + RTCORBA::RTORB::_narrow (object.in ()); + + this->config_manager_.init (this->rtorb_.in ()); + + return 0; +} + +int +CIAO::RTNodeApp_Configurator::init_resource_manager +(const ::Deployment::Properties &properties) +{ + + // if (CIAO::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager\n")); + // @@ Should we cache the properties that we consumed here? + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + // if (CIAO::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager processing property: %s\n", + properties[i].name.in ())); + + if (ACE_OS::strcmp ("CIAOServerResources", properties[i].name.in ()) == 0) + { + const CIAO::DAnCE::ServerResource *svr_resource; + if (properties[i].value >>= svr_resource) + { + this->config_manager_.init_resources (*svr_resource); + // Now we have the information to initialize the manager. + } + else + CIAO_ERROR_RETURN ((LM_ERROR, + "ERROR: RTNodeApp_Configurator::init_resource_manager unable to extract CIAOServerResources\n"), -1); + } + + // Ignore other stuff + } + + return 0; +} + +CORBA::PolicyList * +CIAO::RTNodeApp_Configurator::find_container_policies +(const ::Deployment::Properties &properties) +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies\n")); + // @@ Should we cache the properties that we consumed here? + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies processing property: %s\n", + properties[i].name.in ())); + + if (ACE_OS::strcmp ("ContainerPolicySet", properties[i].name) == 0) + { + const char *policy_name = 0; + if (properties[i].value >>= policy_name) + { + return this->config_manager_.find_policies_by_name (policy_name); + } + else + CIAO_ERROR_RETURN ((LM_ERROR, + "ERROR: RTNodeApp_Configurator::find_container_policies unable to extract ContainerPolicySet\n"), 0); + } + } + + return 0; +} + + +extern "C" CIAO_RTNA_Configurator_Export CIAO::NodeApp_Configurator *create_nodeapp_configurator (void); + +CIAO::NodeApp_Configurator * +create_nodeapp_configurator (void) +{ + CIAO::RTNodeApp_Configurator *config = 0; + ACE_NEW_RETURN (config, CIAO::RTNodeApp_Configurator, 0); + return config; +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h new file mode 100644 index 00000000000..fc2388b6aff --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h @@ -0,0 +1,78 @@ +// $Id$ +/**======================================================== + * + * @file RTNodeApp_Configurator.h + * + * @Brief This file contains the implementation of + * the RTNodeApp_Configurator, a concrete NodeApp_Configurator for + * setting up real-time support for NodeApplication. + * + * + * @author Nanbor Wang + *========================================================*/ + +#ifndef RTNODEAPP_CONFIGURATOR_H +#define RTNODEAPP_CONFIGURATOR_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "NodeApp_Configurator.h" +#include "RTNA_Configurator_Export.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "RTConfig_Manager.h" + +namespace CIAO +{ + /** + * @class RTNodeApp_Configurator + * + * @brief This class implements a concrete NodeApp_Configurator for + * setting up the NodeApplication process for RT support. + **/ + class CIAO_RTNA_Configurator_Export RTNodeApp_Configurator : + public NodeApp_Configurator + { + public: + /// Default destructor. + virtual ~RTNodeApp_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "initialize" is called after NodeApplication get a hold + * at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by NodeApplication when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Deployment::Properties &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Deployment::Properties &properties); + + protected: + CORBA::ORB_var orb_; + + RTCORBA::RTORB_var rtorb_; + + RTResource_Config_Manager config_manager_; + }; +} + +#include /**/ "ace/post.h" +#endif /* RTNODEAPP_CONFIGURATOR_H */ diff --git a/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp new file mode 100644 index 00000000000..406817972de --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp @@ -0,0 +1,334 @@ +// $Id$ + +#include "Server_Configurator.h" +#include "ace/Log_Msg.h" +#include "ciao/CIAO_common.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +namespace CIAO +{ + namespace Deployment + { + + ComponentServer_Configurator::ComponentServer_Configurator (bool rt) + : rt_support_ (rt) + { + } + + ComponentServer_Configurator::~ComponentServer_Configurator (void) + { + // Not much to do. + } + + void + ComponentServer_Configurator::set_rt_support (void) + { + this->rt_support_ = 1; + } + + bool + ComponentServer_Configurator::rt_support (void) + { + return this->rt_support_; + } + + bool + ComponentServer_Configurator::create_config_managers (void) + { + typedef CIAO::Deployment::Config_Manager * (*na_intelligent_designer)(void); + typedef CIAO::Deployment::Config_Manager * (*rtna_intelligent_designer)(void); + CIAO::Deployment::Config_Manager* ptr = 0; + CIAO::Deployment::Config_Manager* rt_ptr = 0; + + int retval = this->config_dll_.open (/*ACE_DLL_PREFIX*/ ACE_TEXT ("CIAO_Basic_Config_Manager"), + ACE_DEFAULT_SHLIB_MODE, + 0); + + if (0 != retval) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator - Error loading CIAO_Basic_Config_manager DLL: %p\n", + "dll.open"), + false); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_basic_config_manager")); + + ptrdiff_t tmp = reinterpret_cast (void_ptr); + + // "id" is for na_intelligent-designer. + na_intelligent_designer config_id = + reinterpret_cast (tmp); + + if (0 == config_id) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator - Error loading CIAO_Basic_Configurator entrypoint: %p\n", + "dll.symbol"), + false); + } + + ptr = config_id (); + + if (0 == ptr) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error creating ComponentServer_Configurator\n"), + false); + } + + this->na_config_manager_.reset (ptr); + + if (this->rt_support_) + { + int rt_retval = this->config_dll_.open (ACE_DLL_PREFIX ACE_TEXT ("CIAO_RTNA_Configurator"), + ACE_DEFAULT_SHLIB_MODE, + false); + + if (0 != rt_retval) + { + CIAO_ERROR_RETURN ((LM_ERROR, + "ComponentServer_Configurator - Error while loading CIAO_RTNA_Configurator: %p\n", + "dll.open"), + false); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *rt_void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_rt_config_manager")); + ptrdiff_t rt_tmp = reinterpret_cast (rt_void_ptr); + + // "id" is for na_intelligent-designer. + rtna_intelligent_designer rt_config_id = + reinterpret_cast (rt_tmp); + + if (0 == rt_config_id) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error while using RTNA entrypoint: %p", + "dll.symbol"), + false); + } + + rt_ptr = rt_config_id (); + + if (0 == rt_ptr) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error creating RTComponentServer_Configurator\n"), + false); + } + + this->rt_config_manager_.reset (rt_ptr); + } + + return true; + } + + int + ComponentServer_Configurator::pre_orb_initialize () + { + CIAO_DEBUG ((LM_TRACE,CLINFO "ComponentServer_Configurator::pre_orb_init\n")); + + (*this->na_config_manager_.get ()).pre_orb_initialize (); + if (this->rt_support_) + { + (*this->rt_config_manager_.get ()).pre_orb_initialize (); + } + + return 0; + } + + int + ComponentServer_Configurator::post_orb_initialize (CORBA::ORB_ptr o) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Configurator::post_orb_init\n")); + this->orb_ = CORBA::ORB::_duplicate (o); + + (*this->na_config_manager_.get ()).init (this->orb_.in ()); + if (this->rt_support_ == 1) + { + (*this->rt_config_manager_.get ()).init (this->orb_.in ()); + } + + (*this->na_config_manager_.get ()).post_orb_initialize (this->orb_.in ()); + if (this->rt_support_ == 1) + { + (*this->rt_config_manager_.get ()).post_orb_initialize (this->orb_.in ()); + } + + return 0; + } + + int + ComponentServer_Configurator::init_resource_manager + (const ::Components::ConfigValues &properties) + { + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp ("CIAOServerResources", properties[i]->name ()) == 0) + { + const ServerResource *svr_resource; + if (properties[i]->value () >>= svr_resource) + { + (*this->na_config_manager_.get ()). + init_resources (*svr_resource); + + if (this->rt_support_ == 1) + { + (*this->rt_config_manager_.get ()). + init_resources (*svr_resource); + } + } + else + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ERROR: ComponentServer_Configurator::" + "init_resource_manager unable to extract" + "CIAOServerResources\n"), -1); + } + } + } + + return 0; + } + + CORBA::PolicyList * + ComponentServer_Configurator::find_container_policies + (const ::Components::ConfigValues &properties) + { + if (!this->na_config_manager_.get ()) + return 0; + + CORBA::PolicyList *configured_policies = 0; + CORBA::PolicyList *rt_configured_policies = 0; + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp ("ContainerPolicySet", properties[i]->name ()) == 0) + { + const char *policy_name; + if (properties[i]->value () >>= policy_name) + { + configured_policies = (*this->na_config_manager_.get ()). + find_policies_by_name (policy_name); + + CORBA::ULong p_length = 0; + if (configured_policies != 0) + { + p_length = configured_policies->length (); + } + + if (this->rt_support_ == 1) + { + rt_configured_policies = (*this->rt_config_manager_.get ()). + find_policies_by_name (policy_name); + } + + CORBA::PolicyList_var temp_policies; + CORBA::ULong rtp_length = 0; + if (rt_configured_policies != 0) + { + rtp_length = rt_configured_policies->length (); + temp_policies = rt_configured_policies; + } + else + { + return configured_policies; + } + + CORBA::ULong final_length = p_length + rtp_length; + temp_policies->length (final_length); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + temp_policies[i+rtp_length] = + CORBA::Policy::_duplicate ((*configured_policies)[i]); + } + return temp_policies._retn (); + } + else + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ERROR: ComponentServer_Configurator:" + "find_container_policies unable to extract" + "ContainerPolicySet\n"), 0); + } + } + } + return 0; + } + + CORBA::PolicyList * + ComponentServer_Configurator::find_policies_by_name (const char *policy_name) + { + if (!this->na_config_manager_.get ()) + return 0; + + CORBA::PolicyList *configured_policies = 0; + CORBA::PolicyList *rt_configured_policies = 0; + + configured_policies = (*this->na_config_manager_.get ()). + find_policies_by_name (policy_name); + + CORBA::ULong p_length = 0; + if (configured_policies != 0) + { + p_length = configured_policies->length (); + } + + if (this->rt_support_ == 1) + { + rt_configured_policies = (*this->rt_config_manager_.get ()). + find_policies_by_name (policy_name); + } + + CORBA::PolicyList_var temp_policies; + CORBA::ULong rtp_length = 0; + if (rt_configured_policies != 0) + { + rtp_length = rt_configured_policies->length (); + temp_policies = rt_configured_policies; + } + else + { + return configured_policies; + } + + CORBA::ULong final_length = p_length + rtp_length; + temp_policies->length (final_length); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + temp_policies[i+rtp_length] = + CORBA::Policy::_duplicate ((*configured_policies)[i]); + } + return temp_policies._retn (); + } + + bool + ComponentServer_Configurator::policy_exists (const char *policy_set_id) + { + if (!this->na_config_manager_.get ()) + return 0; + + bool result; + result = (*this->na_config_manager_.get ()). + policy_exists (policy_set_id); + + if (result == false) + { + if (this->rt_support_ == 1) + { + result = (*this->rt_config_manager_.get ()). + policy_exists (policy_set_id); + } + } + return result; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h new file mode 100644 index 00000000000..4a8074b083d --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h @@ -0,0 +1,125 @@ +//$Id$ +/**======================================================== + * + * @file ComponentServer_Configurator.h + * + * @Brief This file contains the implementation of + * the basic ComponentServer_Configurator interface, the one + * that does nothing more + * + * @author Nanbor Wang + *========================================================*/ + +#ifndef COMPONENTSERVER_CONFIGURATOR_H +#define COMPONENTSERVER_CONFIGURATOR_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/DLL.h" +#include "ace/Auto_Ptr.h" +#include "ccm/CCM_StandardConfiguratorC.h" +#include "ComponentServer_Configurator_export.h" +#include "Config_Manager.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * + * @class ComponentServer_Configurator + * + * @brief This class defines and implements the default + * ComponentServer_Configurator base class that's needed for configuring the + * ComponentServer application process. + **/ + class ComponentServer_Configurator_Export ComponentServer_Configurator + { + public: + + /// Default constructor. + ComponentServer_Configurator (bool rt); + + /// Default destructor. + virtual ~ComponentServer_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "post_orb_initialize" is called after ComponentServer + * get a hold at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by ComponentServer when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Components::ConfigValues &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Components::ConfigValues &properties); + + /// @@ Perhaps we also need a finalizer method here. Perhaps we + /// even need to differentiate finalizer before ORB is destroyed + /// and the one after that. + + bool rt_support (void); + + void set_rt_support (void); + + virtual bool create_config_managers (void); + + bool policy_exists (const char *policy_set_id); + + CORBA::PolicyList * + find_policies_by_name (const char *name); + + protected: + + int rt_support_; + + CORBA::ORB_var orb_; + + auto_ptr rt_config_manager_; + + auto_ptr na_config_manager_; + + ACE_DLL config_dll_; + }; + } +} + +/** + * For dynamically linkable concrete ComponentServer_Configurator + * implementation, remember to create a factory method using "C" + * calling convention in the CPP file as follow: + + extern "C" EXPORT_MACRO CIAO::ComponentServer_Configurator *create_nodeapp_configurator (void); + + CIAO::ComponentServer_Configurator * + create_nodeapp_configurator (void) + { + concrete_ComponentServer_Configurator *config; + ACE_NEW_RETURN (config, concrete_ComponentServer_Configurator, 0); + return config; + } + +*/ + + +#include /**/ "ace/post.h" +#endif /* NODEAPP_CONFIGURATOR_H */ + diff --git a/CIAO/ciao/FTComponentServer/Name_Helper_T.h b/CIAO/ciao/FTComponentServer/Name_Helper_T.h new file mode 100644 index 00000000000..16da1d6c901 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Name_Helper_T.h @@ -0,0 +1,196 @@ +#ifndef _NAME_HELPER_T_H_ +#define _NAME_HELPER_T_H_ + +#include +#include +#include + +class Name_Helper_Exception : public std::domain_error +{ + public: + Name_Helper_Exception (const std::string & reason = "") + : std::domain_error (reason) {} +}; + +template +class Name_Helper_T +{ + public: + Name_Helper_T (CORBA::ORB_ptr orb, bool use_env_var = false) + { + CORBA::Object_var ns_obj; + + if (use_env_var) + { + std::string ns_ior = ACE_Env_Value ("NameServiceIOR", + std::string ()); + + if (ns_ior.empty ()) + { + throw Name_Helper_Exception ("Name_Helper_T - no NameServiceIOR env variable"); + } + + ns_obj = orb->string_to_object (ns_ior.c_str ()); + } + else + { + ns_obj = orb->resolve_initial_references ("NameService"); + } + + if (CORBA::is_nil (ns_obj.in ())) + { + throw Name_Helper_Exception ("Name_Helper_T - could not resolve NameService"); + } + + ns_ = CosNaming::NamingContextExt::_narrow (ns_obj.in ()); + + if (CORBA::is_nil (ns_.in ())) + { + throw Name_Helper_Exception ("Name_Helper_T - could not narrow to NameContextExt"); + } + } + + void bind (std::string path, typename T::_ptr_type obj) + { + size_t last_slash = path.find_last_of ('/'); + + std::string obj_name; + std::string obj_path; + + if (last_slash != std::string::npos) + { + obj_path = path.substr (0, last_slash); + obj_name = path.substr (last_slash + 1); + } + else + { + obj_name = path; + } + + if (obj_name.empty ()) + throw Name_Helper_Exception ("Name_Helper_T::bind - no object name."); + + ACE_DEBUG ((LM_INFO, "path=%s, name=%s\n", obj_path.c_str (), obj_name.c_str ())); + + CosNaming::Name_var name; + CosNaming::NamingContext_var nc; + + if (!obj_path.empty ()) + { + name = ns_->to_name (obj_path.c_str ()); + + nc = CosNaming::NamingContext::_narrow (ns_.in ()); + + CosNaming::Name entry; + entry.length (1); + + for (size_t i = 0; + i < name->length (); + ++i) + { + entry[0] = CosNaming::NameComponent (name[i]); + try + { + nc = nc->bind_new_context (entry); + } + catch (CosNaming::NamingContext::AlreadyBound & ex) + { + // if the entry is already there just go on + nc = CosNaming::NamingContext::_narrow (nc->resolve (entry)); + } + } + } + + name = ns_->to_name (obj_name.c_str ()); + + try + { + nc->bind (name, obj); + } + catch (CosNaming::NamingContext::AlreadyBound & e) + { + nc->rebind (name, obj); + } + } + + void unbind (const std::string & path, size_t depth = 0) + { + std::string current_path = path; + size_t current_depth = 0; + CosNaming::Name_var name; + + if (path.empty ()) + throw Name_Helper_Exception ("Name_Helper_T::unbind - empty path"); + + do + { + name = ns_->to_name (current_path.c_str ()); + + CosNaming::NamingContext_var nc = + CosNaming::NamingContext::_narrow ( + ns_->resolve (name.in ())); + + bool no_more_entries = true; + + if (!CORBA::is_nil (nc.in ())) + { + CosNaming::BindingList_var bl; + CosNaming::BindingIterator_var bit; + nc->list (2, bl.out (), bit.out ()); + + if (bl->length () > 0) + no_more_entries = false; + } + + if (no_more_entries) + ns_->unbind (name.in ()); + + if (current_depth < depth) + { + size_t pos = current_path.find_last_of ('/'); + + if (pos == std::string::npos) + break; + + current_path = current_path.substr (0, pos); + ++current_depth; + } + } + while (depth >= current_depth); + } + + typename T::_ptr_type resolve (const std::string & path) + { + CORBA::Object_var obj = ns_->resolve_str (path.c_str ()); + + typename T::_var_type ret = T::_narrow (obj.in ()); + + if (CORBA::is_nil (ret.in ())) + throw Name_Helper_Exception ("Name_Helper_T::resolve - could not narrow resolved obj"); + + return ret._retn (); + } + + std::string escape_dots (const std::string &path) + { + std::string esc_path (path); + + // replace all dots in the path with excaped dots for + // to_name conversion. + for (size_t pos = esc_path.find ('.', 0); + pos < esc_path.length (); + pos = esc_path.find ('.', pos)) + { + esc_path.replace (pos, 1, "\\."); + pos += 2; + } + + return esc_path; + } + + private: + CORBA::ORB_var orb_; + CosNaming::NamingContextExt_var ns_; +}; + +#endif /* _NAME_HELPER_T_H_ */ -- cgit v1.2.1