diff options
Diffstat (limited to 'CIAO/ciao/ComponentServer')
20 files changed, 66 insertions, 3098 deletions
diff --git a/CIAO/ciao/ComponentServer/CIAO_Base.mpc b/CIAO/ciao/ComponentServer/CIAO_Base.mpc new file mode 100644 index 00000000000..cff6c631d1f --- /dev/null +++ b/CIAO/ciao/ComponentServer/CIAO_Base.mpc @@ -0,0 +1,59 @@ +// $Id$ + +project(CIAO_Base_IDL) : install, ciaoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_BASE_STUB_Export \ + -Wb,stub_export_include=CIAO_Base_stub_export.h \ + -SS -Sci + custom_only=1 + + IDL_Files { + CIAO_Properties.idl + idlflags += -Gxhst + } + + IDL_Files { + CIAO_FailureReasons.idl + } +} + +project(CIAO_Base_stub) : install, ciaolib_with_idl, ciao_output, \ + ciao_logger, ciao_lib, \ + ccm_cookie, ccm_configvalue { + dynamicflags = CIAO_BASE_STUB_BUILD_DLL + after += CIAO_Base_IDL + + IDL_Files { + } + Source_Files { + CIAO_PropertiesC.cpp + CIAO_FailureReasonsC.cpp + Server_init.cpp + Client_init.cpp + } + Header_Files { + CIAO_FailureReasonsC.h + CIAO_PropertiesC.h + Server_init.h + Client_init.h + CIAO_Properties_stub_export.h + } + + specific { + install_dir = ciao + } + InstallData_Files { + gendir = . + ../../COPYING + ../../NEWS + ../../PROBLEM-REPORT-FORM + ../../VERSION + ../../docs + ../../MPC + } + verbatim(gnuace, postinstall) { +" cp ../../rules.ciao.GNU $(INSTALL_PREFIX)/share/ciao" +" perl -i -pe's!\\$$[{(]CIAO_ROOT[})]!$(INSTALL_PREFIX)/include!g;' -e'if (/ifndef TAO_IDL3_TO_IDL2\\b/) {print qq!TAO_IDL3_TO_IDL2=$(INSTALL_PREFIX)/share/ciao/bin/tao_idl3_to_idl2\\nTAO_IDL3_TO_IDL2DEP=\\$$(TAO_IDL3_TO_IDL2)\\$$(EXEEXT)\\n!}' $(INSTALL_PREFIX)/share/ciao/rules.ciao.GNU" +" echo export CIAO_ROOT=$(INSTALL_PREFIX)/share/ciao> $(INSTALL_PREFIX)/share/ciao/ciao-devel.sh" +" echo export DANCE_ROOT=$(INSTALL_PREFIX)/share/DAnCE>> $(INSTALL_PREFIX)/share/ciao/ciao-devel.sh" + } +} diff --git a/CIAO/ciao/ComponentServer/CIAO_CS_Client.idl b/CIAO/ciao/ComponentServer/CIAO_CS_Client.idl deleted file mode 100644 index c966ac7ccf5..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_CS_Client.idl +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file CIAO_CS_Client.idl - * @author William R. Otte <wotte@dre.vanderbilt.edu> - * $Id$ - * A couple CIAO-specific extensions to the component server client - * interfaces. - */ - -#ifndef CIAO_COMPONENTSERVER_IDL_ -#define CIAO_COMPONENTSERVER_IDL_ - -#include <ccm/ComponentServer/CCM_ComponentServer_Client.idl> - -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/ComponentServer/CIAO_ComponentInstallation_Impl.cpp b/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.cpp deleted file mode 100644 index 4e6b323ccdb..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// $Id$ - -#include "CIAO_ComponentInstallation_Impl.h" -#include "ciao/Logger/Log_Macros.h" - -namespace CIAO -{ - namespace Deployment - { - - ComponentInstallation_Impl::ComponentInstallation_Impl() - { - CIAO_TRACE ("ComponentInstallation_Impl::ComponentInstallation_Impl"); - } - - ComponentInstallation_Impl::~ComponentInstallation_Impl() - { - CIAO_TRACE ("ComponentInstallation_Impl::~ComponentInstallation_Impl"); - } - - void - ComponentInstallation_Impl::install (const char * implUUID, const char * component_loc) - { - CIAO_TRACE ("ComponentInstallation_Impl::install"); - - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "ComponentInstallation_Impl::install - " - "implUUID %C, component_loc %C\n", implUUID, component_loc)); - - ACE_CString location = component_loc; - - if (0 == this->locations_.find (implUUID)) - { - this->locations_.bind (implUUID, location); - } - else - { - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "ComponentInstallation_Impl::install - Location for artifact %C " - "already present, replacing.\n", - implUUID)); - this->locations_.rebind (implUUID, location); - } - } - - - void - ComponentInstallation_Impl::replace (const char *uuid, const char *loc) - { - CIAO_TRACE ("ComponentInstallation_Impl::replace"); - - this->locations_.rebind (uuid, loc); - } - - void - ComponentInstallation_Impl::remove (const char *uuid) - { - CIAO_TRACE ("ComponentInstallation_Impl::remove"); - this->locations_.unbind (uuid); - } - - char * - ComponentInstallation_Impl::get_implementation (const char * implUUID) - { - CIAO_TRACE ("ComponentInstallation_Impl::get_implementation"); - - ACE_CString s; - if (0 == this->locations_.find (implUUID, s)) - { - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "ComponentInstallation_Impl::get_implementation - " - "ComponentInstallation_Impl::get_implementation for UUID %C, location %C\n", - implUUID, s.c_str())); - - return CORBA::string_dup (s.c_str()); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "ComponentInstallation_Impl::get_implementation - " - "cannot find location for specified implementation UUID %C\n", implUUID)); - throw ::Components::Deployment::UnknownImplId(); - return 0; - } - } - - - char * - ComponentInstallation_Impl::get_valuetypefactory_location (const char * implUUID, - const char * repid) - { - CIAO_TRACE ("ComponentInstallation_Impl::get_valuetypefactory_location"); - - ACE_CString key = ComponentInstallation_Impl::valuefactory_key (implUUID, repid); - ACE_CString s; - if (0 == this->locations_.find (implUUID, s)) - { - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "ComponentInstallation_Impl::get_valuetypefactory_location - " - "UUID:\"%C\" repid:\"%C\" -> location:\"%C\"\n", implUUID, repid, s.c_str())); - return CORBA::string_dup (s.c_str()); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "ComponentInstallation_Impl::get_valuetypefactory_location - " - "cannot find location for implementation UUID %C and repid %C.\n", implUUID, repid)); - throw ::Components::Deployment::InstallationFailure(); - return 0; - } - return 0; - } - - - void - ComponentInstallation_Impl::install_valuetypefactory_location (const char * implUUID, - const char * repid, - const char * loc) - { - CIAO_TRACE ("ComponentInstallation_Impl::install_valuetypefactory_location"); - 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/ComponentServer/CIAO_ComponentInstallation_Impl.h b/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.h deleted file mode 100644 index 3ca52bb1608..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file CIAO_ComponentInstallation_Impl.h - * - * $Id$ - * - * @brief Return location of component artifact - * - * @author Erwin Gottlieb <eg@prismtech.com> - */ -//============================================================================= - -#ifndef COMPONENTINSTALLATION_IMPL_H_ -#define COMPONENTINSTALLATION_IMPL_H_ - -#include "ace/Map_Manager.h" -#include "ciao/ComponentServer/CIAO_CS_ClientS.h" - -#include "tao/ORB.h" -#include "ciao/ComponentServer/CIAO_CS_Client_svnt_export.h" - -namespace CIAO -{ - namespace Deployment - { - - class CIAO_CS_CLIENT_SVNT_Export ComponentInstallation_Impl - : public virtual POA_Components::Deployment::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/ComponentServer/CIAO_ComponentServer.cpp b/CIAO/ciao/ComponentServer/CIAO_ComponentServer.cpp deleted file mode 100644 index 11960829c16..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file CIAO_ComponentServer.cpp - * @author William R. Otte - * $Id$ - * - * Implementation and main for CIAO_ComponentServer. - */ - -#include "CIAO_ComponentServer_Task.h" -#include "ciao/Logger/Log_Macros.h" - -int ACE_TMAIN (int argc, ACE_TCHAR **argv) -{ - // Tracing disabled by default - CIAO_DISABLE_TRACE (); - - CIAO_TRACE ("CIAO_ComponentServer::ACE_TMAIN"); - - int retval = 0; - try - { - CIAO::Deployment::ComponentServer_Task cs (argc, argv); - cs.run (); - - // Wait for the threads to exit. - //ACE_Thread_Manager::instance ()->wait (); - } - catch (const CIAO::Deployment::ComponentServer_Task::Error &e) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_ComponentServer main: Caught ComponentServer exception: %C\n", - e.err_.c_str ())); - retval = -1; - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("CIAO_ComponentServer main: Caught corba exception:"); - retval = -1; - } - catch (...) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_ComponentServer main: Caught unknown exception.\n")); - retval = -1; - } - - return retval; -} - diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl b/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl deleted file mode 100644 index 0acb62bb092..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file CIAO_ComponentServer.idl - * @author William R. Otte <wotte@dre.vanderbilt.edu> - * $Id$ - * A couple CIAO-specific extensions to the component server - * interfaces. - */ - -#ifndef CIAO_COMPONENTSERVER_IDL_ -#define CIAO_COMPONENTSERVER_IDL_ - -#include <ccm/CCM_Object.idl> -#include <ccm/ComponentServer/CCM_ComponentServer.idl> - -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 (); - - void connect_local_facet (in ::Components::CCMObject provider_ref, - in string provider_port, - in ::Components::CCMObject user_ref, - in string user_port) - raises (::Components::InvalidConnection, - ::Components::AlreadyConnected); - - void disconnect_local_facet (in ::Components::CCMObject provider_ref, - in string provider_port, - in ::Components::CCMObject user_ref, - in string user_port) - raises (::Components::InvalidConnection); - }; - }; -}; - -#endif /* CIAO_COMPONENTSERVER_IDL_ */ diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.mpc b/CIAO/ciao/ComponentServer/CIAO_ComponentServer.mpc deleted file mode 100644 index 901c09024d4..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.mpc +++ /dev/null @@ -1,170 +0,0 @@ -// $Id$ - -project(CIAO_ComponentServer_IDL) : install, ciaoidldefaults, anytypecode { - idlflags += -Wb,stub_export_macro=CIAO_COMPONENTSERVER_STUB_Export \ - -Wb,stub_export_include=CIAO_ComponentServer_stub_export.h \ - -Wb,skel_export_macro=CIAO_COMPONENTSERVER_SVNT_Export \ - -Wb,skel_export_include=CIAO_ComponentServer_svnt_export.h \ - -Gxhst -Gxhsk - - custom_only=1 - - IDL_Files { - CIAO_ComponentServer.idl - } - specific { - install_dir = ciao/ComponentServer - } -} - -project(CIAO_CS_Client_IDL) : install, ciaoidldefaults, anytypecode { - idlflags += -Wb,stub_export_macro=CIAO_COMPONENTSERVER_STUB_Export \ - -Wb,stub_export_include=CIAO_ComponentServer_stub_export.h \ - -Wb,skel_export_macro=CIAO_CS_CLIENT_SVNT_Export \ - -Wb,skel_export_include=CIAO_CS_Client_svnt_export.h - - custom_only=1 - - IDL_Files { - CIAO_Properties.idl - idlflags += -SS -Sci -Gxhsk - } - IDL_Files { - CIAO_CS_Client.idl - } - IDL_Files { - idlflags += -Sci -SS - CIAO_FailureReasons.idl - } - specific { - install_dir = ciao/ComponentServer - } -} - -project(CIAO_ComponentServer_stub) : install, ccm_componentserver_stub, ciaolib_with_idl, ciao_output, \ - messaging, anytypecode, ciao_logger, ciao_lib, ccm_configvalue, \ - ccm_cookie { - after += CIAO_ComponentServer_IDL CIAO_CS_Client_IDL - dynamicflags = CIAO_COMPONENTSERVER_STUB_BUILD_DLL - - IDL_Files { - } - Source_Files { - CIAO_ComponentServerC.cpp - CIAO_CS_ClientC.cpp - CIAO_PropertiesC.cpp - Server_init.cpp - Client_init.cpp - } - Header_Files { - CIAO_ComponentServer_stub_export.h - CIAO_ComponentServerC.h - CIAO_CS_ClientC.h - CIAO_PropertiesC.h - } - Inline_Files { - CIAO_ComponentServerC.inl - CIAO_CS_ClientC.inl - } - specific { - install_dir = ciao/ComponentServer - } -} - -project(CIAO_CS_Client_svnt) : install, ccm_svnt, ccm_componentserver_svnt, ciao_componentserver_stub, portableserver, \ - ciao_lib, threads, avoids_ace_for_tao, ciao_logger { - dynamicflags = CIAO_CS_CLIENT_SVNT_BUILD_DLL - after += CIAO_CS_Client_IDL - IDL_Files { - } - Source_Files { - CIAO_ServerActivator_Impl.cpp - CIAO_ComponentInstallation_Impl.cpp - CIAO_CS_ClientS.cpp - } - Header_Files { - CIAO_ServerActivator_Impl.h - CIAO_ComponentInstallation_Impl.h - CIAO_CS_ClientS.h - CIAO_CS_Client_svnt_export.h - } - Inline_Files { - CIAO_CS_ClientS.inl - } - specific { - install_dir = ciao/ComponentServer - } -} - -project(CIAO_ComponentServer_svnt) : install, ccm_componentserver_svnt, ciao_componentserver_stub, portableserver, \ - ciao_session_container, ciao_lib, ciao_cs_client { - dynamicflags = CIAO_COMPONENTSERVER_SVNT_BUILD_DLL - - IDL_Files { - } - Source_Files { - CIAO_ComponentServer_Impl.cpp - CIAO_ComponentServerS.cpp - CIAO_Container_Impl.cpp - } - Header_Files { - CIAO_ComponentServer_svnt_export.h - CIAO_ComponentServerS.h - CIAO_PropertiesS.h - } - Inline_Files { - CIAO_ComponentServerS.inl - } - specific { - install_dir = ciao/ComponentServer - } -} - -project(CIAO_ComponentServer_exe) : install, ccm_componentserver_svnt, portableserver, ciao_componentserver_svnt, \ - messaging, anytypecode, ciaoexe, ciao_session_container,\ - ciao_logger { - exename = ciao_componentserver - Source_Files { - CIAO_ComponentServer.cpp - CIAO_ComponentServer_Task.cpp - } - Inline_Files { - } - IDL_Files { - } - - specific { - install_dir = ciao - } - InstallData_Files { - gendir = . - ../../COPYING - ../../NEWS - ../../PROBLEM-REPORT-FORM - ../../VERSION - ../../docs - ../../MPC - } - verbatim(gnuace, postinstall) { -" cp ../../rules.ciao.GNU $(INSTALL_PREFIX)/share/ciao" -" perl -i -pe's!\\$$[{(]CIAO_ROOT[})]!$(INSTALL_PREFIX)/include!g;' -e'if (/ifndef TAO_IDL3_TO_IDL2\\b/) {print qq!TAO_IDL3_TO_IDL2=$(INSTALL_PREFIX)/share/ciao/bin/tao_idl3_to_idl2\\nTAO_IDL3_TO_IDL2_DEP=\\$$(TAO_IDL3_TO_IDL2)\\$$(EXEEXT)\\n!}' $(INSTALL_PREFIX)/share/ciao/rules.ciao.GNU" -" echo export CIAO_ROOT=$(INSTALL_PREFIX)/share/ciao> $(INSTALL_PREFIX)/share/ciao/ciao-devel.sh" -" echo export DANCE_ROOT=$(INSTALL_PREFIX)/share/DAnCE>> $(INSTALL_PREFIX)/share/ciao/ciao-devel.sh" - } -} - -project(CIAO_RTComponentServer_exe) : install, ccm_componentserver_svnt, portableserver, ciao_componentserver_svnt, \ - messaging, anytypecode, ciaoexe, ciao_session_container,\ - ciao_logger, rt_server, rtportableserver { - exename = ciao_rtcomponentserver - Source_Files { - CIAO_RTComponentServer.cpp - CIAO_RTComponentServer_Task.cpp - } - Inline_Files { - } - IDL_Files { - } - -} - diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.cpp b/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.cpp deleted file mode 100644 index a2dd4343e44..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// $Id$ -#include "CIAO_ComponentServer_Impl.h" - -#include "ciao/Logger/Log_Macros.h" - -#include "CIAO_CS_ClientC.h" -#include "CIAO_Container_Impl.h" -#include "CIAO_PropertiesC.h" - -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 (6, (LM_DEBUG, CLINFO - "CIAO_ComponentServer_i::shutdown - ORB shutdown request " - "received at %C.\n", - this->uuid_.c_str ())); - - if (!this->containers_.is_empty ()) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_ComponentServer_i::shutdown - ComponentServer %C " - "still has %u containers!\n", - this->uuid_.c_str (), - this->containers_.size ())); - } - - 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 (6, (LM_INFO, CLINFO - "CIAO_ComponentServer_i::create_container - Request " - "received with %u config values\n", - config.length ())); - - CORBA::PolicyList policies; - const char *name = 0; - CIAO_Container_i *cont = 0; - ACE_NEW_THROW_EX (cont, - CIAO_Container_i (config, 0, name, &policies, - this->ci_.in (), this->orb_.in (), - this->poa_.in ()), - CORBA::NO_MEMORY ()); - - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "CIAO_ComponentServer_i::create_container - " - "Container servant successfully allocated.\n")); - - PortableServer::ServantBase_var safe_config = cont; - PortableServer::ObjectId_var id = - this->poa_->activate_object (cont); - CORBA::Object_var object = this->poa_->id_to_reference (id.in ()); - CIAO::Deployment::Container_var cont_var = - CIAO::Deployment::Container::_narrow (object.in ()); - - this->containers_.insert (CIAO::Deployment::Container::_duplicate(cont_var.in ())); - - CIAO_DEBUG (6, (LM_INFO, CLINFO - "CIAO_ComponentServer_i::create_container - Container successfully activated and stored," - " now managing %u containers\n", - this->containers_.size ())); - - return cont_var._retn (); - } - catch (const CORBA::NO_MEMORY &) - { - CIAO_ERROR (1, (LM_CRITICAL, CLINFO "CIAO_ComponentServer_Impl: Out of memory exception whilst creating container.\n")); - throw; - } - catch (...) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "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 (9, (LM_TRACE, CLINFO - "CIAO_ComponentServer_i::remove_container - Remove request received.\n")); - - if (CORBA::is_nil (cref)) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_ComponentServer_i::remove_container - " - "Error: Received nil container reference\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 (9, (LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Found container, invoking remove....\n")); - cref->remove (); - if (this->containers_.remove (*i) != 0) - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_ComponentServer_i::remove_container - Unable to remove " - "container reference from internal structure....\n")); - CIAO_DEBUG (9, (LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Remove completed, destroying object, " - "now manage %u containers\n", this->containers_.size ())); - return; - } - } - } - catch (const CORBA::Exception &ex) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - " - "Caught CORBA exception whilst removing container: %C\n", - ex._info ().c_str ())); - } - catch (...) - { - CIAO_ERROR (1, (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; - 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 (const CORBA::Exception &ex) - { - successful = false; - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_ComponentServer_i::remove - " - "Intercepted CORBA exception while trying to remove a container:%C\n", - ex._info ().c_str ())); - } - catch (...) - { - successful = false; - CIAO_ERROR (1, (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); - if (cvs != 0) - { - this->config_values_ = cvs; - - for (CORBA::ULong i = 0; i < this->config_values_->length (); ++i) - { - if (ACE_OS::strcmp (CIAO::Deployment::COMPONENTINSTALLATION_REF, - this->config_values_[i]->name ()) == 0) - { - Components::Deployment::ComponentInstallation_ptr tmp; - this->config_values_[i]->value () >>= tmp; - this->ci_ = Components::Deployment::ComponentInstallation::_duplicate (tmp); - } - } - } - } - } -} diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.h b/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.h deleted file mode 100644 index 354bc5a7af7..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.h +++ /dev/null @@ -1,82 +0,0 @@ -// $Id$ -/** - * @file CIAO_ComponentServer_Impl.h - * @author William R. Otte <wotte@dre.vanderbilt.edu> - */ - -#ifndef CIAO_COMPONENTSERVER_IMPL_H_ -#define CIAO_COMPONENTSERVER_IMPL_H_ - -#include "ciao/ComponentServer/CIAO_ComponentServerS.h" -#include "ciao/ComponentServer/CIAO_CS_ClientC.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<typename T> - struct _is_equivalent - { - bool operator() (const T &a, const T &b) const - { - return a->_is_equivalent (const_cast <T&> (b)); - } - }; - - typedef ACE_Unbounded_Set_Ex <Container_var, - _is_equivalent<Container_var> > CONTAINERS; - - CONTAINERS containers_; - - Components::Deployment::ComponentInstallation_var ci_; - }; - } -} - -#endif diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Task.cpp b/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Task.cpp deleted file mode 100644 index 732c8e33a30..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Task.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/** - * @file CIAO_ComponentServer_Task.cpp - * @author William R. Otte - * $Id$ - * - * Implementation and main for CIAO_ComponentServer. - */ - -#include "CIAO_ComponentServer_Task.h" - -#include "ace/OS_NS_string.h" -#include "ace/Log_Msg.h" -#include "ace/Get_Opt.h" -#include "tao/ORB.h" -#include "tao/PortableServer/PortableServer.h" -#include "ciao/Logger/Logger_Service.h" -#include "ciao/Logger/Log_Macros.h" -#include "CIAO_ComponentServer_Impl.h" -#include "Server_init.h" - -namespace CIAO -{ - namespace Deployment - { - ComponentServer_Task::Error::Error(const ACE_CString &err) : err_(err) - { - } - - ComponentServer_Task::ComponentServer_Task (int argc, ACE_TCHAR **argv) - { - CIAO_TRACE ("CIAO_ComponentServer_Task::CIAO_ComponentServer_Task ()"); - - Logger_Service - *clf = ACE_Dynamic_Service<Logger_Service>::instance ("CIAO_Logger"); - - if (clf) - { - clf->init (argc, argv); - } - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " - "Creating ORB\n")); - - this->orb_ = CORBA::ORB_init (argc, argv); - - this->parse_args (argc, argv); - - CIAO::Server_init (this->orb_.in ()); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " - "CIAO_ComponentServer object created.\n")); - } - - int - ComponentServer_Task::svc (void) - { - CIAO_TRACE ("ComponentServer_Task::svc"); - - CIAO_DEBUG (9, (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 (9, (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 (1, (LM_CRITICAL, - "ComponentServer_Task::run - " - "Out of memory error while allocating servant.")); - throw Error ("Out of memory whilst allocating servant."); - } - - PortableServer::ServantBase_var safe_config = ci_srv; - PortableServer::ObjectId_var id = - root_poa->activate_object (ci_srv); - CORBA::Object_var cs_object = root_poa->id_to_reference (id.in ()); - ComponentServer_var cs = - ComponentServer::_narrow (cs_object.in ()); - - if (this->output_file_ != ACE_TEXT("")) - { - CORBA::String_var ior = this->orb_->object_to_string (cs.in ()); - ::CIAO::Utility::write_IOR (this->output_file_.c_str (), ior.in ()); - } - - if (this->callback_ior_str_ != ACE_TEXT("")) - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "ComponentServer_Task::run - " - "Resolving callback IOR\n")); - CORBA::Object_var 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 (6, (LM_ERROR, CLINFO - "ComponentServer_Task::svc - " - "Failed to narrow callback IOR [%s]\n", - this->callback_ior_str_.c_str ())); - throw Error ("Failed to narrow callback IOR"); - } - - Components::ConfigValues_var config; - { - Components::ConfigValues *cf = 0; - ACE_NEW_NORETURN (cf, Components::ConfigValues (0)); - - if (cf == 0) - { - CIAO_ERROR (1, (LM_CRITICAL, "ComponentServer_Task::run - " - "Out of memory error while allocating config values.")); - } - else - { - config = cf; - } - } - - // Make callback. - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "ComponentServer_Task::svc - " - "Making callback on my ServerActivator\n")); - - try - { - // Callback to NodeApplication to get configuration - sa->component_server_callback (cs.in (), - this->uuid_.c_str (), - config.out ()); - - CIAO_DEBUG (9, (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 (6, (LM_NOTICE, CLINFO "ComponentServer_Task::svc - " - "Configuration complete for component server %C\n", - this->uuid_.c_str ())); - - sa->configuration_complete (this->uuid_.c_str ()); - } - catch (const ::CORBA::BAD_PARAM &) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "ComponentServer_Task::svc - " - "The Callback IOR provided pointed to the " - "wrong ServerActivator\n")); - throw Error ("Bad callback IOR"); - } - catch (const ::CORBA::Exception &ex) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "ComponentServer_Task::svc - " - "Caught CORBA Exception %C\n", - ex._info().c_str ())); - throw Error ("Caught exception while calling back"); - } - catch (...) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "ComponentServer_Task::svc - " - "Caught exception while calling back\n")); - throw Error ("Caught exception while calling back"); - } - - } - else - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "ComponentServer_Task::svc - " - "Initializing ComponentServer without ServantActivator " - "callback\n")); - ci_srv->init (0, 0); - } - - this->orb_->run (); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO "ComponentServer_Task::svc - " - "ORB Event loop completed.\n")); - - root_poa->destroy (1, 1); - - this->orb_->destroy (); - - return 0; - } - - void - ComponentServer_Task::run (void) - { - CIAO_TRACE ("ComponentServer_Task::run"); - - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB\n")); - this->svc (); - CIAO_DEBUG (6, (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 (9, (LM_TRACE, CLINFO "ComponentServer_Task::parse_args - " - "parsing arguments...\n")); - - ACE_Get_Opt opts (argc, argv, ACE_TEXT("hu:c:"), 1, 0, - ACE_Get_Opt::RETURN_IN_ORDER); - opts.long_option (ACE_TEXT("uuid"), 'u', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("callback-ior"), 'c', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("help"), 'h'); - opts.long_option (ACE_TEXT("log-level"),'l', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("trace"),'t', ACE_Get_Opt::NO_ARG); - opts.long_option (ACE_TEXT("output-ior"),'o', ACE_Get_Opt::ARG_REQUIRED); - - int c = 0; - while ((c = opts ()) != -1) - { - CIAO_DEBUG (9, (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 (6, (LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " - "uuid is %s\n", - opts.opt_arg ())); - this->uuid_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ()); - break; - - case 'c': - CIAO_DEBUG (6, (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 (6, (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 (1, (LM_ERROR, CLINFO " Unknown option: %s\n", - opts.last_option ())); - this->usage (); - ACE_CString err ("Unknown option "); - err += ACE_TEXT_ALWAYS_CHAR (opts.last_option ()); - throw Error (err); - } - } - - // check required options. - if (this->uuid_ == "") - throw Error ("Option required: -u|--uuid"); - if (this->callback_ior_str_ == ACE_TEXT("")) - { - CIAO_ERROR (1, (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 <options>\n" - "Options:\n" - "\t-h|--help\t\t\t\tShow help\n" - "\t-l|--log-level <level>\t\t\tSets log level (default 5). 1 - most detailed.\n" - "\t-u|--uuid <uuid> \t\t\tSets UUID of spawned component server (required)\n" - "\t-c|--callback-ior <string ior>\t\tSets callback url for the spawning ServerActivator.\n" - "\t-o|--output-ior <filename>\t\tOutputs the IOR of the component server object to file\n" - )); - - } - } -} - - diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Task.h b/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Task.h deleted file mode 100644 index ba3f00d5c31..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Task.h +++ /dev/null @@ -1,50 +0,0 @@ -// $Id$ -/** - * @file CIAO_ComponentServer_Task.h - * @author William R. Otte - * - * Defines interface for the bootstrap element of the CIAO Component - * Server. - */ - -#ifndef CIAO_COMPONENTSERVER_TASK_H_ -#define CIAO_COMPONENTSERVER_TASK_H_ - -#include "ace/String_Base.h" -#include "ace/Task.h" -#include "tao/ORB.h" - -namespace CIAO -{ - namespace Deployment - { - class ComponentServer_Task : ACE_Task_Base - { - public: - ComponentServer_Task (int argc, ACE_TCHAR **argv); - - int svc (void); - - struct Error - { - Error (const ACE_CString &err); - ACE_CString err_; - }; - - void run (void); - - private: - void parse_args (int argc, ACE_TCHAR **argv); - - void usage (void); - - CORBA::ORB_var orb_; - - ACE_CString uuid_; - ACE_TString callback_ior_str_; - ACE_TString output_file_; - }; - } -} - -#endif diff --git a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp b/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp deleted file mode 100644 index 20752532008..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp +++ /dev/null @@ -1,490 +0,0 @@ -// $Id$ -#include "CIAO_Container_Impl.h" - -#include "ace/Log_Msg.h" -#include "ccm/CCM_HomeC.h" -#include "CIAO_PropertiesC.h" -#include "CIAO_CS_ClientC.h" -#include "Client_init.h" -#include "ciao/Logger/Log_Macros.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, - Components::Deployment::ComponentInstallation_ptr ci, - 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), - ci_ (Components::Deployment::ComponentInstallation::_duplicate (ci)) - { - 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 (6, (LM_DEBUG, CLINFO "CIAO_Container_i: creating Session container with dynamic linkage\n")); - this->container_ = new CIAO::Session_Container (this->orb_.in (), this->poa_.in (), this, false, - 0, name, policies); - } - else - { - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "CIAO_Container_i: creating Session container with static linkage\n")); - this->container_ = new CIAO::Session_Container (this->orb_.in (), this->poa_.in (), this, true, - this->static_entrypts_maps_, - name, policies); - } - } - catch (...) - { - CIAO_ERROR (1, (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"); - - if (!id) - { - CIAO_ERROR (1, (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 (id, comp) == 0) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_Container_i::install_component - " - "Component with id %C already installed, aborting\n", - id)); - throw Components::CreateFailure (); - } - - if (!entrypt) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_Container_i::install_component - " - "No executor entrypoint found.\n")); - throw ::Components::Deployment::InvalidConfiguration (); - } - - CIAO_DEBUG (6, (LM_INFO, CLINFO "CIAO_Container_i::install_component - " - "Attempting to install home with id [%C]\n", - id)); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_component - " - "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 (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_component - " - "Found Servant entrypoint %C\n", svnt_entry.in ())); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_Container_i::install_component - " - "Error: No Servant entrypoint provided, aborting installation\n")); - throw Components::InvalidConfiguration (); - } - - if (cm.find (SVNT_ARTIFACT, val) == 0) - { - val >>= tmp; - svnt_art = this->ci_->get_implementation (tmp); - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_component - " - "Found Servant artifact %C\n", svnt_art.in ())); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_Container_i::install_component - " - "Error: No Servant artifact provided, aborting installation\n")); - throw Components::InvalidConfiguration (); - } - - - if (cm.find (EXEC_ARTIFACT, val) == 0) - { - val >>= tmp; - exec_art = this->ci_->get_implementation (tmp); - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_component - " - "Found executor artifact: %C\n", exec_art.in ())); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_Container_i::install_component - " - "Error: No Executor artifact provided, aborting installation\n")); - } - - CIAO_DEBUG (9, (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, - id); - - if (this->component_map_.bind (id, - Components::CCMObject::_duplicate (comp.in ())) == -1) - { - CIAO_ERROR (1, (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"); - - Component_Iterator i = this->component_map_.begin (); - while (!i.done ()) - { - if (i->item ()->_is_equivalent (cref)) - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "CIAO_Container_i::remove_component - " - "Successfully found matching component\n")); - break; - } - i.advance (); - } - - if (i.done ()) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_Container_i::remove_component - " - "Unable to find matching component managed by this container, throwing RemoveFailure\n")); - throw Components::RemoveFailure (); - } - - if (!CORBA::is_nil (this->container_.in ())) - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "CIAO_Container_i::remove_component - " - "Invoking remove on the container impl for component %C.\n", - i->key ().c_str ())); - this->container_->uninstall_component (cref); - CIAO_DEBUG (6, (LM_INFO, CLINFO "CIAO_Container_i::remove_component - " - "Successfully removed component %C\n", - i->key ().c_str ())); - } - - if (this->component_map_.unbind (i->key ()) != 0) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_Container_i::remove_component - " - "Unable to unbind removed component with id %C from component map\n", - i->key ().c_str ())); - } - } - - ::Components::CCMObjectSeq * - CIAO_Container_i::get_components (void) - { - CIAO_TRACE("CIAO_Container_i::get_components"); - throw CORBA::NO_IMPLEMENT (); - } - - ::Components::ConfigValues * - CIAO_Container_i::configuration (void) - { - CIAO_TRACE("CIAO_Container_i::configuration"); - throw CORBA::NO_IMPLEMENT (); - } - - ::Components::Deployment::ComponentServer_ptr - CIAO_Container_i::get_component_server (void) - { - CIAO_TRACE("CIAO_Container_i::get_component_server"); - throw CORBA::NO_IMPLEMENT (); - } - - ::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) - { - CIAO_ERROR (1, (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 (1, (LM_ERROR, CLINFO "CIAO_Container_i::install_home - " - "Home with id %C already installed, aborting\n", - id)); - throw Components::CreateFailure (); - } - - if (!entrypt) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "CIAO_Container_i::install_home - " - "No executor entrypoint found.\n")); - throw ::Components::Deployment::InvalidConfiguration (); - } - - CIAO_DEBUG (6, (LM_INFO, CLINFO "CIAO_Container_i::install_home - " - "Attempting to install home with id [%C]\n", id)); - - CIAO_DEBUG (9, (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 (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_home - " - "Found Servant entrypoint %C\n", svnt_entry.in ())); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_Container_i::install_home - " - "Error: No Servant entrypoint provided, aborting installation\n")); - throw Components::InvalidConfiguration (); - } - - if (cm.find (SVNT_ARTIFACT, val) == 0) - { - val >>= tmp; - svnt_art = this->ci_->get_implementation (tmp); - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_home - " - "Found Servant artifact %C\n", svnt_art.in ())); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_Container_i::install_home - " - "Error: No Servant artifact provided, aborting installation\n")); - throw Components::InvalidConfiguration (); - } - - - if (cm.find (EXEC_ARTIFACT, val) == 0) - { - val >>= tmp; - exec_art = this->ci_->get_implementation (tmp); - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_Container_i::install_home - " - "Found executor artifact: %C\n", exec_art.in ())); - } - else - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_Container_i::install_home - " - "Error: No Executor artifact provided, aborting installation\n")); - } - - CIAO_DEBUG (9, (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 (6, (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 (1, (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"); - - Home_Iterator i = this->home_map_.begin (); - while (!i.done ()) - { - if (i->item ()->_is_equivalent (href)) - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " - "Successfully found matching home\n")); - break; - } - i.advance (); - } - - if (i.done ()) - { - CIAO_ERROR (1, (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 (9, (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 (href); - CIAO_DEBUG (6, (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 (1, (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 (1, (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 ())); - } - } - - 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 ()); - } - - void CIAO_Container_i::connect_local_facet (::Components::CCMObject_ptr provider, - const char * provider_port, - ::Components::CCMObject_ptr user, - const char * user_port) - { - CIAO_TRACE ("CIAO_Container_i::connect_local_facet"); - this->container_->connect_local_facet (provider, provider_port, user, user_port); - - } - - void CIAO_Container_i::disconnect_local_facet (::Components::CCMObject_ptr provider, - const char * provider_port, - ::Components::CCMObject_ptr user, - const char * user_port) - { - CIAO_TRACE ("CIAO_Container_i::connect_local_facet"); - this->container_->disconnect_local_facet (provider, provider_port, user, user_port); - } - } -} diff --git a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h b/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h deleted file mode 100644 index ea0b19e1a2d..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h +++ /dev/null @@ -1,129 +0,0 @@ -// $Id$ -/** - * @file CIAO_Container_Impl.h - * @author William R. Otte <wotte@dre.vanderbilt.edu> - */ - -#ifndef CIAO_CONTAINER_IMPL_H_ -#define CIAO_CONTAINER_IMPL_H_ - -#include "CIAO_ComponentServerS.h" -#include "CIAO_CS_ClientC.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ciao/Containers/Session/Session_Container.h" - -#include "CIAO_ComponentServer_svnt_export.h" - -namespace CIAO -{ - namespace Deployment - { - /** - * @class CIAO_Container - * @brief Implements external interface for CIAO container. - */ - class CIAO_COMPONENTSERVER_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 *name, - const CORBA::PolicyList *, - Components::Deployment::ComponentInstallation_ptr, - 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); - - virtual void connect_local_facet (::Components::CCMObject_ptr provider, - const char * provider_port, - ::Components::CCMObject_ptr user, - const char * user_port); - - virtual void disconnect_local_facet (::Components::CCMObject_ptr provider, - const char * provider_port, - ::Components::CCMObject_ptr user, - const char * user_port); - - 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_CString, - Components::CCMHome_var, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - 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_CString, - Components::CCMObject_var, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - ACE_Null_Mutex> CCMComponent_Map; - - typedef CCMComponent_Map::iterator Component_Iterator; - CCMComponent_Map component_map_; - - typedef ACE_Hash_Map_Manager_Ex<ACE_CString, - ACE_CString, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - ACE_Null_Mutex> CCMNaming_Map; - CCMNaming_Map naming_map_; - - Components::Deployment::ComponentInstallation_var ci_; - }; - } -} -#endif /* CIAO_CONTAINER_IMPL_H_ */ diff --git a/CIAO/ciao/ComponentServer/CIAO_RTComponentServer.cpp b/CIAO/ciao/ComponentServer/CIAO_RTComponentServer.cpp deleted file mode 100644 index 9501b81c4de..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_RTComponentServer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file CIAO_RTComponentServer.cpp - * - * $Id$ - * - * Implementation and main for CIAO_RTComponentServer. - */ - -#include "CIAO_RTComponentServer_Task.h" -#include "ace/Thread_Manager.h" -#include "ciao/Logger/Log_Macros.h" - -int ACE_TMAIN (int argc, ACE_TCHAR **argv) -{ - // Tracing disabled by default - CIAO_DISABLE_TRACE (); - - CIAO_TRACE ("CIAO_RTComponentServer::ACE_TMAIN"); - - int retval = 0; - try - { - CIAO::Deployment::RTComponentServer_Task cs (argc, argv); - cs.run (); - - // Wait for the threads to exit. - //ACE_Thread_Manager::instance ()->wait (); - } - catch (const CIAO::Deployment::RTComponentServer_Task::Error &e) - { - CIAO_DEBUG (6, (LM_ALERT, CLINFO "CIAO_RTComponentServer main: Caught ComponentServer exception: %C\n", - e.err_.c_str ())); - retval = -1; - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("CIAO_RTComponentServer main: Caught corba exception:"); - retval = -1; - } - catch (...) - { - CIAO_DEBUG (6, (LM_ALERT, CLINFO "CIAO_RTComponentServer main: Caught unknown exception.\n")); - retval = -1; - } - - return retval; -} - diff --git a/CIAO/ciao/ComponentServer/CIAO_RTComponentServer_Task.cpp b/CIAO/ciao/ComponentServer/CIAO_RTComponentServer_Task.cpp deleted file mode 100644 index 4fadbf8b1b5..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_RTComponentServer_Task.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/** - * @file CIAO_RTComponentServer_Task.cpp - * @author Johnny Willemsen <jwillemsen@remedy.nl> - * $Id$ - * - * Implementation and main for CIAO_RTComponentServer. - */ - -#include "CIAO_RTComponentServer_Task.h" - -#include "ace/OS_NS_string.h" -#include "ace/Log_Msg.h" -#include "ace/Get_Opt.h" -#include "tao/ORB.h" -#include "tao/PortableServer/PortableServer.h" -#include "tao/RTPortableServer/RTPortableServer.h" -#include "ciao/Logger/Logger_Service.h" -#include "ciao/Logger/Log_Macros.h" -#include "CIAO_ComponentServer_Impl.h" -#include "Server_init.h" -#include "tao/RTCORBA/Priority_Mapping_Manager.h" -#include "tao/Protocols_Hooks.h" -#include "tao/ORB_Core.h" - -namespace CIAO -{ - namespace Deployment - { - CORBA::Short - get_implicit_thread_CORBA_priority (CORBA::ORB_ptr orb) - { - CORBA::Object_var obj = - orb->resolve_initial_references (TAO_OBJID_PRIORITYMAPPINGMANAGER); - - TAO_Priority_Mapping_Manager_var mapping_manager = - TAO_Priority_Mapping_Manager::_narrow (obj.in ()); - - if (CORBA::is_nil (mapping_manager.in ())) - throw CORBA::INTERNAL (); - - RTCORBA::PriorityMapping *pm = - mapping_manager.in ()->mapping (); - - TAO_Protocols_Hooks *tph = - orb->orb_core ()->get_protocols_hooks (); - - CORBA::Short corba_priority; - CORBA::Short native_priority; - - if (tph->get_thread_native_priority (native_priority) == 0 && - pm->to_CORBA (native_priority, corba_priority)) - { - return corba_priority; - } - - ACE_DEBUG ((LM_DEBUG, "get_implicit_thread_CORBA_priority - failed to access priority\n")); - throw CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO); - } - - RTComponentServer_Task::Error::Error(const ACE_CString &err) : err_(err) - { - } - - RTComponentServer_Task::RTComponentServer_Task (int argc, ACE_TCHAR **argv) : - static_threads_ (0), - dynamic_threads_ (0) - { - CIAO_TRACE ("CIAO_RTComponentServer_Task::CIAO_RTComponentServer_Task"); - - Logger_Service - *clf = ACE_Dynamic_Service<Logger_Service>::instance ("CIAO_Logger"); - - if (clf) - { - clf->init (argc, argv); - } - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_RTComponentServer_Task::CIAO_RTComponentServer_Task - " - "Creating ORB\n")); - - this->orb_ = CORBA::ORB_init (argc, argv); - - this->parse_args (argc, argv); - - CIAO::Server_init (this->orb_.in ()); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_RTComponentServer_Task::CIAO_RTComponentServer_Task - " - "CIAO_ComponentServer object created.\n")); - } - - int - RTComponentServer_Task::svc (void) - { - CIAO_TRACE ("RTComponentServer_Task::svc"); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "RTComponentServer_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 (); - - object = - this->orb_->resolve_initial_references ("RTORB"); - - RTCORBA::RTORB_var rt_orb = - RTCORBA::RTORB::_narrow (object.in ()); - CORBA::ULong stacksize = 0; - CORBA::Boolean allow_request_buffering = false; - CORBA::ULong max_buffered_requests = 0; - CORBA::ULong max_request_buffer_size = 0; - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "RTComponentServer_Task::svc - " - "Creating server implementation object\n")); - - CORBA::PolicyList policies (0); - - if (this->static_threads_ > 0) - { - object = - this->orb_->resolve_initial_references ("RTCurrent"); - - RTCORBA::Current_var current = - RTCORBA::Current::_narrow (object.in ()); - - RTCORBA::Priority default_thread_priority = - get_implicit_thread_CORBA_priority (this->orb_.in ()); - - RTCORBA::ThreadpoolId threadpool_id_1 = - rt_orb->create_threadpool (stacksize, - this->static_threads_, - this->dynamic_threads_, - default_thread_priority, - allow_request_buffering, - max_buffered_requests, - max_request_buffer_size); - - CORBA::Policy_var threadpool_policy_1 = - rt_orb->create_threadpool_policy (threadpool_id_1); - - policies.length (2); - policies[0] = - CORBA::Policy::_duplicate (threadpool_policy_1); - - policies[1] = - rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED, - 0); - } - - // Create the POA under the RootPOA. - PortableServer::POA_var poa = - root_poa->create_POA ("RTPOA", - poa_manager, - policies); - - // Creation of POAs is over. Destroy the Policy objects. - for (CORBA::ULong i = 0; - i < policies.length (); - ++i) - { - policies[i]->destroy (); - } - - CIAO::Deployment::CIAO_ComponentServer_i *ci_srv = 0; - ACE_NEW_NORETURN (ci_srv, - CIAO_ComponentServer_i (this->uuid_, - this->orb_.in (), - poa.in ())); - - if (ci_srv == 0) - { - CIAO_ERROR (1, (LM_CRITICAL, - "RTComponentServer_Task::run - " - "Out of memory error while allocating servant.")); - throw Error ("Out of memory whilst allocating servant."); - } - - PortableServer::ServantBase_var safe (ci_srv); - - PortableServer::ObjectId_var id = - poa->activate_object (ci_srv); - CORBA::Object_var cs_object = poa->id_to_reference (id.in ()); - ComponentServer_var cs = - ComponentServer::_narrow (cs_object.in ()); - - if (this->output_file_ != ACE_TEXT("")) - { - CORBA::String_var ior = this->orb_->object_to_string (cs.in ()); - ::CIAO::Utility::write_IOR (this->output_file_.c_str (), ior.in ()); - } - - - if (this->callback_ior_str_ != ACE_TEXT("")) - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "RTComponentServer_Task::run - " - "Resolving callback IOR\n")); - CORBA::Object_var 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 (6, (LM_ERROR, CLINFO - "RTComponentServer_Task::svc - " - "Failed to narrow callback IOR\n")); - throw Error ("Failed to narrow callback IOR"); - } - - Components::ConfigValues_var config; - { - Components::ConfigValues *cf = 0; - ACE_NEW_NORETURN (cf, Components::ConfigValues (0)); - - if (cf == 0) - { - CIAO_ERROR (1, (LM_CRITICAL, "RTComponentServer_Task::run - " - "Out of memory error while allocating config values.")); - } - else - { - config = cf; - } - } - - // Make callback. - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "RTComponentServer_Task::svc - " - "Making callback on my ServerActivator\n")); - - try - { - // Callback to NodeApplication to get configuration - sa->component_server_callback (cs.in (), - this->uuid_.c_str (), - config.out ()); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO "RTComponentServer_Task::svc - " - "Configuration received\n")); - // @@WO: Probably need to do something with these config values. - - ci_srv->init (sa.in (), config._retn ()); - - CIAO_DEBUG (6, (LM_NOTICE, CLINFO "RTComponentServer_Task::svc - " - "Configuration complete for component server %C\n", - this->uuid_.c_str ())); - - sa->configuration_complete (this->uuid_.c_str ()); - } - catch (const CORBA::BAD_PARAM &) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "RTComponentServer_Task::svc - " - "The Callback IOR provided pointed to the " - "wrong ServerActivator\n")); - throw Error ("Bad callback IOR"); - } - catch (const ::CORBA::Exception &ex) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "RTComponentServer_Task::svc - " - "Caught CORBA Exception %C\n", - ex._info().c_str ())); - throw Error ("Caught exception while calling back"); - } - catch (...) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO "RTComponentServer_Task::svc - " - "Caught exception while calling back\n")); - throw Error ("Caught exception while calling back"); - } - - } - else - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "RTComponentServer_Task::svc - " - "Initializing ComponentServer without ServantActivator " - "callback\n")); - ci_srv->init (0, 0); - } - - this->orb_->run (); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO "RTComponentServer_Task::svc - " - "ORB Event loop completed.\n")); - - root_poa->destroy (1, 1); - - this->orb_->destroy (); - - return 0; - } - - void - RTComponentServer_Task::run (void) - { - CIAO_TRACE ("RTComponentServer_Task::run"); - - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "RTComponentServer_Task::run - Starting ORB\n")); - this->svc (); - CIAO_DEBUG (6, (LM_INFO, - CLINFO "RTComponentServer_Task::run - ORB has " - "shutdown, terminating ComponentServer\n")); - } - - void - RTComponentServer_Task::parse_args (int argc, ACE_TCHAR **argv) - { - CIAO_TRACE ("RTComponentServer_Task::parse_args"); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO "RTComponentServer_Task::parse_args - " - "parsing arguments...\n")); - - ACE_Get_Opt opts (argc, argv, ACE_TEXT("hu:c:s:d:"), 1, 0, - ACE_Get_Opt::RETURN_IN_ORDER); - opts.long_option (ACE_TEXT("uuid"), 'u', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("callback-ior"), 'c', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("help"), 'h'); - opts.long_option (ACE_TEXT("log-level"),'l', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("trace"),'t', ACE_Get_Opt::NO_ARG); - opts.long_option (ACE_TEXT("output-ior"),'o', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("static"),'s', ACE_Get_Opt::ARG_REQUIRED); - opts.long_option (ACE_TEXT("dynamic"),'d', ACE_Get_Opt::ARG_REQUIRED); - - int c = 0; - while ((c = opts ()) != -1) - { - CIAO_DEBUG (9, (LM_TRACE, CLINFO "RTComponentServer_Task::parse_args - " - "Found option: \"%s\" with argument \"%s\"\n", - opts.last_option (), opts.opt_arg ())); - - switch (c) - { - case 's': - this->static_threads_ = ACE_OS::atoi (opts.opt_arg ()); - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "RTComponentServer_Task::parse_args - " - "Using %d static threads\n", - this->static_threads_)); - break; - - case 'd': - this->dynamic_threads_ = ACE_OS::atoi (opts.opt_arg ()); - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "RTComponentServer_Task::parse_args - " - "Using %d dynamic threads\n", - this->dynamic_threads_)); - break; - - case 'u': - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "RTComponentServer_Task::parse_args - " - "uuid is %s\n", - opts.opt_arg ())); - this->uuid_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ()); - break; - - case 'c': - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "RTComponentServer_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 (6, (LM_DEBUG, CLINFO "RTComponentServer_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 (1, (LM_ERROR, CLINFO " Unknown option: %s\n", - opts.last_option ())); - this->usage (); - ACE_CString err ("Unknown option "); - err += ACE_TEXT_ALWAYS_CHAR (opts.last_option ()); - throw Error (err); - } - } - - // check required options. - if (this->uuid_ == "") - throw Error ("Option required: -u|--uuid"); - if (this->callback_ior_str_ == ACE_TEXT("")) - { - CIAO_ERROR (1, (LM_WARNING, CLINFO - "RTComponentServer_Task::parse_args - Starting ComponentServer without a callback IOR\n")); - } - } - - void - RTComponentServer_Task::usage (void) - { - CIAO_TRACE ("RTComponentServer_Task::usage"); - // Shouldn't be subject to CIAO's logging policy - ACE_ERROR ((LM_EMERGENCY, "Usage: CIAO_ComponentServer <options>\n" - "Options:\n" - "\t-h|--help\t\t\t\tShow help\n" - "\t-l|--log-level <level>\t\t\tSets log level (default 5). 1 - most detailed.\n" - "\t-u|--uuid <uuid> \t\t\tSets UUID of spawned component server (required)\n" - "\t-c|--callback-ior <string ior>\t\tSets callback url for the spawning ServerActivator.\n" - "\t-o|--output-ior <filename>\t\tOutputs the IOR of the component server object to file\n" - "\t-s|--static <number>\t\tNumber of static threads to run\n" - "\t-d|--dynamic <number>\t\tNumber of dynamic threads to run\n" - )); - - } - } -} - - diff --git a/CIAO/ciao/ComponentServer/CIAO_RTComponentServer_Task.h b/CIAO/ciao/ComponentServer/CIAO_RTComponentServer_Task.h deleted file mode 100644 index 4212bcb7751..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_RTComponentServer_Task.h +++ /dev/null @@ -1,54 +0,0 @@ -// $Id$ -/** - * @file CIAO_RTComponentServer_Task.h - * @author William R. Otte - * - * Defines interface for the bootstrap element of the CIAO Component - * Server. - */ - -#ifndef CIAO_COMPONENTSERVER_TASK_H_ -#define CIAO_COMPONENTSERVER_TASK_H_ - -#include "ace/String_Base.h" -#include "ace/Task.h" -#include "tao/ORB.h" -#include "tao/RTPortableServer/RTPortableServer.h" - -namespace CIAO -{ - namespace Deployment - { - class RTComponentServer_Task : ACE_Task_Base - { - public: - RTComponentServer_Task (int argc, ACE_TCHAR **argv); - - int svc (void); - - struct Error - { - Error (const ACE_CString &err); - ACE_CString err_; - }; - - void run (void); - - private: - void parse_args (int argc, ACE_TCHAR **argv); - - void usage (void); - - CORBA::ORB_var orb_; - - ACE_CString uuid_; - ACE_TString callback_ior_str_; - ACE_TString output_file_; - - CORBA::ULong static_threads_; - CORBA::ULong dynamic_threads_; - }; - } -} - -#endif diff --git a/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.cpp b/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.cpp deleted file mode 100644 index 4c17f0fac0d..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.cpp +++ /dev/null @@ -1,510 +0,0 @@ -// $Id$ - -#include "CIAO_ServerActivator_Impl.h" -#include "ace/Log_Msg.h" -#include "ace/UUID.h" -#include "ciao/Logger/Log_Macros.h" - -#include "CIAO_FailureReasonsC.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, - Components::Deployment::ComponentInstallation_ptr ci, - 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_), - ci_ (Components::Deployment::ComponentInstallation::_duplicate (ci)) - - { - CIAO_TRACE ("CIAO_ServerActivator_i::CIAO_ServerActivator_i"); - ACE_Utils::UUID_GENERATOR::instance ()->init (); - } - - 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("CIAO_ServerActivator_i::component_server_callback"); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_ServerActivator_i::component_server_callback - " - "Received callback from ComponentServer %C\n", - server_UUID)); - - Server_Info *info = 0; - - for (SERVER_INFOS::iterator i (this->server_infos_.begin ()); - !i.done (); ++i) - { - CIAO_DEBUG (9, (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) - { - CIAO_ERROR (1, (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 (1, (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 (1, (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 (9, (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 (6, (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 ("CIAO_ServerActivator_i::configuration_complete"); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_ServerActivator_i::configuration_complete - " - "Received configuration_complete from ComponentServer %C\n", - server_UUID)); - - try - { - 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) - { - CIAO_ERROR (1, (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 (1, (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 (1, (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 (1, (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("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 (6, (LM_DEBUG, CLINFO - "CIAO_ServerActivator_i::create_component_server - ComponentServer arguments: %C\n", - cmd_options.c_str ())); - - server_infos_.insert_tail (server); - - CIAO_DEBUG (9, (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 const 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 (6, (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 (1, (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 (6, (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 ("CIAO_ServerActivator_i::construct_command_line"); - - // Build our command line to launch the component 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 (9, (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 (9, (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 (); - } - - if (server.cmap_->find (SERVER_ARGUMENTS, val) == 0) - { - const char *args = 0; - val >>= args; - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_ServerActivator_i::construct_command_line - " - "Adding provided server arguments %C\n", args)); - - cmd_options += ' '; - cmd_options += args; - cmd_options += ' '; - } - - CIAO_DEBUG (6, (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_; - - 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"); - - // 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 (6, (LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " - "Using provided component server executable: %C\n", path)); - } - else - { - CIAO_DEBUG (6, (LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " - "Using default component server executable\n")); - } - - ACE_Process_Options options (true, - ACE_OS::strlen (path) + ACE_OS::strlen (cmd_line.c_str()) + ACE_OS::strlen (ior.in ()) + 15); - if (options.command_line ("%s %s -c %s", - path, - cmd_line.c_str (), - ior.in ()) != 0) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "Failed to create commandline\n")); - throw Components::CreateFailure (CIAO::SERVER_SPAWN_FAILURE); - } - - options.avoid_zombies (0); - - CIAO_DEBUG (9, (LM_TRACE, CLINFO - "CIAO_ServerActivator_i::spawn_component_server - Spawning process, command line is %s\n", - options.command_line_buf ())); - - pid_t const pid = this->process_manager_.spawn (options, - &this->child_handler_); - - if (pid == ACE_INVALID_PID) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "Failed to spawn a ComponentServer process\n")); - throw Components::CreateFailure (CIAO::SERVER_SPAWN_FAILURE); - } - - CIAO_DEBUG (9, (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 ("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 <register_node_application>, - // the <perform_work> 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 (1, (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 ("CIAO_ServerActivator_i::multi_threaded_wait_for_callback"); - - // Wait for a conditional variable - ACE_GUARD_THROW_EX ( TAO_SYNCH_MUTEX, - guard, - this->mutex_, - CORBA::NO_RESOURCES ()); - - while (! si.activated_ ) - if (this->condition_.wait (&timeout) == -1) - { - CIAO_ERROR (1, (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 ("CIAO_ServerActivator_i::remove_component_server"); - - 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) - { - CIAO_ERROR (1, (LM_ERROR, CLINFO - "CIAO_ServerActivator_i::remove_component_server - " - "Failed to find equivalent ComponentServer under my management.\n")); - throw ::Components::RemoveFailure (); - } - - try - { - CIAO_DEBUG (9, (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 (1, (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 (9, (LM_TRACE, CLINFO - "CIAO_ServerActivator_i::remove_component_server - " - "Calling shutdown () on ComponentServer %C\n", - info->uuid_.c_str ())); - ccs->shutdown (); - } - else - CIAO_DEBUG (9, (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 (6, (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 ("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 (1), - CORBA::NO_MEMORY ()); - - Components::Deployment::ComponentInstallation_ptr ci = - Components::Deployment::ComponentInstallation::_duplicate (this->ci_.in ()); - CORBA::Any ci_any; - ci_any <<= ci; - - OBV_Components::ConfigValue* p = 0; - ACE_NEW_THROW_EX (p, - OBV_Components::ConfigValue (), - CORBA::NO_MEMORY ()); - p->name (CIAO::Deployment::COMPONENTINSTALLATION_REF); - p->value (ci_any); - config->length (1); - config.operator[](0) = p; - } - } -} - diff --git a/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.h b/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.h deleted file mode 100644 index 23057b2c550..00000000000 --- a/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.h +++ /dev/null @@ -1,191 +0,0 @@ -// $Id$ -/** - * @file CIAO_ServerActivator_Impl.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 "ace/Condition_T.h" -#include "tao/PortableServer/PortableServer.h" -#include "ciao/ComponentServer/CIAO_CS_ClientS.h" -#include "ciao/ComponentServer/CIAO_ComponentServerC.h" -#include "ciao/ComponentServer/CIAO_CS_Client_svnt_export.h" -#include "Client_init.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -namespace CIAO -{ - namespace Deployment - { - /** - * @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 <wotte@dre.vanderbilt.edu> - * @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, - Components::Deployment::ComponentInstallation_ptr ci, - 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 @c perform_work 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 <CIAO::Utility::CONFIGVALUE_MAP, - ACE_Null_Mutex> 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<Server_Info, ACE_Null_Mutex> 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 <Safe_Server_Info, _server_info> 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_; - - TAO_SYNCH_MUTEX mutex_; - - ACE_Condition<TAO_SYNCH_MUTEX> condition_; - - Components::Deployment::ComponentInstallation_var ci_; - }; - - - } -} -#endif /* CIAO_SERVERACTIVATOR_H_ */ diff --git a/CIAO/ciao/ComponentServer/Client_init.h b/CIAO/ciao/ComponentServer/Client_init.h index d2a7c9323c4..07be2fcbae4 100644 --- a/CIAO/ciao/ComponentServer/Client_init.h +++ b/CIAO/ciao/ComponentServer/Client_init.h @@ -24,7 +24,7 @@ #include "tao/AnyTypeCode/Any.h" #include "ccm/CCM_StandardConfiguratorC.h" -#include "ciao/ComponentServer/CIAO_ComponentServer_stub_export.h" +#include "ciao/ComponentServer/CIAO_Base_stub_export.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace CORBA @@ -43,7 +43,7 @@ namespace CIAO * should be call right after ORB initialization but we should try * to register these stuff automatically. */ - CIAO_COMPONENTSERVER_STUB_Export int Client_init (CORBA::ORB_ptr o); + CIAO_BASE_STUB_Export int Client_init (CORBA::ORB_ptr o); namespace Utility { @@ -53,10 +53,10 @@ namespace CIAO ACE_Equal_To<ACE_CString>, ACE_Null_Mutex> CONFIGVALUE_MAP; - CIAO_COMPONENTSERVER_STUB_Export void build_config_values_map (CONFIGVALUE_MAP &map, + CIAO_BASE_STUB_Export void build_config_values_map (CONFIGVALUE_MAP &map, const ::Components::ConfigValues &config); - CIAO_COMPONENTSERVER_STUB_Export void build_config_values_sequence (::Components::ConfigValues &config, + CIAO_BASE_STUB_Export void build_config_values_sequence (::Components::ConfigValues &config, const CONFIGVALUE_MAP &map); } } diff --git a/CIAO/ciao/ComponentServer/Server_init.h b/CIAO/ciao/ComponentServer/Server_init.h index d56c5fe50fc..a5ba167476d 100644 --- a/CIAO/ciao/ComponentServer/Server_init.h +++ b/CIAO/ciao/ComponentServer/Server_init.h @@ -16,7 +16,7 @@ #include /**/ "ace/pre.h" -#include "ciao/ComponentServer/CIAO_ComponentServer_stub_export.h" +#include "ciao/ComponentServer/CIAO_Base_stub_export.h" #if !defined ACE_LACKS_PRAGMA_ONCE #pragma once @@ -42,14 +42,14 @@ namespace CIAO * should be call right after ORB initialization but we should try * to register these stuff automatically. */ - CIAO_COMPONENTSERVER_STUB_Export int Server_init (CORBA::ORB_ptr o); + CIAO_BASE_STUB_Export int Server_init (CORBA::ORB_ptr o); namespace Utility { /// Write a string (usually a stringified IOR) to a file /// designated by the @c pathname. The file named will always get /// overwritten. - CIAO_COMPONENTSERVER_STUB_Export int write_IOR (const ACE_TCHAR *pathname, + CIAO_BASE_STUB_Export int write_IOR (const ACE_TCHAR *pathname, const char *IOR); } } |