summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/NodeApplication
diff options
context:
space:
mode:
Diffstat (limited to 'CIAO/DAnCE/NodeApplication')
-rw-r--r--CIAO/DAnCE/NodeApplication/CIAO_NodeApplication_export.h54
-rwxr-xr-xCIAO/DAnCE/NodeApplication/Config_Manager.h53
-rw-r--r--CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp153
-rw-r--r--CIAO/DAnCE/NodeApplication/Configurator_Factory.h103
-rw-r--r--CIAO/DAnCE/NodeApplication/Container_Impl.cpp621
-rw-r--r--CIAO/DAnCE/NodeApplication/Container_Impl.h192
-rw-r--r--CIAO/DAnCE/NodeApplication/Container_Impl.inl39
-rwxr-xr-xCIAO/DAnCE/NodeApplication/NAConfig_Manager.cpp225
-rwxr-xr-xCIAO/DAnCE/NodeApplication/NAConfig_Manager.h75
-rwxr-xr-xCIAO/DAnCE/NodeApplication/NAConfig_Manager.inl12
-rwxr-xr-xCIAO/DAnCE/NodeApplication/NA_Configurator_Export.h54
-rw-r--r--CIAO/DAnCE/NodeApplication/NoOp_Configurator.cpp39
-rw-r--r--CIAO/DAnCE/NodeApplication/NoOp_Configurator.h62
-rw-r--r--CIAO/DAnCE/NodeApplication/NoOp_Configurator_export.h54
-rwxr-xr-xCIAO/DAnCE/NodeApplication/NodeApp_Configurator.cpp312
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApp_Configurator.h119
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApp_Configurator_Export.h54
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication.cpp52
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication.mpc53
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Core.cpp255
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Core.h70
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Core.inl9
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp1209
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h315
-rw-r--r--CIAO/DAnCE/NodeApplication/NodeApplication_Impl.inl75
-rw-r--r--CIAO/DAnCE/NodeApplication/RTConfig_Manager.cpp513
-rw-r--r--CIAO/DAnCE/NodeApplication/RTConfig_Manager.h134
-rw-r--r--CIAO/DAnCE/NodeApplication/RTConfig_Manager.inl7
-rw-r--r--CIAO/DAnCE/NodeApplication/RTNA_Configurator_Export.h54
-rw-r--r--CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.cpp108
-rw-r--r--CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.h78
31 files changed, 5153 insertions, 0 deletions
diff --git a/CIAO/DAnCE/NodeApplication/CIAO_NodeApplication_export.h b/CIAO/DAnCE/NodeApplication/CIAO_NodeApplication_export.h
new file mode 100644
index 00000000000..b9ebab3d7cb
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/CIAO_NodeApplication_export.h
@@ -0,0 +1,54 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl NODEAPPLICATION
+// ------------------------------
+#ifndef NODEAPPLICATION_EXPORT_H
+#define NODEAPPLICATION_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if !defined (NODEAPPLICATION_HAS_DLL)
+# define NODEAPPLICATION_HAS_DLL 1
+#endif /* ! NODEAPPLICATION_HAS_DLL */
+
+#if defined (NODEAPPLICATION_HAS_DLL) && (NODEAPPLICATION_HAS_DLL == 1)
+# if defined (NODEAPPLICATION_BUILD_DLL)
+# define NODEAPPLICATION_Export ACE_Proper_Export_Flag
+# define NODEAPPLICATION_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define NODEAPPLICATION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* NODEAPPLICATION_BUILD_DLL */
+# define NODEAPPLICATION_Export ACE_Proper_Import_Flag
+# define NODEAPPLICATION_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define NODEAPPLICATION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* NODEAPPLICATION_BUILD_DLL */
+#else /* NODEAPPLICATION_HAS_DLL == 1 */
+# define NODEAPPLICATION_Export
+# define NODEAPPLICATION_SINGLETON_DECLARATION(T)
+# define NODEAPPLICATION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* NODEAPPLICATION_HAS_DLL == 1 */
+
+// Set NODEAPPLICATION_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (NODEAPPLICATION_NTRACE)
+# if (ACE_NTRACE == 1)
+# define NODEAPPLICATION_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define NODEAPPLICATION_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !NODEAPPLICATION_NTRACE */
+
+#if (NODEAPPLICATION_NTRACE == 1)
+# define NODEAPPLICATION_TRACE(X)
+#else /* (NODEAPPLICATION_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define NODEAPPLICATION_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (NODEAPPLICATION_NTRACE == 1) */
+
+#endif /* NODEAPPLICATION_EXPORT_H */
+
+// End of auto generated file.
diff --git a/CIAO/DAnCE/NodeApplication/Config_Manager.h b/CIAO/DAnCE/NodeApplication/Config_Manager.h
new file mode 100755
index 00000000000..06e4dc47c39
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/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 "DAnCE/Deployment/CIAO_ServerResourcesC.h"
+#include "ace/Null_Mutex.h"
+#include "ace/SString.h"
+#include "ace/Hash_Map_Manager_T.h"
+
+namespace CIAO
+{
+ /**
+ */
+ 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 CIAO::DAnCE::ServerResource &info) = 0;
+
+ virtual void init (CORBA::ORB_ptr orb) = 0;
+
+ virtual CORBA::PolicyList *find_policies_by_name (const char *name)= 0;
+
+ virtual bool policy_exists (const char *name) = 0;
+ };
+}
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_CONFIG_MANAGER_H */
+
diff --git a/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp b/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp
new file mode 100644
index 00000000000..b9a05bfe7fa
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp
@@ -0,0 +1,153 @@
+// $Id$
+
+#include "Configurator_Factory.h"
+// #include "NoOp_Configurator.h"
+#include "NodeApp_Configurator.h"
+#include "ace/Null_Mutex.h"
+#include "ciao/CIAO_common.h"
+#include "ace/Arg_Shifter.h"
+
+int
+CIAO::NodeApplication_Options::parse_args (int &argc, char *argv[])
+{
+ ACE_Arg_Shifter shifter (argc, argv);
+
+ while (shifter.is_anything_left ())
+ {
+ const char *parm = 0;
+
+ if (shifter.cur_arg_strncasecmp ("-n") == 0) // Use callback.
+ {
+ this->use_callback_ = false;
+ shifter.consume_arg ();
+ }
+ else if (shifter.cur_arg_strncasecmp ("-r") == 0)
+ {
+ this->rt_support_ = true;
+ shifter.consume_arg ();
+ }
+ else if (ACE_OS::strncmp (shifter.get_current (),
+ "-ORB",
+ ACE_OS::strlen ("-ORB")) == 0)
+ {
+ // Ignore ORB parameter
+ shifter.ignore_arg ();
+ }
+ else if (shifter.cur_arg_strncasecmp ("-o") == 0)
+ {
+ // This double checking is necessary to avoid the Arg_Shifter from
+ // mistaking any -ORBxxx flag as -o flag.
+ if ((parm = shifter.get_the_parameter ("-o")) !=0)
+ {
+ this->ior_output_filename_ = parm;
+ }
+ shifter.consume_arg ();
+ }
+ else if ((parm = shifter.get_the_parameter ("-k")) !=0)
+ {
+ this->callback_ior_ = parm;
+ shifter.consume_arg ();
+ }
+ else if (shifter.cur_arg_strncasecmp ("-h") == 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-n Do not use Callback (for testing)\n"
+ "-o <ior_output_file>\n"
+ "-k <NodeApplicationManager_callback_ior>\n"
+ "-r Request RT support\n"
+ "-h Usage help"
+ "\n",
+ argv [0]),
+ -1);
+ shifter.consume_arg ();
+ }
+ else
+ {
+ shifter.ignore_arg ();
+ }
+ }
+
+ if (this->use_callback_ && 0 == this->callback_ior_.length ())
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Callback IOR to NodeApplicationManager "
+ "is required.\n"),
+ -1);
+ }
+
+ return 0;
+}
+
+CIAO::NodeApp_Configurator *
+CIAO::NodeApplication_Options::create_nodeapp_configurator (void)
+{
+ CIAO::NodeApp_Configurator* ptr = 0;
+ ACE_NEW_THROW_EX (ptr,
+ CIAO::NodeApp_Configurator (),
+ CORBA::NO_MEMORY (TAO::VMCID,
+ CORBA::COMPLETED_NO));
+ if (this->rt_support_)
+ {
+ ptr->set_rt_support ();
+ }
+
+ return ptr;
+ /*
+ typedef CIAO::NodeApp_Configurator * (*intelligent_designer)(void);
+ CIAO::NodeApp_Configurator* ptr = 0;
+
+ if (this->rt_support_)
+ {
+ int const retval =
+ this->config_dll_.open (
+ ACE_DLL_PREFIX ACE_TEXT ("CIAO_RTNA_Configurator"),
+ ACE_DEFAULT_SHLIB_MODE,
+ 0);
+
+ if (0 != retval)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "dll.open"),
+ 0);
+ }
+
+
+ // 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_nodeapp_configurator"));
+ ptrdiff_t tmp = reinterpret_cast<ptrdiff_t> (void_ptr);
+
+ // "id" is for intelligent-designer.
+ intelligent_designer config_id =
+ reinterpret_cast<intelligent_designer> (tmp);
+
+ if (0 == config_id)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p",
+ "dll.symbol"),
+ 0);
+ }
+
+ ptr = config_id ();
+
+ if (0 == ptr)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error creating RTNodeApp_Configurator\n"),
+ 0);
+ }
+ }
+ else
+ {
+ ACE_NEW_RETURN (ptr,
+ CIAO::NoOp_Configurator (),
+ 0);
+ }
+
+ return ptr;
+ */
+}
diff --git a/CIAO/DAnCE/NodeApplication/Configurator_Factory.h b/CIAO/DAnCE/NodeApplication/Configurator_Factory.h
new file mode 100644
index 00000000000..d80f12c3cee
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/Configurator_Factory.h
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Configurator_Factory.h
+ *
+ * $Id$
+ *
+ * Configurator Factory contains the factory method for creating concret
+ * NodeApp_Configurator object.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_CONFIGURATOR_FACTORY_H
+#define CIAO_CONFIGURATOR_FACTORY_H
+#include /**/ "ace/pre.h"
+
+#include "CIAO_NodeApplication_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/ORB_Core.h"
+#include "tao/ORB.h"
+#include "ace/Task.h"
+#include "ace/SString.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/DLL.h"
+#include "NodeApp_Configurator.h"
+
+namespace CIAO
+{
+
+
+ /**
+ * @class NodeApplication_Options
+ *
+ * @brief An class for managing and extracting command line options
+ * for NodeApplication.
+ *
+ * @note We currently support loading one single external module for
+ * RT support. Perhaps how this should really be done is to allow
+ * the NodeApplication_Core to load up a list of external modules
+ * (in DLLs or otherwise) and call the corresponding init methods in
+ * sequence. This way, we open up the component server so system
+ * developers can plug in their own system configuration needs into
+ * the whole system.
+ */
+ class NODEAPPLICATION_Export NodeApplication_Options
+ {
+ public:
+ // default ctor.
+ NodeApplication_Options () : use_callback_ (true), rt_support_ (false) {}
+
+ /// extracting commandline arguments
+ int parse_args (int &argc, char *argv[]);
+
+ NodeApp_Configurator *create_nodeapp_configurator (void);
+
+ bool use_callback () {return this->use_callback_; }
+
+ bool rt_support () {return this->rt_support_; }
+
+ int write_ior_file ()
+ { return (this->ior_output_filename_.length () != 0); }
+
+ const char *ior_output_filename ()
+ { return this->ior_output_filename_.c_str (); }
+
+ const char *callback_ior ()
+ { return this->callback_ior_.c_str (); }
+
+ private:
+ /// The name of the file to write stringified IOR to.
+ ACE_CString ior_output_filename_;
+
+ /// Stringified IOR of a CIAO's callback object.
+ ACE_CString callback_ior_;
+
+ /// CIAO ComponentServer uses the callback object to pass it's
+ /// own object reference back to NodeApplicationManager.
+ bool use_callback_;
+
+ /// If we need to support RT-CORBA. Currently, this is
+ /// mandatory, but we can probably allow some sort of
+ /// "best-effort" RT support. I.e., if the platform/environment
+ /// doesn't support RT, then we will still deploy the NodeApp but
+ /// ignore the RT spec. Perhaps something in the future.
+ bool rt_support_;
+
+ // For managing dynamically loaded configurator library
+ ACE_DLL config_dll_;
+ };
+
+}
+
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_CONFIGURATOR_FACTORY_H */
diff --git a/CIAO/DAnCE/NodeApplication/Container_Impl.cpp b/CIAO/DAnCE/NodeApplication/Container_Impl.cpp
new file mode 100644
index 00000000000..42d834c2ba5
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/Container_Impl.cpp
@@ -0,0 +1,621 @@
+// $Id$
+
+#include "Container_Impl.h"
+#include "ciao/CCM_StandardConfiguratorC.h"
+#include "ciao/CCM_KeylessCCMHomeC.h"
+
+#include "orbsvcs/CosNamingC.h"
+
+#if !defined (__ACE_INLINE__)
+# include "Container_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+CIAO::Container_Impl::~Container_Impl ()
+{
+ // @@ remove all components and home?
+ delete this->container_;
+}
+
+PortableServer::POA_ptr
+CIAO::Container_Impl::_default_POA (void)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::_default_POA");
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+ ///////////////////////////////////////////////////////////////
+
+CORBA::Long
+CIAO::Container_Impl::init (const CORBA::PolicyList *policies)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::init");
+ // @@ Initialize container and create the internal container
+ // implementation that actually interacts with installed
+ // homes/components.
+
+ // @@ We will need a container factory here later on when we support
+ // more kinds of container implementations.
+
+ // @@Jai, what is the condition to create an upgradeable container?
+ // Where is it getting created and how? Need to address that.
+
+ if (this->static_entrypts_maps_ == 0)
+ {
+ ACE_NEW_THROW_EX (this->container_,
+ CIAO::Session_Container (this->orb_.in (), this),
+ CORBA::NO_MEMORY ());
+ }
+ else
+ {
+ ACE_NEW_THROW_EX (this->container_,
+ CIAO::Session_Container (this->orb_.in (), this, 1,
+ this->static_entrypts_maps_),
+ CORBA::NO_MEMORY ());
+ }
+
+ return this->container_->init (0, policies);
+}
+
+
+Deployment::ComponentInfos *
+CIAO::Container_Impl::install (
+ const ::Deployment::ContainerImplementationInfo & container_impl_info
+ )
+{
+ CIAO_TRACE ("CIAO::Container_Impl::install");
+ Deployment::ComponentInfos_var retv;
+ try
+ {
+ ACE_NEW_THROW_EX (retv,
+ Deployment::ComponentInfos,
+ CORBA::NO_MEMORY ());
+
+ // Get the ComponentImplementationInfos from the
+ // ContainerImplementationInfo
+ // to avoid too long syntax representation
+ const ::Deployment::ComponentImplementationInfos impl_infos =
+ container_impl_info.impl_infos;
+
+ CORBA::ULong const len = impl_infos.length ();
+ retv->length (len);
+ REC_POL_MAP rec_pol_map;
+
+ for (CORBA::ULong i = 0; i < len; ++i)
+ {
+ const CORBA::ULong cplen = impl_infos[i].component_config.length ();
+ for (CORBA::ULong cp_len = 0; cp_len < cplen; ++cp_len)
+ {
+ if (impl_infos[i].component_config[cp_len].
+ value.type ()->kind () == CORBA::tk_string)
+ {
+ const char* policy_set_id;
+ ACE_CString receptacle_name;
+ ACE_CString instance_name;
+ impl_infos[i].component_config[cp_len].value >>=
+ policy_set_id;
+ bool result = this->configurator_.policy_exists (
+ policy_set_id);
+ if (result == true)
+ {
+ receptacle_name = impl_infos[i].component_config[cp_len].
+ name.in ();
+ instance_name = impl_infos[i].
+ component_instance_name.in ();
+ receptacle_name += "_";
+ receptacle_name += instance_name;
+ CORBA::PolicyList_var policies =
+ this->configurator_.find_policies_by_name (
+ policy_set_id);
+ CORBA::PolicyList temp_policies (0);
+ if (policies != 0)
+ {
+ temp_policies = *policies;
+ }
+ rec_pol_map.bind (receptacle_name, temp_policies);
+ }
+ }
+ }
+
+ // Install home
+ Components::CCMHome_var home =
+ this->install_home (impl_infos[i]);
+
+ Components::KeylessCCMHome_var kh =
+ Components::KeylessCCMHome::_narrow (home.in ());
+
+ if (CORBA::is_nil (kh.in ()))
+ throw Deployment::InstallationFailure ();
+
+ // Create component from home
+ Components::CCMObject_var comp = kh->create_component ();
+
+ if (CORBA::is_nil (comp.in ()))
+ throw Deployment::InstallationFailure ();
+
+ if (this->component_map_.bind
+ (impl_infos[i].component_instance_name.in (),
+ Components::CCMObject::_duplicate (comp.in ())))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::install -"
+ "error in binding component "
+ "instance name [%s] into the component map \n",
+ impl_infos[i].component_instance_name.in ()));
+ throw Deployment::InstallationFailure ();
+ }
+
+ // Set the return value.
+ (*retv)[i].component_instance_name
+ = impl_infos[i].component_instance_name.in ();
+
+ (*retv)[i].component_ref =
+ Components::CCMObject::_duplicate (comp.in ());
+
+ // Deal with Component instance related Properties.
+ // Now I am only concerning about the COMPOENTIOR and attribute
+ // configuration initialization.
+
+ // I need to map Properties to Components::ConfigValues
+ ::Components::ConfigValues comp_attributes;
+ comp_attributes.length (0);
+
+ const CORBA::ULong clen = impl_infos[i].component_config.length ();
+ for (CORBA::ULong prop_len = 0; prop_len < clen; ++prop_len)
+ {
+ // Set up the ComponentIOR attribute
+ if (ACE_OS::strcmp
+ (impl_infos[i].component_config[prop_len].name.in (),
+ "ComponentIOR") == 0)
+ {
+ const char * path;
+ impl_infos[i].component_config[prop_len].value >>= path;
+
+ CORBA::String_var ior =
+ this->orb_->object_to_string (comp.in ());
+
+ if (CIAO::Utility::write_IOR (path, ior.in ()) != 0)
+ {
+ if (CIAO::debug_level () > 1)
+ ACE_DEBUG ((LM_DEBUG, "Failed to write the IOR.\n"));
+
+ throw CORBA::INTERNAL ();
+ }
+ }
+
+ // Set up the naming service attribute
+ if (ACE_OS::strcmp
+ (impl_infos[i].component_config[prop_len].name.in (),
+ "RegisterNaming") == 0)
+ {
+ const char * naming_context;
+ impl_infos[i].
+ component_config[prop_len].value >>= naming_context;
+
+ // Register the component with the naming service
+ ACE_DEBUG ((LM_DEBUG,
+ "Register component with naming service.\n"));
+ bool result =
+ register_with_ns (
+ naming_context,
+ this->orb_.in (),
+ Components::CCMObject::_duplicate (comp.in ())
+ );
+
+ if (!result)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Failed to register with naming service.\n"));
+ }
+ else
+ {
+ if (this->naming_map_.bind
+ (impl_infos[i].component_instance_name.in (),
+ ACE_CString (naming_context)))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::install -"
+ "error in binding component "
+ "instance name [%s] into the naming map \n",
+ impl_infos[i].component_instance_name.in ()));
+ throw Deployment::InstallationFailure ();
+ }
+ }
+
+
+ }
+
+ // Initialize attributes through StandardConfigurator interface
+ // @@Todo: Currently I have to manually map
+ // the Deployment::Properties to
+ // Components::ConfigValues, we should use a
+ // common data structure in
+ // the future. - Gan
+ CORBA::ULong cur_len = comp_attributes.length ();
+ comp_attributes.length (cur_len + 1);
+
+ Components::ConfigValue *item = new OBV_Components::ConfigValue ();
+ item->name (impl_infos[i].component_config[prop_len].name.in ());
+ CORBA::Any tmp = impl_infos[i].component_config[prop_len].value;
+ item->value (tmp);
+
+ comp_attributes[cur_len] = item;
+ }
+
+ if (comp_attributes.length () != 0)
+ {
+ //std_configurator.set_configuration
+ ::Components::StandardConfigurator_var std_configurator =
+ comp->get_standard_configurator ();
+
+ std_configurator->set_configuration (comp_attributes);
+ }
+ }
+ this->container_->set_receptacle_policy_map (rec_pol_map);
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Container_Impl::install\t\n");
+ throw;
+ }
+
+ return retv._retn ();
+}
+
+::Deployment::Properties *
+CIAO::Container_Impl::properties ()
+{
+ CIAO_TRACE ("CIAO::Container_Impl::properties");
+ ::Deployment::Properties *retval = 0;
+
+ ACE_NEW_THROW_EX (retval,
+ ::Deployment::Properties,
+ CORBA::NO_MEMORY ());
+
+ *retval = this->properties_;
+
+ return retval;
+}
+
+::Deployment::NodeApplication_ptr
+CIAO::Container_Impl::get_node_application ()
+{
+ CIAO_TRACE ("CIAO::Container_Impl::get_node_application");
+ return ::Deployment::NodeApplication::_duplicate (this->nodeapp_.in ());
+}
+
+::Components::CCMHome_ptr
+CIAO::Container_Impl::install_home (
+ const ::Deployment::ComponentImplementationInfo & impl_info)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::install_home");
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::install_home -"
+ "installing home for component "
+ "instance [%s] \n",
+ impl_info.component_instance_name.in ()));
+ }
+
+ Components::CCMHome_var newhome =
+ this->container_->ciao_install_home (impl_info.executor_dll.in (),
+ impl_info.executor_entrypt.in (),
+ impl_info.servant_dll.in (),
+ impl_info.servant_entrypt.in (),
+ impl_info.component_instance_name.in ());
+
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::install_home -"
+ "success in installing home for component "
+ "instance [%s] \n",
+ impl_info.component_instance_name.in ()));
+ }
+
+ // We don't have to do _narrow since the generated code makes sure of
+ // the object type for us
+ // Bind the home in the map.
+ if (this->home_map_.bind (impl_info.component_instance_name.in (),
+ Components::CCMHome::_duplicate (newhome.in ())))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::install_home -"
+ "error in binding home for component "
+ "instance [%s] \n",
+ impl_info.component_instance_name.in ()));
+ throw Deployment::InstallationFailure ();
+ }
+
+ //Note: If the return value will be discarded, it must be kept in a var or
+ // release () will have to be called explicitly.
+ return newhome._retn ();
+}
+
+
+void
+CIAO::Container_Impl::remove_home (const char * comp_ins_name)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::remove_home");
+
+ Components::CCMHome_ptr home;
+ ACE_CString str (comp_ins_name);
+
+ if (this->home_map_.find (str, home) != 0)
+ throw CORBA::BAD_PARAM ();
+
+ // @@TODO We should remove all components created by this home as well.
+ // This is not implemented yet.
+
+ this->container_->ciao_uninstall_home (home);
+
+ // If the previous calls failed, what should we do here??
+ CORBA::release (home);
+
+ // @@ Still need to remove the home if the previous operation fails?
+ if (this->home_map_.unbind (str) == -1)
+ throw ::Components::RemoveFailure ();
+}
+
+// Remove all homes and components
+void
+CIAO::Container_Impl::remove ()
+{
+ CIAO_TRACE ("CIAO::Container_Impl::remove");
+
+ // Remove all components first.
+ this->remove_components ();
+
+ // Even if above operation failed we should still remove homes.
+ const Home_Iterator end = this->home_map_.end ();
+ for (Home_Iterator iter (this->home_map_.begin ());
+ iter != end;
+ ++iter)
+ {
+ this->container_->ciao_uninstall_home ( (*iter).int_id_);
+
+ CORBA::release ( (*iter).int_id_);
+ }
+
+ this->home_map_.unbind_all ();
+
+ if (CIAO::debug_level () > 3)
+ ACE_DEBUG ((LM_DEBUG,
+ "Removed all homes and components from this container!\n"));
+}
+
+////////////////////////////////////////////////////////////////////////
+// Internal helper functions.
+////////////////////////////////////////////////////////////////////////
+
+void
+CIAO::Container_Impl::remove_components ()
+{
+ CIAO_TRACE ("CIAO::Container_Impl::remove_components");
+
+ // Remove all the components in the NodeApplication/Container
+ // Release all component servant object.
+ const Component_Iterator end = this->component_map_.end ();
+ for (Component_Iterator iter (this->component_map_.begin ());
+ iter != end;
+ ++iter)
+ {
+ // Find the component home first, then call the remove_component
+ // on the home.
+ Components::CCMHome_ptr home;
+ if (this->home_map_.find ( (*iter).ext_id_, home) != 0)
+ throw CORBA::BAD_PARAM ();
+
+ // This will call ccm_passivate on the component executor.
+ home->remove_component (((*iter).int_id_).in ());
+
+ //CORBA::release (((*iter).int_id_).in ());
+ }
+
+ this->component_map_.unbind_all ();
+ // To this point the servant should have been destroyed. However,
+ // if someone is still making calls on the servant, terrible thing
+ // will happen.
+}
+
+
+// Below method is not used actually.
+void
+CIAO::Container_Impl::remove_component (const char * comp_ins_name)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::remove_component");
+
+ Components::CCMObject_var comp;
+ Components::CCMHome_ptr home;
+
+ ACE_CString naming_context;
+
+ ACE_CString str (comp_ins_name);
+
+ if (CIAO::debug_level () > 5)
+ ACE_DEBUG ((LM_DEBUG, "CIAO::COntainer_Impl::remove_component: Removing comp_ins_name:: %s\n",
+ str.c_str ()));
+
+ /* Before we do remove component we have to inform the homeservant so
+ * Component::ccm_passivate ()
+ * constainer::uninstall_component () ->deactivate_object () will be called.
+ *
+ * ccm_remove will be called when the poa destroys the servant.
+ */
+
+ if (this->component_map_.find (str, comp) != 0)
+ throw CORBA::BAD_PARAM ();
+
+ if (this->home_map_.find (str, home) != 0)
+ throw CORBA::BAD_PARAM ();
+
+ // This will call ccm_passivate on the component executor.
+ home->remove_component (comp.in ());
+
+ // If the previous calls failed, what should we do here??
+
+ // @@ Still need to remove the home if the previous operation fails?
+ if (this->component_map_.unbind (str) == -1)
+ throw ::Components::RemoveFailure ();
+
+ if (this->naming_map_.find (str, naming_context) == 0)
+ {
+
+ bool const result =
+ unregister_with_ns (
+ naming_context.c_str (),
+ this->orb_.in ()
+ );
+
+ if (!result)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Failed to unregister with naming service.\n"));
+ }
+ else
+ {
+ if (this->naming_map_.unbind (str) == -1)
+ throw ::Components::RemoveFailure ();
+ }
+ }
+}
+
+bool
+CIAO::Container_Impl::register_with_ns (const char * s,
+ CORBA::ORB_ptr orb,
+ Components::CCMObject_ptr obj)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::register_with_ns");
+
+ try
+ {
+ // Obtain the naming service
+ CORBA::Object_var naming_obj =
+ orb->resolve_initial_references ("NameService");
+
+ if (CORBA::is_nil (naming_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "DAnCE: (%P|%t) Unable to get the Naming Service.\n"),
+ false);
+
+ CosNaming::NamingContextExt_var root =
+ CosNaming::NamingContextExt::_narrow (naming_obj.in ());
+
+ CosNaming::Name name (0);
+ name.length (0);
+
+ // Get the multicomponent naming context from the <naming_context>.
+ // The convention of this <naming_context> input string is that
+ // different naming context is separated by character '/', such as
+ // "create a naming context A/B/C/D".
+ ACE_CString tmp (s);
+ char * naming_string = tmp.rep ();
+ char seps[] = "/:";
+
+ char *token, *lastToken = 0;
+ token = ACE_OS::strtok (naming_string, seps);
+
+ for (CORBA::ULong i = 0; token != 0; ++i)
+ {
+ // While there still are tokens in the "naming_string"
+ name.length (name.length () + 1);
+ name[i].id = CORBA::string_dup (token);
+
+ // Get next naming context
+ lastToken = token;
+ token = ACE_OS::strtok ( 0, seps );
+ }
+
+ if (name.length() > 1)
+ {
+ // Let's create the context path first
+ name.length(name.length()-1);
+ Utility::NameUtility::CreateContextPath (root.in (), name);
+ name.length(name.length()+1);
+ name[name.length()-1].id = CORBA::string_dup(lastToken);
+ }
+
+ // Bind the actual object
+ Utility::NameUtility::BindObjectPath (root.in (), name, obj);
+
+ return true;
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::register_with_ns -"
+ "NodeApplication: failed to register "
+ "with naming service.");
+ return false;
+ }
+ return true;
+}
+
+bool
+CIAO::Container_Impl::unregister_with_ns (const char * obj_name,
+ CORBA::ORB_ptr orb)
+{
+ CIAO_TRACE ("CIAO::Container_Impl::unregister_with_ns");
+
+ try
+ {
+ // Obtain the naming service
+ CORBA::Object_var naming_obj =
+ orb->resolve_initial_references ("NameService");
+
+ if (CORBA::is_nil (naming_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to get the Naming Service.\n"),
+ false);
+
+ CosNaming::NamingContext_var naming_context =
+ CosNaming::NamingContext::_narrow (naming_obj.in ());
+
+ CosNaming::Name name (0);
+ name.length (0);
+
+ // Get the multicomponent naming context from the <naming_context>.
+ // The convention of this <naming_context> input string is that
+ // different naming context is separated by character '/', such as
+ // "create a naming context A/B/C/D".
+ ACE_CString tmp (obj_name);
+ char * naming_string = tmp.rep ();
+ char seps[] = "/:";
+
+ char *token, *lastToken = 0;
+ token = ACE_OS::strtok (naming_string, seps);
+
+ for (CORBA::ULong i = 0; token != 0; ++i)
+ {
+ // While there still are tokens in the "naming_string"
+ name.length (name.length () + 1);
+ name[i].id = CORBA::string_dup (token);
+
+ // Get next naming context
+ lastToken = token;
+ token = ACE_OS::strtok ( 0, seps );
+ }
+
+ // Unregister with the Name Server
+ ACE_DEBUG ((LM_DEBUG,
+ "Unregister component with the name server : %s!\n",
+ obj_name));
+ naming_context->unbind (name);
+
+ return true;
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("CIAO (%P|%t) Container_Impl.cpp -"
+ "CIAO::Container_Impl::unregister_with_ns -"
+ "NodeApplication: failed to unregister "
+ "with naming service.");
+ return false;
+ }
+ return true;
+}
diff --git a/CIAO/DAnCE/NodeApplication/Container_Impl.h b/CIAO/DAnCE/NodeApplication/Container_Impl.h
new file mode 100644
index 00000000000..8d749149acb
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/Container_Impl.h
@@ -0,0 +1,192 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Container_Impl.h
+ *
+ * $Id$
+ *
+ * This file contains implementation for the servant of
+ * Components::Deployment::Container interface.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Gan Deng <gan.deng@vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_CONTAINER_IMPL_H
+#define CIAO_CONTAINER_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "CIAO_NodeApplication_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "DAnCE/Deployment/Deployment_ContainerS.h"
+#include "DAnCE/Deployment/Deployment_NodeApplicationC.h"
+#include "DAnCE/Deployment//DeploymentC.h"
+#include "ciao/Session_Container.h"
+#include "ace/SString.h"
+#include "ciao/Server_init.h" // write_IOR function & NameUtility
+#include "ciao/CIAO_common.h" // CIAO::debug_level
+#include "NodeApp_Configurator.h"
+
+namespace CIAO
+{
+ /**
+ * @class Container_Impl
+ *
+ * @brief Servant implementation for the interface Deployment::Container
+ *
+ * This class implements the Deployment::Container
+ * interface which is not defined by the CCM DnC specification.
+ * As the interface implies, this is actually part of the deployment
+ * interface and is used to manage the lifecycle of the installed
+ * components and homes.
+ */
+ class NODEAPPLICATION_Export Container_Impl
+ : public virtual POA_Deployment::Container
+ {
+ public:
+ /// Constructor
+ Container_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ ::Deployment::NodeApplication_ptr server,
+ NodeApp_Configurator &c,
+ const Static_Config_EntryPoints_Maps* static_entrypts_maps =0);
+
+ /// Destructor
+ virtual ~Container_Impl (void);
+
+ /*-------------------------------------------------------------*/
+ /*-------------------- IDL operations (idl) ------------------*/
+
+ /// Initialize the container.
+ virtual CORBA::Long init (const CORBA::PolicyList *policies);
+
+ /// Install all homes and components
+ Deployment::ComponentInfos *
+ install (const ::Deployment::ContainerImplementationInfo & container_impl_info);
+
+ /// Remove all homes and components
+ virtual void remove ();
+
+ /// Deployment::Container interface defined attributes/operations.
+ virtual ::Deployment::Properties *properties ();
+
+ virtual ::Deployment::NodeApplication_ptr get_node_application ();
+
+ /*-------------------------------------------------------------*/
+ /*------------------- C++ help methods (c++) -----------------*/
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ // Install the home of this particular component
+ virtual ::Components::CCMHome_ptr
+ install_home (const ::Deployment::ComponentImplementationInfo & impl_info);
+
+ /**
+ * @@Note: I don't know how to remove a home right now.
+ * I assume that user will only call remove instead.
+ * This is true at least for DnC run time.
+ *
+ * Right now, in this implementation I assumpe that there will be
+ * same number of homes as the components even if the components
+ * are of the same type. I don't think that we have the modeling
+ * side support of this either. So bear me if you think I avoid
+ * the real thinking for easiness.
+ */
+ // Remove the home of this particular component
+ virtual void remove_home (const char * comp_ins_name);
+
+ bool
+ register_with_ns (const char * obj_name,
+ CORBA::ORB_ptr orb,
+ Components::CCMObject_ptr obj);
+
+ bool
+ unregister_with_ns (const char * obj_name, CORBA::ORB_ptr orb);
+
+ // ------------------- CIAO Internal Operations ------------------------
+ // These below two are helper methods to clean up components
+ // should only be called when we are sure that there is no
+ // active connection on this component.
+ virtual void remove_components ();
+
+ virtual void remove_component (const char * comp_ins_name);
+
+ /// Set the cached object reference.
+ void set_objref (Deployment::Container_ptr o);
+
+ /// Get the cached object reference. This operation will invoke
+ /// _this if there's no cached reference available. Notice that
+ /// this method does *NOT* increase the reference count of the
+ /// cached reference.
+ /// @@ Gan, caller should own memory. In this case you shoudl
+ /// return a duplicate OR add a const to the operation
+ /// signature. This is simply bad programming.
+ Deployment::Container_ptr get_objref ();
+
+protected:
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// Internal container implementation.
+ // @@ Gan/Jai, heard of auto_ptr <>?
+ CIAO::Container *container_;
+
+ /// Cached ConfigValues.
+ Deployment::Properties properties_;
+
+ /// Cached Container reference (of ourselves.)
+ Deployment::Container_var objref_;
+
+ /// Cached NodeApplication.
+ Deployment::NodeApplication_var nodeapp_;
+
+ NodeApp_Configurator &configurator_;
+
+ /// To store all created CCMHome object
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Components::CCMHome_ptr,
+ 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_;
+
+ const Static_Config_EntryPoints_Maps* static_entrypts_maps_;
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "Container_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_CONTAINER_IMPL_H */
diff --git a/CIAO/DAnCE/NodeApplication/Container_Impl.inl b/CIAO/DAnCE/NodeApplication/Container_Impl.inl
new file mode 100644
index 00000000000..5473cfcb434
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/Container_Impl.inl
@@ -0,0 +1,39 @@
+/* -*- C++ -*- */
+// $Id$
+
+ACE_INLINE
+CIAO::Container_Impl::Container_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ ::Deployment::NodeApplication_ptr server,
+ NodeApp_Configurator &c,
+ const Static_Config_EntryPoints_Maps* static_entrypts_maps)
+ : orb_ (CORBA::ORB::_duplicate (o)),
+ poa_ (PortableServer::POA::_duplicate (p)),
+ nodeapp_ (::Deployment::NodeApplication::_duplicate (server)),
+ configurator_ (c),
+ static_entrypts_maps_ (static_entrypts_maps)
+{
+}
+
+ACE_INLINE void
+CIAO::Container_Impl::set_objref (Deployment::Container_ptr o)
+{
+ CIAO_TRACE("CIAO::Container_Imp::set_objref");
+
+ if (!CORBA::is_nil (this->objref_.in ()))
+ throw CORBA::BAD_INV_ORDER ();
+
+ this->objref_ = Deployment::Container::_duplicate (o);
+}
+
+ACE_INLINE ::Deployment::Container_ptr
+CIAO::Container_Impl::get_objref ()
+{
+ CIAO_TRACE("CIAO::Container_Imp::get_objref");
+
+ if (CORBA::is_nil (this->objref_.in ()))
+ {
+ this->objref_ = this->_this ();
+ }
+ return this->objref_.in ();
+}
diff --git a/CIAO/DAnCE/NodeApplication/NAConfig_Manager.cpp b/CIAO/DAnCE/NodeApplication/NAConfig_Manager.cpp
new file mode 100755
index 00000000000..a85c5d1a688
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NAConfig_Manager.cpp
@@ -0,0 +1,225 @@
+// $Id$
+
+#include "NAConfig_Manager.h"
+#include "ciao/CIAO_common.h"
+#include "ace/SString.h"
+#include "tao/SystemException.h"
+#include "tao/DiffServPolicy/DiffServPolicyC.h"
+#include "tao/DiffServPolicy/Client_Network_Priority_Policy.h"
+#include "tao/DiffServPolicy/Server_Network_Priority_Policy.h"
+
+void
+CIAO::NAResource_Config_Manager::init (CORBA::ORB_ptr orb)
+{
+ this->orb_ = CORBA::ORB::_duplicate (orb);
+}
+
+int
+CIAO::NAResource_Config_Manager::pre_orb_initialize (void)
+{
+ return 0;
+}
+
+int
+CIAO::NAResource_Config_Manager::post_orb_initialize (CORBA::ORB_ptr)
+{
+ return 0;
+}
+
+void
+CIAO::NAResource_Config_Manager::init_resources
+(const CIAO::DAnCE::ServerResource &server_resource)
+{
+ ACE_DEBUG ((LM_DEBUG,"NAResource_Config_Manager::init_resources\n"));
+
+ if (CORBA::is_nil (this->orb_.in()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "NAResource_Config_Manager has not been properly initialized\n"));
+ throw CORBA::INTERNAL ();
+ }
+
+ const CIAO::DAnCE::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)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error binding Policy_Set with name: %s\n",
+ sets[i].Id.in ()));
+ throw CORBA::INTERNAL ();
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "NAResource_Config_Manager::init_resource"
+ " added policy set : %s with %d policies\n",
+ sets[i].Id.in (), array_index));
+ }
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "NAResource_Config_Manager::init_resource"
+ " added policy set : %s with %d policies\n",
+ sets[i].Id.in (), array_index));
+ }
+ }
+}
+
+bool
+CIAO::NAResource_Config_Manager::policy_exists (const char *name)
+{
+ if (name == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Invalid name string found in "
+ "CIAO::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::NAResource_Config_Manager::find_policies_by_name (const char *name)
+{
+ if (name == 0)
+ {
+ ACE_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)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Unable to find a PolicyList named %s\n",
+ name));
+ retv = 0;
+ }
+ else
+ {
+ retv = new CORBA::PolicyList (entry->int_id_.in ());
+ }
+ return retv._retn ();
+}
+
+CORBA::Policy_ptr
+CIAO::NAResource_Config_Manager::create_single_policy
+(const CIAO::DAnCE::PolicyDef &policy_def)
+{
+ CORBA::Policy_var retv;
+
+ switch (policy_def._d ())
+ {
+ case TAO::NETWORK_PRIORITY_TYPE:
+ {
+ const CIAO::DAnCE::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 ()))
+ ACE_DEBUG ((LM_DEBUG,
+ "NAConfigManager::Create NetworkPriority policy: %d\n",
+ nw_tmp.nw_priority_model));
+ }
+ break;
+
+ case TAO::CLIENT_NETWORK_PRIORITY_TYPE:
+ {
+ const CIAO::DAnCE::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 ()))
+ ACE_DEBUG ((LM_DEBUG,
+ "NAConfigManager::Create NetworkPriority policy \n"));
+ }
+ break;
+
+ default:
+ retv = 0;
+ }
+
+ return retv._retn ();
+}
+
+extern "C" CIAO_NA_Configurator_Export CIAO::Config_Manager *create_na_config_manager (void);
+
+CIAO::Config_Manager *
+create_na_config_manager (void)
+{
+ CIAO::NAResource_Config_Manager *config;
+ ACE_NEW_RETURN (config, CIAO::NAResource_Config_Manager, 0);
+ return config;
+}
diff --git a/CIAO/DAnCE/NodeApplication/NAConfig_Manager.h b/CIAO/DAnCE/NodeApplication/NAConfig_Manager.h
new file mode 100755
index 00000000000..00248c5c551
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NAConfig_Manager.h
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file NAConfig_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 "DAnCE/Deployment/CIAO_ServerResourcesC.h"
+#include "ace/Null_Mutex.h"
+#include "ace/SString.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "Config_Manager.h"
+#include "NA_Configurator_Export.h"
+
+namespace CIAO
+{
+ /**
+ */
+ class CIAO_NA_Configurator_Export NAResource_Config_Manager
+ : public Config_Manager
+ {
+ public:
+ virtual ~NAResource_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 CIAO::DAnCE::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 CIAO::DAnCE::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/CIAO/DAnCE/NodeApplication/NAConfig_Manager.inl b/CIAO/DAnCE/NodeApplication/NAConfig_Manager.inl
new file mode 100755
index 00000000000..67203a91ff8
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NAConfig_Manager.inl
@@ -0,0 +1,12 @@
+// $Id$
+
+ACE_INLINE
+CIAO::NAResource_Config_Manager::NAResource_Config_Manager ()
+{
+}
+
+ACE_INLINE
+CIAO::NAResource_Config_Manager::~NAResource_Config_Manager ()
+{
+}
+
diff --git a/CIAO/DAnCE/NodeApplication/NA_Configurator_Export.h b/CIAO/DAnCE/NodeApplication/NA_Configurator_Export.h
new file mode 100755
index 00000000000..78d65b4eb45
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NA_Configurator_Export.h
@@ -0,0 +1,54 @@
+
+// -*- 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 (CIAO_NA_CONFIGURATOR_HAS_DLL)
+# define CIAO_NA_CONFIGURATOR_HAS_DLL 1
+#endif /* ! CIAO_NA_CONFIGURATOR_HAS_DLL */
+
+#if defined (CIAO_NA_CONFIGURATOR_HAS_DLL) && (CIAO_NA_CONFIGURATOR_HAS_DLL == 1)
+# if defined (CIAO_NA_CONFIGURATOR_BUILD_DLL)
+# define CIAO_NA_Configurator_Export ACE_Proper_Export_Flag
+# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* CIAO_NA_CONFIGURATOR_BUILD_DLL */
+# define CIAO_NA_Configurator_Export ACE_Proper_Import_Flag
+# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* CIAO_NA_CONFIGURATOR_BUILD_DLL */
+#else /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */
+# define CIAO_NA_Configurator_Export
+# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T)
+# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */
+
+// Set CIAO_NA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (CIAO_NA_CONFIGURATOR_NTRACE)
+# if (ACE_NTRACE == 1)
+# define CIAO_NA_CONFIGURATOR_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define CIAO_NA_CONFIGURATOR_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !CIAO_NA_CONFIGURATOR_NTRACE */
+
+#if (CIAO_NA_CONFIGURATOR_NTRACE == 1)
+# define CIAO_NA_CONFIGURATOR_TRACE(X)
+#else /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define CIAO_NA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */
+
+#endif /* CIAO_NA_CONFIGURATOR_EXPORT_H */
+
+// End of auto generated file.
diff --git a/CIAO/DAnCE/NodeApplication/NoOp_Configurator.cpp b/CIAO/DAnCE/NodeApplication/NoOp_Configurator.cpp
new file mode 100644
index 00000000000..4ffe48cd7d2
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NoOp_Configurator.cpp
@@ -0,0 +1,39 @@
+// $Id$
+
+#include "NoOp_Configurator.h"
+
+CIAO::NoOp_Configurator::~NoOp_Configurator (void)
+{
+ // Not much to do.
+}
+
+int
+CIAO::NoOp_Configurator::pre_orb_initialize ()
+{
+ return 0;
+}
+
+int
+CIAO::NoOp_Configurator::post_orb_initialize (CORBA::ORB_ptr)
+{
+ return 0;
+}
+
+int
+CIAO::NoOp_Configurator::init_resource_manager
+(const ::Deployment::Properties & /*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 *
+CIAO::NoOp_Configurator::find_container_policies
+(const ::Deployment::Properties & /*properties*/)
+{
+ // Not much to do.
+
+ return 0;
+}
diff --git a/CIAO/DAnCE/NodeApplication/NoOp_Configurator.h b/CIAO/DAnCE/NodeApplication/NoOp_Configurator.h
new file mode 100644
index 00000000000..6c32b83ce0d
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NoOp_Configurator.h
@@ -0,0 +1,62 @@
+/** $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 "NodeApp_Configurator.h"
+#include "NoOp_Configurator_export.h"
+
+namespace CIAO
+{
+ /**
+ * @class NoOP_Configurator
+ *
+ * @brief The NoOp_Configurator doesn't do anything.
+ */
+ class NoOp_Configurator_Export NoOp_Configurator
+ : public NodeApp_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 ::Deployment::Properties &properties);
+
+ /**
+ * @brief get a policyset by its name.
+ */
+ virtual CORBA::PolicyList *
+ find_container_policies (const ::Deployment::Properties &properties);
+ };
+
+}
+
+#include /**/ "ace/post.h"
+#endif /* NOOP_CONFIGURATOR_H */
diff --git a/CIAO/DAnCE/NodeApplication/NoOp_Configurator_export.h b/CIAO/DAnCE/NodeApplication/NoOp_Configurator_export.h
new file mode 100644
index 00000000000..dce4b728146
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NoOp_Configurator_export.h
@@ -0,0 +1,54 @@
+
+// -*- 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 (NOOP_CONFIGURATOR_HAS_DLL)
+# define NOOP_CONFIGURATOR_HAS_DLL 1
+#endif /* ! NOOP_CONFIGURATOR_HAS_DLL */
+
+#if defined (NOOP_CONFIGURATOR_HAS_DLL) && (NOOP_CONFIGURATOR_HAS_DLL == 1)
+# if defined (NOOP_CONFIGURATOR_BUILD_DLL)
+# define NoOp_Configurator_Export ACE_Proper_Export_Flag
+# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* NOOP_CONFIGURATOR_BUILD_DLL */
+# define NoOp_Configurator_Export ACE_Proper_Import_Flag
+# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* NOOP_CONFIGURATOR_BUILD_DLL */
+#else /* NOOP_CONFIGURATOR_HAS_DLL == 1 */
+# define NoOp_Configurator_Export
+# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T)
+# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* NOOP_CONFIGURATOR_HAS_DLL == 1 */
+
+// Set NOOP_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (NOOP_CONFIGURATOR_NTRACE)
+# if (ACE_NTRACE == 1)
+# define NOOP_CONFIGURATOR_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define NOOP_CONFIGURATOR_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !NOOP_CONFIGURATOR_NTRACE */
+
+#if (NOOP_CONFIGURATOR_NTRACE == 1)
+# define NOOP_CONFIGURATOR_TRACE(X)
+#else /* (NOOP_CONFIGURATOR_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define NOOP_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (NOOP_CONFIGURATOR_NTRACE == 1) */
+
+#endif /* NOOP_CONFIGURATOR_EXPORT_H */
+
+// End of auto generated file.
diff --git a/CIAO/DAnCE/NodeApplication/NodeApp_Configurator.cpp b/CIAO/DAnCE/NodeApplication/NodeApp_Configurator.cpp
new file mode 100755
index 00000000000..8c1ffda2579
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApp_Configurator.cpp
@@ -0,0 +1,312 @@
+// $Id$
+
+#include "NodeApp_Configurator.h"
+#include "ace/Log_Msg.h"
+
+CIAO::NodeApp_Configurator::NodeApp_Configurator (void)
+ : rt_support_ (0)
+{
+}
+
+CIAO::NodeApp_Configurator::~NodeApp_Configurator (void)
+{
+ // Not much to do.
+}
+
+void
+CIAO::NodeApp_Configurator::set_rt_support (void)
+{
+ this->rt_support_ = 1;
+}
+
+int
+CIAO::NodeApp_Configurator::create_config_managers (void)
+{
+ typedef CIAO::Config_Manager * (*na_intelligent_designer)(void);
+ typedef CIAO::Config_Manager * (*rtna_intelligent_designer)(void);
+ CIAO::Config_Manager* ptr = 0;
+ CIAO::Config_Manager* rt_ptr = 0;
+
+ int retval = this->config_dll_.open (
+ ACE_DLL_PREFIX ACE_TEXT ("CIAO_NA_Configurator"),
+ ACE_DEFAULT_SHLIB_MODE,
+ 0);
+
+ if (0 != retval)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "dll.open"),
+ 0);
+ }
+
+ // 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_na_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)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p",
+ "dll.symbol"),
+ 0);
+ }
+
+ ptr = config_id ();
+
+ if (0 == ptr)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error creating NodeApp_Configurator\n"),
+ 0);
+ }
+
+ 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,
+ 0);
+
+ if (0 != rt_retval)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "dll.open"),
+ 0);
+ }
+
+ // 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)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p",
+ "dll.symbol"),
+ 0);
+ }
+
+ rt_ptr = rt_config_id ();
+
+ if (0 == rt_ptr)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error creating RTNodeApp_Configurator\n"),
+ 0);
+ }
+
+ this->rt_config_manager_.reset (rt_ptr);
+ }
+
+ return 0;
+}
+
+int
+CIAO::NodeApp_Configurator::pre_orb_initialize ()
+{
+ ACE_DEBUG ((LM_DEBUG, "NodeApp_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
+CIAO::NodeApp_Configurator::post_orb_initialize (CORBA::ORB_ptr o)
+{
+ ACE_DEBUG ((LM_DEBUG, "NodeApp_Configurator::post_orb_init\n"));
+ this->orb_ = CORBA::ORB::_duplicate (o);
+
+ (*this->na_config_manager_.get ()).init (this->orb_.in ());
+ if (this->rt_support_ == 1)
+ {
+ (*this->rt_config_manager_.get ()).init (this->orb_.in ());
+ }
+
+ (*this->na_config_manager_.get ()).post_orb_initialize (this->orb_.in ());
+ if (this->rt_support_ == 1)
+ {
+ (*this->rt_config_manager_.get ()).post_orb_initialize (this->orb_.in ());
+ }
+
+ return 0;
+}
+
+int
+CIAO::NodeApp_Configurator::init_resource_manager
+(const ::Deployment::Properties &properties)
+{
+ for (CORBA::ULong i = 0; i < properties.length (); ++i)
+ {
+ if (ACE_OS::strcmp (
+ "CIAOServerResources", properties[i].name.in ()) == 0)
+ {
+ const CIAO::DAnCE::ServerResource *svr_resource;
+ if (properties[i].value >>= svr_resource)
+ {
+ (*this->na_config_manager_.get ()).
+ init_resources (*svr_resource);
+
+ if (this->rt_support_ == 1)
+ {
+ (*this->rt_config_manager_.get ()).
+ init_resources (*svr_resource);
+ }
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "ERROR: NodeApp_Configurator::"
+ "init_resource_manager unable to extract"
+ "CIAOServerResources\n"), -1);
+ }
+ }
+ }
+
+ return 0;
+}
+
+CORBA::PolicyList *
+CIAO::NodeApp_Configurator::find_container_policies
+(const ::Deployment::Properties &properties)
+{
+ CORBA::PolicyList *configured_policies = 0;
+ CORBA::PolicyList *rt_configured_policies = 0;
+
+ for (CORBA::ULong i = 0; i < properties.length (); ++i)
+ {
+ if (ACE_OS::strcmp ("ContainerPolicySet", properties[i].name) == 0)
+ {
+ const char *policy_name;
+ if (properties[i].value >>= policy_name)
+ {
+ configured_policies = (*this->na_config_manager_.get ()).
+ find_policies_by_name (policy_name);
+
+ CORBA::ULong p_length = 0;
+ if (configured_policies != 0)
+ {
+ p_length = configured_policies->length ();
+ }
+
+ if (this->rt_support_ == 1)
+ {
+ rt_configured_policies = (*this->rt_config_manager_.get ()).
+ find_policies_by_name (policy_name);
+ }
+
+ CORBA::PolicyList_var temp_policies;
+ CORBA::ULong rtp_length = 0;
+ if (rt_configured_policies != 0)
+ {
+ rtp_length = rt_configured_policies->length ();
+ temp_policies = rt_configured_policies;
+ }
+ else
+ {
+ return configured_policies;
+ }
+
+ CORBA::ULong final_length = p_length + rtp_length;
+ temp_policies->length (final_length);
+
+ for (CORBA::ULong i = 0; i < p_length; ++i)
+ {
+ temp_policies[i+rtp_length] =
+ CORBA::Policy::_duplicate ((*configured_policies)[i]);
+ }
+ return temp_policies._retn ();
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "ERROR: NodeApp_Configurator:"
+ "find_container_policies unable to extract"
+ "ContainerPolicySet\n"), 0);
+ }
+ }
+ }
+ return 0;
+}
+
+CORBA::PolicyList *
+CIAO::NodeApp_Configurator::find_policies_by_name (const char *policy_name)
+{
+ CORBA::PolicyList *configured_policies = 0;
+ CORBA::PolicyList *rt_configured_policies = 0;
+
+ configured_policies = (*this->na_config_manager_.get ()).
+ find_policies_by_name (policy_name);
+
+ CORBA::ULong p_length = 0;
+ if (configured_policies != 0)
+ {
+ p_length = configured_policies->length ();
+ }
+
+ if (this->rt_support_ == 1)
+ {
+ rt_configured_policies = (*this->rt_config_manager_.get ()).
+ find_policies_by_name (policy_name);
+ }
+
+ CORBA::PolicyList_var temp_policies;
+ CORBA::ULong rtp_length = 0;
+ if (rt_configured_policies != 0)
+ {
+ rtp_length = rt_configured_policies->length ();
+ temp_policies = rt_configured_policies;
+ }
+ else
+ {
+ return configured_policies;
+ }
+
+ CORBA::ULong final_length = p_length + rtp_length;
+ temp_policies->length (final_length);
+
+ for (CORBA::ULong i = 0; i < p_length; ++i)
+ {
+ temp_policies[i+rtp_length] =
+ CORBA::Policy::_duplicate ((*configured_policies)[i]);
+ }
+ return temp_policies._retn ();
+}
+
+bool
+CIAO::NodeApp_Configurator::policy_exists (const char *policy_set_id)
+{
+ bool result;
+ result = (*this->na_config_manager_.get ()).
+ policy_exists (policy_set_id);
+
+ if (result == false)
+ {
+ if (this->rt_support_ == 1)
+ {
+ result = (*this->rt_config_manager_.get ()).
+ policy_exists (policy_set_id);
+ }
+ }
+ return result;
+}
diff --git a/CIAO/DAnCE/NodeApplication/NodeApp_Configurator.h b/CIAO/DAnCE/NodeApplication/NodeApp_Configurator.h
new file mode 100644
index 00000000000..7ec10b9f053
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApp_Configurator.h
@@ -0,0 +1,119 @@
+//$Id$
+/**========================================================
+ *
+ * @file NodeApp_Configurator.h
+ *
+ * @Brief This file contains the implementation of
+ * the basic NodeApp_Configurator interface, the one
+ * that does nothing more
+ *
+ * @author Nanbor Wang <nanbor@exothermic.txcorp.com>
+ *========================================================*/
+
+#ifndef NODEAPP_CONFIGURATOR_H
+#define NODEAPP_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 "DAnCE/Deployment/Deployment_CoreC.h"
+#include "Config_Manager.h"
+#include "ace/DLL.h"
+#include "ace/Auto_Ptr.h"
+#include "NodeApp_Configurator_Export.h"
+
+namespace CIAO
+{
+ /**
+ *
+ * @class NodeApp_Configurator
+ *
+ * @brief This class defines and implements the default
+ * NodeApp_Configurator base class that's needed for configuring the
+ * NodeApplication process.
+ **/
+ class NODEAPP_Configurator_Export NodeApp_Configurator
+ {
+ public:
+
+ /// Default constructor.
+ NodeApp_Configurator (void);
+
+ /// Default destructor.
+ virtual ~NodeApp_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 ::Deployment::Properties &properties);
+
+ /**
+ * @brief get a policyset by its name.
+ */
+ virtual CORBA::PolicyList *
+ find_container_policies (const ::Deployment::Properties &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.
+
+ void set_rt_support (void);
+
+ int create_config_managers (void);
+
+ bool policy_exists (const char *policy_set_id);
+
+ CORBA::PolicyList *
+ find_policies_by_name (const char *name);
+
+ protected:
+
+ int rt_support_;
+
+ CORBA::ORB_var orb_;
+
+ auto_ptr<Config_Manager> rt_config_manager_;
+
+ auto_ptr<Config_Manager> na_config_manager_;
+
+ ACE_DLL config_dll_;
+ };
+}
+
+/**
+ * For dynamically linkable concrete NodeApp_Configurator
+ * implementation, remember to create a factory method using "C"
+ * calling convention in the CPP file as follow:
+
+ extern "C" EXPORT_MACRO CIAO::NodeApp_Configurator *create_nodeapp_configurator (void);
+
+ CIAO::NodeApp_Configurator *
+ create_nodeapp_configurator (void)
+ {
+ concrete_NodeApp_Configurator *config;
+ ACE_NEW_RETURN (config, concrete_NodeApp_Configurator, 0);
+ return config;
+ }
+
+ */
+
+
+#include /**/ "ace/post.h"
+#endif /* NODEAPP_CONFIGURATOR_H */
diff --git a/CIAO/DAnCE/NodeApplication/NodeApp_Configurator_Export.h b/CIAO/DAnCE/NodeApplication/NodeApp_Configurator_Export.h
new file mode 100644
index 00000000000..48db48231ac
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApp_Configurator_Export.h
@@ -0,0 +1,54 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl NODEAPP_Configurator
+// ------------------------------
+#ifndef NODEAPP_CONFIGURATOR_EXPORT_H
+#define NODEAPP_CONFIGURATOR_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if !defined (NODEAPP_CONFIGURATOR_HAS_DLL)
+# define NODEAPP_CONFIGURATOR_HAS_DLL 1
+#endif /* ! NODEAPP_CONFIGURATOR_HAS_DLL */
+
+#if defined (NODEAPP_CONFIGURATOR_HAS_DLL) && (NODEAPP_CONFIGURATOR_HAS_DLL == 1)
+# if defined (NODEAPP_CONFIGURATOR_BUILD_DLL)
+# define NODEAPP_Configurator_Export ACE_Proper_Export_Flag
+# define NODEAPP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define NODEAPP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* NODEAPP_CONFIGURATOR_BUILD_DLL */
+# define NODEAPP_Configurator_Export ACE_Proper_Import_Flag
+# define NODEAPP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define NODEAPP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* NODEAPP_CONFIGURATOR_BUILD_DLL */
+#else /* NODEAPP_CONFIGURATOR_HAS_DLL == 1 */
+# define NODEAPP_Configurator_Export
+# define NODEAPP_CONFIGURATOR_SINGLETON_DECLARATION(T)
+# define NODEAPP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* NODEAPP_CONFIGURATOR_HAS_DLL == 1 */
+
+// Set NODEAPP_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (NODEAPP_CONFIGURATOR_NTRACE)
+# if (ACE_NTRACE == 1)
+# define NODEAPP_CONFIGURATOR_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define NODEAPP_CONFIGURATOR_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !NODEAPP_CONFIGURATOR_NTRACE */
+
+#if (NODEAPP_CONFIGURATOR_NTRACE == 1)
+# define NODEAPP_CONFIGURATOR_TRACE(X)
+#else /* (NODEAPP_CONFIGURATOR_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define NODEAPP_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (NODEAPP_CONFIGURATOR_NTRACE == 1) */
+
+#endif /* NODEAPP_CONFIGURATOR_EXPORT_H */
+
+// End of auto generated file.
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication.cpp b/CIAO/DAnCE/NodeApplication/NodeApplication.cpp
new file mode 100644
index 00000000000..021f1e5322c
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication.cpp
@@ -0,0 +1,52 @@
+// $Id$
+
+#include "NodeApplication_Core.h"
+#include "ace/Sched_Params.h"
+#include "ace/OS_NS_errno.h"
+#include "ciao/CIAO_common.h"
+
+#include <orbsvcs/Event/EC_Default_Factory.h>
+
+void print_arg (int argc, char *argv[])
+{
+ for (int i = 0; i < argc; ++i)
+ ACE_DEBUG ((LM_DEBUG, "NodeApplication ARGV[%d] = %s\n", i, argv [i]));
+}
+
+int
+main (int argc, char *argv[])
+{
+ try
+ {
+ TAO_EC_Default_Factory::init_svcs ();
+
+ ACE_DEBUG ((LM_DEBUG, "*** Starting NodeApplication\n"));
+
+ CIAO::NodeApplication_Options nodeapp_options;
+
+ if (CIAO::debug_level () > 9)
+ print_arg (argc, argv);
+
+ if (nodeapp_options.parse_args (argc, argv) != 0)
+ return -1;
+
+ CIAO::NodeApplication_Core nodeapp_core (nodeapp_options);
+
+ if (nodeapp_core.startup (argc, argv) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to start up the NodeApplication_Core\n"), -1);
+
+ // Run the main event loop for the ORB.
+ nodeapp_core.run_orb ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("NodeApp::main\t\n");
+ return 1;
+ }
+
+ if (CIAO::debug_level () > 1)
+ ACE_DEBUG ((LM_DEBUG, "CIAO (%P|%t) - This NodeApplication is destroyed!\n"));
+
+ return 0;
+}
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication.mpc b/CIAO/DAnCE/NodeApplication/NodeApplication.mpc
new file mode 100644
index 00000000000..69c31b3e790
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication.mpc
@@ -0,0 +1,53 @@
+// -*- MPC -*-
+// $Id$
+
+project(NodeApp_Configurator): ciao_deployment_stub {
+ sharedname = CIAO_NodeApp_Configurator
+ dynamicflags = NODEAPP_CONFIGURATOR_BUILD_DLL
+ Source_Files {
+ NodeApp_Configurator.cpp
+ }
+}
+
+project(NoOp_Configurator): ciao_deployment_stub, ciao_nodeapp_configurator {
+ sharedname = CIAO_NoOp_Configurator
+ dynamicflags = NOOP_CONFIGURATOR_BUILD_DLL
+ Source_Files {
+ NoOp_Configurator.cpp
+ }
+}
+
+project(RTNA_Configurator): ciao_deployment_stub, rt_server, ciao_nodeapp_configurator {
+ sharedname = CIAO_RTNA_Configurator
+ dynamicflags = CIAO_RTNA_CONFIGURATOR_BUILD_DLL
+ Source_Files {
+ RTConfig_Manager.cpp
+ }
+}
+
+project(NA_Configurator): ciao_deployment_stub, diffservpolicy, ciao_nodeapp_configurator {
+ sharedname = CIAO_NA_Configurator
+ dynamicflags = CIAO_NA_CONFIGURATOR_BUILD_DLL
+ Source_Files {
+ NAConfig_Manager.cpp
+ }
+}
+
+project(NodeApplicationLib): ciao_server_dnc, ciao_events_dnc, ciao_nodeapp_configurator {
+ sharedname = CIAO_NodeApplication
+ dynamicflags = NODEAPPLICATION_BUILD_DLL
+ Source_Files {
+ Configurator_Factory.cpp
+ Container_Impl.cpp
+ NodeApplication_Core.cpp
+ NodeApplication_Impl.cpp
+ }
+}
+
+project(NodeApplication): ciao_server_dnc, ciao_events_dnc, ciao_nodeapplication, ciaoexe {
+ exename = NodeApplication
+ Source_Files {
+ NodeApplication.cpp
+ }
+}
+
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Core.cpp b/CIAO/DAnCE/NodeApplication/NodeApplication_Core.cpp
new file mode 100644
index 00000000000..de85c365c5f
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Core.cpp
@@ -0,0 +1,255 @@
+// $Id$
+
+#include "DAnCE/Deployment/CIAO_NodeApplication_CallBackC.h"
+#include "ace/Sched_Params.h"
+#include "NodeApplication_Impl.h"
+#include "NodeApplication_Core.h"
+#include "ace/Null_Mutex.h"
+#include "ciao/Server_init.h"
+#include "ciao/CIAO_common.h"
+
+#if !defined (__ACE_INLINE__)
+# include "NodeApplication_Core.inl"
+#endif /* __ACE_INLINE__ */
+
+const char *
+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/
+int
+check_supported_priorities (CORBA::ORB_ptr orb)
+{
+ CIAO_TRACE ("NodeApplication_Core::check_supported_priorities");
+
+ int const sched_policy =
+ 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)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Not enough priority levels with the %s scheduling policy\n"
+ "on this platform to run, terminating program....\n"
+ "Check svc.conf options\n",
+ sched_policy_name (sched_policy)));
+
+ return -1;
+ }
+ return 0;
+}
+
+int
+CIAO::NodeApplication_Core::svc ()
+{
+ CIAO_TRACE ("CIAO::NodeApplication_Core::svc");
+
+ try
+ {
+ 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::NodeApplication_Impl *nodeapp_servant = 0;
+
+ ACE_NEW_RETURN (nodeapp_servant,
+ CIAO::NodeApplication_Impl (this->orb_.in (),
+ root_poa.in (),
+ *this->configurator_.get ()),
+ -1);
+
+ PortableServer::ServantBase_var safe_servant (nodeapp_servant);
+
+ // Configuring NodeApplication.
+ PortableServer::ObjectId_var nodeapp_oid
+ = root_poa->activate_object (nodeapp_servant);
+
+ object = root_poa->id_to_reference (nodeapp_oid.in ());
+
+ Deployment::NodeApplication_var nodeapp_obj =
+ Deployment::NodeApplication::_narrow (object.in ());
+
+ if (CORBA::is_nil (nodeapp_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to activate NodeApplication object\n"),
+ -1);
+
+ /** @@ We need to call NodeApplication servant's init method.
+ * But it's not sure to me where exactly we can get the
+ * Properties needed by the init method at this moment. There are two
+ * ways to set the property of the NodeApplication:
+ * 1. call init remotely from NodeApplicationManager
+ * 2. call init locally on the servant of NodeApplication.
+ */
+ bool retval = nodeapp_servant->init ();
+
+ if (retval)
+ {
+ ACE_DEBUG ((LM_DEBUG, "NodeApplication Failed on creating and\
+ initializing the session container!"));
+ return 1;
+ }
+
+ CORBA::String_var str = this->orb_->object_to_string (nodeapp_obj.in ());
+
+ if (this->options_.write_ior_file ())
+ CIAO::Utility::write_IOR (this->options_.ior_output_filename (),
+ str.in ());
+
+ // End Deployment part
+ if (CIAO::debug_level () > 10)
+ {
+ ACE_DEBUG ((LM_INFO, "NodeApplication IOR: %s\n", str.in ()));
+
+ }
+
+ Deployment::NodeApplicationManager_var nodeapp_man;
+ Deployment::Properties_var prop = new Deployment::Properties;
+
+ if (this->options_.use_callback ())
+ {
+ object = this->orb_->string_to_object (this->options_.callback_ior ());
+
+ CIAO::NodeApplication_Callback_var nam_callback
+ = CIAO::NodeApplication_Callback::_narrow (object.in ());
+
+ Deployment::Properties_out properties_out (prop.out ());
+
+ nodeapp_man
+ = nam_callback->register_node_application (nodeapp_obj.in (),
+ properties_out);
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Running NodeApplication...\n"));
+
+ this->orb_->run ();
+
+ root_poa->destroy (1, 1);
+
+ this->orb_->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught");
+ return -1;
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Exiting NodeApplication...\n"));
+ return 0;
+}
+
+int
+CIAO::NodeApplication_Core::startup (int argc, char *argv[])
+{
+ CIAO_TRACE ("CIAO::NodeApplication_Core::startup");
+
+ // pre-init
+ this->configurator_.reset (this->options_.create_nodeapp_configurator ());
+
+ if (this->configurator_->create_config_managers ())
+ return -1;
+
+ if (this->configurator_->pre_orb_initialize ())
+ return -1;
+
+ // Initialize orb
+ this->orb_ =
+ CORBA::ORB_init (argc,
+ argv,
+ "");
+ CIAO::Server_init (this->orb_.in ());
+
+ return this->configurator_->post_orb_initialize (this->orb_.in ());
+}
+
+int
+CIAO::NodeApplication_Core::run_orb ()
+{
+ CIAO_TRACE ("CIAO::NodeApplication_Core::run_orb");
+
+ // check supported priority before running RT
+ if (this->options_.rt_support () &&
+ check_supported_priorities (this->orb_.in ()) != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR, "ERROR: DISABLE RT SUPPORT\n"), -1);
+ // this->options_.rt_support_ = 0;
+ }
+
+ if (this->options_.rt_support ()) // RT support reuqested
+ {
+
+
+ // 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)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot create thread with scheduling policy %s\n"
+ "because the user does not have the appropriate privileges, terminating program....\n"
+ "Check svc.conf options and/or run as root\n",
+ sched_policy_name (this->orb_->orb_core ()->orb_params ()->ace_sched_policy ())),
+ 2);
+ }
+ else
+ return -1;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "*** Running NodeApplication in RT mode\n"));
+
+ // Wait for task to exit.
+ result =
+ this->wait ();
+ ACE_ASSERT (result != -1);
+
+ ACE_DEBUG ((LM_INFO, "*** Ending NodeApplication\n"));
+ return 0;
+
+ }
+ else
+ return this->svc ();
+}
+
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Core.h b/CIAO/DAnCE/NodeApplication/NodeApplication_Core.h
new file mode 100644
index 00000000000..aceef49209c
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Core.h
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file NodeApplication_Core.h
+ *
+ * $Id$
+ *
+ * An ACE_Task subclass that manages the NodeApplication runtime. We
+ * can run this class as a separate thread, as in the case of RT
+ * support, or as a event driven ORB.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_NODEAPPLICATION_CORE_H
+#define CIAO_NODEAPPLICATION_CORE_H
+#include /**/ "ace/pre.h"
+
+#include "CIAO_NodeApplication_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/ORB_Core.h"
+#include "tao/ORB.h"
+#include "ace/Task.h"
+#include "ace/Auto_Ptr.h"
+#include "Configurator_Factory.h"
+#include "NoOp_Configurator.h"
+
+namespace CIAO
+{
+ /**
+ * @class NodeApplication_Core
+ *
+ * @brief An ACE_Task subclass that allow the ORB thread to be run
+ * as separate thread when RT behaviors are needed.
+ */
+ class NODEAPPLICATION_Export NodeApplication_Core
+ : public virtual ACE_Task_Base
+ {
+ public:
+ NodeApplication_Core (NodeApplication_Options &opts);
+
+ virtual int svc (void);
+
+ int startup (int argc, char *argv[]);
+
+ int run_orb (void);
+
+ protected:
+ CORBA::ORB_var orb_;
+
+ NodeApplication_Options &options_;
+
+ auto_ptr<NodeApp_Configurator> configurator_;
+ };
+
+}
+
+#if defined (__ACE_INLINE__)
+# include "NodeApplication_Core.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_NODEAPPLICAITON_CORE_H */
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Core.inl b/CIAO/DAnCE/NodeApplication/NodeApplication_Core.inl
new file mode 100644
index 00000000000..f1f1e82da0c
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Core.inl
@@ -0,0 +1,9 @@
+// -*- C++ -*-
+// $Id$
+
+ACE_INLINE
+CIAO::NodeApplication_Core::NodeApplication_Core (CIAO::NodeApplication_Options &opts)
+ : options_ (opts)
+{
+}
+
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp
new file mode 100644
index 00000000000..c0e85d79b4a
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp
@@ -0,0 +1,1209 @@
+// $Id$
+
+#include "NodeApplication_Impl.h"
+#include "ace/SString.h"
+#include "Container_Impl.h"
+#include "DAnCE/Deployment/Deployment_EventsC.h"
+#include "ciaosvcs/Events/CIAO_RTEC/CIAO_RTEventC.h"
+
+#if !defined (__ACE_INLINE__)
+# include "NodeApplication_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+CIAO::NodeApplication_Impl::~NodeApplication_Impl (void)
+{
+}
+
+
+CORBA::Long
+CIAO::NodeApplication_Impl::init ()
+{
+ /// @todo initialize this NodeApplication properties
+ return 0;
+}
+
+CORBA::Long
+CIAO::NodeApplication_Impl::create_all_containers (
+ const ::Deployment::ContainerImplementationInfos & container_infos
+ )
+{
+ // Create all the containers here based on the input node_impl_info.
+ CORBA::ULong const len = container_infos.length ();
+
+ for (CORBA::ULong i = 0; i < len; ++i)
+ {
+ // The factory method <create_container> will intialize the container
+ // servant with properties, so we don't need to call <init> on the
+ // container object reference.
+ // Also, the factory method will add the container object reference
+ // to the set for us.
+ ::Deployment::Container_var cref =
+ this->create_container (container_infos[i].container_config);
+
+ // Build the Component_Container_Map
+ for (CORBA::ULong j = 0;
+ j < container_infos[i].impl_infos.length ();
+ ++j)
+ {
+ this->component_container_map_.bind (
+ container_infos[i].impl_infos[j].component_instance_name.in (),
+ ::Deployment::Container::_duplicate (cref.in ()));
+ }
+ }
+
+ return 0;
+}
+
+void
+CIAO::NodeApplication_Impl::finishLaunch (
+ const Deployment::Connections & providedReference,
+ CORBA::Boolean start,
+ CORBA::Boolean add_connection)
+{
+ ACE_UNUSED_ARG (start);
+
+ // If parameter "add_connection" is true, then it means we want to "add"
+ // new connections, other, we remove existing connections
+ this->finishLaunch_i (providedReference, start, add_connection);
+}
+
+void
+CIAO::NodeApplication_Impl::finishLaunch_i (
+ const Deployment::Connections & connections,
+ CORBA::Boolean start,
+ CORBA::Boolean add_connection)
+{
+ ACE_UNUSED_ARG (start);
+
+ try
+ {
+ CORBA::ULong const length = connections.length ();
+
+ // For every connection struct we finish the connection.
+ for (CORBA::ULong i = 0; i < length; ++i)
+ {
+ ACE_CString name = connections[i].instanceName.in ();
+
+ // For ES_to_Consumer connection, we simply call
+ // handle_es_consumer_connection method.
+ //if (connections[i].kind == Deployment::rtecEventConsumer)
+ if (this->_is_es_consumer_conn (connections[i]))
+ {
+ this->handle_es_consumer_connection (
+ connections[i],
+ add_connection);
+ continue;
+ }
+
+ // For other type of connections, we need to fetch the
+ // objref of the source component
+ Component_State_Info comp_state;
+
+ if (this->component_state_map_.find (name, comp_state) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::finishLaunch, "
+ "invalid port name [%s] in instance [%s] \n",
+ connections[i].portName.in (),
+ name.c_str ()));
+ throw Deployment::InvalidConnection ();
+ }
+
+ Components::EventConsumerBase_var consumer;
+
+ Components::CCMObject_var comp = comp_state.objref_;
+
+ if (CORBA::is_nil (comp.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "comp is nil\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ switch (connections[i].kind)
+ {
+ case Deployment::SimplexReceptacle:
+ case Deployment::MultiplexReceptacle:
+ this->handle_facet_receptable_connection (
+ comp.in (),
+ connections[i],
+ add_connection);
+ break;
+
+ case Deployment::EventEmitter:
+ this->handle_emitter_consumer_connection (
+ comp.in (),
+ connections[i],
+ add_connection);
+ break;
+
+ case Deployment::EventPublisher:
+ if (this->_is_publisher_es_conn (connections[i]))
+ this->handle_publisher_es_connection (
+ comp.in (),
+ connections[i],
+ add_connection);
+ else
+ this->handle_publisher_consumer_connection (
+ comp.in (),
+ connections[i],
+ add_connection);
+ break;
+
+ default:
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::finishLaunch_i: "
+ "Unsupported event port type encounted\n"));
+ throw CORBA::NO_IMPLEMENT ();
+ }
+ }
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("NodeApplication_Impl::finishLaunch\t\n");
+ throw;
+ }
+
+}
+
+void
+CIAO::NodeApplication_Impl::ciao_preactivate ()
+{
+ Component_Iterator end = this->component_state_map_.end ();
+ for (Component_Iterator iter (this->component_state_map_.begin ());
+ iter != end;
+ ++iter)
+ {
+ if (((*iter).int_id_).state_ == NEW_BORN)
+ {
+ ((*iter).int_id_).objref_->ciao_preactivate ();
+ }
+
+ ((*iter).int_id_).state_ = PRE_ACTIVE;
+ }
+}
+
+void
+CIAO::NodeApplication_Impl::start ()
+{
+ Component_Iterator end = this->component_state_map_.end ();
+ for (Component_Iterator iter (this->component_state_map_.begin ());
+ iter != end;
+ ++iter)
+ {
+ if (((*iter).int_id_).state_ == PRE_ACTIVE)
+ {
+ ((*iter).int_id_).objref_->ciao_activate ();
+ }
+
+ ((*iter).int_id_).state_ = ACTIVE;
+ }
+}
+
+void
+CIAO::NodeApplication_Impl::ciao_postactivate ()
+{
+ Component_Iterator end = this->component_state_map_.end ();
+ for (Component_Iterator iter (this->component_state_map_.begin ());
+ iter != end;
+ ++iter)
+ {
+ if (((*iter).int_id_).state_ == ACTIVE)
+ {
+ ((*iter).int_id_).objref_->ciao_postactivate ();
+
+ ((*iter).int_id_).state_ = POST_ACTIVE;
+ }
+ }
+}
+
+void
+CIAO::NodeApplication_Impl::ciao_passivate ()
+{
+ Component_Iterator end = this->component_state_map_.end ();
+ for (Component_Iterator iter (this->component_state_map_.begin ());
+ iter != end;
+ ++iter)
+ {
+ ((*iter).int_id_).objref_->ciao_passivate ();
+
+ ((*iter).int_id_).state_ = PASSIVE;
+ }
+ ACE_DEBUG ((LM_DEBUG, "exiting passivate\n"));
+}
+
+Deployment::ComponentInfos *
+CIAO::NodeApplication_Impl::install (
+ const ::Deployment::NodeImplementationInfo & node_impl_info)
+{
+ Deployment::ComponentInfos_var retv;
+ try
+ {
+ // Extract ORB resource def here.
+ this->configurator_.init_resource_manager (node_impl_info.nodeapp_config);
+
+ const ::Deployment::ContainerImplementationInfos container_infos =
+ node_impl_info.impl_infos;
+
+ ACE_NEW_THROW_EX (retv,
+ Deployment::ComponentInfos,
+ CORBA::NO_MEMORY ());
+
+ retv->length (0UL);
+
+ // Call create_all_containers to create all the necessary containers..
+ // @@(GD): The "create_all_containers" mechanism needs to be refined, so
+ // we should always try to reuse existing containers as much as possible!
+ // We need not only factory pattern, but also finder pattern here as well.
+ if (CIAO::debug_level () > 15)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) NodeApplication_Impl.cpp -"
+ "CIAO::NodeApplication_Impl::install -"
+ "creating all the containers. \n"));
+ }
+
+ CORBA::ULong old_set_size = this->container_set_.size ();
+
+ (void) this->create_all_containers (container_infos);
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) NodeApplication_Impl.cpp -"
+ "CIAO::NodeApplication_Impl::install -"
+ "create_all_containers() called.\n"));
+ }
+
+ // For each container, invoke <install> operation, this will return
+ // the ComponentInfo for components installed in each container.
+ // Merge all the returned ComponentInfo, which will be used
+ // as the return value of this method.
+ CORBA::ULong const num_containers = container_infos.length ();
+ for (CORBA::ULong i = 0; i < num_containers; ++i)
+ {
+ Deployment::ComponentInfos_var comp_infos =
+ this->container_set_.at(i+old_set_size)->
+ install (container_infos[i]);
+
+ // Append the return sequence to the *big* return sequence
+ CORBA::ULong curr_len = retv->length ();
+ retv->length (curr_len + comp_infos->length ());
+
+ for (CORBA::ULong j = curr_len; j < retv->length (); j++)
+ retv[j] = comp_infos[j-curr_len];
+ }
+
+ // @@ Maybe we can optimize this. We can come up with a decision later.
+ // Cache a copy of the component object references for all the components
+ // installed on this NodeApplication. I know we can delegates these to the
+ // undelying containers, but in that case, we should loop
+ // all the containers to find the component object reference. - Gan
+ CORBA::ULong const comp_len = retv->length ();
+ for (CORBA::ULong len = 0;
+ len < comp_len;
+ ++len)
+ {
+ Component_State_Info tmp;
+
+ tmp.state_ = NEW_BORN;
+ tmp.objref_ =
+ Components::CCMObject::_duplicate (retv[len].component_ref.in ());
+
+ //Since we know the type ahead of time...narrow is omitted here.
+ if (this->component_state_map_.rebind (
+ retv[len].component_instance_name.in(), tmp))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) NodeApplication_Impl.cpp -"
+ "CIAO::NodeApplication_Impl::install -"
+ "error binding component instance [%s] "
+ "into the map. \n",
+ retv[len].component_instance_name.in ()));
+ throw Deployment::InstallationFailure (
+ "NodeApplication_Imp::install",
+ "Duplicate component instance name");
+ }
+ }
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("CIAO_NodeApplication::install error\t\n");
+ throw;
+ }
+
+ return retv._retn ();
+}
+
+void
+CIAO::NodeApplication_Impl::remove_component (const char * inst_name)
+{
+ ACE_DEBUG ((LM_DEBUG, "NA_I: removing component %s\n",
+ inst_name));
+
+ // Fetch the container object reference from the componet_container_map
+ ::Deployment::Container_var container_ref;
+ if (this->component_container_map_.find (inst_name, container_ref) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::remove_component, "
+ "invalid instance [%s] in the component_container_map.\n",
+ inst_name));
+ throw ::Components::RemoveFailure ();
+ }
+
+ // Remove this component instance from the node application
+ ACE_CString name (inst_name);
+ this->component_container_map_.unbind (name);
+ this->component_state_map_.unbind (name);
+ container_ref->remove_component (inst_name);
+}
+
+void
+CIAO::NodeApplication_Impl::passivate_component (const char * name)
+{
+ Component_State_Info comp_state;
+
+ if (this->component_state_map_.find (name, comp_state) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::passivate_component, "
+ "invalid instance [%s] \n",
+ name));
+ throw Components::RemoveFailure ();
+ }
+
+ if (CORBA::is_nil (comp_state.objref_.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "comp is nil\n"));
+ throw Components::RemoveFailure ();
+ }
+
+ comp_state.objref_->ciao_passivate ();
+}
+
+void
+CIAO::NodeApplication_Impl::activate_component (const char * name)
+{
+ Component_State_Info comp_state;
+
+ if (this->component_state_map_.find (name, comp_state) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::activate_component, "
+ "invalid instance [%s] \n",
+ name));
+ throw Deployment::StartError ();
+ }
+
+ if (CORBA::is_nil (comp_state.objref_.in ()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "comp is nil\n"));
+ throw Deployment::StartError ();
+ }
+
+ comp_state.objref_->ciao_preactivate ();
+
+ comp_state.objref_->ciao_activate ();
+
+ comp_state.objref_->ciao_postactivate ();
+}
+
+
+void
+CIAO::NodeApplication_Impl::remove ()
+{
+ // If we still have components installed, then do nothing
+
+ if (this->component_state_map_.current_size () != 0)
+ return;
+
+ // For each container, invoke <remove> operation to remove home and components.
+ CORBA::ULong const set_size = this->container_set_.size ();
+ for (CORBA::ULong i = 0; i < set_size; ++i)
+ {
+ if (CIAO::debug_level () > 5)
+ {
+ ACE_DEBUG ((LM_DEBUG, "NA: calling remove on container %i\n"));
+ }
+
+ this->container_set_.at(i)->remove ();
+ }
+
+ // Remove all containers
+ // Maybe we should also deactivate container object reference.
+ if (CIAO::debug_level () > 5)
+ {
+ ACE_DEBUG ((LM_DEBUG, "NA: remove all\n"));
+ }
+
+ this->container_set_.remove_all ();
+
+ if (CIAO::debug_level () > 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Removed all containers from this NodeApplication!\n"));
+ }
+
+ // For static deployment, ORB will be shutdown in the Static_NodeManager
+ if (this->static_entrypts_maps_ == 0)
+ {
+ this->orb_->shutdown (0);
+ ACE_DEBUG ((LM_DEBUG, "NA: shutdown\n"));
+ }
+}
+
+
+// Create a container interface, which will be hosted in this NodeApplication.
+::Deployment::Container_ptr
+CIAO::NodeApplication_Impl::create_container (
+ const ::Deployment::Properties &properties)
+{
+ //if (CIAO::debug_level () > 1)
+ // ACE_DEBUG ((LM_DEBUG, "ENTERING: NodeApplication_Impl::create_container()\n"));
+
+ CORBA::PolicyList_var policies
+ = this->configurator_.find_container_policies (properties);
+
+ CIAO::Container_Impl *container_servant = 0;
+
+ ACE_NEW_THROW_EX (container_servant,
+ CIAO::Container_Impl (this->orb_.in (),
+ this->poa_.in (),
+ this->get_objref (),
+ this->configurator_,
+ this->static_entrypts_maps_),
+ CORBA::NO_MEMORY ());
+
+ PortableServer::ServantBase_var safe_servant (container_servant);
+
+ // @TODO: Need to decide a "component_installation" equivalent data
+ // structure to pass to the container, which will be used to
+ // suggest how to install the components. Each such data stucture
+ // should be correspond to one <process_collocation> tag in the XML
+ // file to describe the deployment plan.
+ container_servant->init (policies.ptr ());
+
+ PortableServer::ObjectId_var oid
+ = this->poa_->activate_object (container_servant);
+
+ CORBA::Object_var obj
+ = this->poa_->id_to_reference (oid.in ());
+
+ ::Deployment::Container_var ci
+ = ::Deployment::Container::_narrow (obj.in ());
+
+ // Cached the objref in its servant.
+ container_servant->set_objref (ci.in ());
+
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
+
+ this->container_set_.add (ci.in ());
+ }
+
+ //if (CIAO::debug_level () > 1)
+ // ACE_DEBUG ((LM_DEBUG,
+ // "LEAVING: NodeApplication_Impl::create_container()\n"));
+ return ci._retn ();
+}
+
+// Remove a container interface.
+void
+CIAO::NodeApplication_Impl::remove_container (::Deployment::Container_ptr cref)
+{
+ ACE_DEBUG ((LM_DEBUG, "ENTERING: NodeApplication_Impl::remove_container()\n"));
+ ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
+
+ if (this->container_set_.object_in_set (cref) == 0)
+ {
+ throw Components::RemoveFailure();
+ }
+
+ cref->remove ();
+
+ // @@ Deactivate object.
+ PortableServer::ObjectId_var oid
+ = this->poa_->reference_to_id (cref);
+
+ this->poa_->deactivate_object (oid.in ());
+
+ // Should we remove the server still, even if the previous call failed.
+ if (this->container_set_.remove (cref) == -1)
+ {
+ throw ::Components::RemoveFailure ();
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "LEAVING: NodeApplication_Impl::remove_container()\n"));
+}
+
+// Get containers
+::Deployment::Containers *
+CIAO::NodeApplication_Impl::get_containers ()
+{
+ return 0;
+}
+
+CIAO::CIAO_Event_Service *
+CIAO::NodeApplication_Impl::
+install_es (const ::CIAO::DAnCE::EventServiceDeploymentDescription & es_info)
+{
+ try
+ {
+ ACE_DEBUG ((LM_DEBUG, "\nNodeApplication_Impl::install_es() called.\n\n"));
+
+ CIAO_Event_Service_var ciao_es =
+ es_factory_.create (es_info.type, es_info.name.in ());
+
+ // Set up the event channel federations
+ if (es_info.type == CIAO::RTEC)
+ {
+ // Narrow the event service to CIAO_RT_Event_Service
+ ::CIAO::CIAO_RT_Event_Service_var ciao_rtes =
+ ::CIAO::CIAO_RT_Event_Service::_narrow (ciao_es.in ());
+
+ if (CORBA::is_nil (ciao_rtes.in ()))
+ throw ::Deployment::InstallationFailure ();
+
+ // Set up the event channel federations
+ for (CORBA::ULong j = 0; j < es_info.addr_servs.length (); ++j)
+ {
+ bool retv =
+ ciao_rtes->create_addr_serv (
+ es_info.addr_servs[j].name.in (),
+ es_info.addr_servs[j].port,
+ es_info.addr_servs[j].address);
+
+ if (retv == false)
+ {
+ ACE_DEBUG ((LM_ERROR, "RTEC failed to create addr serv object\t\n"));
+ throw ::Deployment::InstallationFailure ();
+ }
+ }
+
+ for (CORBA::ULong j = 0; j < es_info.senders.length (); ++j)
+ {
+ bool retv =
+ ciao_rtes->create_sender (
+ es_info.senders[j].addr_serv_id.in ());
+
+ if (retv == false)
+ {
+ ACE_DEBUG ((LM_ERROR, "RTEC failed to create UDP sender object\t\n"));
+ throw ::Deployment::InstallationFailure ();
+ }
+ }
+
+ for (CORBA::ULong j = 0; j < es_info.receivers.length (); ++j)
+ {
+ bool retv =
+ ciao_rtes->create_receiver (
+ es_info.receivers[j].addr_serv_id.in (),
+ es_info.receivers[j].is_multicast,
+ es_info.receivers[j].listen_port);
+
+ if (retv == false)
+ {
+ ACE_DEBUG ((LM_ERROR, "RTEC failed to create UDP receiver object\t\n"));
+ throw ::Deployment::InstallationFailure ();
+ }
+ }
+ }
+ return ciao_es._retn ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("NodeApplication_Impl::finishLaunch\t\n");
+ throw ::Deployment::InstallationFailure ();
+ }
+
+}
+
+
+ACE_CString *
+CIAO::NodeApplication_Impl::
+create_connection_key (const Deployment::Connection & connection)
+{
+ ACE_CString * retv;
+ ACE_NEW_RETURN (retv, ACE_CString, 0);
+
+ (*retv) += connection.instanceName.in ();
+ (*retv) += connection.portName.in ();
+ (*retv) += connection.endpointInstanceName.in ();
+ (*retv) += connection.endpointPortName.in ();
+
+ if (CIAO::debug_level () > 3)
+ ACE_ERROR ((LM_ERROR, "The key is: %s\n", (*retv).c_str ()));
+
+ return retv;
+}
+
+
+void
+CIAO::NodeApplication_Impl::
+handle_facet_receptable_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection)
+{
+ if (CIAO::debug_level () > 11)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::finishLaunch, "
+ "working on port name [%s] in instance [%s] \n",
+ connection.portName.in (),
+ connection.instanceName.in ()));
+ }
+
+ if (add_connection)
+ {
+ ::Components::Cookie_var cookie =
+ comp->connect (connection.portName.in (),
+ connection.endpoint.in ());
+
+ ACE_CString key = (*create_connection_key (connection));
+ if (CIAO::debug_level () > 10)
+ {
+ ACE_ERROR ((LM_ERROR, "[BINDING KEY]: %s\n", key.c_str ()));
+ }
+ this->cookie_map_.rebind (key, cookie);
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::finishLaunch\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] connected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+ else
+ {
+ ACE_CString key = (*create_connection_key (connection));
+ ::Components::Cookie_var cookie;
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_ERROR ((LM_ERROR, "[FINDING KEY]: %s\n", key.c_str ()));
+ }
+ if (this->cookie_map_.find (key, cookie) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Cookie Not Found!\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ comp->disconnect (connection.portName.in (),
+ cookie.in ());
+ this->cookie_map_.unbind (key);
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::finishLaunch\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] disconnected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+}
+
+
+void
+CIAO::NodeApplication_Impl::
+handle_emitter_consumer_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection)
+{
+ Components::EventConsumerBase_var consumer =
+ Components::EventConsumerBase::_narrow (connection.endpoint.in ());
+
+ if (CORBA::is_nil (consumer.in ()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_emitter_consumer_connection, "
+ "for port name [%s] in instance [%s] ,"
+ "there is an invalid endPoint. \n",
+ connection.portName.in (),
+ connection.instanceName.in ()));
+ throw Deployment::InvalidConnection ();
+ }
+
+ if (CIAO::debug_level () > 11)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_emitter_consumer_connection, "
+ "working on port name [%s] in instance [%s] \n",
+ connection.portName.in (),
+ connection.instanceName.in ()));
+ }
+
+ if (add_connection)
+ {
+ comp->connect_consumer (connection.portName.in (),
+ consumer.in ());
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_emitter_consumer_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] connected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+ else
+ {
+// Operation not implemented by the CIDLC.
+// comp->disconnect_consumer (connection.portName.in (),
+// 0
+//);
+// ACE_TRY_CHECK;
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_emitter_consumer_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] disconnected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+}
+
+
+void
+CIAO::NodeApplication_Impl::
+handle_publisher_consumer_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection)
+{
+ Components::EventConsumerBase_var consumer =
+ Components::EventConsumerBase::_narrow (connection.endpoint.in ());
+
+ if (CORBA::is_nil (consumer.in ()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_consumer_connection, "
+ "for port name [%s] in instance [%s] ,"
+ "there is an invalid endPoint. \n",
+ connection.portName.in (),
+ connection.instanceName.in ()));
+ throw Deployment::InvalidConnection ();
+ }
+
+ if (CIAO::debug_level () > 11)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_consumer_connection, "
+ "working on port name [%s] in instance [%s] \n",
+ connection.portName.in (),
+ connection.instanceName.in ()));
+ }
+
+ if (add_connection)
+ {
+ ::Components::Cookie_var cookie =
+ comp->subscribe (connection.portName.in (),
+ consumer.in ());
+
+ ACE_CString key = (*create_connection_key (connection));
+ this->cookie_map_.rebind (key, cookie);
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_consumer_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] connected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+ else // remove the connection
+ {
+ ACE_CString key = (*create_connection_key (connection));
+ ::Components::Cookie_var cookie;
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_ERROR ((LM_ERROR, "[FINDING KEY]: %s\n", key.c_str ()));
+ }
+ if (this->cookie_map_.find (key, cookie) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Cookie Not Found!\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ comp->unsubscribe (connection.portName.in (),
+ cookie.in ());
+ this->cookie_map_.unbind (key);
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_consumer_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] disconnected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+}
+
+
+void
+CIAO::NodeApplication_Impl::
+handle_publisher_es_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection)
+{
+ if (! this->_is_publisher_es_conn (connection))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_es_connection: "
+ "Unsupported event connection type\n"));
+ throw CORBA::NO_IMPLEMENT ();
+ }
+
+ const CIAO::CIAO_Event_Service_ptr event_service =
+ connection.event_service;
+
+ if (CORBA::is_nil (event_service))
+ {
+ ACE_DEBUG ((LM_DEBUG, "Nil event_service\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ // supplier ID
+ ACE_CString sid (connection.instanceName.in ());
+ sid += "_";
+ sid += connection.portName.in ();
+
+ if (add_connection)
+ {
+ ::Components::Cookie_var cookie =
+ comp->subscribe (connection.portName.in (),
+ event_service);
+
+ ACE_CString key = (*create_connection_key (connection));
+ this->cookie_map_.rebind (key, cookie);
+
+ // Create a supplier_config and register it to ES
+ CIAO::Supplier_Config_var supplier_config =
+ event_service->create_supplier_config ();
+
+ supplier_config->supplier_id (sid.c_str ());
+ event_service->connect_event_supplier (supplier_config.in ());
+ supplier_config->destroy ();
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_es_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] connected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+ else // remove the connection
+ {
+ ACE_CString key = (*create_connection_key (connection));
+ ::Components::Cookie_var cookie;
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_ERROR ((LM_ERROR, "[FINDING KEY]: %s\n", key.c_str ()));
+ }
+ if (this->cookie_map_.find (key, cookie) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Cookie Not Found!\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ comp->unsubscribe (connection.portName.in (),
+ cookie.in ());
+ this->cookie_map_.unbind (key);
+ event_service->disconnect_event_supplier (sid.c_str ());
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_publisher_es_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] disconnected.\n",
+ connection.instanceName.in (),
+ connection.portName.in (),
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in ()));
+ }
+ }
+}
+
+
+void
+CIAO::NodeApplication_Impl::
+handle_es_consumer_connection (
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection)
+{
+ if (! this->_is_es_consumer_conn (connection))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_es_consumer_connection: "
+ "Unsupported event connection type\n"));
+ throw CORBA::NO_IMPLEMENT ();
+ }
+
+ // Get ES object
+ const CIAO::CIAO_Event_Service_ptr event_service =
+ connection.event_service;
+
+ if (CORBA::is_nil (event_service))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_es_consumer_connection: "
+ "NIL event_service\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ // Get consumer object
+ Components::EventConsumerBase_var consumer =
+ Components::EventConsumerBase::_narrow (connection.endpoint.in ());
+
+ if (CORBA::is_nil (consumer.in ()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_es_consumer_connection: "
+ "Nil consumer port object reference\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ // consumer ID
+ ACE_CString cid (connection.instanceName.in ());
+ cid += "_";
+ cid += connection.portName.in ();
+ cid += "_consumer";
+
+ if (add_connection)
+ {
+ CIAO::Consumer_Config_var consumer_config =
+ event_service->create_consumer_config ();
+
+ consumer_config->consumer_id (cid.c_str ());
+ consumer_config->consumer (consumer.in ());
+
+ // Need to setup a filter, if it's specified in the descriptor
+ for (CORBA::ULong i = 0; i < connection.config.length (); ++i)
+ {
+ if (ACE_OS::strcmp (connection.config[i].name.in (),
+ "EventFilter") != 0)
+ continue;
+
+ // Extract the filter information
+ CIAO::DAnCE::EventFilter *filter = 0;
+ connection.config[i].value >>= filter;
+
+ CORBA::ULong size = (*filter).sources.length ();
+
+ if ((*filter).type == DAnCE::CONJUNCTION)
+ consumer_config->start_conjunction_group (size);
+ else if ((*filter).type == DAnCE::DISJUNCTION)
+ consumer_config->start_disjunction_group (size);
+
+ for (CORBA::ULong j = 0; j < size; ++j)
+ {
+ consumer_config->insert_source ((*filter).sources[j]);
+ }
+ }
+
+ event_service->connect_event_consumer (consumer_config.in ());
+ consumer_config->destroy ();
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_es_consumer_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] connected.\n",
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in (),
+ connection.instanceName.in (),
+ connection.portName.in ()));
+ }
+ }
+ else // remove the connection
+ {
+ event_service->disconnect_event_consumer (cid.c_str ());
+
+ if (CIAO::debug_level () > 6)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO (%P|%t) - NodeApplication_Impl.cpp, "
+ "CIAO::NodeApplication_Impl::handle_es_consumer_connection\n"
+ "[INSTANCE:PORT] : [%s:%s] --> [%s:%s] disconnected.\n",
+ connection.endpointInstanceName.in (),
+ connection.endpointPortName.in (),
+ connection.instanceName.in (),
+ connection.portName.in ()));
+ }
+ }
+}
+
+// Below code is not used at this time.
+void
+CIAO::NodeApplication_Impl::build_event_connection (
+ const Deployment::Connection & connection,
+ bool add_or_remove)
+{
+ ACE_DEBUG ((LM_DEBUG, "CIAO::NodeApplication_Impl::build_connection ()!!!\n"));
+
+ ACE_DEBUG ((LM_DEBUG, "instanceName: %s\n", connection.instanceName.in ()));
+ ACE_DEBUG ((LM_DEBUG, "portName: %s\n", connection.portName.in ()));
+
+ ACE_DEBUG ((LM_DEBUG, "consumer Component Name: %s\n", connection.endpointInstanceName.in ()));
+ ACE_DEBUG ((LM_DEBUG, "consumer Port Name: %s\n", connection.endpointPortName.in ()));
+
+ ACE_DEBUG ((LM_DEBUG, "portkind: "));
+ switch (connection.kind) {
+ case Deployment::Facet: ACE_DEBUG ((LM_DEBUG, "Facet\n")); break;
+ case Deployment::SimplexReceptacle: ACE_DEBUG ((LM_DEBUG, "SimplexReceptacle\n")); break;
+ case Deployment::MultiplexReceptacle: ACE_DEBUG ((LM_DEBUG, "MultiplexReceptacle\n")); break;
+ case Deployment::EventEmitter: ACE_DEBUG ((LM_DEBUG, "EventEmitter\n")); break;
+ case Deployment::EventPublisher: ACE_DEBUG ((LM_DEBUG, "EventPublisher\n")); break;
+ case Deployment::EventConsumer: ACE_DEBUG ((LM_DEBUG, "EventConsumer\n")); break;
+ default:
+ ACE_DEBUG ((LM_DEBUG, "Unknow\n")); break;
+ }
+
+ const CIAO::CIAO_Event_Service_ptr event_service =
+ connection.event_service;
+
+
+ // Get the consumer port object reference and put it into "consumer"
+ Components::EventConsumerBase_var consumer =
+ Components::EventConsumerBase::_narrow (connection.endpoint.in ());
+
+ if (CORBA::is_nil (consumer.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "Nil consumer port object reference\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ // Get the supplier component object reference.
+ ACE_CString supplier_comp_name = connection.instanceName.in ();
+
+ ACE_DEBUG ((LM_DEBUG, "source component name is: %s\n", supplier_comp_name.c_str ()));
+ Component_State_Info comp_state;
+ if (this->component_state_map_.find (supplier_comp_name, comp_state) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Nil source component object reference\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ // Get the consumer component object reference.
+ ACE_CString consumer_comp_name = connection.endpointInstanceName.in ();
+
+ ACE_DEBUG ((LM_DEBUG, "consumer component name is: %s\n", consumer_comp_name.c_str ()));
+
+ if (CORBA::is_nil (event_service))
+ {
+ ACE_DEBUG ((LM_DEBUG, "Nil event_service\n"));
+ throw Deployment::InvalidConnection ();
+ }
+
+ // supplier ID
+ ACE_CString sid (connection.instanceName.in ());
+ sid += "_";
+ sid += connection.portName.in ();
+
+ // consumer ID
+ ACE_CString cid (connection.endpointInstanceName.in ());
+ cid += "_";
+ cid += connection.endpointPortName.in ();
+ cid += "_consumer";
+
+ //ACE_DEBUG ((LM_DEBUG, "Publisher: %s\n", sid.c_str ()));
+ ACE_DEBUG ((LM_DEBUG, "Subscriber: %s\n", cid.c_str ()));
+
+
+ if (add_or_remove == true)
+ {
+ CIAO::Supplier_Config_var supplier_config =
+ event_service->create_supplier_config ();
+
+ supplier_config->supplier_id (sid.c_str ());
+ event_service->connect_event_supplier (supplier_config.in ());
+ supplier_config->destroy ();
+
+ CIAO::Consumer_Config_var consumer_config =
+ event_service->create_consumer_config ();
+
+ consumer_config->consumer_id (cid.c_str ());
+ consumer_config->consumer (consumer.in ());
+
+ event_service->connect_event_consumer (consumer_config.in ());
+
+ consumer_config->destroy ();
+ }
+ else
+ {
+ event_service->disconnect_event_supplier (sid.c_str ());
+ event_service->disconnect_event_consumer (cid.c_str ());
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "CIAO::NodeApplication_Impl::build_connection () completed!!!!\n"));
+}
+
+bool
+CIAO::NodeApplication_Impl::
+_is_es_consumer_conn (Deployment::Connection conn)
+{
+ if (conn.kind == Deployment::EventConsumer &&
+ ACE_OS::strcmp (conn.endpointPortName, "CIAO_ES") == 0)
+ return true;
+ else
+ return false;
+}
+
+bool
+CIAO::NodeApplication_Impl::
+_is_publisher_es_conn (Deployment::Connection conn)
+{
+ if (conn.kind == Deployment::EventPublisher &&
+ ACE_OS::strcmp (conn.endpointPortName, "CIAO_ES") == 0)
+ return true;
+ else
+ return false;
+}
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h
new file mode 100644
index 00000000000..70d5c1ee0fd
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h
@@ -0,0 +1,315 @@
+//$Id$
+
+/**========================================================
+ *
+ * @file NodeApplication_Impl.h
+ *
+ * @Brief This file contains the implementation of
+ * the NodeApplication interface.
+ *
+ * @author Tao Lu <lu@dre.vanderbilt.edu>
+ * @author Gan Deng <dengg@dre.vanderbilt.edu>
+ *========================================================*/
+
+#ifndef NODEAPPLICATION_IMPL_H
+#define NODEAPPLICATION_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "CIAO_NodeApplication_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Synch.h"
+#include "ace/Synch_Traits.h"
+#include "ace/SString.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "tao/ORB.h"
+#include "DAnCE/Deployment/Deployment_NodeApplicationS.h"
+#include "ciao/Server_init.h"
+#include "ciao/CIAO_common.h"
+#include "ciao/Object_Set_T.h"
+#include "ciaosvcs/Events/CIAO_EventService_Factory_impl.h"
+#include "ciaosvcs/Events/CIAO_Events_Base/CIAO_EventsS.h"
+
+#include "NodeApp_Configurator.h"
+#include "Session_Container.h"
+
+using CIAO::Utility::write_IOR;
+
+/**
+ *
+ * @class NodeApplication_Impl
+ *
+ * @brief This class implements the NodeApplication interface.
+ * This interface is semantically very simillar to container
+ * in the old DnC spec. However this class will also be used
+ * as a Server for hosting home/component. This way we reduce the
+ * complexity of the framework by omitting the componentserver layer.
+ *
+ * @@TODO add configuration capabilities. Threading is one of them.
+ *
+ * @@Assumptions:
+ * 1. Now the implementation is not thread safe.
+ * // @@Gan, the above assumption is _really_ bad. Could you please
+ * use the lock in the imeplementation to do some simple
+ * prootections.
+ **/
+
+namespace CIAO
+{
+ // @@ Gan, as we discussed before can you please wrap this
+ // implementation in a namespace Node_Application or whatever to
+ // signify that it belongs to another software piece of CIAO?
+ class NODEAPPLICATION_Export NodeApplication_Impl
+ : public virtual POA_Deployment::NodeApplication
+ {
+ public:
+ enum Component_State
+ {
+ NEW_BORN, PRE_ACTIVE, ACTIVE, POST_ACTIVE, PASSIVE, DEACTIVATED
+ };
+
+ typedef struct _component_state_info
+ {
+ Components::CCMObject_var objref_;
+ Component_State state_;
+ } Component_State_Info;
+
+ NodeApplication_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ NodeApp_Configurator &c,
+ const Static_Config_EntryPoints_Maps* static_entrypts_maps =0);
+
+ /// Default destructor.
+ virtual ~NodeApplication_Impl (void);
+
+ /**
+ * @brief This operation dose 2 things.
+ * 1. Get the external connction (facet and Event source)
+ * and connect them to the local receptacle/event sink.
+ * 2. If the start augment is true, start the Components.
+ * @Note:
+ * The connection containes the object ref of the provided object
+ * reference (facet/event consumer) of components from other NodeApplications.
+ * However the name field stores the name of the port on the local component.
+ */
+ virtual void
+ finishLaunch (const Deployment::Connections & connections,
+ CORBA::Boolean start,
+ CORBA::Boolean add_connection);
+
+ virtual void start ();
+
+ /*------------- CIAO specific IDL operations (idl)----------
+ *
+ *-----------------------------------------------------------*/
+
+ virtual void ciao_preactivate ();
+
+ virtual void ciao_postactivate ();
+
+ virtual void ciao_passivate ();
+
+ /// Initialize the NodeApplication
+ virtual CORBA::Long init ();
+
+ /// Start install homes and components.
+ virtual ::Deployment::ComponentInfos *
+ install (const ::Deployment::NodeImplementationInfo & node_impl_info);
+
+ /// Install a number of CIAO_Event_Service objects within the NA
+ virtual ::CIAO::CIAO_Event_Service *
+ install_es (const ::CIAO::DAnCE::EventServiceDeploymentDescription & es_info);
+
+ /// Get the object reference of the NodeApplicationManager.
+ /// This might come in handy later.
+ virtual ::CORBA::Object_ptr get_node_application_manager ();
+
+ /// Access the readonly attribute.
+ virtual ::Deployment::Properties * properties ();
+
+ /// Remove a component instance from the NodeApplication
+ virtual void remove_component (const char * inst_name);
+
+ virtual void activate_component (const char * name);
+
+ virtual void passivate_component (const char * name);
+
+ /// Remove everything inside including all components and homes.
+ virtual void remove ();
+
+ /// Create a container interface, which will be hosted in this NodeApplication.
+ virtual ::Deployment::Container_ptr
+ create_container (const ::Deployment::Properties &properties);
+
+ /// Remove a container interface.
+ virtual void remove_container (::Deployment::Container_ptr cref);
+
+ /// Get all container object refs
+ virtual ::Deployment::Containers * get_containers ();
+
+ /*------------- CIAO specific helper functions (C++)---------
+ *
+ *-----------------------------------------------------------*/
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /// Return the cached object reference of this NodeApplication object.
+ /// This operation does *NOT* increase the reference count.
+ ::Deployment::NodeApplication_ptr
+ get_objref ();
+
+ /*------- CIAO helper functions for pub/sub service -------
+ *
+ *--------------------------------------------------------*/
+
+ /// Set up a connection using the CIAO_Event_Service, which
+ /// is available as a field in the <Deployment::Connection>
+ /// struct type.
+ /// If <add_or_remove> input parameter is true, then we will
+ /// add the event connection, otherwise we will remove the
+ /// event connection.
+ void build_event_connection (
+ const Deployment::Connection & connection,
+ bool add_or_remove);
+
+ protected:
+ /// If <add_connection> is "false", then we shall "remove"
+ /// the connections, otherwise we will add these connections.
+ virtual void
+ finishLaunch_i (const Deployment::Connections & connections,
+ CORBA::Boolean start,
+ CORBA::Boolean add_connection);
+ virtual void
+ handle_facet_receptable_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection);
+
+ virtual void
+ handle_emitter_consumer_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection);
+
+ virtual void
+ handle_publisher_consumer_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection);
+
+ virtual bool
+ _is_es_consumer_conn (Deployment::Connection conn);
+
+ virtual bool
+ _is_publisher_es_conn (Deployment::Connection conn);
+
+ /// Register the publisher to the CIAO event service
+ /// The only fields of <connection> struct used in this method
+ /// are: <type>, <event_service>, <instanceName>, <portName>.
+ virtual void
+ handle_publisher_es_connection (
+ Components::CCMObject_ptr comp,
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection);
+
+ /// Register the consumer to the CIAO event service
+ virtual void
+ handle_es_consumer_connection (
+ const Deployment::Connection & connection,
+ CORBA::Boolean add_connection);
+
+ /// Create and initialize all the containers
+ virtual CORBA::Long create_all_containers (
+ const ::Deployment::ContainerImplementationInfos & container_infos);
+
+ /// Create a "key" for the connection
+ virtual ACE_CString *
+ create_connection_key (const Deployment::Connection & connection);
+
+ /// To build a map between a component instance and its container
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Deployment::Container_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> Component_Container_Map;
+ typedef Component_Container_Map::iterator Component_Container_Iterator;
+ Component_Container_Map component_container_map_;
+
+
+ /// To store all created Component objects as well as their lifecycle
+ /// states..
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Component_State_Info,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> CCMComponent_Map;
+ typedef CCMComponent_Map::iterator Component_Iterator;
+ CCMComponent_Map component_state_map_;
+
+ /// A Map which stores all the connection cookies
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ ::Components::Cookie_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> Cookie_Map;
+ typedef Cookie_Map::iterator Cookie_Map_Iterator;
+ Cookie_Map cookie_map_;
+
+ /// Synchronize access to the object set.
+ TAO_SYNCH_MUTEX lock_;
+
+ /// Keep a list of managed Container objects.
+ Object_Set<Deployment::Container, Deployment::Container_var> container_set_;
+
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ // @@Gan/Jai, which POA is this? Same as the component POA or a
+ // different one. My sense is that its different. Could you please
+ //document it?
+ PortableServer::POA_var poa_;
+
+ // Configurator for allocating NodeApp resources and policies
+ NodeApp_Configurator &configurator_;
+
+ /// Cached properties
+ Deployment::Properties properties_;
+
+ /// And a reference to the NodeApplicationManager that created us.
+ ::CORBA::Object_var node_app_manager_;
+
+ /// Cache the object reference (of ourselves).
+ ::Deployment::NodeApplication_var objref_;
+
+ /// A factory to create CIAO event services
+ EventService_Factory_impl es_factory_;
+
+ /// Cache the (NA specific) installation info of all the
+ /// CIAO_Event_Services
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ DAnCE::EventServiceDeploymentDescriptions_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> ES_Installation_Map;
+ typedef ES_Installation_Map::iterator ES_Installation_Map_Iterator;
+ ES_Installation_Map es_info_map_;
+
+ const Static_Config_EntryPoints_Maps* static_entrypts_maps_;
+ private:
+ /// Default constructor, noop
+ NodeApplication_Impl(void);
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "NodeApplication_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* NODEAPPLICATION_IMPL_H */
diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.inl b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.inl
new file mode 100644
index 00000000000..07438304994
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.inl
@@ -0,0 +1,75 @@
+/* -*- C++ -*- */
+// $Id$
+#include "Configurator_Factory.h"
+
+ACE_INLINE
+CIAO::NodeApplication_Impl::
+NodeApplication_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ NodeApp_Configurator &c,
+ const Static_Config_EntryPoints_Maps* static_entrypts_maps)
+ : orb_ (CORBA::ORB::_duplicate (o)),
+ poa_ (PortableServer::POA::_duplicate (p)),
+ configurator_ (c),
+ es_factory_ (o, p),
+ static_entrypts_maps_ (static_entrypts_maps)
+{
+}
+
+// Access the readonly attribute
+ACE_INLINE
+Deployment::Properties *
+CIAO::NodeApplication_Impl::properties ()
+{
+ Deployment::Properties * tmp = 0;
+
+ ACE_NEW_THROW_EX (tmp,
+ Deployment::Properties (this->properties_),
+ CORBA::NO_MEMORY ());
+
+ return tmp;
+}
+
+ACE_INLINE
+PortableServer::POA_ptr
+CIAO::NodeApplication_Impl::_default_POA (void)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+
+ACE_INLINE
+CORBA::Object_ptr
+CIAO::NodeApplication_Impl::get_node_application_manager ()
+{
+ return ::CORBA::Object::_duplicate (this->node_app_manager_.in ());
+}
+
+/*
+ACE_INLINE void
+CIAO::NodeApplication_Impl::
+set_objref (Components::Deployment::ServerActivator_ptr act,
+ const Components::ConfigValues &config,
+ Components::Deployment::ComponentServer_ptr cs)
+{
+ if (!CORBA::is_nil (this->node_app_manager_.in ()) ||
+ !CORBA::is_nil (this->objref_.in ()))
+ throw CORBA::BAD_INV_ORDER ();
+
+ this->config_ = new Components::ConfigValues (config);
+ this->activator_ = Components::Deployment::ServerActivator::_duplicate (act);
+ this->objref_ = Components::Deployment::ComponentServer::_duplicate (cs);
+}
+*/
+
+ACE_INLINE ::Deployment::NodeApplication_ptr
+CIAO::NodeApplication_Impl::
+get_objref ()
+{
+ if (CORBA::is_nil (this->objref_.in ()))
+ {
+ this->objref_ = this->_this ();
+ }
+
+ return this->objref_.in ();
+}
diff --git a/CIAO/DAnCE/NodeApplication/RTConfig_Manager.cpp b/CIAO/DAnCE/NodeApplication/RTConfig_Manager.cpp
new file mode 100644
index 00000000000..0f400349237
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/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::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::RTResource_Config_Manager::pre_orb_initialize (void)
+{
+ return 0;
+}
+
+int
+CIAO::RTResource_Config_Manager::post_orb_initialize (CORBA::ORB_ptr)
+{
+ return 0;
+}
+
+void
+CIAO::RTResource_Config_Manager::print_resources
+(const CIAO::DAnCE::ServerResource &server_resource)
+{
+ const CIAO::DAnCE::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)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "-RTResource_Config_Manager::print_resource threadpool: %s\n"
+ "\tStack size: %d\n"
+ "\tStatic: %d\n"
+ "\tDynamic %d\n"
+ "\tDefault Prio: %d\n"
+ "\tBuffering %s\n"
+ "\tMax Buffered: %d\n"
+ "\tBuffer Size %d\n",
+ orb_resource.threadpool_list[i].Id.in (),
+ orb_resource.threadpool_list[i].stacksize,
+ orb_resource.threadpool_list[i].static_threads,
+ orb_resource.threadpool_list[i].dynamic_threads,
+ orb_resource.threadpool_list[i].default_priority,
+ (orb_resource.threadpool_list[i].allow_request_buffering ? "Y" : "N"),
+ orb_resource.threadpool_list[i].max_buffered_requests,
+ orb_resource.threadpool_list[i].max_request_buffer_size));
+ }
+
+ for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "-RTResource_Config_Manager::print_resource threadpool_with %d, lanes: %s\n",
+ orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (),
+ orb_resource.threadpool_with_lanes_list[i].Id.in ()));
+
+ for (CORBA::ULong l = 0;
+ l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ();
+ ++l)
+ {
+ ACE_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));
+ }
+ ACE_DEBUG ((LM_DEBUG,
+ "\tStack size: %d\n"
+ "\tBorrowing: %s\n"
+ "\tBuffering %s\n"
+ "\tMax Buffered: %d\n"
+ "\tBuffer Size %d\n",
+ orb_resource.threadpool_with_lanes_list[i].stacksize,
+ (orb_resource.threadpool_with_lanes_list[i].allow_borrowing ? "Y" : "N"),
+ (orb_resource.threadpool_with_lanes_list[i].allow_request_buffering ? "Y" : "N"),
+ orb_resource.threadpool_with_lanes_list[i].max_buffered_requests,
+ orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size));
+ }
+
+ for (i = 0; i < orb_resource.connection_bands_list.length (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "-RTResource_Config_Manager::print_resource connection %d bands: %s\n",
+ orb_resource.connection_bands_list[i].bands.length (),
+ orb_resource.connection_bands_list[i].Id.in ()));
+
+ for (CORBA::ULong l = 0;
+ l < orb_resource.connection_bands_list[i].bands.length ();
+ ++l)
+ {
+ ACE_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::RTResource_Config_Manager::init_resources
+(const CIAO::DAnCE::ServerResource &server_resource)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource.\n"));
+
+ if (CORBA::is_nil (this->rtorb_.in()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "RTResource_Config_Manager has not been properly initialized.\n"));
+ throw CORBA::INTERNAL ();
+ }
+
+ this->print_resources (server_resource);
+ // return;
+
+ const CIAO::DAnCE::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)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource threadpool: %s\n",
+ orb_resource.threadpool_list[i].Id.in ()));
+ RTCORBA::ThreadpoolId thr_id =
+ this->rtorb_->create_threadpool
+ (orb_resource.threadpool_list[i].stacksize,
+ orb_resource.threadpool_list[i].static_threads,
+ orb_resource.threadpool_list[i].dynamic_threads,
+ orb_resource.threadpool_list[i].default_priority,
+ orb_resource.threadpool_list[i].allow_request_buffering,
+ orb_resource.threadpool_list[i].max_buffered_requests,
+ orb_resource.threadpool_list[i].max_request_buffer_size);
+ // Simply pass back the exception here
+ // for now. We need to have a better way
+ // to handle execption here.
+ if (this->threadpool_map_.bind (orb_resource.threadpool_list[i].Id.in (),
+ thr_id) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Error binding thread pool Id: %s to map when initializing RTNodeApplication resources.\n", orb_resource.threadpool_list[i].Id.in ()));
+ throw CORBA::INTERNAL ();
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource added thread pool: %s\n",
+ orb_resource.threadpool_list[i].Id.in ()));
+ }
+ }
+
+ for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource threadpool_with %d, lanes: %s\n",
+ orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (),
+ orb_resource.threadpool_with_lanes_list[i].Id.in ()));
+
+ // Duplicate RTCORBA lanes
+ RTCORBA::ThreadpoolLanes lanes
+ (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ());
+ lanes.length (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ());
+
+ for (CORBA::ULong l = 0;
+ l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ();
+ ++l)
+ {
+ lanes[l].lane_priority
+ = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority;
+ lanes[l].static_threads
+ = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads;
+ lanes[l].dynamic_threads
+ = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads;
+ }
+
+ RTCORBA::ThreadpoolId thr_id =
+ this->rtorb_->create_threadpool_with_lanes
+ (orb_resource.threadpool_with_lanes_list[i].stacksize,
+ lanes,
+ orb_resource.threadpool_with_lanes_list[i].allow_borrowing,
+ orb_resource.threadpool_with_lanes_list[i].allow_request_buffering,
+ orb_resource.threadpool_with_lanes_list[i].max_buffered_requests,
+ orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size);
+ // Simply pass back the exception here
+ // for now. We need to have a better way
+ // to handle execption here.
+
+ if (this->threadpool_map_.bind (orb_resource.threadpool_with_lanes_list[i].Id.in (),
+ thr_id) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error binding thread pool name: %s to map when "
+ "initializing RTNodeApplication resources.\n",
+ orb_resource.threadpool_with_lanes_list[i].Id.in ()));
+ throw CORBA::INTERNAL ();
+ }
+
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource added thread pool with lanes: %s\n",
+ orb_resource.threadpool_with_lanes_list[i].Id.in ()));
+ }
+ }
+
+ for (i = 0; i < orb_resource.connection_bands_list.length (); ++i)
+ {
+ RTCORBA::PriorityBands
+ safebands(orb_resource.connection_bands_list[i].bands.length ());
+ safebands.length (orb_resource.connection_bands_list[i].bands.length ());
+
+ for (CORBA::ULong l = 0;
+ l < orb_resource.connection_bands_list[i].bands.length ();
+ ++l)
+ {
+ safebands[l].low = orb_resource.connection_bands_list[i].bands[l].low;
+ safebands[l].high = orb_resource.connection_bands_list[i].bands[l].high;
+ }
+
+ if (this->priority_bands_map_.bind (orb_resource.connection_bands_list[i].Id.in (),
+ safebands) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error binding priority bands name: %s to map "
+ "when initializing RTNodeApplication resources.\n",
+ orb_resource.connection_bands_list[i].Id.in ()));
+ throw CORBA::INTERNAL ();
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource added connection bands: %s\n",
+ orb_resource.connection_bands_list[i].Id.in ()));
+ }
+ }
+
+ // now initialize the policy set part of it.
+ // server_resource.orb_config.policy_set
+ const CIAO::DAnCE::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)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error binding Policy_Set with name: %s\n",
+ sets[i].Id.in ()));
+ throw CORBA::INTERNAL ();
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource "
+ "added policy set: %s with %d policies\n",
+ sets[i].Id.in (), array_index));
+ }
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "RTResource_Config_Manager::init_resource "
+ "added policy set: %s with %d policies\n",
+ sets[i].Id.in (), array_index));
+ }
+ }
+}
+
+void
+CIAO::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::RTResource_Config_Manager::find_threadpool_by_name (const char *name)
+{
+ if (name == 0)
+ {
+ ACE_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)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Unable to find a threadpool named %s\n",
+ name));
+ throw CORBA::INTERNAL ();
+ }
+
+ return ret_id;
+}
+
+RTCORBA::PriorityBands *
+CIAO::RTResource_Config_Manager::find_priority_bands_by_name (const char *name)
+{
+ if (name == 0)
+ {
+ ACE_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)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Unable to find a connection bands named %s\n",
+ name));
+ throw CORBA::INTERNAL ();
+ }
+
+ RTCORBA::PriorityBands_var retv = new RTCORBA::PriorityBands;
+ (*retv.ptr ()) = (*entry->int_id_.ptr ());
+ return retv._retn ();
+}
+
+bool
+CIAO::RTResource_Config_Manager::policy_exists (const char *name)
+{
+ if (name == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Invalid name string found in "
+ "CIAO::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::RTResource_Config_Manager::find_policies_by_name (const char *name)
+{
+ if (name == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Invalid name string found in \"find_policies_by_name\"\n"));
+ throw CORBA::BAD_PARAM ();
+ }
+
+
+ ACE_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name: %s\n",
+ name));
+
+ POLICY_MAP::ENTRY *entry = 0;
+
+ if (this->policy_map_.find (name, entry) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Unable to find a PolicyList named %s\n",
+ name));
+ throw CORBA::INTERNAL ();
+ }
+
+ // duplicate the sequence PolicyList.
+ CORBA::PolicyList_var retv =
+ new CORBA::PolicyList (entry->int_id_.in ());
+
+ ACE_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name ok.\n"));
+
+ return retv._retn ();
+}
+
+CORBA::Policy_ptr
+CIAO::RTResource_Config_Manager::create_single_policy
+(const CIAO::DAnCE::PolicyDef &policy_def)
+{
+ // if (CIAO::debug_level () > 9)
+ ACE_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 CIAO::DAnCE::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 ()))
+ ACE_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 ()))
+ ACE_DEBUG ((LM_DEBUG,
+ "Create Threadpool policy: %s, TPid: %d\n",
+ policy_def.ThreadpoolDef().Id.in (), tpid));
+ }
+ break;
+
+ case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE:
+ {
+ RTCORBA::PriorityBands_var bands =
+ this->find_priority_bands_by_name (policy_def.PriorityBandedConnectionDef().Id.in ());
+
+ retv =
+ this->rtorb_->create_priority_banded_connection_policy (bands.in ());
+
+ if (! CORBA::is_nil (retv.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Created Banded Connection policy: %s\n",
+ policy_def.PriorityBandedConnectionDef().Id.in ()));
+ }
+ }
+ break;
+
+ default:
+ retv = 0;
+ }
+
+ return retv._retn ();
+}
+
+CIAO::RTResource_Config_Manager::~RTResource_Config_Manager ()
+{
+ this->fini ();
+}
+
+extern "C" CIAO_RTNA_Configurator_Export CIAO::Config_Manager
+*create_rt_config_manager (void);
+
+CIAO::Config_Manager *
+create_rt_config_manager (void)
+{
+ CIAO::RTResource_Config_Manager *config;
+ ACE_NEW_RETURN (config, CIAO::RTResource_Config_Manager, 0);
+ return config;
+}
diff --git a/CIAO/DAnCE/NodeApplication/RTConfig_Manager.h b/CIAO/DAnCE/NodeApplication/RTConfig_Manager.h
new file mode 100644
index 00000000000..53ca9de018a
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/RTConfig_Manager.h
@@ -0,0 +1,134 @@
+// -*- 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 "tao/RTCORBA/RTCORBA.h"
+#include "DAnCE/Deployment/CIAO_ServerResourcesC.h"
+#include "ace/Null_Mutex.h"
+#include "ace/SString.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "Config_Manager.h"
+#include "RTNA_Configurator_Export.h"
+
+namespace CIAO
+{
+ /**
+ * @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 CIAO::DAnCE::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 CIAO::DAnCE::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 CIAO::DAnCE::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/CIAO/DAnCE/NodeApplication/RTConfig_Manager.inl b/CIAO/DAnCE/NodeApplication/RTConfig_Manager.inl
new file mode 100644
index 00000000000..7962506555d
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/RTConfig_Manager.inl
@@ -0,0 +1,7 @@
+// $Id$
+
+ACE_INLINE
+CIAO::RTResource_Config_Manager::RTResource_Config_Manager ()
+{
+}
+
diff --git a/CIAO/DAnCE/NodeApplication/RTNA_Configurator_Export.h b/CIAO/DAnCE/NodeApplication/RTNA_Configurator_Export.h
new file mode 100644
index 00000000000..5891c5aca0f
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/RTNA_Configurator_Export.h
@@ -0,0 +1,54 @@
+
+// -*- 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 (CIAO_RTNA_CONFIGURATOR_HAS_DLL)
+# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 1
+#endif /* ! CIAO_RTNA_CONFIGURATOR_HAS_DLL */
+
+#if defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) && (CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1)
+# if defined (CIAO_RTNA_CONFIGURATOR_BUILD_DLL)
+# define CIAO_RTNA_Configurator_Export ACE_Proper_Export_Flag
+# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */
+# define CIAO_RTNA_Configurator_Export ACE_Proper_Import_Flag
+# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */
+#else /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */
+# define CIAO_RTNA_Configurator_Export
+# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T)
+# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */
+
+// Set CIAO_RTNA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (CIAO_RTNA_CONFIGURATOR_NTRACE)
+# if (ACE_NTRACE == 1)
+# define CIAO_RTNA_CONFIGURATOR_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define CIAO_RTNA_CONFIGURATOR_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !CIAO_RTNA_CONFIGURATOR_NTRACE */
+
+#if (CIAO_RTNA_CONFIGURATOR_NTRACE == 1)
+# define CIAO_RTNA_CONFIGURATOR_TRACE(X)
+#else /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define CIAO_RTNA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */
+
+#endif /* CIAO_RTNA_CONFIGURATOR_EXPORT_H */
+
+// End of auto generated file.
diff --git a/CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.cpp b/CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.cpp
new file mode 100644
index 00000000000..04e7bd91f74
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/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 ()
+{
+ ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::pre_orb_init\n"));
+
+ return 0;
+}
+
+int
+CIAO::RTNodeApp_Configurator::post_orb_initialize (CORBA::ORB_ptr o)
+{
+ ACE_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)
+ ACE_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)
+ ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager processing property: %s\n",
+ properties[i].name.in ()));
+
+ if (ACE_OS::strcmp ("CIAOServerResources", properties[i].name.in ()) == 0)
+ {
+ const CIAO::DAnCE::ServerResource *svr_resource;
+ if (properties[i].value >>= svr_resource)
+ {
+ this->config_manager_.init_resources (*svr_resource);
+ // Now we have the information to initialize the manager.
+ }
+ else
+ ACE_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)
+{
+ ACE_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)
+ {
+ ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies processing property: %s\n",
+ properties[i].name.in ()));
+
+ if (ACE_OS::strcmp ("ContainerPolicySet", properties[i].name) == 0)
+ {
+ const char *policy_name = 0;
+ if (properties[i].value >>= policy_name)
+ {
+ return this->config_manager_.find_policies_by_name (policy_name);
+ }
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "ERROR: RTNodeApp_Configurator::find_container_policies unable to extract ContainerPolicySet\n"), 0);
+ }
+ }
+
+ return 0;
+}
+
+
+extern "C" CIAO_RTNA_Configurator_Export CIAO::NodeApp_Configurator *create_nodeapp_configurator (void);
+
+CIAO::NodeApp_Configurator *
+create_nodeapp_configurator (void)
+{
+ CIAO::RTNodeApp_Configurator *config = 0;
+ ACE_NEW_RETURN (config, CIAO::RTNodeApp_Configurator, 0);
+ return config;
+}
diff --git a/CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.h b/CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.h
new file mode 100644
index 00000000000..fc2388b6aff
--- /dev/null
+++ b/CIAO/DAnCE/NodeApplication/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 */