diff options
Diffstat (limited to 'modules/CIAO/ciao/ComponentServer')
42 files changed, 5378 insertions, 0 deletions
diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_CS_Client.idl b/modules/CIAO/ciao/ComponentServer/CIAO_CS_Client.idl new file mode 100644 index 00000000000..43bf4d4eadd --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_CS_Client.idl @@ -0,0 +1,40 @@ +/** + * @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); + }; + + interface ComponentInstallation : + ::Components::Deployment::ComponentInstallation + { + }; + }; +}; + + +#endif + + diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_CS_Client_svnt_export.h b/modules/CIAO/ciao/ComponentServer/CIAO_CS_Client_svnt_export.h new file mode 100644 index 00000000000..32a2ea33fd5 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_CS_Client_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_CS_Client_svnt +// ------------------------------ +#ifndef CIAO_CS_CLIENT_SVNT_EXPORT_H +#define CIAO_CS_CLIENT_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) +# define CIAO_CS_CLIENT_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_CS_CLIENT_SVNT_HAS_DLL */ + +#if !defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) +# define CIAO_CS_CLIENT_SVNT_HAS_DLL 1 +#endif /* ! CIAO_CS_CLIENT_SVNT_HAS_DLL */ + +#if defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) && (CIAO_CS_CLIENT_SVNT_HAS_DLL == 1) +# if defined (CIAO_CS_CLIENT_SVNT_BUILD_DLL) +# define CIAO_CS_Client_svnt_Export ACE_Proper_Export_Flag +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_CS_CLIENT_SVNT_BUILD_DLL */ +# define CIAO_CS_Client_svnt_Export ACE_Proper_Import_Flag +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_CS_CLIENT_SVNT_BUILD_DLL */ +#else /* CIAO_CS_CLIENT_SVNT_HAS_DLL == 1 */ +# define CIAO_CS_Client_svnt_Export +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_CS_CLIENT_SVNT_HAS_DLL == 1 */ + +// Set CIAO_CS_CLIENT_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_CS_CLIENT_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_CS_CLIENT_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_CS_CLIENT_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_CS_CLIENT_SVNT_NTRACE */ + +#if (CIAO_CS_CLIENT_SVNT_NTRACE == 1) +# define CIAO_CS_CLIENT_SVNT_TRACE(X) +#else /* (CIAO_CS_CLIENT_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_CS_CLIENT_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_CS_CLIENT_SVNT_NTRACE == 1) */ + +#endif /* CIAO_CS_CLIENT_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.cpp b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.cpp new file mode 100644 index 00000000000..b01175fcbd4 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.cpp @@ -0,0 +1,129 @@ +// $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 ((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 ((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 ((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 ((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 ((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 ((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/modules/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.h b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.h new file mode 100644 index 00000000000..16f1b00fc8f --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentInstallation_Impl.h @@ -0,0 +1,65 @@ +// -*- 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_CIAO::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/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.cpp b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.cpp new file mode 100644 index 00000000000..fd7d26e46f2 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.cpp @@ -0,0 +1,470 @@ +/** + * @file CIAO_ComponentServer.cpp + * @author William R. Otte + * // $Id$ + * Implementation and main for CIAO_ComponentServer. + */ + +#include "CIAO_ComponentServer.h" + +#include "ace/OS_NS_string.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" +#include "ace/Sched_Params.h" +#include "ace/Trace.h" +#include "ace/Env_Value_T.h" +#include "tao/ORB.h" +#include "tao/Object.h" +#include "tao/CORBA_methods.h" +#include "tao/PortableServer/PortableServer.h" +#include "tao/ORB_Core.h" +#include "ciao/CIAO_common.h" +#include "ciao/Logger/Logger_Service.h" +#include "ciao/Logger/Log_Macros.h" +#include "ciao/Server_init.h" + + +#include "CIAO_ComponentServer_Impl.h" +#include "CIAO_CS_ClientC.h" +#include "Configurator_Factory.h" +#include "Configurators/Server_Configurator.h" + +#ifdef CIAO_BUILD_COMPONENTSERVER_EXE + +int ACE_TMAIN (int argc, ACE_TCHAR **argv) +{ + // Tracing disabled by default + CIAO_DISABLE_TRACE (); + + CIAO_TRACE ("CIAO_ComponentServer::ACE_TMAIN"); + + try + { + CIAO::Deployment::ComponentServer_Task cs (argc, argv); + cs.run (); + return 0; + } + catch (CIAO::Deployment::ComponentServer_Task::Error &e) + { + CIAO_DEBUG ((LM_ALERT, CLINFO "CIAO_ComponentServer main: Caught ComponentServer exception: %C\n", + e.err_.c_str ())); + } + catch (...) + { + CIAO_DEBUG ((LM_ALERT, CLINFO "CIAO_ComponentServer main: Caught unknown exception.\n")); + } + + return -1; +} + +#endif /* CIAO_BUILD_COMPONENTSERVER_EXE */ + +bool +write_IOR (const ACE_TCHAR * ior_file_name, const char* ior) +{ + FILE* ior_output_file_ = + ACE_OS::fopen (ior_file_name, "w"); + + if (ior_output_file_) + { + ACE_OS::fprintf (ior_output_file_, + "%s", + ior); + ACE_OS::fclose (ior_output_file_); + return true; + } + return false; +} + +namespace CIAO +{ + namespace Deployment + { + ComponentServer_Task::ComponentServer_Task (int argc, ACE_TCHAR **argv) + : orb_ (0), + uuid_ (""), + callback_ior_str_ (ACE_TEXT("")) + { + CIAO_TRACE ("CIAO_ComponentServer_Task::CIAO_ComponentServer_Task ()"); + + Logger_Service + *clf = ACE_Dynamic_Service<Logger_Service>::instance ("CIAO_Logger_Backend_Factory"); + + if (!clf) + clf = new Logger_Service; + + this->logger_.reset (clf); + + this->logger_->init (argc, argv); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "Creating server object\n")); + Configurator_Factory cf; + this->configurator_.reset (cf (argc, argv)); + + if (!this->configurator_->create_config_managers ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "ComponentServer_Task::ComponentServer_Task - " + "Error configuring ComponentServer configurator, exiting.\n")); + throw Error ("Unable to load ComponentServer configurator."); + } + + + this->configurator_->pre_orb_initialize (); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "Creating ORB\n")); + this->orb_ = CORBA::ORB_init (argc, argv); + + this->configurator_->post_orb_initialize (this->orb_.in ()); + + this->parse_args (argc, argv); + this->configure_logging_backend (); + + CIAO::Server_init (this->orb_.in ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "CIAO_ComponentServer object created.\n")); + } + + int + ComponentServer_Task::svc (void) + { + CIAO_TRACE ("ComponentServer_Task::svc"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Activating the root POA\n")); + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (object.in ()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + poa_manager->activate (); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Creating server implementation object\n")); + CIAO::Deployment::CIAO_ComponentServer_i *ci_srv = 0; + ACE_NEW_NORETURN (ci_srv, CIAO_ComponentServer_i (this->uuid_, this->orb_.in (), root_poa.in ())); + + if (ci_srv == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating servant.")); + throw Error ("Out of memory whilst allocating servant."); + } + + PortableServer::ServantBase_var safe (ci_srv); + + ComponentServer_var cs (ci_srv->_this ()); + + if (this->output_file_ != ACE_TEXT("")) + { + CORBA::String_var ior = this->orb_->object_to_string (cs.in ()); + write_IOR (this->output_file_.c_str (), ior.in ()); + } + + + if (this->callback_ior_str_ != ACE_TEXT("")) + { + CIAO_DEBUG ((LM_TRACE, CLINFO " resolving callback IOR\n")); + CORBA::Object_ptr obj = this->orb_->string_to_object (this->callback_ior_str_.c_str ()); + ServerActivator_var sa (ServerActivator::_narrow (obj)); + + if (CORBA::is_nil (sa.in ())) + { + CIAO_DEBUG ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Failed to narrow callback IOR\n")); + throw Error ("Failed to narrow callback IOR"); + } + + Components::ConfigValues_var config; + { + Components::ConfigValues *cf = 0; + ACE_NEW_NORETURN (cf, Components::ConfigValues (0)); + + if (cf == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating config values.")); + } + else + { + config = cf; + } + } + + // Make callback. + CIAO_DEBUG ((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 ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Configuration received\n")); + // @@WO: Probably need to do something with these config values. + + ci_srv->init (sa.in (), config._retn ()); + + CIAO_DEBUG ((LM_NOTICE, CLINFO "ComponentServer_Task::svc - " + "Configuration complete for component server %C\n", + this->uuid_.c_str ())); + + sa->configuration_complete (this->uuid_.c_str ()); + } + catch (const CORBA::BAD_PARAM &) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "The Callback IOR provided pointed to the wrong ServerActivator\n")); + throw Error ("Bad callback IOR"); + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Caught exception while calling back\n")); + throw Error ("Caught exception while calling back"); + } + + } + else + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Initializing ComponentServer without ServantActivator callback\n")); + ci_srv->init (0, 0); + } + + this->orb_->run (); + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "ORB Event loop completed.\n")); + + root_poa->destroy (1, 1); + + this->orb_->destroy (); + + return 0; + } + + void + ComponentServer_Task::run (void) + { + CIAO_TRACE ("ComponentServer_Task::run"); + + if (this->configurator_->rt_support ()) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB with RT support\n")); + + this->check_supported_priorities (); + + // spawn a thread + // Task activation flags. + long flags = + THR_NEW_LWP | + THR_JOINABLE | + this->orb_->orb_core ()->orb_params ()->thread_creation_flags (); + + // Activate task. + int result = this->activate (flags); + if (result == -1) + { + if (errno == EPERM) + { + CIAO_ERROR ((LM_EMERGENCY, CLINFO + "ComponentServer_Task::run - Cannot create thread with scheduling policy %C\n" + "because the user does not have the appropriate privileges, terminating program. " + "Check svc.conf options and/or run as root\n", + sched_policy_name (this->orb_->orb_core ()->orb_params ()->ace_sched_policy ()))); + throw Error ("Unable to start RT support due to permissions problem."); + } + else + throw Error ("Unknown error while spawning ORB thread."); + } + + // Wait for task to exit. + result = this->wait (); + + if (result != -1) + throw Error ("Unknown error waiting for ORB thread to complete"); + + CIAO_DEBUG ((LM_INFO, CLINFO "ComponentServer_Task::run - ORB thread completed, terminating ComponentServer %C\n", + this->uuid_.c_str ())); + } + else + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB without RT support\n")); + this->svc (); + CIAO_DEBUG ((LM_INFO, CLINFO "ComponentServer_Task::run - ORB has shutdown, terminating ComponentServer\n")); + } + } + + void + ComponentServer_Task::parse_args (int argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("ComponentServer_Task::parse_args"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::parse_args - parsing arguments...\n")); + + ACE_Get_Opt opts (argc, argv, 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 j; + char c; + ACE_CString s; + + while ((c = opts ()) != -1) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::parse_args - " + "Found option: \"%s\" with argument \"%s\"\n", + opts.last_option (), opts.opt_arg ())); + + switch (c) + { + case 'u': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "uuid is %s\n", + opts.opt_arg ())); + this->uuid_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ()); + break; + + case 'c': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "callback ior is %s\n", + opts.opt_arg ())); + this->callback_ior_str_ = opts.opt_arg (); + break; + + case 'l': + { + continue; // no-op, already taken care of + } + + case 't': + continue; // already taken care of + + case 'o': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "IOR Output file: %s\n", + opts.opt_arg ())); + this->output_file_ = opts.opt_arg (); + break; + + case 'h': + this->usage (); + throw Error ("Command line help requested, bailing out...."); + + default: + CIAO_ERROR ((LM_ERROR, CLINFO " Unknown option: %s\n", + opts.last_option ())); + this->usage (); + ACE_CString err ("Unknown option "); + err += 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 ((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" + )); + + } + + const char * + ComponentServer_Task::sched_policy_name (int sched_policy) + { + const char *name = 0; + + switch (sched_policy) + { + case ACE_SCHED_OTHER: + name = "SCHED_OTHER"; + break; + case ACE_SCHED_RR: + name = "SCHED_RR"; + break; + case ACE_SCHED_FIFO: + name = "SCHED_FIFO"; + break; + } + + return name; + } + + /// The following check is taken from $(TAO_ROOT)/tests/RTCORBA/ + void + ComponentServer_Task::check_supported_priorities (void) + { + CIAO_TRACE ("ComponentServer_Task::check_supported_priorities"); + + int const sched_policy = + this->orb_->orb_core ()->orb_params ()->ace_sched_policy (); + + // Check that we have sufficient priority range to run, + // i.e., more than 1 priority level. + int const max_priority = ACE_Sched_Params::priority_max (sched_policy); + int const min_priority = ACE_Sched_Params::priority_min (sched_policy); + + if (max_priority == min_priority) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::check_supported_priorities - " + " Not enough priority levels with the %C scheduling policy\n" + "on this platform to run, terminating ....\n" + "Check svc.conf options\n", + sched_policy_name (sched_policy))); + + throw Error ("Bad scheduling policy."); + } + } + + void + ComponentServer_Task::configure_logging_backend (void) + { + Logger_Service + *clf = ACE_Dynamic_Service<Logger_Service>::instance ("CIAO_Logger_Backend_Factory"); + if (clf) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::configure_logging_backend - " + "Replacing logger backend\n")); + ACE_Log_Msg_Backend * backend = clf->get_logger_backend(this->orb_); + backend->open(0); + ACE_Log_Msg::msg_backend (backend); + ACE_Log_Msg * ace = ACE_Log_Msg::instance(); + ace->clr_flags(ace->flags()); + ace->set_flags(ACE_Log_Msg::CUSTOM); + } + } + } +} + + diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.h b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.h new file mode 100644 index 00000000000..26919ad8486 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.h @@ -0,0 +1,69 @@ +// $Id$ +/** + * @file CIAO_ComponentServer.h + * @author William R. Otte + * + * Defines interface for the bootstrap element of the CIAO Component + * Server. + */ + +#ifndef CIAO_COMPONENTSERVER_H_ +#define CIAO_COMPONENTSERVER_H_ + +#include "ace/String_Base.h" +#include "ace/Task.h" +#include "tao/ORB.h" +#include "ciao/Logger/Logger_Service.h" + +namespace CIAO +{ + namespace Deployment + { + class ComponentServer_Configurator; + + + class ComponentServer_Task : ACE_Task_Base + { + public: + ComponentServer_Task (int argc, ACE_TCHAR **argv); + + int svc (void); + + struct Error + { + Error (const ACE_CString &err) : err_(err) {} + + ACE_CString err_; + }; + + void run (void); + + private: + void parse_args (int argc, ACE_TCHAR **argv); + + void get_log_level (int argc, ACE_TCHAR **argv); + + void set_log_level (void); + + void configure_logging_backend (void); + + void usage (void); + + const char * sched_policy_name (int sched_policy); + + void check_supported_priorities (void); + + CORBA::ORB_var orb_; + + auto_ptr<CIAO::Logger_Service> logger_; + + ACE_CString uuid_; + ACE_TString callback_ior_str_; + ACE_TString output_file_; + auto_ptr<ComponentServer_Configurator> configurator_; + + }; + } +} + +#endif diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl new file mode 100644 index 00000000000..14290ae6683 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl @@ -0,0 +1,66 @@ +/** + * @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 (); + }; + }; +}; + +#endif /* CIAO_COMPONENTSERVER_IDL_ */ diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.mpc b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.mpc new file mode 100644 index 00000000000..e2373c9d301 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer.mpc @@ -0,0 +1,102 @@ +// $Id$ +project(CIAO_ComponentServer_IDL) : ciaoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_ComponentServer_stub_Export + idlflags += -Wb,stub_export_include=CIAO_ComponentServer_stub_export.h + idlflags += -Wb,skel_export_macro=CIAO_ComponentServer_svnt_Export + idlflags += -Wb,skel_export_include=CIAO_ComponentServer_svnt_export.h + + custom_only=1 + + IDL_Files { + CIAO_ComponentServer.idl + CIAO_ServerResources.idl + } +} + +project(CIAO_CS_Client_IDL) : ciaoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_ComponentServer_stub_Export + idlflags += -Wb,stub_export_include=CIAO_ComponentServer_stub_export.h + idlflags += -Wb,skel_export_macro=CIAO_CS_Client_svnt_Export + idlflags += -Wb,skel_export_include=CIAO_CS_Client_svnt_export.h + + custom_only=1 + + IDL_Files { + CIAO_CS_Client.idl + CIAO_Properties.idl + } +} + +project(CIAO_ComponentServer_stub) : ccm_componentserver_stub, ciaolib_with_idl, ciao_output, \ + messaging, anytypecode, ciao_lib { + 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_ServerResourcesC.cpp + CIAO_PropertiesC.cpp + } + Header_Files { + CIAO_ComponentServer_stub_export.h + } +} + +project(CIAO_CS_Client_svnt) : ccm_svnt, ccm_componentserver_svnt, ciao_componentserver_stub, portableserver, \ + ciao_client, ciao_lib, threads, avoids_ace_for_tao { + 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 + } +} + +project(CIAO_ComponentServer_svnt) : ccm_componentserver_svnt, ciao_componentserver_stub, portableserver, ciao_componentserver_configurator, \ + ciao_session_container, naming, ciao_server { + + dynamicflags = CIAO_COMPONENTSERVER_SVNT_BUILD_DLL + after += CIAO_Basic_Configurator + libs += CIAO_Basic_Configurator + + IDL_Files { + } + Source_Files { + CIAO_ComponentServer_Impl.cpp + CIAO_ComponentServerS.cpp + CIAO_ServerResourcesS.cpp + CIAO_Container_Impl.cpp + Configurator_Factory.cpp + } + Header_Files { + CIAO_ComponentServer_svnt_export.h + } +} + +project(CIAO_ComponentServer_exe) : ccm_componentserver_svnt, portableserver, ciao_componentserver_svnt, \ + messaging, anytypecode, ciao_server, ciaoexe, ciao_session_container,\ + ciao_logger { + exename = ciao_componentserver + libs += CIAO_Basic_Configurator + after += CIAO_Basic_Configurator + macros += CIAO_BUILD_COMPONENTSERVER_EXE + Source_Files { + CIAO_ComponentServer.cpp + } + Inline_Files { + } + IDL_Files { + } +} diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.cpp b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.cpp new file mode 100644 index 00000000000..f316cfe1b96 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.cpp @@ -0,0 +1,262 @@ +// $Id$ +#include "CIAO_ComponentServer_Impl.h" + +#include "ciao/CIAO_common.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 ((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 ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::shutdown - ComponentServer %C still containers!\n", + this->uuid_.c_str ())); + + this->orb_->shutdown (); + } + + + ::Components::ConfigValues * + CIAO_ComponentServer_i::configuration (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::configuration"); + return this->config_values_.out (); + } + + + ::Components::Deployment::ServerActivator_ptr + CIAO_ComponentServer_i::get_server_activator (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::get_server_activator"); + return this->serv_act_.in (); + } + + ::Components::Deployment::Container_ptr + CIAO_ComponentServer_i::create_container (const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_ComponentServer_i::create_container"); + + try + { + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_ComponentServer_i::create_container - Request received with %u config values\n", + config.length ())); + + CORBA::PolicyList policies; + 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 ((LM_DEBUG, CLINFO "CIAO_ComponentServer_i::create_container - " + "Container servant successfully allocated.\n")); + + PortableServer::ServantBase_var safe_config = cont; + CIAO::Deployment::Container_var cont_var = cont->_this (); + + this->containers_.insert (CIAO::Deployment::Container::_duplicate(cont_var.in ())); + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_ComponentServer_i::create_container - Container successfully activated and stored," + "now manage %u containers\n", + this->containers_.size ())); + + return cont_var._retn (); + } + catch (const CORBA::NO_MEMORY &) + { + CIAO_ERROR ((LM_CRITICAL, CLINFO "CIAO_ComponentServer_Impl: Out of memory exception whilst creating container.\n")); + throw; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, "CIAO_ComponentServer_Impl: Caught unknown exception\n")); + } + + throw Components::CreateFailure (); + } + + + + void + CIAO_ComponentServer_i::remove_container (::Components::Deployment::Container_ptr cref) + { + CIAO_TRACE("CIAO_ComponentServer_i::remove_container"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - remove request received.\n")); + + if (CORBA::is_nil (cref)) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Error: Received nil container reference\n")); + throw Components::RemoveFailure (); + } + + if (this->containers_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Error: I don't manage any containers!\n")); + throw Components::RemoveFailure (); + } + + try + { + CONTAINERS::ITERATOR i (this->containers_.begin ()); + + // @@ TODO: artifact from when this was a sequence, should probably use .find, + // which will work properly with the new parameterized set class. + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + if (CORBA::is_nil (*i)) + { + ACE_ERROR ((LM_WARNING, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Managed container reference is nil, skipping.\n")); + continue; + } + + if ((*i)->_is_equivalent (cref)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Found container, invoking remove....\n")); + cref->remove (); + if (this->containers_.remove (*i) != 0) + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - Unable to remove " + "container reference from internal structure....\n")); + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Remove completed, destroying object, " + "now manage %u containers\n", this->containers_.size ())); + return; + } + } + } + catch (const CORBA::Exception &ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - " + "Caught CORBA exception whilst removing container: %C\n", + ex._info ().c_str ())); + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - Error: Unknown exception caught while removing a container.\n")); + } + throw Components::RemoveFailure (); + } + + + ::Components::Deployment::Containers * + CIAO_ComponentServer_i::get_containers (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::get_containers"); + + ::Components::Deployment::Containers *tmp = 0; + 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 ((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 ((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) + { + if (!CORBA::is_nil (sa)) + 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) + { + CIAO::Deployment::ComponentInstallation_ptr tmp; + this->config_values_[i]->value () >>= tmp; + this->ci_ = CIAO::Deployment::ComponentInstallation::_duplicate (tmp); + } + } + } + } + } +} diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.h b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.h new file mode 100644 index 00000000000..3200980c077 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_Impl.h @@ -0,0 +1,82 @@ +// $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_; + + CIAO::Deployment::ComponentInstallation_var ci_; + }; + } +} + +#endif diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_stub_export.h b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_stub_export.h new file mode 100644 index 00000000000..fa958277aae --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_stub_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_ComponentServer_stub +// ------------------------------ +#ifndef CIAO_COMPONENTSERVER_STUB_EXPORT_H +#define CIAO_COMPONENTSERVER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_COMPONENTSERVER_STUB_HAS_DLL) +# define CIAO_COMPONENTSERVER_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_COMPONENTSERVER_STUB_HAS_DLL */ + +#if !defined (CIAO_COMPONENTSERVER_STUB_HAS_DLL) +# define CIAO_COMPONENTSERVER_STUB_HAS_DLL 1 +#endif /* ! CIAO_COMPONENTSERVER_STUB_HAS_DLL */ + +#if defined (CIAO_COMPONENTSERVER_STUB_HAS_DLL) && (CIAO_COMPONENTSERVER_STUB_HAS_DLL == 1) +# if defined (CIAO_COMPONENTSERVER_STUB_BUILD_DLL) +# define CIAO_ComponentServer_stub_Export ACE_Proper_Export_Flag +# define CIAO_COMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_COMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_COMPONENTSERVER_STUB_BUILD_DLL */ +# define CIAO_ComponentServer_stub_Export ACE_Proper_Import_Flag +# define CIAO_COMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_COMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_COMPONENTSERVER_STUB_BUILD_DLL */ +#else /* CIAO_COMPONENTSERVER_STUB_HAS_DLL == 1 */ +# define CIAO_ComponentServer_stub_Export +# define CIAO_COMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) +# define CIAO_COMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_COMPONENTSERVER_STUB_HAS_DLL == 1 */ + +// Set CIAO_COMPONENTSERVER_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_COMPONENTSERVER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_COMPONENTSERVER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_COMPONENTSERVER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_COMPONENTSERVER_STUB_NTRACE */ + +#if (CIAO_COMPONENTSERVER_STUB_NTRACE == 1) +# define CIAO_COMPONENTSERVER_STUB_TRACE(X) +#else /* (CIAO_COMPONENTSERVER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_COMPONENTSERVER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_COMPONENTSERVER_STUB_NTRACE == 1) */ + +#endif /* CIAO_COMPONENTSERVER_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_svnt_export.h b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_svnt_export.h new file mode 100644 index 00000000000..1469845401d --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ComponentServer_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_ComponentServer_svnt +// ------------------------------ +#ifndef CIAO_COMPONENTSERVER_SVNT_EXPORT_H +#define CIAO_COMPONENTSERVER_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_COMPONENTSERVER_SVNT_HAS_DLL) +# define CIAO_COMPONENTSERVER_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_COMPONENTSERVER_SVNT_HAS_DLL */ + +#if !defined (CIAO_COMPONENTSERVER_SVNT_HAS_DLL) +# define CIAO_COMPONENTSERVER_SVNT_HAS_DLL 1 +#endif /* ! CIAO_COMPONENTSERVER_SVNT_HAS_DLL */ + +#if defined (CIAO_COMPONENTSERVER_SVNT_HAS_DLL) && (CIAO_COMPONENTSERVER_SVNT_HAS_DLL == 1) +# if defined (CIAO_COMPONENTSERVER_SVNT_BUILD_DLL) +# define CIAO_ComponentServer_svnt_Export ACE_Proper_Export_Flag +# define CIAO_COMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_COMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_COMPONENTSERVER_SVNT_BUILD_DLL */ +# define CIAO_ComponentServer_svnt_Export ACE_Proper_Import_Flag +# define CIAO_COMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_COMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_COMPONENTSERVER_SVNT_BUILD_DLL */ +#else /* CIAO_COMPONENTSERVER_SVNT_HAS_DLL == 1 */ +# define CIAO_ComponentServer_svnt_Export +# define CIAO_COMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) +# define CIAO_COMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_COMPONENTSERVER_SVNT_HAS_DLL == 1 */ + +// Set CIAO_COMPONENTSERVER_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_COMPONENTSERVER_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_COMPONENTSERVER_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_COMPONENTSERVER_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_COMPONENTSERVER_SVNT_NTRACE */ + +#if (CIAO_COMPONENTSERVER_SVNT_NTRACE == 1) +# define CIAO_COMPONENTSERVER_SVNT_TRACE(X) +#else /* (CIAO_COMPONENTSERVER_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_COMPONENTSERVER_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_COMPONENTSERVER_SVNT_NTRACE == 1) */ + +#endif /* CIAO_COMPONENTSERVER_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp b/modules/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp new file mode 100644 index 00000000000..81c20c0d201 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp @@ -0,0 +1,476 @@ +// $Id$ +#include "CIAO_Container_Impl.h" + +#include "ace/Log_Msg.h" +#include "ccm/CCM_HomeC.h" +#include "ciao/CIAO_common.h" +#include "ciao/Server_init.h" +#include "ciao/Client_init.h" +#include "CIAO_PropertiesC.h" +#include "CIAO_CS_ClientC.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, + CIAO::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_ (CIAO::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((LM_DEBUG, CLINFO "CIAO_Container_i: creating Session container with dynamic linkage\n")); + this->container_ = new CIAO::Session_Container (this->orb_.in (), this, false, + 0, name, policies); + } + else + { + CIAO_DEBUG((LM_DEBUG, CLINFO "CIAO_Container_i: creating Session container with static linkage\n")); + this->container_ = new CIAO::Session_Container (this->orb_.in (), this, true, + this->static_entrypts_maps_, + name, policies); + } + } + catch (...) + { + CIAO_ERROR((LM_ERROR, CLINFO "CIAO_Container_i::CIAO_Container_i - " + "Caught exception while allocating container implementation\n")); + throw; + } + } + + + // Destructor + CIAO_Container_i::~CIAO_Container_i (void) + { + CIAO_TRACE("CIAO_Container_i::~CIAO_Container_i"); + } + + ::Components::CCMObject_ptr + CIAO_Container_i::install_component (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_Container_i::install_component"); + + if (id == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_component - " + "No home ID provided\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + Components::CCMObject_var comp; + + if (this->component_map_.find (id, comp) == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_component - " + "Component with id %C already installed, aborting\n", + id)); + throw Components::CreateFailure (); + } + + if (entrypt == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_component - " + "No executor entrypoint found.\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::install_component - " + "Attempting to install home with id [%C]\n", + id)); + + CIAO_DEBUG ((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; + CORBA::String_var exec_art, svnt_art, svnt_entry; + + if (cm.find (SVNT_ENTRYPT, val) == 0) + { + val >>= tmp; + svnt_entry = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found Servant entrypoint %C\n", svnt_entry.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Error: No Servant entrypoint 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 ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found Servant artifact %C\n", svnt_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Error: No Servant artifact 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 ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Found executor artifact: %C\n", exec_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Error: No Executor artifact provided, aborting installation\n")); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_component - " + "Extraction resulted in map of [%u] values\n", cm.current_size ())); + + comp = this->container_->install_component (exec_art, + entrypt, + svnt_art, + svnt_entry, + id); + + if (this->component_map_.bind (id, + Components::CCMObject::_duplicate (comp.in ())) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_component - " + "Unable to bind componnet into component map\n")); + } + + return comp._retn (); + } + + void + CIAO_Container_i::remove_component (::Components::CCMObject_ptr cref) + { + CIAO_TRACE("CIAO_Container_i::remove_component"); + + Component_Iterator i = this->component_map_.begin (); + while (!i.done ()) + { + if (i->item ()->_is_equivalent (cref)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_component - " + "Successfully found matching component\n")); + break; + } + i.advance (); + } + + if (i.done ()) + { + CIAO_ERROR ((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 ((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 ((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 ((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 (); + return 0; + } + + ::Components::ConfigValues * + CIAO_Container_i::configuration (void) + { + CIAO_TRACE("CIAO_Container_i::configuration"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::Deployment::ComponentServer_ptr + CIAO_Container_i::get_component_server (void) + { + CIAO_TRACE("CIAO_Container_i::get_component_server"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::CCMHome_ptr + CIAO_Container_i::install_home (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_Container_i::install_home"); + + if (id == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "No home ID provided\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + Components::CCMHome_var home; + + if (this->home_map_.find (id, home) == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "Home with id %C already installed, aborting\n", + id)); + throw Components::CreateFailure (); + } + + if (entrypt == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "No executor entrypoint found.\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::install_home - " + "Attempting to install home with id [%C]\n", id)); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Extracting ConfigValues from sequence of length [%u]\n", + config.length ())); + + CIAO::Utility::CONFIGVALUE_MAP cm; + CIAO::Utility::build_config_values_map (cm, config); + CORBA::Any val; + + const char *tmp = 0; + CORBA::String_var exec_art, svnt_art, svnt_entry; + if (cm.find (SVNT_ENTRYPT, val) == 0) + { + val >>= tmp; + svnt_entry = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found Servant entrypoint %C\n", svnt_entry.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Servant entrypoint 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 ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found Servant artifact %C\n", svnt_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Servant artifact 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 ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found executor artifact: %C\n", exec_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Executor artifact provided, aborting installation\n")); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Extraction resulted in map of [%u] values", cm.current_size ())); + + + // extract config values here... + + //CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_Container_i::install_home - ", + //"Executor entrypoint [%C], servant entrypoint [%C], servant library [%C]\n", + //entrypt, svnt_entrypt.in (), svnt_library.in ())); + + home = this->container_->install_home (exec_art, + entrypt, + svnt_art, + svnt_entry, + id); + + if (this->home_map_.bind (id, + Components::CCMHome::_duplicate (home.in ())) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Unable to bind home into home map\n")); + } + + return home._retn (); + } + + void + CIAO_Container_i::remove_home (::Components::CCMHome_ptr href) + { + CIAO_TRACE("CIAO_Container_i::remove_home"); + + Home_Iterator i = this->home_map_.begin (); + while (!i.done ()) + { + if (i->item ()->_is_equivalent (href)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " + "Successfully found matching home\n")); + break; + } + i.advance (); + } + + if (i.done ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::remove_home - " + "Unable to find matching home managed by this container, throwing RemoveFailure\n")); + throw Components::RemoveFailure (); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " + "Invoking remove on the container impl for home %C.\n", + i->key ().c_str ())); + this->container_->uninstall_home (href); + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::remove_home - " + "Successfully removed home %C\n", + i->key ().c_str ())); + + if (this->home_map_.unbind (i->key ()) != 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::remove_home - " + "Unable to unbind removed home with id %C from home map\n", + i->key ().c_str ())); + } + } + + ::Components::CCMHomes * + CIAO_Container_i::get_homes (void) + { + CIAO_TRACE("CIAO_Container_i::get_homes"); + + ::Components::CCMHomes *tmp_homes = 0; + + ACE_NEW_THROW_EX (tmp_homes, + ::Components::CCMHomes (this->home_map_.current_size ()), + CORBA::NO_MEMORY ()); + + ::Components::CCMHomes_var retval (tmp_homes); + retval->length (this->home_map_.current_size ()); + Home_Iterator i = this->home_map_.begin (); + CORBA::ULong pos = 0; + while (!i.done ()) + { + retval[pos++] = ::Components::CCMHome::_duplicate (i->item ().in ()); + i.advance (); + } + + return retval._retn (); + } + + void + CIAO_Container_i::remove (void) + { + CIAO_TRACE("CIAO_Container_i::remove"); + + if (this->home_map_.current_size () != 0 || + this->component_map_.current_size () != 0) + { + CIAO_ERROR ((LM_WARNING, CLINFO "CIAO_Container_i::remove - " + "Attempting to remove container that still has %u homes and %u components installed\n", + this->home_map_.current_size (), + this->component_map_.current_size ())); + } + } + + void + CIAO_Container_i::activate_component (::Components::CCMObject_ptr comp) + { + CIAO_TRACE ("CIAO_Container_i::activate_component"); + + this->container_->activate_component (comp); + } + + + void + CIAO_Container_i::passivate_component (::Components::CCMObject_ptr comp) + { + CIAO_TRACE ("CIAO_Container_i::passivate_component"); + + this->container_->passivate_component (comp); + } + + + PortableServer::POA_ptr + CIAO_Container_i::_default_POA (void) + { + CIAO_TRACE ("CIAO_Container_i::_default_POA"); + return PortableServer::POA::_duplicate (this->poa_.in ()); + } + } +} diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h b/modules/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h new file mode 100644 index 00000000000..5badb6860bc --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h @@ -0,0 +1,119 @@ +// $Id$ +/** + * @file CIAO_Container_Impl.h + * @author William R. Otte <wotte@dre.vanderbilt.edu> + */ + +#ifndef CIAO_CONTAINER_H_ +#define CIAO_CONTAINER_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 *, + const CORBA::PolicyList *, + CIAO::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); + + 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_; + + CIAO::Deployment::ComponentInstallation_var ci_; + }; + } +} +#endif /* CIAO_CONTAINER_H_ */ diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_Properties.idl b/modules/CIAO/ciao/ComponentServer/CIAO_Properties.idl new file mode 100644 index 00000000000..bc696cf4286 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_Properties.idl @@ -0,0 +1,28 @@ +/** + * @file CIAO_Properties.idl + * @author William R. Otte + * $Id$ + * Standardizes names of configvalues used by CIAO. + */ + +#ifndef CIAO_PROPERTIES_IDL +#define CIAO_PROPERTIES_IDL + +module CIAO +{ + module Deployment + { + const string SVNT_ENTRYPT = "edu.vanderbilt.dre.CIAO.ServantEntrypoint"; + const string SVNT_ARTIFACT = "edu.vanderbilt.dre.CIAO.ServantArtifact"; + const string EXEC_ARTIFACT = "edu.vanderbilt.dre.CIAO.ExecutorArtifact"; + const string SERVER_RESOURCES = "edu.vanderbilt.dre.CIAO.ServerResources"; + const string SERVER_UUID = "edu.vanderbilt.dre.CIAO.ServerUUID"; + const string SERVER_EXECUTABLE = "edu.vanderbilt.dre.CIAO.ComponentServerExecutable"; + const string SERVER_ARGUMENTS = "edu.vanderbilt.dre.CIAO.ComponentServerArgs"; + const string SERVER_TIMEOUT = "edu.vanderbilt.dre.CIAO.ServerTimeout"; + const string SERVER_MULTITHREAD = "edu.vanderbilt.dre.CIAO.Multithreaded"; + const string REGISTER_NAMING = "edu.vanderbilt.dre.CIAO.RegisterNaming"; + const string COMPONENTINSTALLATION_REF = "edu.vanderbilt.dre.CIAO.ComponentInstallation"; + }; +}; +#endif /* CIAO_PROPERTIES_IDL */ diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.cpp b/modules/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.cpp new file mode 100644 index 00000000000..7f320cd6390 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.cpp @@ -0,0 +1,550 @@ +// $Id$ +#include "CIAO_ServerActivator_Impl.h" + +#include "ace/Log_Msg.h" +#include "ace/UUID.h" +#include "ciao/CIAO_common.h" +#include "ciao/Client_init.h" +#include "ciao/CIAO_FailureReasonsC.h" + +#include "CIAO_ServerResourcesC.h" +#include "CIAO_ComponentServerC.h" +#include "CIAO_PropertiesC.h" + +namespace CIAO +{ + namespace Deployment + { + CIAO_ServerActivator_i::CIAO_ServerActivator_i (CORBA::ULong def_spawn_delay, + const char * default_cs_path, + const char * cs_args, + bool multithreaded, + CIAO::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_ (CIAO::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 ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C\n", + server_UUID)); + + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, but I don't manage any.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + //SERVER_INFOS::iterator i (this->server_infos_.begin ()); + //i.first (); + Server_Info *info = 0; + + for (SERVER_INFOS::iterator i (this->server_infos_.begin ()); + !i.done (); ++i) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Comparing %C with %C\n", (*i)->uuid_.c_str (), server_UUID)); + if ((*i)->uuid_ == server_UUID) + { + info = (*i).get (); + } + } + + if (info == 0) + { CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, which doesn't belong to me.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + if (info->activated_) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, which has already been configured.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + if (!CORBA::is_nil (info->ref_)) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C, which has already called back.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %C\n", + server_UUID)); + + info->ref_ = ::Components::Deployment::ComponentServer::_duplicate (serverref); + + this->create_component_server_config_values (*info, config); + + // @@TODO: May want to print out configvalues here. + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Generated %u ConfigValues for ComponentServer %C\n", + config->length (), server_UUID)); + } + + void + CIAO_ServerActivator_i::configuration_complete (const char *server_UUID) + { + CIAO_TRACE ("CIAO_ServerActivator_i::configuration_complete"); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C\n", + server_UUID)); + + try + { + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received callback from ComponentServer %C, but I don't manage any.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + Server_Info *info = 0; + + for (SERVER_INFOS::ITERATOR j (this->server_infos_); + !j.done (); ++j) + { + if ((*j)->uuid_ == server_UUID) + { + info = (*j).get (); + } + } + + if (info == 0) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C, which doesn't belong to me.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + if (info->activated_) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C, which has already been completed.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + if (CORBA::is_nil (info->ref_.in ())) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %C, which has not called back.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + info->activated_ = true; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Caught unknown exception while processing configuration_complete\n")); + throw; + } + } + + ::Components::Deployment::ComponentServer_ptr + CIAO_ServerActivator_i::create_component_server (const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_ServerActivator_i::create_component_server"); + + Safe_Server_Info server (new Server_Info (config.length () + 1)); + + CIAO::Utility::build_config_values_map (*server->cmap_, config); + + ACE_CString cmd_options = this->construct_command_line (*server); + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::create_component_server - ComponentServer arguments: %C\n", + cmd_options.c_str ())); + + server_infos_.insert_tail (server); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::create_component_server - " + "Attempting to spawn ComponentServer with UUID %C\n", + server->uuid_.c_str ())); + // Now we need to get a copy of the one that was inserted... + pid_t pid = this->spawn_component_server (*server, cmd_options); + ACE_UNUSED_ARG (pid); + + ACE_Time_Value timeout (this->spawn_delay_); + + CORBA::Any val; + + if (server->cmap_->find (SERVER_TIMEOUT, val) == 0) + { + CORBA::ULong t; + if (val >>= t) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::create_component_server - " + "Using provided non-default server timeout of %u\n", t)); + timeout = ACE_Time_Value (t); + } + else + { + CIAO_ERROR ((LM_WARNING, CLINFO "CIAO_ServerActivator_i::create_component_server - " + "Failed to extract provided non-default server timeout from property '%C', " + "falling back to default timeout of %u\n", + this->spawn_delay_)); + } + } + + if (this->multithreaded_) + this->multi_threaded_wait_for_callback (*server, timeout/*, pid*/); + else + this->single_threaded_wait_for_callback (*server, timeout/*, pid*/); + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::create_component_server - " + "ComponentServer %C successfully spawned and configured!\n", + server->uuid_.c_str ())); + + return ::Components::Deployment::ComponentServer::_duplicate (server->ref_.in ()); + } + + ACE_CString + CIAO_ServerActivator_i::construct_command_line (Server_Info &server) + { + CIAO_TRACE ("CIAO_ServerActivator_i::construct_command_line"); + + // Build our command line to launch the compoent server + ACE_CString cmd_options (this->cs_args_); + + CORBA::Any val; + + if (server.cmap_->find (SERVER_UUID, val) == 0) + { + // Nodeapplication has requested a custom uuid + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using provided UUID\n")); + const char *uuid = 0; + val >>= uuid; + server.uuid_ = uuid; + } + else + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using generated UUID\n")); + ACE_Utils::UUID uuid; + ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid); + server.uuid_ = *uuid.to_string (); + } + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Creating component server " + " with UUID %C\n", server.uuid_.c_str ())); + + cmd_options += " -u "; + cmd_options += server.uuid_; + + if (server.cmap_->find (SERVER_RESOURCES, val) == 0) + { + // There may be command line arguments specified in the plan + ServerResource_var sr; + val >>= sr; + + // If command line options are specified through RTCCM descriptors, + // then we should honor these command line options as well. + for (CORBA::ULong arg_i = 0; + arg_i < sr->args.length (); + ++arg_i) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Adding argument %C from ServerResource\n", + sr->args[arg_i].in ())); + cmd_options += " "; // space between command line args + cmd_options += sr->args[arg_i]; + } + + // If service configuration file is specified through RTCCM + // descriptors, then we should honor it as well. + if (ACE_OS::strcmp (sr->svcconf.in (), "") != 0) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using SvcConf file %C\n", + sr->svcconf.in ())); + cmd_options += " -ORBSvcConf "; + cmd_options += sr->svcconf; + } + } + + return cmd_options; + } + + pid_t + CIAO_ServerActivator_i::spawn_component_server (const Server_Info &si, + const ACE_CString &cmd_line) + { + CIAO_TRACE ("CIAO_ServerActivator_i::spawn_component_server"); + + ACE_Process_Options options; + + // Get my object reference + CORBA::Object_var obj = this->poa_->servant_to_reference (this); + CORBA::String_var ior = this->orb_->object_to_string (obj.in ()); + CORBA::Any val; + + const char *path = this->cs_path_.c_str (); + + if (si.cmap_->find (SERVER_EXECUTABLE, val) == 0) + { + val >>= path; + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " + "Using provided component server executable:%C\n", path)); + } + else + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " + "Using default component server execuable\n")); + } + + options.command_line ("%s %s -c %s", + path, + cmd_line.c_str (), + ior.in ()); + + options.avoid_zombies (0); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::spawn_component_server - Spawning process, command line is %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 ((LM_ERROR, CLINFO + "Failed to spawn a ComponentServer process\n")); + throw Components::CreateFailure (CIAO::SERVER_SPAWN_FAILURE); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::spawn_component_server - Process successfully spawned with pid %u\n", + pid)); + return pid; + } + + void + CIAO_ServerActivator_i:: + single_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout) + { + CIAO_TRACE ("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 ((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 ((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"); + + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "I don't manage any ComponentServers.\n")); + throw CORBA::BAD_PARAM (); + } + + Server_Info *info = 0; + + for (SERVER_INFOS::ITERATOR i (this->server_infos_); + !i.done (); ++i) + { + if ((*i)->ref_->_is_equivalent (server)) + { + info = (*i).get (); + } + } + + if (info == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Failed to find equivalent ComponentServer under my management.\n")); + throw ::Components::RemoveFailure (); + } + + try + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Calling remove () on ComponentServer %C\n", + info->uuid_.c_str ())); + server->remove (); + } + catch (::Components::RemoveFailure &) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Received RemoveFailure exception from ComponentServer %C\n", + info->uuid_.c_str ())); + } + + // If this is a CIAO component server, call shutdown + CIAO::Deployment::ComponentServer_var ccs = + CIAO::Deployment::ComponentServer::_narrow (server); + if (!CORBA::is_nil (ccs)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Calling shutdown () on ComponentServer %C\n", + info->uuid_.c_str ())); + ccs->shutdown (); + } + else + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "ComponentServer %C is not a CIAO_ComponentServer, not calling shutdown.\n", + info->uuid_.c_str ())); + + CIAO_DEBUG ((LM_INFO, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "ComponentServer %C successfully shut down.\n", + info->uuid_.c_str ())); + } + + ::Components::Deployment::ComponentServers * + CIAO_ServerActivator_i::get_component_servers (void) + { + CIAO_TRACE ("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 ()); + + CIAO::Deployment::ComponentInstallation_ptr ci = + CIAO::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/modules/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.h b/modules/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.h new file mode 100644 index 00000000000..9dfa5a209fb --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ServerActivator_Impl.h @@ -0,0 +1,196 @@ +// $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 "tao/orbconf.h" +#include "ciao/Client_init.h" +#include "ciao/ComponentServer/CIAO_CS_ClientS.h" +#include "ciao/ComponentServer/CIAO_ComponentServerC.h" +#include "ciao/ComponentServer/CIAO_CS_Client_svnt_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace CIAO +{ + namespace Deployment + { + //namespace + //{ + /** + * @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, + CIAO::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 <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_; + + CIAO::Deployment::ComponentInstallation_var ci_; + }; + + + } +} +#endif /* CIAO_SERVERACTIVATOR_H_ */ diff --git a/modules/CIAO/ciao/ComponentServer/CIAO_ServerResources.idl b/modules/CIAO/ciao/ComponentServer/CIAO_ServerResources.idl new file mode 100644 index 00000000000..751569143c0 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/CIAO_ServerResources.idl @@ -0,0 +1,269 @@ +// $Id$ + +/** + * @file CIAO_ServerResources.idl + * + * @brief A collection of IDL data types for + * + * @author Nanbor Wang + */ + +#if !defined (CIAO_SERVERRESOURCES_IDL) +#define CIAO_SERVERRESOURCES_IDL + +#include <orb.idl> + +module CIAO +{ + module Deployment + { + /** + * @brief A single command line argument corresponds to a string as + * in the case of "argv". + */ + typedef string CommandlineArg; + /** + * @brief A list of command line arguments which a + * NodeApplicationManager will use to start up the NodeApplication + * this list is associated to. The command line arguments will be + * appended to the command line in order. + */ + typedef sequence<CommandlineArg> CommandlineArgs; + + /** + * @brief A string containing the filename of the svc.conf file the + * NodeApplication uses. The current approach of specifying + * svc.conf filename directly some harder problems such as + * distribution of svc.conf files and the relative/absolute path to + * the svc.conf file (the ServerResrouces xml document will have to + * assume the svc.conf file will be available at specific location.) + */ + typedef string SvcconfURI; + + /** + * @brief enumeration of ORB Resource Types (ORT) supported in RT + * extension. + */ + enum ORBResourceType + { + ORT_THREADPOOL, + ORT_THREADPOOLWITHLANES, + ORT_CONNECTIONBANDS + }; + + typedef short Priority; + + /** + * @brief Define a threadpool resource that an ORB must provide + */ + struct ORS_Threadpool + { + string Id; + unsigned long stacksize; + unsigned long static_threads; + unsigned long dynamic_threads; + Priority default_priority; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence<ORS_Threadpool> ORS_ThreadpoolSeq; + + /** + * @brief Defines the configuration of a threadpool lane. We need + * to redefine it here to avoid dependency to RTCORBA library. + */ + struct ORS_ThreadpoolLane + { + Priority lane_priority; + unsigned long static_threads; + unsigned long dynamic_threads; + }; + + /** + * @brief Defines a set of threadpool lanes. We need + * to redefine it here to avoid dependency to RTCORBA library. + */ + typedef sequence<ORS_ThreadpoolLane> ORS_ThreadpoolLanes; + + /** + * @brief Defines a Threadpool with Lanes resource that an ORB + * must provide. + */ + struct ORS_ThreadpoolWithLanes + { + string Id; + unsigned long stacksize; + ORS_ThreadpoolLanes threadpool_lanes; + boolean allow_borrowing; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence<ORS_ThreadpoolWithLanes> ORS_ThreadpoolWithLanesSeq; + + /** + * @brief Define a priority band for BandedConnection policies. + */ + struct ORS_PriorityBand + { + Priority low; + Priority high; + }; + /** + * @brief Define a list of priority bands for BandedConnection + * policies. + */ + typedef sequence<ORS_PriorityBand> ORS_PriorityBands; + + /** + * @brief Define the information needed to create a + * BandedConnection policy. This info can be referred to via its + * name (Id). + */ + struct ORS_ConnectionBands + { + string Id; + ORS_PriorityBands bands; + }; + + typedef sequence<ORS_ConnectionBands> ORS_ConnectionBandsSeq; + + /** + * @brief Collection of resources managed by the NodeApplication + * ORB. + */ + struct ORBResource + { + ORS_ThreadpoolSeq threadpool_list; + + ORS_ThreadpoolWithLanesSeq threadpool_with_lanes_list; + + ORS_ConnectionBandsSeq connection_bands_list; + }; + + typedef sequence<ORBResource, 1> ORBResources; + + // ================================================================= + + /** + * @brief PolicyType supported by DAnCE extension. Again, we are + * redefining these value to avoid dependencies to various ORB + * modules such as RTCORBA and DiffServ policy libraries. + * @JW This is a bad thing to redefine. Maybe we have to make a seperate + * IDL lib for these libraries, but redefinition is really a bad thing + */ + const CORBA::PolicyType PRIORITY_MODEL_POLICY_TYPE = 40; + const CORBA::PolicyType THREADPOOL_POLICY_TYPE = 41; + const CORBA::PolicyType PRIORITY_BANDED_CONNECTION_POLICY_TYPE = 45; + const CORBA::PolicyType CLIENT_NETWORK_PRIORITY_TYPE = 86; + const CORBA::PolicyType NETWORK_PRIORITY_TYPE = 87; + + enum PriorityModel + { + CLIENT_PROPAGATED, + SERVER_DECLARED + }; + + enum NWPriorityModel + { + CLIENT_PROPAGATED_NWPRIORITY, + SERVER_DECLARED_NWPRIORITY + }; + + /** + * @brief Defines data required for creating a PriorityModel Policy + */ + struct PriorityModelPolicyDef + { + PriorityModel priority_model; + Priority server_priority; + }; + + /** + * @brief Defines data required for creating a server side DiffServ policy + */ + struct NWPriorityModelPolicyDef + { + NWPriorityModel nw_priority_model; + long request_dscp; + long reply_dscp; + }; + + /** + * @brief Defines data required for creating a client side DiffServ policy + */ + struct CNWPriorityModelPolicyDef + { + long request_dscp; + long reply_dscp; + }; + + /** + * @brief Define data required for creating a Threadpool policy + */ + struct ThreadpoolPolicyDef + { + /// Threadpool name defined in ORBResource + string Id; + }; + + /** + * @brief Define data required for creating a PriorityBandedConnection + * policy + */ + struct PriorityBandedConnectionPolicyDef + { + /// PriorityBands name defined in ORBResource + string Id; + }; + + union PolicyDef switch (CORBA::PolicyType) + { + case PRIORITY_MODEL_POLICY_TYPE: PriorityModelPolicyDef PriorityModelDef; + case THREADPOOL_POLICY_TYPE: ThreadpoolPolicyDef ThreadpoolDef; + case PRIORITY_BANDED_CONNECTION_POLICY_TYPE: PriorityBandedConnectionPolicyDef PriorityBandedConnectionDef; + case CLIENT_NETWORK_PRIORITY_TYPE: CNWPriorityModelPolicyDef CNWPriorityModelDef; + case NETWORK_PRIORITY_TYPE: NWPriorityModelPolicyDef NWPriorityModelDef; + }; + + /** + * @brief Define a set of policy definitions. + */ + typedef sequence<PolicyDef> PolicyDefs; + + /** + * @brief A policy set is named. + */ + struct PolicySet + { + /// Name of this policy set + string Id; + PolicyDefs policies; + }; + + /** + * @brief A list of all policy sets. + */ + typedef sequence<PolicySet> PolicySets; + + struct ORBConfigs + { + ORBResources orb_resources; + PolicySets policy_set; + }; + + struct ServerResource + { + string Id; + + CommandlineArgs args; + SvcconfURI svcconf; + ORBConfigs orb_config; + }; + }; +}; + +#endif /* CIAO_SERVERRESOURCES_IDL */ diff --git a/modules/CIAO/ciao/ComponentServer/Configurator_Factory.cpp b/modules/CIAO/ciao/ComponentServer/Configurator_Factory.cpp new file mode 100644 index 00000000000..1bdc33a8558 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurator_Factory.cpp @@ -0,0 +1,48 @@ +#include "Configurator_Factory.h" +// $Id$ +#include "ace/Arg_Shifter.h" +#include "ciao/CIAO_common.h" +#include "Configurators/Server_Configurator.h" + +namespace CIAO +{ + namespace Deployment + { + ComponentServer_Configurator * + Configurator_Factory::operator() (int &argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("Configurator_Factory::operator()"); + bool const rt = this->parse_args (argc, argv); + + ComponentServer_Configurator *ptr = 0; + ACE_NEW_THROW_EX (ptr, + ComponentServer_Configurator (rt), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return ptr; + } + + bool + Configurator_Factory::parse_args (int &argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("Configurator_Factory::parse_args"); + ACE_Arg_Shifter shifter (argc, argv); + bool retval = false; + + while (shifter.is_anything_left ()) + { + if (shifter.cur_arg_strncasecmp (ACE_TEXT("-r")) == 0) + { + retval = true; + shifter.consume_arg (); + } + else + { + shifter.ignore_arg (); + } + } + return retval; + } + } +} diff --git a/modules/CIAO/ciao/ComponentServer/Configurator_Factory.h b/modules/CIAO/ciao/ComponentServer/Configurator_Factory.h new file mode 100644 index 00000000000..0e421fb1a9e --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurator_Factory.h @@ -0,0 +1,39 @@ +// $Id$ +/** + * @file Configurator_Factory.h + * @author William R. Otte <wotte@dre.vanderbilt.edu> + * @author Nanbor Wang <> + * + * Factory for creating configurators, based on old NodeApplication_Options + * class + */ + +#ifndef CIAO_CONFIGURATOR_FACTORY_H +#define CIAO_CONFIGURATOR_FACTORY_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "CIAO_ComponentServer_svnt_export.h" + +namespace CIAO +{ + namespace Deployment + { + class ComponentServer_Configurator; + + class CIAO_ComponentServer_svnt_Export Configurator_Factory + { + public: + ComponentServer_Configurator * operator () (int &argc, ACE_TCHAR **argv); + + private: + bool parse_args (int &argc, ACE_TCHAR **argv); + }; + } +} +#include /**/ "ace/post.h" + +#endif diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.cpp b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.cpp new file mode 100755 index 00000000000..ecd2c0003cc --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.cpp @@ -0,0 +1,240 @@ +// $Id$ + +#include "Basic_Config_Manager.h" +#include "ciao/CIAO_common.h" +#include "ace/SString.h" +#include "tao/SystemException.h" +#include "tao/DiffServPolicy/DiffServPolicy.h" +#include "tao/DiffServPolicy/Client_Network_Priority_Policy.h" +#include "tao/DiffServPolicy/Server_Network_Priority_Policy.h" + +namespace CIAO +{ + namespace Deployment + { + + void + Basic_Config_Manager::init (CORBA::ORB_ptr orb) + { + this->orb_ = CORBA::ORB::_duplicate (orb); + } + + int + Basic_Config_Manager::pre_orb_initialize (void) + { + return 0; + } + + int + Basic_Config_Manager::post_orb_initialize (CORBA::ORB_ptr) + { + return 0; + } + + void + Basic_Config_Manager::init_resources + (const ServerResource &server_resource) + { + CIAO_DEBUG ((LM_DEBUG,"Basic_Config_Manager::init_resources\n")); + + if (CORBA::is_nil (this->orb_.in())) + { + CIAO_ERROR ((LM_ERROR, + "Basic_Config_Manager has not been properly initialized\n")); + throw CORBA::INTERNAL (); + } + + const PolicySets &sets = server_resource.orb_config.policy_set; + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong np = sets[i].policies.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + CORBA::ULong index = 0; + CORBA::ULong array_index = np; + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + CORBA::Policy_var temp_policy = + this->create_single_policy (sets[i].policies[pc]); + + if (CORBA::is_nil (temp_policy.in ())) + { + array_index = array_index - 1; + policy_list->length (array_index); + } + else + { + policy_list[index] = temp_policy; + index = index + 1; + } + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (array_index != 0) + { + if (this->policy_map_.bind (sets[i].Id.in (), + policy_list) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding Policy_Set with name: %C\n", + sets[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "Basic_Config_Manager::init_resource" + " added policy set : %C with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "Basic_Config_Manager::init_resource" + " added policy set : %C with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + } + + bool + Basic_Config_Manager::policy_exists (const char *name) + { + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in " + "Basic_Config_Manager::policy_exists\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + return false; + } + + return true; + } + + CORBA::PolicyList * + Basic_Config_Manager::find_policies_by_name (const char *name) + { + if (name == 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Invalid name string found in find_policies_by_name\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + CORBA::PolicyList_var retv; + + if (this->policy_map_.find (name, entry) != 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Unable to find a PolicyList named %C\n", + name)); + retv = 0; + } + else + { + retv = new CORBA::PolicyList (entry->int_id_.in ()); + } + return retv._retn (); + } + + CORBA::Policy_ptr + Basic_Config_Manager::create_single_policy + (const PolicyDef &policy_def) + { + CORBA::Policy_var retv; + + switch (policy_def._d ()) + { + case TAO::NETWORK_PRIORITY_TYPE: + { + const NWPriorityModelPolicyDef &nw_tmp + = policy_def.NWPriorityModelDef (); + retv = this->orb_->_create_policy (TAO::NETWORK_PRIORITY_TYPE); + + TAO::NetworkPriorityPolicy_var nw_priority = + TAO::NetworkPriorityPolicy::_narrow (retv.in ()); + + nw_priority->network_priority_model ( + (TAO::NetworkPriorityModel) nw_tmp.nw_priority_model); + + nw_priority->request_diffserv_codepoint ( + (TAO::DiffservCodepoint) nw_tmp.request_dscp); + + nw_priority->reply_diffserv_codepoint ( + (TAO::DiffservCodepoint) nw_tmp.reply_dscp); + + retv = nw_priority._retn (); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "NAConfigManager::Create NetworkPriority policy: %d\n", + nw_tmp.nw_priority_model)); + } + break; + + case TAO::CLIENT_NETWORK_PRIORITY_TYPE: + { + const CNWPriorityModelPolicyDef &cnw_tmp + = policy_def.CNWPriorityModelDef (); + retv = this->orb_->_create_policy (TAO::CLIENT_NETWORK_PRIORITY_TYPE); + + TAO::NetworkPriorityPolicy_var cnw_priority = + TAO::NetworkPriorityPolicy::_narrow (retv.in ()); + + cnw_priority->request_diffserv_codepoint ( + (TAO::DiffservCodepoint) cnw_tmp.request_dscp); + + cnw_priority->reply_diffserv_codepoint ( + (TAO::DiffservCodepoint) cnw_tmp.reply_dscp); + + retv = cnw_priority._retn (); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "NAConfigManager::Create NetworkPriority policy\n")); + } + break; + + default: + retv = 0; + } + + return retv._retn (); + } + + } +} + +using CIAO::Deployment::Config_Manager; +using CIAO::Deployment::Basic_Config_Manager; + +extern "C" Basic_Config_Manager_Export Config_Manager *create_basic_config_manager (void); + +extern "C" +{ + Config_Manager * + create_basic_config_manager (void) + { + Basic_Config_Manager *config; + ACE_NEW_RETURN (config, Basic_Config_Manager, 0); + return config; + } +} + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.h b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.h new file mode 100755 index 00000000000..e599cc7eb04 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.h @@ -0,0 +1,79 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Basic_Config_Manager.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_NACONFIG_MANAGER_H +#define CIAO_NACONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/SString.h" +#include "ace/Hash_Map_Manager_T.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +#include "Config_Manager.h" +#include "Basic_Config_Manager_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + */ + class Basic_Config_Manager_Export Basic_Config_Manager + : public Config_Manager + { + public: + virtual ~Basic_Config_Manager (void) {} + + virtual int pre_orb_initialize (void); + + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + virtual void init (CORBA::ORB_ptr orb); + + /// Initializing the NAResource_Config_Manager + virtual void init_resources (const ServerResource &info); + + /// Query a policy set by name + virtual CORBA::PolicyList *find_policies_by_name (const char *name); + + virtual bool policy_exists (const char *name); + + private: + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + CORBA::Policy_ptr create_single_policy + (const PolicyDef &policy_def); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + CORBA::PolicyList_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; + }; +} + } + +#include /**/ "ace/post.h" +#endif /* CIAO_NACONFIG_MANAGER_H */ + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.inl b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.inl new file mode 100755 index 00000000000..67203a91ff8 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager.inl @@ -0,0 +1,12 @@ +// $Id$ + +ACE_INLINE +CIAO::NAResource_Config_Manager::NAResource_Config_Manager () +{ +} + +ACE_INLINE +CIAO::NAResource_Config_Manager::~NAResource_Config_Manager () +{ +} + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager_export.h b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager_export.h new file mode 100644 index 00000000000..51cb9778168 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Config_Manager_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Basic_Config_Manager +// ------------------------------ +#ifndef BASIC_CONFIG_MANAGER_EXPORT_H +#define BASIC_CONFIG_MANAGER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BASIC_CONFIG_MANAGER_HAS_DLL) +# define BASIC_CONFIG_MANAGER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BASIC_CONFIG_MANAGER_HAS_DLL */ + +#if !defined (BASIC_CONFIG_MANAGER_HAS_DLL) +# define BASIC_CONFIG_MANAGER_HAS_DLL 1 +#endif /* ! BASIC_CONFIG_MANAGER_HAS_DLL */ + +#if defined (BASIC_CONFIG_MANAGER_HAS_DLL) && (BASIC_CONFIG_MANAGER_HAS_DLL == 1) +# if defined (BASIC_CONFIG_MANAGER_BUILD_DLL) +# define Basic_Config_Manager_Export ACE_Proper_Export_Flag +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BASIC_CONFIG_MANAGER_BUILD_DLL */ +# define Basic_Config_Manager_Export ACE_Proper_Import_Flag +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BASIC_CONFIG_MANAGER_BUILD_DLL */ +#else /* BASIC_CONFIG_MANAGER_HAS_DLL == 1 */ +# define Basic_Config_Manager_Export +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BASIC_CONFIG_MANAGER_HAS_DLL == 1 */ + +// Set BASIC_CONFIG_MANAGER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BASIC_CONFIG_MANAGER_NTRACE) +# if (ACE_NTRACE == 1) +# define BASIC_CONFIG_MANAGER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BASIC_CONFIG_MANAGER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BASIC_CONFIG_MANAGER_NTRACE */ + +#if (BASIC_CONFIG_MANAGER_NTRACE == 1) +# define BASIC_CONFIG_MANAGER_TRACE(X) +#else /* (BASIC_CONFIG_MANAGER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BASIC_CONFIG_MANAGER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BASIC_CONFIG_MANAGER_NTRACE == 1) */ + +#endif /* BASIC_CONFIG_MANAGER_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Configurator_export.h b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Configurator_export.h new file mode 100644 index 00000000000..098b4c87f0d --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Basic_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Basic_Configurator +// ------------------------------ +#ifndef BASIC_CONFIGURATOR_EXPORT_H +#define BASIC_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BASIC_CONFIGURATOR_HAS_DLL) +# define BASIC_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BASIC_CONFIGURATOR_HAS_DLL */ + +#if !defined (BASIC_CONFIGURATOR_HAS_DLL) +# define BASIC_CONFIGURATOR_HAS_DLL 1 +#endif /* ! BASIC_CONFIGURATOR_HAS_DLL */ + +#if defined (BASIC_CONFIGURATOR_HAS_DLL) && (BASIC_CONFIGURATOR_HAS_DLL == 1) +# if defined (BASIC_CONFIGURATOR_BUILD_DLL) +# define Basic_Configurator_Export ACE_Proper_Export_Flag +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BASIC_CONFIGURATOR_BUILD_DLL */ +# define Basic_Configurator_Export ACE_Proper_Import_Flag +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BASIC_CONFIGURATOR_BUILD_DLL */ +#else /* BASIC_CONFIGURATOR_HAS_DLL == 1 */ +# define Basic_Configurator_Export +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BASIC_CONFIGURATOR_HAS_DLL == 1 */ + +// Set BASIC_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BASIC_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define BASIC_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BASIC_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BASIC_CONFIGURATOR_NTRACE */ + +#if (BASIC_CONFIGURATOR_NTRACE == 1) +# define BASIC_CONFIGURATOR_TRACE(X) +#else /* (BASIC_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BASIC_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BASIC_CONFIGURATOR_NTRACE == 1) */ + +#endif /* BASIC_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/ComponentServer_Configurator_export.h b/modules/CIAO/ciao/ComponentServer/Configurators/ComponentServer_Configurator_export.h new file mode 100644 index 00000000000..9793cd0ed44 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/ComponentServer_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ComponentServer_Configurator +// ------------------------------ +#ifndef COMPONENTSERVER_CONFIGURATOR_EXPORT_H +#define COMPONENTSERVER_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) +# define COMPONENTSERVER_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && COMPONENTSERVER_CONFIGURATOR_HAS_DLL */ + +#if !defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) +# define COMPONENTSERVER_CONFIGURATOR_HAS_DLL 1 +#endif /* ! COMPONENTSERVER_CONFIGURATOR_HAS_DLL */ + +#if defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) && (COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1) +# if defined (COMPONENTSERVER_CONFIGURATOR_BUILD_DLL) +# define ComponentServer_Configurator_Export ACE_Proper_Export_Flag +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* COMPONENTSERVER_CONFIGURATOR_BUILD_DLL */ +# define ComponentServer_Configurator_Export ACE_Proper_Import_Flag +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* COMPONENTSERVER_CONFIGURATOR_BUILD_DLL */ +#else /* COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1 */ +# define ComponentServer_Configurator_Export +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1 */ + +// Set COMPONENTSERVER_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (COMPONENTSERVER_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define COMPONENTSERVER_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define COMPONENTSERVER_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !COMPONENTSERVER_CONFIGURATOR_NTRACE */ + +#if (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) +# define COMPONENTSERVER_CONFIGURATOR_TRACE(X) +#else /* (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define COMPONENTSERVER_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) */ + +#endif /* COMPONENTSERVER_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Config_Manager.cpp b/modules/CIAO/ciao/ComponentServer/Configurators/Config_Manager.cpp new file mode 100644 index 00000000000..bfab13b286d --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Config_Manager.cpp @@ -0,0 +1,12 @@ +// $Id$ +#include "Config_Manager.h" + +namespace CIAO +{ + namespace Deployment + { + Config_Manager::~Config_Manager (void) + { + } + } +} diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Config_Manager.h b/modules/CIAO/ciao/ComponentServer/Configurators/Config_Manager.h new file mode 100755 index 00000000000..2ce46aa980f --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Config_Manager.h @@ -0,0 +1,53 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Config_Manager.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_CONFIG_MANAGER_H +#define CIAO_CONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +namespace CIAO +{ + namespace Deployment + { + /** + */ + class Config_Manager + { + public: + virtual ~Config_Manager (void) {}; + + virtual int pre_orb_initialize (void) = 0; + + virtual int post_orb_initialize (CORBA::ORB_ptr o) = 0; + + virtual void init_resources (const ServerResource &info) = 0; + + virtual void init (CORBA::ORB_ptr orb) = 0; + + virtual CORBA::PolicyList *find_policies_by_name (const char *name)= 0; + + virtual bool policy_exists (const char *name) = 0; + }; + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_MANAGER_H */ + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Configurators.mpc b/modules/CIAO/ciao/ComponentServer/Configurators/Configurators.mpc new file mode 100644 index 00000000000..de17a603bc6 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Configurators.mpc @@ -0,0 +1,22 @@ +// $Id$ +project(CIAO_Basic_Configurator) : ccm_stub, ciao_componentserver_stub, ciao_lib { + dynamicflags += COMPONENTSERVER_CONFIGURATOR_BUILD_DLL + Source_Files { + Server_Configurator.cpp + } + Header_Files { + Server_Configurator.h + } +} + +project(CIAO_Basic_Config_Manager) : ciao_lib, ciao_config_manager, ciao_componentserver_stub, \ + diffservpolicy { + dynamicflags += BASIC_CONFIG_MANAGER_BUILD_DLL + Source_Files { + Basic_Config_Manager.cpp + } + Header_Files { + Basic_Config_Manager.h + } +} + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/NA_Configurator_Export.h b/modules/CIAO/ciao/ComponentServer/Configurators/NA_Configurator_Export.h new file mode 100755 index 00000000000..2e30fd59cc1 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/NA_Configurator_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_NA_Configurator +// ------------------------------ +#ifndef CIAO_NA_CONFIGURATOR_EXPORT_H +#define CIAO_NA_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_NA_CONFIGURATOR_HAS_DLL) +# define CIAO_NA_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_NA_CONFIGURATOR_HAS_DLL */ + +#if !defined (CIAO_NA_CONFIGURATOR_HAS_DLL) +# define CIAO_NA_CONFIGURATOR_HAS_DLL 1 +#endif /* ! CIAO_NA_CONFIGURATOR_HAS_DLL */ + +#if defined (CIAO_NA_CONFIGURATOR_HAS_DLL) && (CIAO_NA_CONFIGURATOR_HAS_DLL == 1) +# if defined (CIAO_NA_CONFIGURATOR_BUILD_DLL) +# define CIAO_NA_Configurator_Export ACE_Proper_Export_Flag +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_NA_CONFIGURATOR_BUILD_DLL */ +# define CIAO_NA_Configurator_Export ACE_Proper_Import_Flag +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_NA_CONFIGURATOR_BUILD_DLL */ +#else /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */ +# define CIAO_NA_Configurator_Export +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */ + +// Set CIAO_NA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_NA_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_NA_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_NA_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_NA_CONFIGURATOR_NTRACE */ + +#if (CIAO_NA_CONFIGURATOR_NTRACE == 1) +# define CIAO_NA_CONFIGURATOR_TRACE(X) +#else /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_NA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */ + +#endif /* CIAO_NA_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.cpp b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.cpp new file mode 100644 index 00000000000..e4c377e436a --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "NoOp_Configurator.h" + +namespace CIAO +{ + namespace Deployment + { + + NoOp_Configurator::~NoOp_Configurator (void) + { + // Not much to do. + } + + int + NoOp_Configurator::pre_orb_initialize () + { + return 0; + } + + int + NoOp_Configurator::post_orb_initialize (CORBA::ORB_ptr) + { + return 0; + } + + int + NoOp_Configurator::init_resource_manager + (const ::Components::ConfigValues & /*properties*/) + { + // @@ Currently do thing. We should go over the resource struct in + // the future and throw exceptions if there are + // un-recognizable/supported stuff in it. + return 0; + } + + CORBA::PolicyList * + NoOp_Configurator::find_container_policies + (const ::Components::ConfigValues & /*properties*/) + { + // Not much to do. + + return 0; + } + } +} diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.h b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.h new file mode 100644 index 00000000000..d84715d5bca --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.h @@ -0,0 +1,66 @@ +/** $Id$ + * @file NoOp_Configurator.h + * @brief This file contains the noop configurator. + */ + +#ifndef NOOP_CONFIGURATOR_H +#define NOOP_CONFIGURATOR_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include <ccm/CCM_StandardConfiguratorC.h> + +#include "ciao/ComponentServer/Configurators/Server_Configurator.h" +#include "NoOp_Configurator_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @class NoOP_Configurator + * + * @brief The NoOp_Configurator doesn't do anything. + */ + class NoOp_Configurator_Export NoOp_Configurator + : public ComponentServer_Configurator + { + public: + /// Default destructor. + virtual ~NoOp_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "post_orb_initialize" is called after NodeApplication + * get a hold at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by NodeApplication when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Components::ConfigValues &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Components::ConfigValues &properties); + }; + } +} + +#include /**/ "ace/post.h" +#endif /* NOOP_CONFIGURATOR_H */ diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.mpc b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.mpc new file mode 100644 index 00000000000..fd7e9c06285 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator.mpc @@ -0,0 +1,14 @@ +// $Id$ +project(CIAO_NoOp_Configurator) : ccm_stub, ciao_componentserver_stub, ciao_lib { + after += CIAO_Basic_Configurator + libs += CIAO_Basic_Configurator + dynamicflags = NOOP_CONFIGURATOR_BUILD_DLL + Source_Files { + NoOp_Configurator.cpp + } + Header_Files { + NoOp_Configurator.h + } +} + + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator_export.h b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator_export.h new file mode 100644 index 00000000000..b6b3a9ec841 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/NoOp/NoOp_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl NoOp_Configurator +// ------------------------------ +#ifndef NOOP_CONFIGURATOR_EXPORT_H +#define NOOP_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (NOOP_CONFIGURATOR_HAS_DLL) +# define NOOP_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && NOOP_CONFIGURATOR_HAS_DLL */ + +#if !defined (NOOP_CONFIGURATOR_HAS_DLL) +# define NOOP_CONFIGURATOR_HAS_DLL 1 +#endif /* ! NOOP_CONFIGURATOR_HAS_DLL */ + +#if defined (NOOP_CONFIGURATOR_HAS_DLL) && (NOOP_CONFIGURATOR_HAS_DLL == 1) +# if defined (NOOP_CONFIGURATOR_BUILD_DLL) +# define NoOp_Configurator_Export ACE_Proper_Export_Flag +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* NOOP_CONFIGURATOR_BUILD_DLL */ +# define NoOp_Configurator_Export ACE_Proper_Import_Flag +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* NOOP_CONFIGURATOR_BUILD_DLL */ +#else /* NOOP_CONFIGURATOR_HAS_DLL == 1 */ +# define NoOp_Configurator_Export +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* NOOP_CONFIGURATOR_HAS_DLL == 1 */ + +// Set NOOP_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (NOOP_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define NOOP_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define NOOP_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !NOOP_CONFIGURATOR_NTRACE */ + +#if (NOOP_CONFIGURATOR_NTRACE == 1) +# define NOOP_CONFIGURATOR_TRACE(X) +#else /* (NOOP_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define NOOP_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (NOOP_CONFIGURATOR_NTRACE == 1) */ + +#endif /* NOOP_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.cpp b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.cpp new file mode 100644 index 00000000000..6619a445db1 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.cpp @@ -0,0 +1,513 @@ +// $Id$ + +#include "RTConfig_Manager.h" +#include "ciao/CIAO_common.h" +#include "ace/SString.h" + +#if !defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +void +CIAO::Deployment::RTResource_Config_Manager::init (CORBA::ORB_ptr orb) +{ + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB"); + this->rtorb_ = RTCORBA::RTORB::_narrow (object.in ()); +} + +int +CIAO::Deployment::RTResource_Config_Manager::pre_orb_initialize (void) +{ + return 0; +} + +int +CIAO::Deployment::RTResource_Config_Manager::post_orb_initialize (CORBA::ORB_ptr) +{ + return 0; +} + +void +CIAO::Deployment::RTResource_Config_Manager::print_resources +(const ServerResource &server_resource) +{ + const ORBResource &orb_resource + = server_resource.orb_config.orb_resources[0]; + + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < orb_resource.threadpool_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource threadpool: %C\n" + "\tStack size: %d\n" + "\tStatic: %d\n" + "\tDynamic %d\n" + "\tDefault Prio: %d\n" + "\tBuffering %C\n" + "\tMax Buffered: %d\n" + "\tBuffer Size %d\n", + orb_resource.threadpool_list[i].Id.in (), + orb_resource.threadpool_list[i].stacksize, + orb_resource.threadpool_list[i].static_threads, + orb_resource.threadpool_list[i].dynamic_threads, + orb_resource.threadpool_list[i].default_priority, + (orb_resource.threadpool_list[i].allow_request_buffering ? "Y" : "N"), + orb_resource.threadpool_list[i].max_buffered_requests, + orb_resource.threadpool_list[i].max_request_buffer_size)); + } + + for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource threadpool_with %d, lanes: %C\n", + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (), + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + + for (CORBA::ULong l = 0; + l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (); + ++l) + { + CIAO_DEBUG ((LM_DEBUG, + "\tLane %d:\n" + "\t\tPriority: %d\n" + "\t\tStatic: %d\n" + "\t\tDynamic: %d\n", + l, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads)); + } + CIAO_DEBUG ((LM_DEBUG, + "\tStack size: %d\n" + "\tBorrowing: %C\n" + "\tBuffering %C\n" + "\tMax Buffered: %d\n" + "\tBuffer Size %d\n", + orb_resource.threadpool_with_lanes_list[i].stacksize, + (orb_resource.threadpool_with_lanes_list[i].allow_borrowing ? "Y" : "N"), + (orb_resource.threadpool_with_lanes_list[i].allow_request_buffering ? "Y" : "N"), + orb_resource.threadpool_with_lanes_list[i].max_buffered_requests, + orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size)); + } + + for (i = 0; i < orb_resource.connection_bands_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource connection %d bands: %C\n", + orb_resource.connection_bands_list[i].bands.length (), + orb_resource.connection_bands_list[i].Id.in ())); + + for (CORBA::ULong l = 0; + l < orb_resource.connection_bands_list[i].bands.length (); + ++l) + { + CIAO_DEBUG ((LM_DEBUG, + "\tBand %d Prio: %d -- %d\n", + l, + orb_resource.connection_bands_list[i].bands[l].low, + orb_resource.connection_bands_list[i].bands[l].high)); + } + } +} + +void +CIAO::Deployment::RTResource_Config_Manager::init_resources +(const ServerResource &server_resource) +{ + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource.\n")); + + if (CORBA::is_nil (this->rtorb_.in())) + { + CIAO_ERROR ((LM_ERROR, + "RTResource_Config_Manager has not been properly initialized.\n")); + throw CORBA::INTERNAL (); + } + + this->print_resources (server_resource); + // return; + + const ORBResource &orb_resource + = server_resource.orb_config.orb_resources[0]; + + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < orb_resource.threadpool_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource threadpool: %C\n", + orb_resource.threadpool_list[i].Id.in ())); + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool + (orb_resource.threadpool_list[i].stacksize, + orb_resource.threadpool_list[i].static_threads, + orb_resource.threadpool_list[i].dynamic_threads, + orb_resource.threadpool_list[i].default_priority, + orb_resource.threadpool_list[i].allow_request_buffering, + orb_resource.threadpool_list[i].max_buffered_requests, + orb_resource.threadpool_list[i].max_request_buffer_size); + // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + if (this->threadpool_map_.bind (orb_resource.threadpool_list[i].Id.in (), + thr_id) != 0) + { + CIAO_ERROR ((LM_ERROR, "Error binding thread pool Id: %C to map when initializing RTNodeApplication resources.\n", orb_resource.threadpool_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added thread pool: %C\n", + orb_resource.threadpool_list[i].Id.in ())); + } + } + + for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource threadpool_with %d, lanes: %C\n", + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (), + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + + // Duplicate RTCORBA lanes + RTCORBA::ThreadpoolLanes lanes + (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ()); + lanes.length (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ()); + + for (CORBA::ULong l = 0; + l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (); + ++l) + { + lanes[l].lane_priority + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority; + lanes[l].static_threads + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads; + lanes[l].dynamic_threads + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads; + } + + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool_with_lanes + (orb_resource.threadpool_with_lanes_list[i].stacksize, + lanes, + orb_resource.threadpool_with_lanes_list[i].allow_borrowing, + orb_resource.threadpool_with_lanes_list[i].allow_request_buffering, + orb_resource.threadpool_with_lanes_list[i].max_buffered_requests, + orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size); + // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + + if (this->threadpool_map_.bind (orb_resource.threadpool_with_lanes_list[i].Id.in (), + thr_id) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding thread pool name: %C to map when " + "initializing RTNodeApplication resources.\n", + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added thread pool with lanes: %C\n", + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + } + } + + for (i = 0; i < orb_resource.connection_bands_list.length (); ++i) + { + RTCORBA::PriorityBands + safebands(orb_resource.connection_bands_list[i].bands.length ()); + safebands.length (orb_resource.connection_bands_list[i].bands.length ()); + + for (CORBA::ULong l = 0; + l < orb_resource.connection_bands_list[i].bands.length (); + ++l) + { + safebands[l].low = orb_resource.connection_bands_list[i].bands[l].low; + safebands[l].high = orb_resource.connection_bands_list[i].bands[l].high; + } + + if (this->priority_bands_map_.bind (orb_resource.connection_bands_list[i].Id.in (), + safebands) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding priority bands name: %C to map " + "when initializing RTNodeApplication resources.\n", + orb_resource.connection_bands_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added connection bands: %C\n", + orb_resource.connection_bands_list[i].Id.in ())); + } + } + + // now initialize the policy set part of it. + // server_resource.orb_config.policy_set + const PolicySets &sets = server_resource.orb_config.policy_set; + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong const np = sets[i].policies.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + CORBA::ULong index = 0; + CORBA::ULong array_index = np; + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + CORBA::Policy_var temp_policy = + this->create_single_policy (sets[i].policies[pc]); + if (CORBA::is_nil (temp_policy.in ())) + { + array_index = array_index - 1; + policy_list->length (array_index); + } + else + { + policy_list[index] = CORBA::Policy::_duplicate (temp_policy.in ()); + index = index + 1; + } + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (array_index != 0) + { + if (this->policy_map_.bind (sets[i].Id.in (), + policy_list._retn ()) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding Policy_Set with name: %C\n", + sets[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource " + "added policy set: %C with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource " + "added policy set: %C with %d policies\n", + sets[i].Id.in (), array_index)); + } + } +} + +void +CIAO::Deployment::RTResource_Config_Manager::fini () +{ + TP_MAP::ITERATOR iter = this->threadpool_map_.begin (); + TP_MAP::ITERATOR end = this->threadpool_map_.end (); + + for (; iter != end; ++iter) + { + this->rtorb_->destroy_threadpool ((*iter).int_id_); + } + +} + +RTCORBA::ThreadpoolId +CIAO::Deployment::RTResource_Config_Manager::find_threadpool_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_threadpool_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + + RTCORBA::ThreadpoolId ret_id = 0; // return id + + if (this->threadpool_map_.find (name, ret_id) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a threadpool named %C\n", + name)); + throw CORBA::INTERNAL (); + } + + return ret_id; +} + +RTCORBA::PriorityBands * +CIAO::Deployment::RTResource_Config_Manager::find_priority_bands_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_priority_bands_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + PB_MAP::ENTRY *entry = 0; + + if (this->priority_bands_map_.find (name, entry) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a connection bands named %C\n", + name)); + throw CORBA::INTERNAL (); + } + + RTCORBA::PriorityBands_var retv = new RTCORBA::PriorityBands; + (*retv.ptr ()) = (*entry->int_id_.ptr ()); + return retv._retn (); +} + +bool +CIAO::Deployment::RTResource_Config_Manager::policy_exists (const char *name) +{ + if (name == 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Invalid name string found in " + "CIAO::Deployment::NAResource_Config_Manager::policy_exists\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + return false; + } + + return true; +} + +CORBA::PolicyList * +CIAO::Deployment::RTResource_Config_Manager::find_policies_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_policies_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + + CIAO_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name: %C\n", + name)); + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a PolicyList named %C\n", + name)); + throw CORBA::INTERNAL (); + } + + // duplicate the sequence PolicyList. + CORBA::PolicyList_var retv = + new CORBA::PolicyList (entry->int_id_.in ()); + + CIAO_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name ok.\n")); + + return retv._retn (); +} + +CORBA::Policy_ptr +CIAO::Deployment::RTResource_Config_Manager::create_single_policy +(const PolicyDef &policy_def) +{ + // if (CIAO::Deployment::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::create_single_policy: %d\n", + policy_def._d ())); + + CORBA::Policy_var retv; + + switch (policy_def._d ()) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE: + { + const PriorityModelPolicyDef &tmp + = policy_def.PriorityModelDef (); + + retv = this->rtorb_->create_priority_model_policy ((RTCORBA::PriorityModel) tmp.priority_model, + tmp.server_priority); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "Create PriorityModel policy: %d - %d\n", + tmp.priority_model, tmp.server_priority)); + } + break; + + case RTCORBA::THREADPOOL_POLICY_TYPE: + { + RTCORBA::ThreadpoolId tpid = + this->find_threadpool_by_name (policy_def.ThreadpoolDef().Id.in ()); + + retv = this->rtorb_->create_threadpool_policy (tpid); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "Create Threadpool policy: %C, TPid: %d\n", + policy_def.ThreadpoolDef().Id.in (), tpid)); + } + break; + + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE: + { + RTCORBA::PriorityBands_var bands = + this->find_priority_bands_by_name (policy_def.PriorityBandedConnectionDef().Id.in ()); + + retv = + this->rtorb_->create_priority_banded_connection_policy (bands.in ()); + + if (! CORBA::is_nil (retv.in ())) + { + CIAO_DEBUG ((LM_DEBUG, + "Created Banded Connection policy: %C\n", + policy_def.PriorityBandedConnectionDef().Id.in ())); + } + } + break; + + default: + retv = 0; + } + + return retv._retn (); +} + +CIAO::Deployment::RTResource_Config_Manager::~RTResource_Config_Manager () +{ + this->fini (); +} + +extern "C" CIAO_RTNA_Configurator_Export CIAO::Deployment::Config_Manager +*create_rt_config_manager (void); + +CIAO::Deployment::Config_Manager * +create_rt_config_manager (void) +{ + CIAO::Deployment::RTResource_Config_Manager *config; + ACE_NEW_RETURN (config, CIAO::Deployment::RTResource_Config_Manager, 0); + return config; +} diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.h b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.h new file mode 100644 index 00000000000..071536a5fc6 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.h @@ -0,0 +1,138 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RTConfig_Manager.h + * + * $Id$ + * + * This file contains classes that manage name to configuration + * mapping info in a RTComponentServer. + * + * @author Nanbor Wang <nanbor@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef CIAO_RTCONFIG_MANAGER_H +#define CIAO_RTCONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/SString.h" +#include "ace/Hash_Map_Manager_T.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +#include "ciao/ComponentServer/Configurators/Config_Manager.h" +#include "RTNA_Configurator_Export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @brief RTResource_Config_Manager maintains a collection of + * RTCORBA related resources. + * + * This class is responsible to create and manage a list of RTCORBA + * related resources that are global to an RT ComponentServer. The + * information required to create and configure these resources are + * passed in via the @a info argument in the @c init method. These + * resources are identified by names and can be used to associate + * these resources with related RTPolicies. These resources are + * destoryed along with this class. + * + * Currently, the only resources supported (and managed) by this + * class are Threadpool and Threadpool_with_Lanes. + */ + class RTResource_Config_Manager : public Config_Manager + { + public: + RTResource_Config_Manager (void); + ~RTResource_Config_Manager (void); + + virtual void init (CORBA::ORB_ptr orb); + + virtual int pre_orb_initialize (void); + + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /// Initializing the RTResource_Config_Manager + virtual void init_resources (const ServerResource &info); + + /// Finalizing the RTResource_Config_Manager and the resources it + /// manages. + void fini (); + + /// Query a policy set by name + virtual CORBA::PolicyList *find_policies_by_name (const char *name); + + virtual bool policy_exists (const char *name); + + protected: + void print_resources (const ServerResource &info); + + /// Query a thread pool by name. + RTCORBA::ThreadpoolId find_threadpool_by_name (const char *name); + + + /// Query a priority bands info by name. + RTCORBA::PriorityBands *find_priority_bands_by_name (const char *name); + + private: + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + // Cached an RTORB reference. + RTCORBA::RTORB_var rtorb_; + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + RTCORBA::ThreadpoolId, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> TP_MAP; + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + RTCORBA::PriorityBands_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> PB_MAP; + + /// Internal TP name to id map. + TP_MAP threadpool_map_; + + /// Internal PB name to priority bands map. + PB_MAP priority_bands_map_; + + /// create a single policy + CORBA::Policy_ptr create_single_policy + (const PolicyDef &policy_def); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + CORBA::PolicyList_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; +}; +} +} + +#if defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* CIAO_RTCONFIG_MANAGER_H */ + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.inl b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.inl new file mode 100644 index 00000000000..08aaef9f6ad --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTConfig_Manager.inl @@ -0,0 +1,8 @@ +// $Id$ + + +ACE_INLINE +CIAO::Deployment::RTResource_Config_Manager::RTResource_Config_Manager () +{ +} + diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTNA_Configurator_Export.h b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTNA_Configurator_Export.h new file mode 100644 index 00000000000..689a871c7e5 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/RT/RTNA_Configurator_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_RTNA_Configurator +// ------------------------------ +#ifndef CIAO_RTNA_CONFIGURATOR_EXPORT_H +#define CIAO_RTNA_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) +# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_RTNA_CONFIGURATOR_HAS_DLL */ + +#if !defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) +# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 1 +#endif /* ! CIAO_RTNA_CONFIGURATOR_HAS_DLL */ + +#if defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) && (CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1) +# if defined (CIAO_RTNA_CONFIGURATOR_BUILD_DLL) +# define CIAO_RTNA_Configurator_Export ACE_Proper_Export_Flag +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */ +# define CIAO_RTNA_Configurator_Export ACE_Proper_Import_Flag +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */ +#else /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */ +# define CIAO_RTNA_Configurator_Export +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */ + +// Set CIAO_RTNA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_RTNA_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_RTNA_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_RTNA_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_RTNA_CONFIGURATOR_NTRACE */ + +#if (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) +# define CIAO_RTNA_CONFIGURATOR_TRACE(X) +#else /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_RTNA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */ + +#endif /* CIAO_RTNA_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/RTNodeApp_Configurator.cpp b/modules/CIAO/ciao/ComponentServer/Configurators/RTNodeApp_Configurator.cpp new file mode 100644 index 00000000000..91e8a3b3f36 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/RTNodeApp_Configurator.cpp @@ -0,0 +1,108 @@ +// $Id$ + +#include "RTNodeApp_Configurator.h" +#include "DAnCE/Deployment/CIAO_ServerResourcesC.h" +#include "tao/RTPortableServer/RTPortableServer.h" + +CIAO::RTNodeApp_Configurator::~RTNodeApp_Configurator () +{ +} + +int +CIAO::RTNodeApp_Configurator::pre_orb_initialize () +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::pre_orb_init\n")); + + return 0; +} + +int +CIAO::RTNodeApp_Configurator::post_orb_initialize (CORBA::ORB_ptr o) +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::post_orb_init\n")); + + this->orb_ = CORBA::ORB::_duplicate (o); + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RTORB"); + + this->rtorb_ = + RTCORBA::RTORB::_narrow (object.in ()); + + this->config_manager_.init (this->rtorb_.in ()); + + return 0; +} + +int +CIAO::RTNodeApp_Configurator::init_resource_manager +(const ::Deployment::Properties &properties) +{ + + // if (CIAO::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager\n")); + // @@ Should we cache the properties that we consumed here? + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + // if (CIAO::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager processing property: %C\n", + properties[i].name.in ())); + + if (ACE_OS::strcmp ("CIAOServerResources", properties[i].name.in ()) == 0) + { + const CIAO::DAnCE::ServerResource *svr_resource; + if (properties[i].value >>= svr_resource) + { + this->config_manager_.init_resources (*svr_resource); + // Now we have the information to initialize the manager. + } + else + CIAO_ERROR_RETURN ((LM_ERROR, + "ERROR: RTNodeApp_Configurator::init_resource_manager unable to extract CIAOServerResources\n"), -1); + } + + // Ignore other stuff + } + + return 0; +} + +CORBA::PolicyList * +CIAO::RTNodeApp_Configurator::find_container_policies +(const ::Deployment::Properties &properties) +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies\n")); + // @@ Should we cache the properties that we consumed here? + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies processing property: %C\n", + properties[i].name.in ())); + + if (ACE_OS::strcmp ("ContainerPolicySet", properties[i].name) == 0) + { + const char *policy_name = 0; + if (properties[i].value >>= policy_name) + { + return this->config_manager_.find_policies_by_name (policy_name); + } + else + CIAO_ERROR_RETURN ((LM_ERROR, + "ERROR: RTNodeApp_Configurator::find_container_policies unable to extract ContainerPolicySet\n"), 0); + } + } + + return 0; +} + + +extern "C" CIAO_RTNA_Configurator_Export CIAO::NodeApp_Configurator *create_nodeapp_configurator (void); + +CIAO::NodeApp_Configurator * +create_nodeapp_configurator (void) +{ + CIAO::RTNodeApp_Configurator *config = 0; + ACE_NEW_RETURN (config, CIAO::RTNodeApp_Configurator, 0); + return config; +} diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/RTNodeApp_Configurator.h b/modules/CIAO/ciao/ComponentServer/Configurators/RTNodeApp_Configurator.h new file mode 100644 index 00000000000..fc2388b6aff --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/RTNodeApp_Configurator.h @@ -0,0 +1,78 @@ +// $Id$ +/**======================================================== + * + * @file RTNodeApp_Configurator.h + * + * @Brief This file contains the implementation of + * the RTNodeApp_Configurator, a concrete NodeApp_Configurator for + * setting up real-time support for NodeApplication. + * + * + * @author Nanbor Wang <nanbor@exothermic.txcorp.com> + *========================================================*/ + +#ifndef RTNODEAPP_CONFIGURATOR_H +#define RTNODEAPP_CONFIGURATOR_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "NodeApp_Configurator.h" +#include "RTNA_Configurator_Export.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "RTConfig_Manager.h" + +namespace CIAO +{ + /** + * @class RTNodeApp_Configurator + * + * @brief This class implements a concrete NodeApp_Configurator for + * setting up the NodeApplication process for RT support. + **/ + class CIAO_RTNA_Configurator_Export RTNodeApp_Configurator : + public NodeApp_Configurator + { + public: + /// Default destructor. + virtual ~RTNodeApp_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "initialize" is called after NodeApplication get a hold + * at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by NodeApplication when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Deployment::Properties &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Deployment::Properties &properties); + + protected: + CORBA::ORB_var orb_; + + RTCORBA::RTORB_var rtorb_; + + RTResource_Config_Manager config_manager_; + }; +} + +#include /**/ "ace/post.h" +#endif /* RTNODEAPP_CONFIGURATOR_H */ diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Server_Configurator.cpp b/modules/CIAO/ciao/ComponentServer/Configurators/Server_Configurator.cpp new file mode 100755 index 00000000000..a3138f1a038 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Server_Configurator.cpp @@ -0,0 +1,334 @@ +// $Id$ + +#include "Server_Configurator.h" +#include "ace/Log_Msg.h" +#include "ciao/CIAO_common.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +namespace CIAO +{ + namespace Deployment + { + + ComponentServer_Configurator::ComponentServer_Configurator (bool rt) + : rt_support_ (rt) + { + } + + ComponentServer_Configurator::~ComponentServer_Configurator (void) + { + // Not much to do. + } + + void + ComponentServer_Configurator::set_rt_support (void) + { + this->rt_support_ = true; + } + + bool + ComponentServer_Configurator::rt_support (void) + { + return this->rt_support_; + } + + bool + ComponentServer_Configurator::create_config_managers (void) + { + typedef CIAO::Deployment::Config_Manager * (*na_intelligent_designer)(void); + typedef CIAO::Deployment::Config_Manager * (*rtna_intelligent_designer)(void); + CIAO::Deployment::Config_Manager* ptr = 0; + CIAO::Deployment::Config_Manager* rt_ptr = 0; + + int retval = this->config_dll_.open (/*ACE_DLL_PREFIX*/ ACE_TEXT ("CIAO_Basic_Config_Manager"), + ACE_DEFAULT_SHLIB_MODE, + 0); + + if (0 != retval) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator - Error loading CIAO_Basic_Config_manager DLL: %p\n", + "dll.open"), + false); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_basic_config_manager")); + + ptrdiff_t tmp = reinterpret_cast<ptrdiff_t> (void_ptr); + + // "id" is for na_intelligent-designer. + na_intelligent_designer config_id = + reinterpret_cast<na_intelligent_designer> (tmp); + + if (0 == config_id) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator - Error loading CIAO_Basic_Configurator entrypoint: %p\n", + "dll.symbol"), + false); + } + + ptr = config_id (); + + if (0 == ptr) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error creating ComponentServer_Configurator\n"), + false); + } + + this->na_config_manager_.reset (ptr); + + if (this->rt_support_) + { + int rt_retval = this->config_dll_.open (ACE_DLL_PREFIX ACE_TEXT ("CIAO_RTNA_Configurator"), + ACE_DEFAULT_SHLIB_MODE, + false); + + if (0 != rt_retval) + { + CIAO_ERROR_RETURN ((LM_ERROR, + "ComponentServer_Configurator - Error while loading CIAO_RTNA_Configurator: %p\n", + "dll.open"), + false); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *rt_void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_rt_config_manager")); + ptrdiff_t rt_tmp = reinterpret_cast<ptrdiff_t> (rt_void_ptr); + + // "id" is for na_intelligent-designer. + rtna_intelligent_designer rt_config_id = + reinterpret_cast<rtna_intelligent_designer> (rt_tmp); + + if (0 == rt_config_id) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error while using RTNA entrypoint: %p", + "dll.symbol"), + false); + } + + rt_ptr = rt_config_id (); + + if (0 == rt_ptr) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error creating RTComponentServer_Configurator\n"), + false); + } + + this->rt_config_manager_.reset (rt_ptr); + } + + return true; + } + + int + ComponentServer_Configurator::pre_orb_initialize () + { + CIAO_DEBUG ((LM_TRACE,CLINFO "ComponentServer_Configurator::pre_orb_init\n")); + + (*this->na_config_manager_.get ()).pre_orb_initialize (); + if (this->rt_support_) + { + (*this->rt_config_manager_.get ()).pre_orb_initialize (); + } + + return 0; + } + + int + ComponentServer_Configurator::post_orb_initialize (CORBA::ORB_ptr o) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Configurator::post_orb_init\n")); + this->orb_ = CORBA::ORB::_duplicate (o); + + (*this->na_config_manager_.get ()).init (this->orb_.in ()); + if (this->rt_support_) + { + (*this->rt_config_manager_.get ()).init (this->orb_.in ()); + } + + (*this->na_config_manager_.get ()).post_orb_initialize (this->orb_.in ()); + if (this->rt_support_) + { + (*this->rt_config_manager_.get ()).post_orb_initialize (this->orb_.in ()); + } + + return 0; + } + + int + ComponentServer_Configurator::init_resource_manager + (const ::Components::ConfigValues &properties) + { + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp ("CIAOServerResources", properties[i]->name ()) == 0) + { + const ServerResource *svr_resource; + if (properties[i]->value () >>= svr_resource) + { + (*this->na_config_manager_.get ()). + init_resources (*svr_resource); + + if (this->rt_support_) + { + (*this->rt_config_manager_.get ()). + init_resources (*svr_resource); + } + } + else + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ERROR: ComponentServer_Configurator::" + "init_resource_manager unable to extract" + "CIAOServerResources\n"), -1); + } + } + } + + return 0; + } + + CORBA::PolicyList * + ComponentServer_Configurator::find_container_policies + (const ::Components::ConfigValues &properties) + { + if (!this->na_config_manager_.get ()) + return 0; + + CORBA::PolicyList *configured_policies = 0; + CORBA::PolicyList *rt_configured_policies = 0; + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp ("ContainerPolicySet", properties[i]->name ()) == 0) + { + const char *policy_name; + if (properties[i]->value () >>= policy_name) + { + configured_policies = (*this->na_config_manager_.get ()). + find_policies_by_name (policy_name); + + CORBA::ULong p_length = 0; + if (configured_policies != 0) + { + p_length = configured_policies->length (); + } + + if (this->rt_support_) + { + rt_configured_policies = (*this->rt_config_manager_.get ()). + find_policies_by_name (policy_name); + } + + CORBA::PolicyList_var temp_policies; + CORBA::ULong rtp_length = 0; + if (rt_configured_policies != 0) + { + rtp_length = rt_configured_policies->length (); + temp_policies = rt_configured_policies; + } + else + { + return configured_policies; + } + + CORBA::ULong final_length = p_length + rtp_length; + temp_policies->length (final_length); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + temp_policies[i+rtp_length] = + CORBA::Policy::_duplicate ((*configured_policies)[i]); + } + return temp_policies._retn (); + } + else + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ERROR: ComponentServer_Configurator:" + "find_container_policies unable to extract" + "ContainerPolicySet\n"), 0); + } + } + } + return 0; + } + + CORBA::PolicyList * + ComponentServer_Configurator::find_policies_by_name (const char *policy_name) + { + if (!this->na_config_manager_.get ()) + return 0; + + CORBA::PolicyList *configured_policies = 0; + CORBA::PolicyList *rt_configured_policies = 0; + + configured_policies = (*this->na_config_manager_.get ()). + find_policies_by_name (policy_name); + + CORBA::ULong p_length = 0; + if (configured_policies != 0) + { + p_length = configured_policies->length (); + } + + if (this->rt_support_) + { + rt_configured_policies = (*this->rt_config_manager_.get ()). + find_policies_by_name (policy_name); + } + + CORBA::PolicyList_var temp_policies; + CORBA::ULong rtp_length = 0; + if (rt_configured_policies != 0) + { + rtp_length = rt_configured_policies->length (); + temp_policies = rt_configured_policies; + } + else + { + return configured_policies; + } + + CORBA::ULong final_length = p_length + rtp_length; + temp_policies->length (final_length); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + temp_policies[i+rtp_length] = + CORBA::Policy::_duplicate ((*configured_policies)[i]); + } + return temp_policies._retn (); + } + + bool + ComponentServer_Configurator::policy_exists (const char *policy_set_id) + { + if (!this->na_config_manager_.get ()) + return 0; + + bool result; + result = (*this->na_config_manager_.get ()). + policy_exists (policy_set_id); + + if (result == false) + { + if (this->rt_support_) + { + result = (*this->rt_config_manager_.get ()). + policy_exists (policy_set_id); + } + } + return result; + } + } +} diff --git a/modules/CIAO/ciao/ComponentServer/Configurators/Server_Configurator.h b/modules/CIAO/ciao/ComponentServer/Configurators/Server_Configurator.h new file mode 100644 index 00000000000..c12e34522e2 --- /dev/null +++ b/modules/CIAO/ciao/ComponentServer/Configurators/Server_Configurator.h @@ -0,0 +1,123 @@ +//$Id$ +/**======================================================== + * + * @file Server_Configurator.h + * + * @Brief This file contains the implementation of + * the basic ComponentServer_Configurator interface, the one + * that does nothing more + * + * @author Nanbor Wang <nanbor@exothermic.txcorp.com> + *========================================================*/ + +#ifndef COMPONENTSERVER_CONFIGURATOR_H +#define COMPONENTSERVER_CONFIGURATOR_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/DLL.h" +#include "ace/Auto_Ptr.h" +#include "ccm/CCM_StandardConfiguratorC.h" +#include "ComponentServer_Configurator_export.h" +#include "Config_Manager.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * + * @class ComponentServer_Configurator + * + * @brief This class defines and implements the default + * ComponentServer_Configurator base class that's needed for configuring the + * ComponentServer application process. + **/ + class ComponentServer_Configurator_Export ComponentServer_Configurator + { + public: + + /// Default constructor. + ComponentServer_Configurator (bool rt = false); + + /// Default destructor. + virtual ~ComponentServer_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "post_orb_initialize" is called after ComponentServer + * get a hold at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by ComponentServer when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Components::ConfigValues &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Components::ConfigValues &properties); + + /// @@ Perhaps we also need a finalizer method here. Perhaps we + /// even need to differentiate finalizer before ORB is destroyed + /// and the one after that. + bool rt_support (void); + + void set_rt_support (void); + + virtual bool create_config_managers (void); + + bool policy_exists (const char *policy_set_id); + + CORBA::PolicyList * + find_policies_by_name (const char *name); + + protected: + bool rt_support_; + + CORBA::ORB_var orb_; + + auto_ptr<Config_Manager> rt_config_manager_; + + auto_ptr<Config_Manager> na_config_manager_; + + ACE_DLL config_dll_; + }; + } +} + +/** + * For dynamically linkable concrete ComponentServer_Configurator + * implementation, remember to create a factory method using "C" + * calling convention in the CPP file as follow: + + extern "C" EXPORT_MACRO CIAO::ComponentServer_Configurator *create_nodeapp_configurator (void); + + CIAO::ComponentServer_Configurator * + create_nodeapp_configurator (void) + { + concrete_ComponentServer_Configurator *config; + ACE_NEW_RETURN (config, concrete_ComponentServer_Configurator, 0); + return config; + } + +*/ + + +#include /**/ "ace/post.h" +#endif /* NODEAPP_CONFIGURATOR_H */ + |