diff options
author | dengg <dengg@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-01-26 18:12:23 +0000 |
---|---|---|
committer | dengg <dengg@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-01-26 18:12:23 +0000 |
commit | fe21d7a64fb8a5c1994eca04e69a38d53cf61c28 (patch) | |
tree | 99f698bbe30dc056b5071473e02715b8daeeeea3 | |
parent | a879731bef4fe081ee0d7aa2fffe260e5593beed (diff) | |
download | ATCD-fe21d7a64fb8a5c1994eca04e69a38d53cf61c28.tar.gz |
Wed Jan 26 12:02:41 2005 Gan Deng <dengg@dre.vanderbilt.edu>
-rw-r--r-- | TAO/CIAO/DAnCE/ChangeLog | 24 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeApplication/NodeApplication.cpp | 43 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/ciao/Container_Impl.cpp | 181 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/ciao/Container_Impl.h | 94 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/ciao/Deployment_Core.idl | 65 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp | 457 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h | 166 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl | 73 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/tests/NodeApplicationTest/NodeApp_test_client_simple.cpp | 42 |
9 files changed, 472 insertions, 673 deletions
diff --git a/TAO/CIAO/DAnCE/ChangeLog b/TAO/CIAO/DAnCE/ChangeLog index 926f0baa489..48d31e24bad 100644 --- a/TAO/CIAO/DAnCE/ChangeLog +++ b/TAO/CIAO/DAnCE/ChangeLog @@ -1,3 +1,27 @@ +Wed Jan 26 12:02:41 2005 Gan Deng <dengg@dre.vanderbilt.edu> + + * DAnCE/ciao/Deployment_Core.idl + + Modified to have totally 3 abstraction layers of ImplementationInfo, + NodeImplementationInfo, ContainerImplementationInfo and + ComponentImplementationInfo. + + * DAnCE/NodeApplication/NodeApplication.cpp + * DAnCE/ciao/Container_Impl.cpp + * DAnCE/ciao/Container_Impl.h + * DAnCE/ciao/NodeApplication_Impl.cpp + * DAnCE/ciao/NodeApplication_Impl.h + * DAnCE/ciao/NodeApplication_Impl.inl + + Added the abstraction layer of container interface. Reorganize + the functionality between NodeApplication and Container. + + * tests/NodeApplicationTest/NodeApp_test_client_simple.cpp + + Modified this to test against the above change. This test + could run successfully when we have 1 component hosted in + 1 container, which in turn hosted in 1 NodeApplication. + Wed Jan 19 21:41:48 2005 Gan Deng <dengg@dre.vanderbilt.edu> * DAnCE/Config_Handlers/ADD_Handler.cpp diff --git a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication.cpp b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication.cpp index 0ca6d48da6d..09ad12c6f44 100644 --- a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication.cpp +++ b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication.cpp @@ -11,6 +11,7 @@ const char *ior_file_name = 0; const char *callback_ior = 0; +int use_callback = 1; int parse_args (int argc, char *argv[]) @@ -21,6 +22,11 @@ parse_args (int argc, char *argv[]) while ((c = get_opts ()) != -1) switch (c) { + case 'n': + use_callback = 0; + break; + + case 'o': // get the file name to write to ior_file_name = get_opts.opt_arg (); break; @@ -41,7 +47,7 @@ parse_args (int argc, char *argv[]) -1); } - if (callback_ior == 0) + if (use_callback && callback_ior == 0) ACE_ERROR_RETURN ((LM_ERROR, "Callback IOR to NodeApplicationManager is required.\n"), -1); @@ -121,22 +127,25 @@ main (int argc, char *argv[]) Deployment::NodeApplicationManager_var nodeapp_man; Deployment::Properties_var prop = new Deployment::Properties; - obj = orb->string_to_object (callback_ior - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CIAO::NodeApplication_Callback_var nam_callback - = CIAO::NodeApplication_Callback::_narrow (obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - Deployment::Properties_out properties_out (prop.out ()); - - nodeapp_man - = nam_callback->register_node_application (nodeapp_obj.in (), - properties_out - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + if (use_callback) + { + obj = orb->string_to_object (callback_ior + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CIAO::NodeApplication_Callback_var nam_callback + = CIAO::NodeApplication_Callback::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Deployment::Properties_out properties_out (prop.out ()); + + nodeapp_man + = nam_callback->register_node_application (nodeapp_obj.in (), + properties_out + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } /** @@ We need to call NodeApplication servant's init method. * But it's not sure to me where exactly we can get the diff --git a/TAO/CIAO/DAnCE/ciao/Container_Impl.cpp b/TAO/CIAO/DAnCE/ciao/Container_Impl.cpp index c16870736d5..db90a71d928 100644 --- a/TAO/CIAO/DAnCE/ciao/Container_Impl.cpp +++ b/TAO/CIAO/DAnCE/ciao/Container_Impl.cpp @@ -7,7 +7,8 @@ CIAO::Container_Impl::~Container_Impl () { - // @@ remove all home? + // @@ remove all components and home? + delete this->container_; } PortableServer::POA_ptr @@ -16,7 +17,7 @@ CIAO::Container_Impl::_default_POA (void) return PortableServer::POA::_duplicate (this->poa_.in ()); } -int +CORBA::Long CIAO::Container_Impl::init (const ::Deployment::Properties &properties ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) @@ -40,97 +41,35 @@ CIAO::Container_Impl::init (const ::Deployment::Properties &properties ACE_ENV_ARG_PARAMETER); } -::Deployment::Properties * -CIAO::Container_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - ::Deployment::Properties *retval; - - ACE_NEW_THROW_EX (retval, - ::Deployment::Properties, - CORBA::INTERNAL ()); - ACE_CHECK_RETURN (0); - - *retval = this->properties_; - - return retval; -} - -::Deployment::NodeApplication_ptr -CIAO::Container_Impl::get_node_application (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - return ::Deployment::NodeApplication::_duplicate (this->nodeapp_.in ()); -} - -::Components::CCMHome_ptr -CIAO::Container_Impl::install_home (const ::Deployment::ImplementationInfo & impl_info - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)) -{ - 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 () - ACE_ENV_ARG_PARAMETER); - - ACE_CHECK_RETURN (Components::CCMHome::_nil ()); - // 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_THROW_RETURN (Deployment::InstallationFailure (), - Components::CCMHome::_nil ()); - - //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 (); -} Deployment::ComponentInfos * CIAO::Container_Impl::install ( - const ::Deployment::ImplementationInfos & impl_infos + const ::Deployment::ContainerImplementationInfo & container_impl_info ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::UnknownImplId, Deployment::ImplEntryPointNotFound, Deployment::InstallationFailure, - Components::InvalidConfiguration)) + Components::InvalidConfiguration, + Components::RemoveFailure)) { Deployment::ComponentInfos_var retv; ACE_TRY { - Deployment::ComponentInfos * tmp; - ACE_NEW_THROW_EX (tmp, + ACE_NEW_THROW_EX (retv, Deployment::ComponentInfos, CORBA::NO_MEMORY ()); ACE_TRY_CHECK; - retv = tmp; - - const CORBA::ULong len = impl_infos.length (); - + const CORBA::ULong len = container_impl_info.length (); retv->length (len); - // @@ (OO) There is no need to declare these variables outside of - // the loop. Some folks doing so is an optimization but - // doing so generally defeats some compiler optimizations. - // Please move these declaration within the loop. - Components::CCMHome_var home; - Components::CCMObject_var comp; - for (CORBA::ULong i = 0; i < len; ++i) { - home = this->install_home (impl_infos[i] - ACE_ENV_ARG_PARAMETER); + // Install home + Components::CCMHome_var home = + this->install_home (container_impl_info[i] + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; Components::KeylessCCMHome_var kh = @@ -141,37 +80,38 @@ CIAO::Container_Impl::install ( if (CORBA::is_nil (kh.in ())) ACE_THROW_RETURN (Deployment::InstallationFailure (), 0); - // @@ Note, here we are missing the CreateFailure. - // Sometime I will come back to add exception rethrow. - comp = kh->create_component (ACE_ENV_SINGLE_ARG_PARAMETER); + // Create component from home + Components::CCMObject_var comp = + kh->create_component (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - if (this->component_map_.bind (impl_infos[i].component_instance_name.in (), + if (CORBA::is_nil (comp.in ())) + ACE_THROW_RETURN (Components::RemoveFailure (), 0); + + if (this->component_map_.bind (container_impl_info[i].component_instance_name.in (), Components::CCMObject::_duplicate (comp.in ()))) ACE_TRY_THROW (Deployment::InstallationFailure ()); // Set the return value. (*retv)[i].component_instance_name - = impl_infos[i].component_instance_name.in (); + = container_impl_info[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 here is only - // the hardcoded version of the configuration. Hopefully we will - // reach an agreement after the RTWS about how the configuration - // should be done. + // the hardcoded version of the configuration. - const CORBA::ULong clen = impl_infos[i].component_config.length (); + const CORBA::ULong clen = container_impl_info[i].component_config.length (); for (CORBA::ULong prop_len = 0; prop_len < clen; ++prop_len) { - if (ACE_OS::strcmp (impl_infos[i].component_config[prop_len].name.in (), + if (ACE_OS::strcmp (container_impl_info[i].component_config[prop_len].name.in (), "ComponentIOR") == 0) { if (CIAO::debug_level () > 1) ACE_DEBUG ((LM_DEBUG, "Found property to write the IOR.\n")); const char * path; - impl_infos[i].component_config[prop_len].value >>= path; + container_impl_info[i].component_config[prop_len].value >>= path; CORBA::String_var ior = this->orb_->object_to_string (comp.in () @@ -193,7 +133,7 @@ CIAO::Container_Impl::install ( ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "CIAO_NodeApplication::install error\t\n"); + "Container_Impl::install\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -202,6 +142,60 @@ CIAO::Container_Impl::install ( return retv._retn (); } +::Deployment::Properties * +CIAO::Container_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Deployment::Properties *retval; + + ACE_NEW_THROW_EX (retval, + ::Deployment::Properties, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (0); + + *retval = this->properties_; + + return retval; +} + +::Deployment::NodeApplication_ptr +CIAO::Container_Impl::get_node_application (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return ::Deployment::NodeApplication::_duplicate (this->nodeapp_.in ()); +} + +::Components::CCMHome_ptr +CIAO::Container_Impl::install_home ( + const ::Deployment::ComponentImplementationInfo & impl_info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::UnknownImplId, + Deployment::ImplEntryPointNotFound, + Deployment::InstallationFailure, + Components::InvalidConfiguration)) +{ + 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 () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (Components::CCMHome::_nil ()); + // 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_THROW_RETURN (Deployment::InstallationFailure (), + Components::CCMHome::_nil ()); + + //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 @@ -215,7 +209,7 @@ CIAO::Container_Impl::remove_home (const char * comp_ins_name if (this->home_map_.find (str, home) != 0) ACE_THROW (CORBA::BAD_PARAM ()); - // We should remove all components created by this home as well. + // @@TODO We should remove all components created by this home as well. // This is not implemented yet. this->container_->ciao_uninstall_home (home @@ -258,21 +252,19 @@ CIAO::Container_Impl::get_homes (ACE_ENV_SINGLE_ARG_DECL) return retval._retn (); } - +// Remove all homes and components void CIAO::Container_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { // Remove all components first. - remove_components (); - + this->remove_components (ACE_ENV_ARG_PARAMETER); ACE_CHECK; // 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->home_map_.end (); ++iter) { this->container_->ciao_uninstall_home ( (*iter).int_id_ @@ -286,7 +278,7 @@ CIAO::Container_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) //if (CIAO::debug_level () > 1) if (true) - ACE_DEBUG ((LM_DEBUG, "Shutting down this NodeApplication!\n")); + ACE_DEBUG ((LM_DEBUG, "Removing this Container!\n")); this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); } @@ -302,9 +294,8 @@ CIAO::Container_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) { // 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 != this->component_map_.end (); ++iter) { // Find the component home first, then call the remove_component @@ -326,6 +317,8 @@ CIAO::Container_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) // will happen. } + +// Below method is not used actually. void CIAO::Container_Impl::remove_component (const char * comp_ins_name ACE_ENV_ARG_DECL) diff --git a/TAO/CIAO/DAnCE/ciao/Container_Impl.h b/TAO/CIAO/DAnCE/ciao/Container_Impl.h index c7b525d4dfd..125dab5898e 100644 --- a/TAO/CIAO/DAnCE/ciao/Container_Impl.h +++ b/TAO/CIAO/DAnCE/ciao/Container_Impl.h @@ -32,24 +32,16 @@ namespace CIAO { - - struct home_installation_info - { - CORBA::String_var executor_dll_; - CORBA::String_var servant_dll_; - CORBA::String_var servant_entrypt_; - }; - /** * @class Container_Impl * * @brief Servant implementation for the interface Deployment::Container * * This class implements the Deployment::Container - * interface as defined by the new 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. + * 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 CIAO_SERVER_Export Container_Impl : public virtual POA_Deployment::Container, @@ -64,16 +56,32 @@ namespace CIAO /// Destructor virtual ~Container_Impl (void); - /// Get the containing POA. This operation does *not* - /// increase the reference count of the POA. - virtual PortableServer::POA_ptr _default_POA (void); + /*-------------------------------------------------------------*/ + /*-------------------- IDL operations (idl) ------------------*/ /// Initialize the container. - int init (const ::Deployment::Properties &properties - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + virtual CORBA::Long init (const ::Deployment::Properties &properties + ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - /// Deployment::Container defined attributes/operations. + /// Install all homes and components + Deployment::ComponentInfos * + install (const ::Deployment::ContainerImplementationInfo & container_impl_info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::UnknownImplId, + Deployment::ImplEntryPointNotFound, + Deployment::InstallationFailure, + Components::InvalidConfiguration, + Components::RemoveFailure)); + + /// Remove all homes and components + virtual void + remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)); + + /// Deployment::Container interface defined attributes/operations. virtual ::Deployment::Properties * properties (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); @@ -82,17 +90,17 @@ namespace CIAO get_node_application (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - Deployment::ComponentInfos * - install (const ::Deployment::ImplementationInfos & impl_infos - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)); + /*-------------------------------------------------------------*/ + /*------------------- 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::ImplementationInfo & impl_info + install_home (const ::Deployment::ComponentImplementationInfo & impl_info ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::UnknownImplId, @@ -100,20 +108,29 @@ namespace CIAO Deployment::InstallationFailure, Components::InvalidConfiguration)); + /** + * @@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 ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)); + // Get all homes virtual ::Components::CCMHomes * get_homes (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - virtual void - remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); // ------------------- CIAO Internal Operations ------------------------ // These below two are helper methods to clean up components @@ -139,21 +156,6 @@ namespace CIAO Deployment::Container_ptr get_objref (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); protected: - /// parse ConfigValues - /* - We should define a way how the config value should be set up here! - The Deployment::Properties IDL data type should be used for this new DnC thing. - - void parse_config_values (const char *exe_id, - const Components::ConfigValues &options, - struct home_installation_info &component_install_info - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::Deployment::UnknownImplId, - Components::Deployment::ImplEntryPointNotFound, - Components::InvalidConfiguration)); - */ - /// Keep a pointer to the managing ORB serving this servant. CORBA::ORB_var orb_; diff --git a/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl b/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl index 0035af12c2f..ddba0cf5734 100644 --- a/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl +++ b/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl @@ -63,7 +63,7 @@ module Deployment typedef sequence < Connection > Connections; //======================================= - struct ImplementationInfo + struct ComponentImplementationInfo { string component_instance_name; string executor_dll; @@ -75,7 +75,11 @@ module Deployment // Properties container_config //igore for now }; - typedef sequence < ImplementationInfo > ImplementationInfos; + typedef sequence <ComponentImplementationInfo> ComponentImplementationInfos; + + typedef ComponentImplementationInfos ContainerImplementationInfo; + + typedef sequence <ContainerImplementationInfo> NodeImplementationInfo; //================================== interface Application @@ -94,7 +98,7 @@ module Deployment typedef sequence < Component_Info > ComponentInfos; - // @@ (OO) Tao, you're altering an OMG defined interface below. In + // @@ (OO) You're altering an OMG defined interface below. In // order to avoid confusion, it is probably better to create // another NodeApplication interface in the CIAO namespace // that inherits from Deployment::NodeApplication. You'd @@ -105,13 +109,6 @@ module Deployment // typeprefix within your altered NodeApplication interface // to prevent interoperability issues. - // This NodeApplication contains the semantic from both Container and - // the new DnC NodeApplication --Tao - - // I separated the Container and NodeApplication interfaces for the - // fine-grained container properties purpose, such as setting RTCCM - // policies.. -- Gan Deng - interface NodeApplication; // Forward decl. typedef sequence<NodeApplication> NodeApplications; @@ -119,8 +116,12 @@ module Deployment { readonly attribute ::Deployment::Properties properties; + /// Get the NodeApplication which created us NodeApplication get_node_application (); + /// Initialize the container with properties. + long init (in ::Deployment::Properties properties); + //@@ The properties will contain //1 component instance name as the key. //2 dll/so name of the exec @@ -128,47 +129,25 @@ module Deployment //4 dll/so name of the svnt //5 entry point of the svnt //6 Poosible other configuration for container/home/component - //Note:: We have to decide later how container/home/component could be configured. - // These properties could be passed in here or at higher level - // according to the plan(@ NodeApplicationManager/NodeApplication?) - // - ::Components::CCMHome install_home (in ImplementationInfo impl_info) + + /// Install all homes and components + Deployment::ComponentInfos install (in ContainerImplementationInfo container_impl_info) raises (UnknownImplId, ImplEntryPointNotFound, InstallationFailure, ::Components::InvalidConfiguration); - void remove_home (in string comp_ins_name) - raises (::Components::RemoveFailure); - - ::Components::CCMHomes get_homes (); - + /// Remove all homes and components void remove () raises (::Components::RemoveFailure); }; - typedef sequence<Container> Containers; + typedef sequence<Container> Containers; interface NodeApplication : Application { readonly attribute ::Deployment::Properties properties; - /*@@ This operation is added for the NodeApplicationManager to - * initialize the NodeApplication after creating it. The - * properties are those for the Container and they will be - * implemented upon request from our users. --Tao - * - * Seems Kitty is opposing the idea of sending anys around. But - * what really stroke me down was that OMG is working out - * another property&configuration specification so all the - * properties we set/used might have to be thrown away in the - * future.....I am totally speachless and confused...and - * frustrated. - * - * But any way seems I can forget about the configuration - * now. --Tao - */ - // @@ Initialize the nodeapplication, so it will know what // components it will create and home many of them are // there. However the real create action will take place when @@ -177,19 +156,19 @@ module Deployment // @@ This operation will be called by NodeApplicationManager // client to really start to create homes and components. - ComponentInfos install (in ImplementationInfos impl_infos) + ComponentInfos install (in NodeImplementationInfo node_impl_info) raises (UnknownImplId, ImplEntryPointNotFound, InstallationFailure, - ::Components::InvalidConfiguration); - + ::Components::InvalidConfiguration, + ::Components::RemoveFailure); //@@ We know that Dployment::NodeApplicationManager will be returned, // however to avoid the size of the shared object of CIAO_Server. // we return an Object. Object get_node_application_manager (); - Container create_container (in ::Components::ConfigValues config) + Container create_container (in ::Deployment::Properties properties) raises (::Components::CreateFailure, ::Components::InvalidConfiguration); @@ -197,6 +176,10 @@ module Deployment raises (::Components::RemoveFailure); Containers get_containers (); + + // Remove all containers, components and component homes. + void remove () + raises (::Components::RemoveFailure); }; }; diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp index 5c8c4fcf553..6aaa7853b71 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp @@ -1,6 +1,7 @@ //$Id$ #include "NodeApplication_Impl.h" +#include "Container_Impl.h" #if !defined (__ACE_INLINE__) # include "NodeApplication_Impl.inl" @@ -8,7 +9,16 @@ CIAO::NodeApplication_Impl::~NodeApplication_Impl (void) { - delete this->container_; +} + +CORBA::Long +CIAO::NodeApplication_Impl::init (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + //@@TODO We need to create all the containers in this stage + // Which properties should be passed in? + this->create_container (this->properties_); + return 0; } void @@ -32,7 +42,7 @@ CIAO::NodeApplication_Impl::finishLaunch ( if (this->component_map_.find (name, comp) != 0) { - ACE_TRY_THROW (Deployment::InvalidConnection ()); + ACE_THROW (Deployment::InvalidConnection ()); } Components::EventConsumerBase_var consumer; @@ -41,19 +51,13 @@ CIAO::NodeApplication_Impl::finishLaunch ( switch (providedReference[i].kind) { case Deployment::SimplexReceptacle: + case Deployment::MultiplexReceptacle: comp->connect (providedReference[i].portName.in (), providedReference[i].endpoint.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; break; - case Deployment::MultiplexReceptacle: - comp->connect(providedReference[i].portName.in (), - providedReference[i].endpoint.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - break; - case Deployment::EventEmitter: consumer = Components::EventConsumerBase:: _narrow (providedReference[i].endpoint.in () @@ -65,9 +69,9 @@ CIAO::NodeApplication_Impl::finishLaunch ( ACE_THROW (Deployment::InvalidConnection ()); } - comp->connect_consumer(providedReference[i].portName.in (), - consumer.in () - ACE_ENV_ARG_PARAMETER); + comp->connect_consumer (providedReference[i].portName.in (), + consumer.in () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; break; @@ -126,39 +130,22 @@ CIAO::NodeApplication_Impl::start (ACE_ENV_SINGLE_ARG_DECL) void CIAO::NodeApplication_Impl::start_i (Funct_Ptr functor - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) { - const Component_Iterator end (this->component_map_.end ()); for (Component_Iterator iter (this->component_map_.begin ()); - iter != end; + iter != this->component_map_.end (); ++iter) { - //@@ I don't know what if Components::InvalidConfiguration - // is thrown from here, so it's ignored for now. --Tao (((*iter).int_id_)->*functor) (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; } } -Deployment::Properties * -CIAO::NodeApplication_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - Deployment::Properties * tmp; - - ACE_NEW_THROW_EX (tmp, - Deployment::Properties (this->properties_), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (0); - - return tmp; -} - Deployment::ComponentInfos * CIAO::NodeApplication_Impl::install ( - const ::Deployment::ImplementationInfos & impl_infos + const ::Deployment::NodeImplementationInfo & node_impl_info ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::UnknownImplId, @@ -168,373 +155,139 @@ CIAO::NodeApplication_Impl::install ( { Deployment::ComponentInfos_var retv; ACE_TRY - { - Deployment::ComponentInfos * tmp; - ACE_NEW_THROW_EX (tmp, - Deployment::ComponentInfos, - CORBA::NO_MEMORY ()); - ACE_TRY_CHECK; - - retv = tmp; - - const CORBA::ULong len = impl_infos.length (); - - retv->length (len); - - // @@ (OO) There is no need to declare these variables outside of - // the loop. Some folks doing so is an optimization but - // doing so generally defeats some compiler optimizations. - // Please move these declaration within the loop. - Components::CCMHome_var home; - Components::CCMObject_var comp; - - for (CORBA::ULong i = 0; i < len; ++i) - { - home = this->install_home (impl_infos[i] - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - Components::KeylessCCMHome_var kh = - Components::KeylessCCMHome::_narrow (home.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (kh.in ())) - ACE_THROW_RETURN (Deployment::InstallationFailure (), 0); - - // @@ Note, here we are missing the CreateFailure. - // Sometime I will come back to add exception rethrow. - comp = kh->create_component (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->component_map_.bind (impl_infos[i].component_instance_name.in (), - Components::CCMObject::_duplicate (comp.in ()))) - ACE_TRY_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 here is only - // the hardcoded version of the configuration. Hopefully we will - // reach an agreement after the RTWS about how the configuration - // should be done. - - const CORBA::ULong clen = impl_infos[i].component_config.length (); - for (CORBA::ULong prop_len = 0; prop_len < clen; ++prop_len) - { - if (ACE_OS::strcmp (impl_infos[i].component_config[prop_len].name.in (), - "ComponentIOR") == 0) - { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "Found property to write the IOR.\n")); - const char * path; - impl_infos[i].component_config[prop_len].value >>= path; - - CORBA::String_var ior = - this->orb_->object_to_string (comp.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + { + ACE_NEW_THROW_EX (retv, + Deployment::ComponentInfos, + CORBA::NO_MEMORY ()); + ACE_TRY_CHECK; - if (write_IOR (path, ior.in ()) != 0) - { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "Failed to write the IOR.\n")); + retv->length (0); - ACE_TRY_THROW (CORBA::INTERNAL ()); - } + CORBA::ULong num_containers = node_impl_info.length (); - } - } - } - } + // 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. + for (CORBA::ULong i = 0; i < num_containers; ++i) + { + Deployment::ComponentInfos_var comp_infos = + this->container_set_.at(i)->install (node_impl_info[i] + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // 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]; + } + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "CIAO_NodeApplication::install error\t\n"); - ACE_RE_THROW; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "CIAO_NodeApplication::install error\t\n"); + ACE_RE_THROW; + } ACE_ENDTRY; ACE_CHECK_RETURN (0); return retv._retn (); } -// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" -// versions of emulated exception parameters. Please remove -// the "_WITH_DEFAULTS" -Components::CCMHome_ptr -CIAO::NodeApplication_Impl::install_home ( - const ::Deployment::ImplementationInfo & impl_info - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)) -{ - 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 () - ACE_ENV_ARG_PARAMETER); - - ACE_CHECK_RETURN (Components::CCMHome::_nil ()); - // 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_THROW_RETURN (Deployment::InstallationFailure (), - Components::CCMHome::_nil ()); - - //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::NodeApplication_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { - // Remove all components first. - remove_components (); - - ACE_CHECK; - - // Even if above op 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) + // For each container, invoke <remove> operation. + for (CORBA::ULong i = 0; i < this->container_set_.size (); ++i) { - this->container_->ciao_uninstall_home ( (*iter).int_id_ - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - CORBA::release ( (*iter).int_id_); + this->container_set_.at(i)->remove (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; } - this->home_map_.unbind_all (); - if (CIAO::debug_level () > 1) ACE_DEBUG ((LM_DEBUG, "Shutting down this NodeApplication!\n")); this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); } -void -CIAO::NodeApplication_Impl::remove_home (const char * comp_ins_name - ACE_ENV_ARG_DECL) + +// Create a container interface, which will be hosted in this NodeApplication. +::Deployment::Container_ptr +CIAO::NodeApplication_Impl::create_container (const ::Deployment::Properties &properties + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) + ::Components::CreateFailure, + ::Components::InvalidConfiguration)) { - Components::CCMHome_ptr home; - ACE_CString str (comp_ins_name); - - if (this->home_map_.find (str, home) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); + ACE_DEBUG ((LM_DEBUG, "ENTERING: NodeApplication_Impl::create_container()\n")); - // We should remove all components created by this home as well. - // This is not implemented yet. + CIAO::Container_Impl *container_servant = 0; - this->container_->ciao_uninstall_home (home - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - // 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) - ACE_THROW (::Components::RemoveFailure ()); -} - -Components::CCMHomes * -CIAO::NodeApplication_Impl::get_homes (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - Components::CCMHomes * tmp; - ACE_NEW_THROW_EX (tmp, - Components::CCMHomes (), - CORBA::NO_MEMORY ()); + ACE_NEW_THROW_EX (container_servant, + CIAO::Container_Impl (this->orb_.in (), + this->poa_.in (), + this->get_objref ()), + CORBA::INTERNAL ()); ACE_CHECK_RETURN (0); - Components::CCMHomes_var retval (tmp); + PortableServer::ServantBase_var safe_servant (container_servant); - // @@ (OO) Please declare len as "const". - CORBA::ULong len = this->home_map_.current_size (); - retval->length (len); - - - CORBA::ULong i = 0; - const Home_Iterator end = this->home_map_.end (); - for (Home_Iterator iter (this->home_map_.begin ()); - iter != end; - ++iter, ++i) - { - retval[i] = Components::CCMHome::_duplicate ( (*iter).int_id_); - } - - return retval._retn (); -} - -CORBA::Long -CIAO::NodeApplication_Impl::init (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_NEW_THROW_EX (this->container_, - CIAO::Session_Container (this->orb_.in (), - 0, - 0), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (-1); - - return this->container_->init (0, - 0 - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + // @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 (properties + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); - return 0; -} + PortableServer::ObjectId_var oid + = this->poa_->activate_object (container_servant + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); -CORBA::Object_ptr -CIAO::NodeApplication_Impl::get_node_application_manager ( - ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - return ::CORBA::Object::_duplicate (this->node_app_manager_.in ()); -} + CORBA::Object_var obj + = this->poa_->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + ::Deployment::Container_var ci + = ::Deployment::Container::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); -PortableServer::POA_ptr -CIAO::NodeApplication_Impl::_default_POA (void) -{ - return PortableServer::POA::_duplicate (this->poa_.in ()); -} + // Cached the objref in its servant. + container_servant->set_objref (ci.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); -void -CIAO::NodeApplication_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) -{ - //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) { - Components::CCMHome_ptr home; - if (this->home_map_.find ( (*iter).ext_id_, home) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); - // This will call ccm_passivate on the component executor. - home->remove_component ((*iter).int_id_); - ACE_CHECK; - - CORBA::release ((*iter).int_id_); + this->container_set_.add (ci.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. + ACE_DEBUG ((LM_DEBUG, "LEAVING: NodeApplication_Impl::create_container()\n")); + return ci._retn (); } +// Remove a container interface. void -CIAO::NodeApplication_Impl::remove_component (const char * comp_ins_name +CIAO::NodeApplication_Impl::remove_container (::Deployment::Container_ptr cref ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) + ::Components::RemoveFailure)) { - Components::CCMObject_ptr comp; - Components::CCMHome_ptr home; - - ACE_CString str (comp_ins_name); - - /* Before we do remove component we have to inform the homeservant so - * Component::ccm_passivate () - * constainer::ninstall_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) - ACE_THROW (CORBA::BAD_PARAM ()); - - if (this->home_map_.find (str, home) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); - - // This will call ccm_passivate on the component executor. - home->remove_component (comp); - ACE_CHECK; - - // If the previous calls failed, what should we do here?? - CORBA::release (comp); - - // @@ Still need to remove the home if the previous operation fails? - if (this->component_map_.unbind (str) == -1) - ACE_THROW (::Components::RemoveFailure ()); + ACE_DEBUG ((LM_DEBUG, "ENTERING: NodeApplication_Impl::remove_container()\n")); + ACE_DEBUG ((LM_DEBUG, "LEAVING: NodeApplication_Impl::remove_container()\n")); } -// The code below is obsolete now. However I want to keep it arround as a -// start point for configurations. -/* -void -CIAO::NodeApplication_Impl:: -parse_config_values (const ::Deployment::Properties & properties, - struct home_installation_info &component_install_info - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Components::InvalidConfiguration)) +// Get containers +::Deployment::Containers * +CIAO::NodeApplication_Impl::get_containers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { - - for (CORBA::ULong i = 0; i < properties.length(); ++i) - { - // Place holder for string values - const char * str = 0; - const char * name = properties[i].name.in(); - - // I assume the property will be given in the following format! --Tao - if (ACE_OS::strcmp (name, "CIAO-servant-location")) - { - properties[i].value >>= str; - component_install_info.servant_dll_= str; //deep copy happens here. - } - else if (ACE_OS::strcmp (name, "CIAO-servant-entryPoint")) - { - properties[i].value >>= str; - component_install_info.servant_entrypt_= str; //deep copy happens here. - } - else if (ACE_OS::strcmp (name, "CIAO-executor-location")) - { - properties[i].value >>= str; - component_install_info.executor_dll_= str; //deep copy happens here. - } - else if (ACE_OS::strcmp (name, "CIAO-executor-entryPoint")) - { - properties[i].value >>= str; - component_install_info.executor_entrypt_= str; //deep copy happens here. - } - else - { - ACE_DEBUG ((LM_DEBUG, "Found unrecognized property: %s\n",name)); - //I should put the name of the configuration inside of the exception. --Tao - ACE_THROW (Components::InvalidConfiguration ()); - } - } - - // We don't need to worry about the case when some info is missing since - // the modeling tool will ensure the complete info to presented in the properties. + return 0; } -*/ diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h index 64e497f2fdb..1bdc0ed8000 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h @@ -6,7 +6,8 @@ * @Brief This file contains the implementation of * the NodeApplication interface. * - * @auther Tao Lu <lu@dre.vanderbilt.edu> + * @author Tao Lu <lu@dre.vanderbilt.edu> + * @author Gan Deng <dengg@dre.vanderbilt.edu> *========================================================*/ #ifndef NODEAPPLICATION_IMPL_H @@ -26,6 +27,7 @@ #include "Deployment_CoreS.h" #include "Server_init.h" #include "CIAO_common.h" +#include "Object_Set_T.h" using CIAO::Utility::write_IOR; @@ -42,26 +44,23 @@ using CIAO::Utility::write_IOR; * @@TODO add configuration capabilities. Threading is one of them. * * @@Assumptions: - * 1. There is only 1 container for all components/homes associating - * with 1 NodeApplication - * 2. Now the implementation is not thread safe. + * 1. Now the implementation is not thread safe. **/ namespace CIAO { class CIAO_SERVER_Export NodeApplication_Impl - : public virtual POA_Deployment::NodeApplication + : public virtual POA_Deployment::NodeApplication, + public virtual PortableServer::RefCountServantBase { public: - - // Default constructor. + /// Default constructor. NodeApplication_Impl (CORBA::ORB_ptr o, PortableServer::POA_ptr p); - // Default destructor. + /// Default destructor. virtual ~NodeApplication_Impl (void); - /** * @method finishLaunch * @@ -73,7 +72,6 @@ namespace CIAO * 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 & providedReference, @@ -91,120 +89,87 @@ namespace CIAO ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)); - /*------------- CIAO specific helper operations (idl)-------- + /*------------- CIAO specific IDL operations (idl)---------- * *-----------------------------------------------------------*/ - // Initialize the NodeApplication + /// Initialize the NodeApplication virtual CORBA::Long init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - // Start install homes and components. + /// Start install homes and components. virtual ::Deployment::ComponentInfos * - install (const ::Deployment::ImplementationInfos & impl_infos - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + install (const ::Deployment::NodeImplementationInfo & node_impl_info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, ::Deployment::UnknownImplId, ::Deployment::ImplEntryPointNotFound, ::Deployment::InstallationFailure, ::Components::InvalidConfiguration)); + + /// Get the object reference of the NodeApplicationManager. + /// This might come in handy later. + virtual ::CORBA::Object_ptr + get_node_application_manager (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); // Access the readonly attribute. virtual ::Deployment::Properties * properties (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - virtual ::Components::CCMHome_ptr - install_home (const ::Deployment::ImplementationInfo & impl_info - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)); - - /** - * @@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. - */ - virtual void remove_home (const char * comp_ins_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); - // Remove everything inside including all components and homes. - // User must be sure that no connection is active before calling this!! virtual void remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)); + + /// Create a container interface, which will be hosted in this NodeApplication. + virtual ::Deployment::Container_ptr + create_container (const ::Deployment::Properties &properties + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::CreateFailure, + ::Components::InvalidConfiguration)); + + /// Remove a container interface. + virtual void remove_container (::Deployment::Container_ptr cref + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::RemoveFailure)); - // Return all homes. - virtual ::Components::CCMHomes * - get_homes (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + /// Get all container object refs + virtual ::Deployment::Containers * get_containers ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); /*------------- CIAO specific helper functions (C++)--------- * *-----------------------------------------------------------*/ - // Get the containing POA. This operation does *not* - // increase the reference count of the POA. + /// Get the containing POA. This operation does *not* + /// increase the reference count of the POA. virtual PortableServer::POA_ptr _default_POA (void); - // Get the object reference of the NodeApplicationManager. - // This might comes in handy later. - virtual ::CORBA::Object_ptr - get_node_application_manager (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - - protected: - - // @@ (OO) Methods internal to the class, e.g. protected and not - // defined in IDL should not be using default arguments. - // Please drop the "_WITH_DEFAULTS" in all of the below - // protected methods. + /// Return the cached object reference of this NodeApplication object. + /// This operation does *NOT* increase the reference count. + ::Deployment::NodeApplication_ptr + get_objref (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); - // This is a helper method 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 (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); - - virtual void remove_component (const char * comp_ins_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); + protected: - // This function is a helper for start call. Bala's - // Idea of adding those pre/post activate calls doesn't work - // with the new sepc. - //@@ TODO. Come up with new ways of synchronized initialization process. + /// This function is a helper for start call. Bala's + /// Idea of adding those pre/post activate calls doesn't work + /// with the new sepc. + ///@@ TODO. Come up with new ways of synchronized initialization process. typedef void (Components::CCMObject::*Funct_Ptr) - (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + (ACE_ENV_SINGLE_ARG_DECL); virtual void start_i (Funct_Ptr functor ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)); - // 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 sotre all created Component object. + /// To sotre all created Component object. typedef ACE_Hash_Map_Manager_Ex<ACE_CString, Components::CCMObject_ptr, ACE_Hash<ACE_CString>, @@ -213,35 +178,26 @@ namespace CIAO typedef CCMComponent_Map::iterator Component_Iterator; CCMComponent_Map component_map_; - // Keep a pointer to the managing ORB serving this servant. + /// 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. + /// Keep a pointer to the managing POA. PortableServer::POA_var poa_; - // Internal container implementation. - CIAO::Container *container_; - - // Cached properties + /// Cached properties Deployment::Properties properties_; - // And a reference to the NodeApplicationManager that created us. + /// And a reference to the NodeApplicationManager that created us. ::CORBA::Object_var node_app_manager_; - // Synchronize access to the object set. - // This will be needed in the case when component/home run in different thread - // TAO_SYNCH_MUTEX lock_; - - //@@ As I have stated in the idl we are not going to use properties for now. - // parse The Properties - /*void parse_config_values (const ::Deployment::Properties & properties, - struct home_installation_info &component_install_info - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Components::InvalidConfiguration)); - */ + /// Cache the object reference (of ourselves). + ::Deployment::NodeApplication_var objref_; }; } diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl index dd541db9b70..efa3b18a90c 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl @@ -7,15 +7,68 @@ NodeApplication_Impl (CORBA::ORB_ptr o, PortableServer::POA_ptr p) : orb_ (CORBA::ORB::_duplicate (o)), - poa_ (PortableServer::POA::_duplicate (p)), - container_ (0) - - // @@ (OO) The default size for an ACE_Hash_Map_Mapanger is quiet - // large. The maximum size of an ACE_Hash_Map_Manager is - // also fixed, i.e. it does not grow dynamically on demand. - // Make sure the default size of home_map_ and - // component_map_ is appropriate for your needs. You may - // also want to make the size configurable at compile-time, - // at least. + poa_ (PortableServer::POA::_duplicate (p)) { } + +// Access the readonly attribute +Deployment::Properties * +CIAO::NodeApplication_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + Deployment::Properties * tmp; + + ACE_NEW_THROW_EX (tmp, + Deployment::Properties (this->properties_), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + return tmp; +} + +PortableServer::POA_ptr +CIAO::NodeApplication_Impl::_default_POA (void) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} + + +CORBA::Object_ptr +CIAO::NodeApplication_Impl::get_node_application_manager ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + 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 + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (!CORBA::is_nil (this->node_app_manager_.in ()) || + !CORBA::is_nil (this->objref_.in ())) + ACE_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 (ACE_ENV_SINGLE_ARG_DECL) +{ + if (CORBA::is_nil (this->objref_.in ())) + { + this->objref_ = this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + return this->objref_.in (); +} diff --git a/TAO/CIAO/DAnCE/tests/NodeApplicationTest/NodeApp_test_client_simple.cpp b/TAO/CIAO/DAnCE/tests/NodeApplicationTest/NodeApp_test_client_simple.cpp index 6c497e81255..3ce00441f3a 100644 --- a/TAO/CIAO/DAnCE/tests/NodeApplicationTest/NodeApp_test_client_simple.cpp +++ b/TAO/CIAO/DAnCE/tests/NodeApplicationTest/NodeApp_test_client_simple.cpp @@ -4,6 +4,7 @@ #include "Client_init.h" #include "NodeAppTest_RoundTripC.h" #include "ace/Get_Opt.h" +#include "assert.h" const char *ior = "file://test.ior"; @@ -51,23 +52,23 @@ main (int argc, char *argv[]) orb->string_to_object(ior ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - Deployment::NodeApplication_var comserv = + Deployment::NodeApplication_var node_app = Deployment::NodeApplication::_narrow(tmp.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (CORBA::is_nil (comserv.in ())) + if (CORBA::is_nil (node_app.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, - "Nil ServerActivator reference <%s>\n", + "Nil nodeapplication reference <%s>\n", ior), 1); } - ACE_DEBUG ((LM_DEBUG, "Try installing Home\n")); + ACE_DEBUG ((LM_DEBUG, "Try installing Home and Component\n")); - Deployment::ImplementationInfo info; + Deployment::ComponentImplementationInfo info; // Add the names and entry points of each of the DLLs info.component_instance_name = "NodeAppTest_RoundTrip"; @@ -76,8 +77,18 @@ main (int argc, char *argv[]) info.servant_dll = "NodeAppTest_RoundTrip_svnt"; info.servant_entrypt = "createNodeAppTest_RoundTripHome_Servant"; + // Create a ContainerImplementationInfo sequence + Deployment::ContainerImplementationInfo container_info; + container_info.length (1); + container_info[0] = info; + + // Create a NodeImplementationInfo sequence + Deployment::NodeImplementationInfo node_info; + node_info.length (1); + node_info[0] = container_info; +/* // Install the NodeApplication Test component - ::Components::CCMHome_var home = comserv->install_home (info); + ::Components::CCMHome_var home = node_app->install_home (info); ACE_TRY_CHECK; // Narrow the Home to the appropriate component @@ -93,9 +104,22 @@ main (int argc, char *argv[]) } // Get Component from Home - ACE_DEBUG ((LM_DEBUG, "Try obtaining RoundTrip ref from Home\n")); + ACE_DEBUG ((LM_DEBUG, "Try obtaining RoundTrip component ref from Home\n")); NodeAppTest::NodeAppTest_RoundTrip_var roundtrip_var = home_var->create (ACE_ENV_SINGLE_ARG_PARAMETER); +*/ + Deployment::ComponentInfos_var comp_info = + node_app->install (node_info ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + assert (comp_info->length () == 1); //return 1 component objeref + + const CORBA::ULong i = 0; + Components::CCMObject_ptr objref = + (comp_info[i]).component_ref; + + NodeAppTest::NodeAppTest_RoundTrip_var roundtrip_var = + NodeAppTest::NodeAppTest_RoundTrip::_narrow (objref); if (CORBA::is_nil (roundtrip_var.in ())) { @@ -120,9 +144,11 @@ main (int argc, char *argv[]) exit (1); } + /* ACE_DEBUG ((LM_DEBUG, "Try removing home\n")); - comserv->remove_home (info.component_instance_name); + node_app->remove_home (info.component_instance_name); ACE_DEBUG ((LM_DEBUG, "Home removed successfully\n")); +*/ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; |