diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2007-02-15 12:23:14 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2007-02-15 12:23:14 +0000 |
commit | d06953733bf8bb9553ea610ce46cdebecfc93891 (patch) | |
tree | 0cacd17be5f824262017fa08ba6ee2d95e67fe34 | |
parent | 0656e3999d79c5842fcfa29e77ef29a2c5587743 (diff) | |
download | ATCD-d06953733bf8bb9553ea610ce46cdebecfc93891.tar.gz |
Thu Feb 14 12:22:14 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
31 files changed, 925 insertions, 926 deletions
diff --git a/CIAO/CIDLC/ServantHeaderGenerator.cpp b/CIAO/CIDLC/ServantHeaderGenerator.cpp index 8368d36519b..2e3c584c73a 100644 --- a/CIAO/CIDLC/ServantHeaderGenerator.cpp +++ b/CIAO/CIDLC/ServantHeaderGenerator.cpp @@ -1648,7 +1648,7 @@ ServantHeaderEmitter::pre (TranslationUnit&) bool swapping = (swap_option == "upgradeable"); os << "#include \"ciao/" - << (swapping ? "Swapping_Container.h" : "Container_Base.h") + << (swapping ? "Swapping_Container.h" : "Session_Container.h") << "\"" << endl << "#include \"ciao/" << (swapping ? "Upgradeable_Context_Impl_T.h" diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index f3248df0887..8175962b216 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,12 +1,63 @@ +Thu Feb 14 12:22:14 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl> + + * ciao/Container_Base.cpp: + * ciao/Container_Base.h: + * ciao/Session_Container.cpp: + * ciao/Session_Container.h: + * ciao/Session_Container.inl: + Moved Session_Container to its own file + + * ciao/Container_Base.inl: + Removed, not needed anymore + + * ciao/CCM_Context.idl: + Added resolve_service_reference + + * ciao/CCM_Core.mpc: + Added new Session_Container + + * ciao/Context_Impl_Base.cpp: + * ciao/Context_Impl_Base.h: + Layout changes and implemented resolve_service_reference + + * ciao/Context_Impl_T.cpp: + * ciao/Context_Impl_T.h: + * ciao/Port_Activator.h: + * ciao/Port_Activator_T.h: + * ciao/Servant_Impl_Base.cpp: + * DAnCE/ExecutionManager/Execution_Manager.cpp: + * DAnCE/DomainApplicationManager/Deployment_Configuration.cpp: + * DAnCE/ExecutionManager/Execution_Manager_Impl.cpp: + * DAnCE/ExecutionManager/Execution_Manager_Impl.h: + * DAnCE/NodeApplication/Container_Impl.cpp: + * DAnCE/NodeApplication/Container_Impl.h: + * DAnCE/TargetManager/CmpClient.cpp: + * DAnCE/NodeApplication/NodeApplication_Impl.h: + * DAnCE/TargetManager/TargetManager_exec.h: + Layout changes + + * ciao/Dynamic_Component_Activator.cpp: + * ciao/Dynamic_Component_Activator.h: + * ciao/Swapping_Container.cpp: + * ciao/Swapping_Container.h: + * ciao/Swapping_Servant_Home_Impl_T.cpp: + Renamed add_servant_map to add_servant_to_map and delete_servant_map + to delete_servant_from_map + + * CIDLC/ServantHeaderGenerator.cpp: + Include Session_Container.h instead of Container_Base.h + + * DAnCE/ExecutionManager/DAM_Map.cpp: + No need to use intermediate variables + Tue Feb 13 20:49:13 UTC 2007 Nilabja R <nilabjar@dre.vanderbilt.edu> * DAnCE/TargetManager/CmpClient.cpp: * DAnCE/TargetManager/DomainDataManager.cpp: - Changed in order to address couple of warnings in the TargetManager. + Changed in order to address couple of warnings in the TargetManager. Mon Feb 12 16:02:14 UTC 2007 Nilabja R <nilabjar@dre.vanderbilt.edu> - * RACE: * RACE/Controller: @@ -196,8 +247,8 @@ Mon Feb 12 16:02:14 UTC 2007 Nilabja R <nilabjar@dre.vanderbilt.edu> * RACE/descriptors/flattened_deploymentplan.cdp: Removed these files. Removed the RACE implementation from the HEAD, - since this is obsolete. This module is now in the process of - re-structuring and will be checked in by Nishanth Shankaran. + since this is obsolete. This module is now in the process of + re-structuring and will be checked in by Nishanth Shankaran. Mon Feb 12 12:53:14 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl> diff --git a/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp b/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp index a0df1e2cac8..f4d93d3e33d 100644 --- a/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp +++ b/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp @@ -102,11 +102,9 @@ CIAO::Deployment_Configuration::get_node_manager_ior (const char *name) const return this->get_default_node_manager_ior (); ACE_Hash_Map_Entry - <ACE_CString, - CIAO::Deployment_Configuration::Node_Manager_Info> *entry = 0; + <ACE_CString, CIAO::Deployment_Configuration::Node_Manager_Info> *entry = 0; - if (this->deployment_info_.find (ACE_CString (name), - entry) != 0) + if (this->deployment_info_.find (ACE_CString (name), entry) != 0) { ACE_ERROR ((LM_ERROR, "DAnCE (%P|%t) Deployment_Configuration, " diff --git a/CIAO/DAnCE/ExecutionManager/DAM_Map.cpp b/CIAO/DAnCE/ExecutionManager/DAM_Map.cpp index 003f25b95e0..5d50cc682d0 100644 --- a/CIAO/DAnCE/ExecutionManager/DAM_Map.cpp +++ b/CIAO/DAnCE/ExecutionManager/DAM_Map.cpp @@ -61,9 +61,8 @@ namespace CIAO ::Deployment::DomainApplicationManager_ptr dam) { CIAO_TRACE("Execution_Manager::DAM_Map::bind_dam_reference"); - int const retval = this->map_.rebind (str, dam); - if (retval != 0) + if (this->map_.rebind (str, dam) != 0) return false; return true; @@ -104,9 +103,8 @@ namespace CIAO DAM_Map::unbind_dam (const ACE_CString &str) { CIAO_TRACE("Execution_Manager::DAM_Map::unbind_dam"); - int const retval = this->map_.unbind (str); - if (retval != 0) + if (this->map_.unbind (str) != 0) return false; return true; diff --git a/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp b/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp index 391a833faf4..aeca2391336 100644 --- a/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp +++ b/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp @@ -61,11 +61,9 @@ namespace CIAO } bool - write_ior_file (CORBA::ORB_ptr orb, - CIAO::ExecutionManagerDaemon_ptr obj) + write_ior_file (CORBA::ORB_ptr orb, CIAO::ExecutionManagerDaemon_ptr obj) { - CORBA::String_var ior = - orb->object_to_string (obj); + CORBA::String_var ior = orb->object_to_string (obj); FILE* ior_output_file_ = ACE_OS::fopen (ior_file_name_, "w"); @@ -137,8 +135,7 @@ namespace CIAO try { - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv); + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (!parse_args (argc, argv)) return -1; @@ -146,8 +143,7 @@ namespace CIAO // Get reference to Root POA. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (obj.in ()); + PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); if (CORBA::is_nil (poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, diff --git a/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp b/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp index 1cf5ab79e86..f45063c93ea 100644 --- a/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp +++ b/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp @@ -219,7 +219,6 @@ namespace CIAO } } - void Execution_Manager_Impl::shutdown () { diff --git a/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.h b/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.h index 269ff9c647a..5862d514421 100644 --- a/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.h +++ b/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.h @@ -64,16 +64,14 @@ namespace CIAO // Below method is CIAO specific extension, please see the IDL // definition for more details. - virtual void - destroyManagerByPlan (const char * plan_uuid); + virtual void destroyManagerByPlan (const char * plan_uuid); virtual void shutdown (); // The input parameter is a *new_plan* which has the // same UUID of the existing running plan. virtual void - perform_redeployment ( - const Deployment::DeploymentPlan & plan); + perform_redeployment (const Deployment::DeploymentPlan & plan); virtual Deployment::DeploymentPlan * getPlan (const char * plan_uuid); diff --git a/CIAO/DAnCE/NodeApplication/Container_Impl.cpp b/CIAO/DAnCE/NodeApplication/Container_Impl.cpp index eaaabd4b70f..fbb4e252c0f 100644 --- a/CIAO/DAnCE/NodeApplication/Container_Impl.cpp +++ b/CIAO/DAnCE/NodeApplication/Container_Impl.cpp @@ -53,8 +53,7 @@ CIAO::Container_Impl::init (const CORBA::PolicyList *policies) CORBA::NO_MEMORY ()); } - return this->container_->init (0, - policies); + return this->container_->init (0, policies); } @@ -93,8 +92,7 @@ CIAO::Container_Impl::install ( throw Deployment::InstallationFailure (); // Create component from home - Components::CCMObject_var comp = - kh->create_component (); + Components::CCMObject_var comp = kh->create_component (); if (CORBA::is_nil (comp.in ())) throw Deployment::InstallationFailure (); diff --git a/CIAO/DAnCE/NodeApplication/Container_Impl.h b/CIAO/DAnCE/NodeApplication/Container_Impl.h index 707e3cdb0a1..7b8870e21c8 100644 --- a/CIAO/DAnCE/NodeApplication/Container_Impl.h +++ b/CIAO/DAnCE/NodeApplication/Container_Impl.h @@ -27,7 +27,8 @@ #include "ciao/Deployment_ContainerS.h" #include "ciao/Deployment_NodeApplicationC.h" -#include "ciao/Container_Base.h" +#include "ciao/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 @@ -69,15 +70,12 @@ namespace CIAO install (const ::Deployment::ContainerImplementationInfo & container_impl_info); /// Remove all homes and components - virtual void - remove (); + virtual void remove (); /// Deployment::Container interface defined attributes/operations. - virtual ::Deployment::Properties * - properties (); + virtual ::Deployment::Properties *properties (); - virtual ::Deployment::NodeApplication_ptr - get_node_application (); + virtual ::Deployment::NodeApplication_ptr get_node_application (); /*-------------------------------------------------------------*/ /*------------------- C++ help methods (c++) -----------------*/ @@ -86,7 +84,6 @@ namespace CIAO /// 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); @@ -103,8 +100,7 @@ namespace CIAO * the real thinking for easiness. */ // Remove the home of this particular component - virtual void - remove_home (const char * comp_ins_name); + virtual void remove_home (const char * comp_ins_name); bool register_with_ns (const char * obj_name, @@ -112,9 +108,7 @@ namespace CIAO Components::CCMObject_ptr obj); bool - unregister_with_ns (const char * obj_name, - CORBA::ORB_ptr orb); - + unregister_with_ns (const char * obj_name, CORBA::ORB_ptr orb); // ------------------- CIAO Internal Operations ------------------------ // These below two are helper methods to clean up components diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h index 2dc39fe5991..9b54353062f 100644 --- a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h +++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h @@ -34,7 +34,7 @@ #include "ciaosvcs/Events/CIAO_Events_Base/CIAO_EventsS.h" #include "NodeApp_Configurator.h" -#include "Container_Base.h" +#include "Session_Container.h" using CIAO::Utility::write_IOR; @@ -100,21 +100,17 @@ namespace CIAO CORBA::Boolean start, CORBA::Boolean add_connection); - virtual void - start (); + virtual void start (); /*------------- CIAO specific IDL operations (idl)---------- * *-----------------------------------------------------------*/ - virtual void - ciao_preactivate (); + virtual void ciao_preactivate (); - virtual void - ciao_postactivate (); + virtual void ciao_postactivate (); - virtual void - ciao_passivate (); + virtual void ciao_passivate (); /// Initialize the NodeApplication virtual CORBA::Long init (); @@ -129,12 +125,10 @@ namespace CIAO /// Get the object reference of the NodeApplicationManager. /// This might come in handy later. - virtual ::CORBA::Object_ptr - get_node_application_manager (); + virtual ::CORBA::Object_ptr get_node_application_manager (); /// Access the readonly attribute. - virtual ::Deployment::Properties * - properties (); + virtual ::Deployment::Properties * properties (); /// Remove a component instance from the NodeApplication virtual void remove_component (const char * inst_name); diff --git a/CIAO/DAnCE/TargetManager/CmpClient.cpp b/CIAO/DAnCE/TargetManager/CmpClient.cpp index 685628c2df7..3a2e8c44101 100644 --- a/CIAO/DAnCE/TargetManager/CmpClient.cpp +++ b/CIAO/DAnCE/TargetManager/CmpClient.cpp @@ -28,7 +28,7 @@ namespace TM_Tester */ void write_to_file (::Deployment::Domain domain); - /// variable contains IOR of the TM + /// variable contains IOR of the TM const char * stringified_TM_IOR; /// if add or delete from domain @@ -37,9 +37,9 @@ namespace TM_Tester /// whether to test update domain or not bool call_update = false; - /// contains the host name + /// contains the host name const char * host_name; - + /// parses the arguments and extracts the params bool parse_args (int argc, char *argv[]) { @@ -85,7 +85,7 @@ namespace TM_Tester if (!TM_Tester::parse_args (argc, argv)) return -1; - + // Use the first argument to create the factory object reference, // in real applications we use the naming service, but let's do // the easy part first! @@ -162,15 +162,13 @@ namespace TM_Tester resource_seq[e.index].resourceName.in (), e.propertyName.in ())); } - catch(CORBA::Exception & ex) + catch(const CORBA::Exception & ex) { ACE_ERROR ((LM_ERROR, "Error:TargetManager:commitResources Exception\n")); ACE_ERROR ((LM_ERROR, "Error:TargetManager:CORBA Generic Exception\n")); ACE_ERROR ((LM_ERROR, "Error:TargetManager:Exception in TargetManager call")); } - - // Make a call to release resources , if resource < 0 try { @@ -180,15 +178,15 @@ namespace TM_Tester manager->releaseResources (resource_seq); } } - catch(CORBA::NO_IMPLEMENT &) + catch(const CORBA::NO_IMPLEMENT &) { ACE_ERROR ((LM_ERROR, "Error:TargetManager:CORBA::NO_IMPLEMENT thrown\n")); } - catch (Deployment::ResourceCommitmentFailure&) + catch (const Deployment::ResourceCommitmentFailure&) { ACE_ERROR ((LM_ERROR, "Error:TargetManager releaseResources ResourceNotAvailable Exception\n")); } - catch(CORBA::Exception & ex) + catch(const CORBA::Exception & ex) { ACE_ERROR ((LM_ERROR, "Error:TargetManager:releaseResources Exception\n")); ACE_ERROR ((LM_ERROR, "Error:TargetManager:CORBA Generic Exception\n")); @@ -264,7 +262,7 @@ namespace TM_Tester // Finally destroy the ORB orb->destroy (); } - catch (CORBA::Exception & ex) + catch (CORBA::Exception & ex) { ACE_ERROR ((LM_ERROR, "Error:TargetManager:CORBA exception raised!\n")); } diff --git a/CIAO/DAnCE/TargetManager/TargetManager_exec.h b/CIAO/DAnCE/TargetManager/TargetManager_exec.h index db9997e6eba..0e1b32ea68b 100644 --- a/CIAO/DAnCE/TargetManager/TargetManager_exec.h +++ b/CIAO/DAnCE/TargetManager/TargetManager_exec.h @@ -54,20 +54,15 @@ namespace CIDL_TargetManager_i set_session_context ( ::Components::SessionContext_ptr ctx); - virtual void - ciao_preactivate (); + virtual void ciao_preactivate (); - virtual void - ciao_postactivate (); + virtual void ciao_postactivate (); - virtual void - ccm_activate (); + virtual void ccm_activate (); - virtual void - ccm_passivate (); + virtual void ccm_passivate (); - virtual void - ccm_remove (); + virtual void ccm_remove (); protected: /// The service context pointer @@ -103,8 +98,7 @@ namespace CIDL_TargetManager_i ::Deployment::DomainUpdateKind updateKind); virtual ::Deployment::ResourceCommitmentManager_ptr - createResourceCommitment ( - const ::Deployment::ResourceAllocations& manager); + createResourceCommitment (const ::Deployment::ResourceAllocations& manager); virtual void destroyResourceCommitment ( diff --git a/CIAO/ciao/CCM_Context.idl b/CIAO/ciao/CCM_Context.idl index 52efd23bad0..e5eb75c218f 100644 --- a/CIAO/ciao/CCM_Context.idl +++ b/CIAO/ciao/CCM_Context.idl @@ -6,6 +6,7 @@ #include "ciao/Security.idl" #include "ciao/CCM_Transaction.idl" #include "ciao/CCM_Home.idl" +#include "ciao/CCM_CCMException.idl" // *************** Basic Container interfaces *************** @@ -35,10 +36,10 @@ module Components raises (IllegalState); /** - * @todo Add for QoS4CCM - * Object resolve_service_reference(in string service_id) - * raises (CCMException); + * Added for QoS4CCM */ + Object resolve_service_reference(in string service_id) + raises (CCMException); }; }; #endif /* CCM_CONTEXT_IDL */ diff --git a/CIAO/ciao/CCM_Core.mpc b/CIAO/ciao/CCM_Core.mpc index ba7a4e8ad98..f32d7dedf51 100644 --- a/CIAO/ciao/CCM_Core.mpc +++ b/CIAO/ciao/CCM_Core.mpc @@ -294,6 +294,7 @@ project (CIAO_DnC_Server) : orbsvcslib, portableserver, valuetype, naming, ifr_c Source_Files { Container_Base.cpp + Session_Container.cpp Swapping_Container.cpp Context_Impl_Base.cpp Home_Servant_Impl_Base.cpp diff --git a/CIAO/ciao/Container_Base.cpp b/CIAO/ciao/Container_Base.cpp index 37685102bf2..a2babd2ecea 100644 --- a/CIAO/ciao/Container_Base.cpp +++ b/CIAO/ciao/Container_Base.cpp @@ -2,14 +2,6 @@ #include "Container_Base.h" #include "CIAO_common.h" -#include "ace/DLL.h" -#include "tao/Utils/PolicyList_Destroyer.h" -#include "ace/OS_NS_stdio.h" -#include "Servant_Activator.h" - -#if !defined (__ACE_INLINE__) -# include "Container_Base.inl" -#endif /* __ACE_INLINE__ */ namespace CIAO { @@ -48,556 +40,4 @@ namespace CIAO { return this->orb_.in (); } - - /////////////////////////////////////////////////////////////// - - ACE_Atomic_Op <ACE_SYNCH_MUTEX, unsigned long> - Session_Container::serial_number_ (0); - - Session_Container::Session_Container (CORBA::ORB_ptr o, - Container_Impl *container_impl, - bool static_config_flag, - const Static_Config_EntryPoints_Maps* maps) - : Container (o, container_impl), - number_ (0), - static_config_flag_ (static_config_flag), - static_entrypts_maps_ (maps), - sa_ (0) - { - } - - Session_Container::~Session_Container (void) - { - if (! CORBA::is_nil (this->component_poa_.in ())) - { - this->component_poa_->destroy (1, 1); - } - - if (! CORBA::is_nil (this->facet_cons_poa_.in ())) - { - this->facet_cons_poa_->destroy (1, 1); - } - - if (! CORBA::is_nil (this->home_servant_poa_.in ())) - { - this->home_servant_poa_->destroy (1, 1); - } - - delete this->sa_; - } - - int - Session_Container::init (const char *name, - const CORBA::PolicyList *more_policies) - { - CIAO_TRACE ("Session_Container::init"); - - char buffer[MAXPATHLEN]; - - if (name == 0) - { - this->number_ = ++Session_Container::serial_number_; - ACE_OS::sprintf (buffer, - "CIAO::Session_Container-%ld", - this->number_); - name = buffer; - } - - CORBA::Object_var poa_object = - this->orb_->resolve_initial_references("RootPOA"); - - if (CORBA::is_nil (poa_object.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to initialize the POA.\n"), - -1); - } - - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (poa_object.in ()); - - this->create_component_POA (name, - more_policies, - root_poa.in ()); - - ACE_CString port_poa_name (name); - port_poa_name += ":Port_POA"; - this->create_facet_consumer_POA (port_poa_name.c_str (), - more_policies, - root_poa.in ()); - - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (); - - poa_manager->activate (); - - return 0; - } - - void - Session_Container::create_component_POA (const char *name, - const CORBA::PolicyList *p, - PortableServer::POA_ptr root) - { - CIAO_TRACE ("Session_Container::create_component_POA"); - - // Set up proper poa policies here. Default policies seems to be - // fine for session container. If you add some other default - // policies here, then you need to "add" more_policies below - // instead of simply assigning more_policies to the init policy - // list. - CORBA::PolicyList policies (0); - - if (p != 0) - { - policies = *p; - } - - PortableServer::POAManager_var poa_manager = - root->the_POAManager (); - - this->component_poa_ = - root->create_POA (name, - poa_manager.in (), - policies); - } - - void - Session_Container::create_facet_consumer_POA ( - const char *name, - const CORBA::PolicyList *p, - PortableServer::POA_ptr root) - { - CIAO_TRACE ("Session_Container::create_facet_consumer_POA"); - - PortableServer::POAManager_var poa_manager = - root->the_POAManager (); - - CORBA::ULong p_length = 0; - if (p != 0) - { - p_length = p->length (); - } - - TAO::Utils::PolicyList_Destroyer policies (p_length + 3); - policies.length (p_length + 3); - - policies[0] = - root->create_id_assignment_policy (PortableServer::USER_ID); - - // Servant Manager Policy - policies[1] = - root->create_request_processing_policy - (PortableServer::USE_SERVANT_MANAGER); - - // Servant Retention Policy - policies[2] = - root->create_servant_retention_policy (PortableServer::RETAIN); - - for (CORBA::ULong i = 0; i < p_length; ++i) - { - policies[i+3] = (*p)[i]; - } - - this->facet_cons_poa_ = - root->create_POA (name, - poa_manager.in (), - policies); - - ACE_NEW_THROW_EX (this->sa_, - Servant_Activator (this->orb_.in ()), - CORBA::NO_MEMORY ()); - - this->facet_cons_poa_->set_servant_manager ( - this->sa_ - ); - } - - CORBA::Object_ptr - Session_Container::install_servant (PortableServer::Servant p, - Container::OA_Type t) - { - CIAO_TRACE ("Session_Container::install_servant"); - - PortableServer::POA_ptr tmp = 0; - - if (t == Container::Component) - { - tmp = this->component_poa_.in (); - } - else - { - tmp = this->facet_cons_poa_.in (); - } - - PortableServer::ObjectId_var oid = - tmp->activate_object (p); - - CORBA::Object_var objref = - tmp->id_to_reference (oid.in ()); - - return objref._retn (); - } - - CORBA::Object_ptr - Session_Container::install_component (PortableServer::Servant p, - PortableServer::ObjectId_out oid) - { - CIAO_TRACE ("Session_Container::install_component"); - PortableServer::ObjectId_var id = - this->component_poa_->activate_object (p); - - CORBA::Object_var objref = - this->component_poa_->id_to_reference (id.in ()); - - oid = id._retn (); - - return objref._retn (); - } - - - //@@ Apparently we need to be cautious when handling the exception - // thrown here. We should make sure that new DnC interfaces - // NodeApplication/NodeApplicationManager etc will cache the new - // exceptions--> rethrow of new exceptions is needed. - // --Tao - Components::CCMHome_ptr - Session_Container::ciao_install_home (const char *exe_dll_name, - const char *exe_entrypt, - const char *sv_dll_name, - const char *sv_entrypt, - const char *ins_name) - { - CIAO_TRACE ("Session_Container::ciao_install_home"); - - HomeFactory hcreator = 0; - ServantFactory screator = 0; - - if (this->static_config_flag_ == false) - { - ACE_DLL executor_dll, servant_dll; - - if (exe_dll_name == 0 || sv_dll_name == 0) - { - ACE_CString exception; - - if (exe_dll_name == 0) - { - exception = "Null component executor DLL name"; - } - - if (sv_dll_name == 0) - { - exception = "Null component servant DLL name"; - } - - ACE_ERROR ((LM_ERROR, - "CIAO (%P|%t) Container_Base.cpp -" - "Session_Container::ciao_install_home -" - "ERROR: %s\n", - exception.c_str ())); - - ACE_THROW_RETURN - (Deployment::UnknownImplId ( - "Session_Container::ciao_install_home", - exception.c_str ()), - Components::CCMHome::_nil ()); - } - - if (executor_dll.open (exe_dll_name, - ACE_DEFAULT_SHLIB_MODE, - 0) != 0) - { - ACE_CString error ("Failed to open executor DLL: "); - error += exe_dll_name; - - ACE_ERROR ((LM_ERROR, - "CIAO (%P|%t) Container_Base.cpp -" - "Session_Container::ciao_install_home -" - "ERROR in opening the executor DLL [%s] \n", - exe_dll_name)); - - ACE_THROW_RETURN - (Deployment::UnknownImplId - ("Session_Container::ciao_install_home", - error.c_str ()), Components::CCMHome::_nil ()); - } - - if (servant_dll.open (sv_dll_name, - ACE_DEFAULT_SHLIB_MODE, - 0) != 0) - { - ACE_CString error ("Failed to open executor DLL: "); - error += sv_dll_name; - - ACE_ERROR ((LM_ERROR, - "CIAO (%P|%t) Container_Base.cpp -" - "Session_Container::ciao_install_home -" - "ERROR in opening the servant DLL [%s] \n", - sv_dll_name)); - - ACE_THROW_RETURN - (Deployment::UnknownImplId - ("Session_Container::ciao_install_home", - error.c_str ()), Components::CCMHome::_nil ()); - } - - if (exe_entrypt == 0 || sv_entrypt == 0) - { - ACE_CString error ("Entry point is null for "); - - if (exe_entrypt == 0) - { - ACE_ERROR ((LM_ERROR, - "CIAO (%P|%t) Container_Base.cpp -" - "Session_Container::ciao_install_home -" - "ERROR in opening the executor entry point " - "for executor DLL [%s] \n", - exe_dll_name)); - error += exe_dll_name; - } - else - { - ACE_ERROR ((LM_ERROR, - "CIAO (%P|%t) Container_Base.cpp -" - "Session_Container::ciao_install_home -" - "ERROR in opening the servant entry point " - "for servant DLL [%s] \n", - sv_dll_name)); - error += sv_dll_name; - } - - ACE_THROW_RETURN - (Deployment::ImplEntryPointNotFound - ("Session_Container::ciao_install_home", - error.c_str ()), Components::CCMHome::_nil ()); - } - - // We have to do this casting in two steps because the C++ - // standard forbids casting a pointer-to-object (including - // void*) directly to a pointer-to-function. - void *void_ptr = executor_dll.symbol (exe_entrypt); - ptrdiff_t tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr); - hcreator = reinterpret_cast<HomeFactory> (tmp_ptr); - - void_ptr = servant_dll.symbol (sv_entrypt); - tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr); - screator = reinterpret_cast<ServantFactory> (tmp_ptr); - } - else - { - if (static_entrypts_maps_ == 0 - || static_entrypts_maps_->home_creator_funcptr_map_ == 0 - || static_entrypts_maps_->home_servant_creator_funcptr_map_ == 0) - { - throw Deployment::ImplEntryPointNotFound (); - } - - ACE_CString exe_entrypt_str (exe_entrypt); - static_entrypts_maps_->home_creator_funcptr_map_->find ( - exe_entrypt_str, - hcreator - ); - - ACE_CString sv_entrypt_str (sv_entrypt); - static_entrypts_maps_->home_servant_creator_funcptr_map_->find ( - sv_entrypt_str, - screator - ); - } - - if (hcreator == 0 || screator == 0) - { - ACE_CString error ("Entry point "); - - if (hcreator == 0) - { - error += exe_entrypt; - error += " invalid in dll "; - error += exe_dll_name; - } - else - { - error += sv_entrypt; - error += " invalid in dll "; - error += sv_dll_name; - } - - ACE_THROW_RETURN - (Deployment::ImplEntryPointNotFound - ("SessionContainer::ciao_install_home", - error.c_str ()), Components::CCMHome::_nil ()); - } - - Components::HomeExecutorBase_var home_executor = hcreator (); - - if (CORBA::is_nil (home_executor.in ())) - { - ACE_THROW_RETURN - (Deployment::InstallationFailure - ("SessionContainer::ciao_install_home", - "Executor entrypoint failed to create a home."), - Components::CCMHome::_nil ()); - } - - PortableServer::Servant home_servant = screator (home_executor.in (), - this, - ins_name); - - if (home_servant == 0) - { - ACE_THROW_RETURN - (Deployment::InstallationFailure - ("SessionContainer::ciao_install_home", - "Servant entrypoing failed to create a home."), - Components::CCMHome::_nil ()); - } - - PortableServer::ServantBase_var safe (home_servant); - - CORBA::Object_var objref = - this->install_servant (home_servant, - Container::Component); - - Components::CCMHome_var homeref = - Components::CCMHome::_narrow (objref.in ()); - - return homeref._retn (); - } - - void - Session_Container::ciao_uninstall_home (Components::CCMHome_ptr homeref) - { - CIAO_TRACE ("Session_Container::ciao_uninstall_home"); - - this->uninstall (homeref, - Container::Component); - } - - void - Session_Container::uninstall (CORBA::Object_ptr objref, - Container::OA_Type t) - { - CIAO_TRACE ("Session_Container::uninstall"); - - PortableServer::POA_ptr tmp = 0; - - if (t == Container::Component) - { - tmp = this->component_poa_.in (); - } - else - { - tmp = this->facet_cons_poa_.in (); - } - - PortableServer::ObjectId_var oid = - tmp->reference_to_id (objref); - - tmp->deactivate_object (oid.in ()); - } - - void - Session_Container::uninstall (PortableServer::Servant svt, - Container::OA_Type t) - { - CIAO_TRACE ("Session_Container::uninstall"); - PortableServer::POA_ptr tmp = 0; - - if (t == Container::Component) - { - tmp = this->component_poa_.in (); - } - else - { - tmp = this->facet_cons_poa_.in (); - } - - PortableServer::ObjectId_var oid - = tmp->servant_to_id (svt); - - tmp->deactivate_object (oid.in ()); - } - - void - Session_Container::uninstall_component (Components::CCMObject_ptr objref, - PortableServer::ObjectId_out oid) - { - CIAO_TRACE ("Session_Container::uninstall_component"); - - PortableServer::ObjectId_var id = - this->component_poa_->reference_to_id (objref); - - this->component_poa_->deactivate_object (id.in ()); - - oid = id._retn (); - } - - void - Session_Container::add_servant_map ( - PortableServer::ObjectId &, - Dynamic_Component_Servant_Base* - ) - { - CIAO_TRACE ("Session_Container::add_servant_map"); - } - - void - Session_Container::deactivate_facet (const PortableServer::ObjectId &) - { - CIAO_TRACE ("Session_Container::deactivate_facet"); - } - - void - Session_Container::delete_servant_map ( - PortableServer::ObjectId & - ) - { - CIAO_TRACE ("Session_Container::delete_servant_map"); - } - - CORBA::Object_ptr - Session_Container::get_home_objref (PortableServer::Servant) - { - CIAO_TRACE ("Session_Container::get_home_objref"); - throw CORBA::NO_IMPLEMENT (); - } - - CORBA::Object_ptr - Session_Container::generate_reference (const char *obj_id, - const char *repo_id, - Container::OA_Type t) - { - CIAO_TRACE ("Session_Container::generate_reference"); - - PortableServer::POA_ptr tmp = 0; - - if (t == Container::Component) - { - tmp = this->component_poa_.in (); - } - else - { - tmp = this->facet_cons_poa_.in (); - } - - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (obj_id); - - CORBA::String_var str = - PortableServer::ObjectId_to_string (oid.in ()); - - if (t == Container::Facet_Consumer) - { - //if (CIAO::debug_level () > 9) - // ACE_DEBUG ((LM_DEBUG, "STRING in container is %s\n", - // str.in ())); - } - - CORBA::Object_var objref = - tmp->create_reference_with_id (oid.in (), - repo_id); - - return objref._retn (); - } } diff --git a/CIAO/ciao/Container_Base.h b/CIAO/ciao/Container_Base.h index 0b028cbfa73..9594187126e 100644 --- a/CIAO/ciao/Container_Base.h +++ b/CIAO/ciao/Container_Base.h @@ -20,23 +20,18 @@ #include /**/ "ace/pre.h" #include "ciao/CCM_ContainerC.h" -#include "ciao/Deployment_CoreC.h" #include "ciao/CIAO_Server_Export.h" #include "tao/PortableServer/PortableServer.h" -#include "tao/PortableServer/Servant_Base.h" #include "tao/ORB.h" -#include "ace/Hash_Map_Manager_T.h" - #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ namespace CIAO { - class Servant_Activator; class Dynamic_Component_Servant_Base; class Container_Impl; @@ -75,8 +70,7 @@ namespace CIAO /// Initialize the container with a name. virtual int init (const char *name = 0, - const CORBA::PolicyList *more_policies = 0) - = 0; + const CORBA::PolicyList *more_policies = 0) = 0; /// Install a new home virtual Components::CCMHome_ptr ciao_install_home ( @@ -84,28 +78,21 @@ namespace CIAO const char *exe_entrypt, const char *sv_dll_name, const char *sv_entrypt, - const char *ins_name - ) - = 0; + const char *ins_name) = 0; // Uninstall a servant for component or home. - virtual void ciao_uninstall_home (Components::CCMHome_ptr homeref) - = 0; + virtual void ciao_uninstall_home (Components::CCMHome_ptr homeref) = 0; // Uninstall a servant for component. virtual void uninstall_component (::Components::CCMObject_ptr objref, - PortableServer::ObjectId_out oid) - = 0; + PortableServer::ObjectId_out oid) = 0; - // @@Jai, please see the Session Container class for comments. - // @@ Jai, do you really need the environment variable? - virtual void add_servant_map (PortableServer::ObjectId &oid, - Dynamic_Component_Servant_Base* servant) = 0; + virtual void add_servant_to_map (PortableServer::ObjectId &oid, + Dynamic_Component_Servant_Base* servant) = 0; - virtual void delete_servant_map (PortableServer::ObjectId &oid) = 0; + virtual void delete_servant_from_map (PortableServer::ObjectId &oid) = 0; - virtual CORBA::Object_ptr get_home_objref (PortableServer::Servant p) - = 0; + virtual CORBA::Object_ptr get_home_objref (PortableServer::Servant p) = 0; protected: /// Reference to the ORB @@ -129,165 +116,6 @@ namespace CIAO /// Not allowed to be used Container (void); }; - - class Session_Container; - - typedef ::Components::HomeExecutorBase_ptr (*HomeFactory) (void); - typedef ::PortableServer::Servant (*ServantFactory) - (::Components::HomeExecutorBase_ptr p, - ::CIAO::Session_Container *c, - const char *ins_name -#if !defined (TAO_HAS_EXCEPTIONS) || defined (ACE_ENV_BKWD_COMPAT) - , CORBA::Environment & -#endif - ); - - typedef ACE_Hash_Map_Manager_Ex<ACE_CString, - HomeFactory, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - ACE_Null_Mutex> HOMECREATOR_FUNCPTR_MAP; - - typedef ACE_Hash_Map_Manager_Ex<ACE_CString, - ServantFactory, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, - ACE_Null_Mutex> HOMESERVANTCREATOR_FUNCPTR_MAP; - - struct Static_Config_EntryPoints_Maps - { - /// Map of home creator entry point name and func ptr - HOMECREATOR_FUNCPTR_MAP* home_creator_funcptr_map_; - - /// Map of home servant creator entry point name and func ptr - HOMESERVANTCREATOR_FUNCPTR_MAP* home_servant_creator_funcptr_map_; - }; - - class CIAO_SERVER_Export Session_Container : public Container - { - public: - Session_Container (CORBA::ORB_ptr o, - Container_Impl *container_impl, - bool static_config_flag = false, - const Static_Config_EntryPoints_Maps* static_entrypts_maps =0); - - virtual ~Session_Container (void); - - /// Initialize the container with a name. - virtual int init (const char *name = 0, - const CORBA::PolicyList *more_policies = 0) -; - - /** - * @brief Simply installing a home executor into the component. - * - * This operation install a home executor into the component. It - * requires the name of the DLLs to executor and the servant glue - * code, and the entry points to the respective DLLs. Currently, - * we don't try to manage the lifetime of DLL objects, but we - * should at some later point. - * - * @retval Home objref of the installed home. - */ - virtual Components::CCMHome_ptr ciao_install_home ( - const char *exe_dll_name, - const char *exe_entrypt, - const char *sv_dll_name, - const char *sv_entrypt, - const char *ins_name - ); - - /// Uninstall a servant for component or home. - virtual void ciao_uninstall_home (Components::CCMHome_ptr homeref); - - /// Uninstall a servant for component. - virtual void uninstall_component (::Components::CCMObject_ptr objref, - PortableServer::ObjectId_out oid); - - /// Install a servant for component or home. - virtual CORBA::Object_ptr install_servant (PortableServer::Servant p, - Container::OA_Type t); - - /// Install a component servant. - CORBA::Object_ptr install_component (PortableServer::Servant p, - PortableServer::ObjectId_out oid); - - /// Get an object reference to a component or home from the servant. - virtual CORBA::Object_ptr get_objref (PortableServer::Servant p); - - /// Uninstall a servant for component or home. - void uninstall (CORBA::Object_ptr objref, - Container::OA_Type t); - - /// Uninstall a servant for component or home. - void uninstall (PortableServer::Servant svt, - Container::OA_Type t); - - // @@Jai, please consider naming this method as - // "add_servant_to_map ()" to be more descriptive. - virtual void add_servant_map (PortableServer::ObjectId &oid, - Dynamic_Component_Servant_Base* servant); - - // @@Jai, please consider naming this method as - // "delete_servant_from_map ()" to be more descriptive. - virtual void delete_servant_map (PortableServer::ObjectId &oid); - - // @@Jai, could yo please add documentation? - /* - * @@Jai, you may want to consider moving these away from the - * container interface. I know what you are going to say - * :-). Consider using dynamic_cast <> to access - * add_servant_to_map, delete_servant_from_map and - * deactivate_facet from the Swapping_Conatiner's interface. It - * would make the base container interface much cleaner. - */ - virtual void deactivate_facet (const PortableServer::ObjectId &oid); - - virtual CORBA::Object_ptr get_home_objref (PortableServer::Servant p); - - /// Analog of the POA method that creates an object reference from - /// an object id string. - CORBA::Object_ptr generate_reference (const char *obj_id, - const char *repo_id, - Container::OA_Type t); - - /// Return the servant activator factory that activates the - /// servants for facets and consumers. - Servant_Activator *ports_servant_activator (void) const; - - private: - - /// Create POA for the component. - /** - * This is the POA that is returned to the component applications - * if they need one. - */ - void create_component_POA (const char *name, - const CORBA::PolicyList *p, - PortableServer::POA_ptr root); - - /// Create POA for the facets and consumers alone. - void create_facet_consumer_POA (const char *name, - const CORBA::PolicyList *p, - PortableServer::POA_ptr root); - - /// Not allowed to be - Session_Container (void); - - protected: - unsigned long number_; - - /// Static variable to store the highest number we have given out until - /// now - static ACE_Atomic_Op <ACE_SYNCH_MUTEX, unsigned long> serial_number_; - - const bool static_config_flag_; - const Static_Config_EntryPoints_Maps* static_entrypts_maps_; - - /// The servant activator factory used to activate facets and - /// consumer servants. - Servant_Activator *sa_; - }; } // Macro for registration of an OBV factory in the generated @@ -308,9 +136,5 @@ namespace CIAO CORBA::add_ref (factory); \ } -#if defined (__ACE_INLINE__) -# include "Container_Base.inl" -#endif /* __ACE_INLINE__ */ - #include /**/ "ace/post.h" #endif /* CIAO_CONTAINER_BASE_H */ diff --git a/CIAO/ciao/Context_Impl_Base.cpp b/CIAO/ciao/Context_Impl_Base.cpp index 55980ea0b71..6c12db12ab5 100644 --- a/CIAO/ciao/Context_Impl_Base.cpp +++ b/CIAO/ciao/Context_Impl_Base.cpp @@ -1,6 +1,9 @@ // $Id$ #include "Context_Impl_Base.h" +#include "Container_Base.h" +#include "Session_Container.h" +#include "tao/ORB.h" namespace CIAO { @@ -23,48 +26,58 @@ namespace CIAO // Operations from ::Components::CCMContext. Components::Principal_ptr - Context_Impl_Base::get_caller_principal ( - ) + Context_Impl_Base::get_caller_principal (void) { throw CORBA::NO_IMPLEMENT (); } Components::CCMHome_ptr - Context_Impl_Base::get_CCM_home ( - ) + Context_Impl_Base::get_CCM_home (void) { return Components::CCMHome::_duplicate (this->home_.in ()); } CORBA::Boolean - Context_Impl_Base::get_rollback_only ( - ) + Context_Impl_Base::get_rollback_only (void) { throw CORBA::NO_IMPLEMENT (); } Components::Transaction::UserTransaction_ptr - Context_Impl_Base::get_user_transaction ( - ) + Context_Impl_Base::get_user_transaction (void) { throw CORBA::NO_IMPLEMENT (); } CORBA::Boolean - Context_Impl_Base::is_caller_in_role ( - const char * /* role */ - ) + Context_Impl_Base::is_caller_in_role (const char * /* role */) { throw CORBA::NO_IMPLEMENT (); } void - Context_Impl_Base::set_rollback_only ( - ) + Context_Impl_Base::set_rollback_only (void) { throw CORBA::NO_IMPLEMENT (); } + CORBA::Object_ptr + Context_Impl_Base::resolve_service_reference(const char *service_id) + { + CORBA::Object_ptr obj; + try + { + obj = this->container_->the_ORB ()->resolve_initial_references (service_id); + } + catch (const ::CORBA::ORB::InvalidName&) + { + throw ::Components::CCMException ( + ::Components::OBJECT_NOT_FOUND); + } + + return obj; + } + // CIAO-specific. CIAO::Session_Container * diff --git a/CIAO/ciao/Context_Impl_Base.h b/CIAO/ciao/Context_Impl_Base.h index 33c12d8ad5c..5dc8cae2a46 100644 --- a/CIAO/ciao/Context_Impl_Base.h +++ b/CIAO/ciao/Context_Impl_Base.h @@ -60,30 +60,26 @@ namespace CIAO /// the compilers want it, have to sort this out in detail. Context_Impl_Base (void); - Context_Impl_Base (Components::CCMHome_ptr home, - Session_Container * c); + Context_Impl_Base (Components::CCMHome_ptr home, Session_Container * c); virtual ~Context_Impl_Base (void); // Operations from ::Components::CCMContext. - virtual Components::Principal_ptr - get_caller_principal (); + virtual Components::Principal_ptr get_caller_principal (); - virtual Components::CCMHome_ptr - get_CCM_home (); + virtual Components::CCMHome_ptr get_CCM_home (); - virtual CORBA::Boolean - get_rollback_only (); + virtual CORBA::Boolean get_rollback_only (); virtual Components::Transaction::UserTransaction_ptr get_user_transaction (); - virtual CORBA::Boolean - is_caller_in_role (const char *role); + virtual CORBA::Boolean is_caller_in_role (const char *role); - virtual void - set_rollback_only (); + virtual void set_rollback_only (); + + virtual CORBA::Object_ptr resolve_service_reference(const char *service_id); // CIAO-specific. diff --git a/CIAO/ciao/Context_Impl_T.cpp b/CIAO/ciao/Context_Impl_T.cpp index eb6153c58d1..29558dafb0b 100644 --- a/CIAO/ciao/Context_Impl_T.cpp +++ b/CIAO/ciao/Context_Impl_T.cpp @@ -32,8 +32,7 @@ namespace CIAO typename SVNT, typename COMP> CORBA::Object_ptr - Context_Impl<BASE_CTX, SVNT, COMP>::get_CCM_object ( - ) + Context_Impl<BASE_CTX, SVNT, COMP>::get_CCM_object (void) { if (CORBA::is_nil (this->component_.in ())) { @@ -41,8 +40,7 @@ namespace CIAO try { - obj = - this->container_->get_objref (this->servant_); + obj = this->container_->get_objref (this->servant_); } catch (const CORBA::Exception& ex) { @@ -50,7 +48,6 @@ namespace CIAO return CORBA::Object::_nil (); } - this->component_ = COMP::_narrow (obj.in ()); if (CORBA::is_nil (this->component_.in ())) diff --git a/CIAO/ciao/Context_Impl_T.h b/CIAO/ciao/Context_Impl_T.h index cc2370b251b..d4e0deb4cba 100644 --- a/CIAO/ciao/Context_Impl_T.h +++ b/CIAO/ciao/Context_Impl_T.h @@ -80,8 +80,7 @@ namespace CIAO // Operations from ::Components::SessionContext. - virtual CORBA::Object_ptr - get_CCM_object (); + virtual CORBA::Object_ptr get_CCM_object (); protected: SVNT *servant_; diff --git a/CIAO/ciao/Dynamic_Component_Activator.cpp b/CIAO/ciao/Dynamic_Component_Activator.cpp index 1c41aa00575..7d24c5c34cf 100644 --- a/CIAO/ciao/Dynamic_Component_Activator.cpp +++ b/CIAO/ciao/Dynamic_Component_Activator.cpp @@ -44,14 +44,14 @@ namespace CIAO { } - void Dynamic_Component_Activator::add_servant_map + void Dynamic_Component_Activator::add_servant_to_map (PortableServer::ObjectId &oid, Dynamic_Component_Servant_Base* servant) { this->servant_map_.bind (oid, servant); } - void Dynamic_Component_Activator::delete_servant_map + void Dynamic_Component_Activator::delete_servant_from_map (PortableServer::ObjectId &oid) { Dynamic_Component_Servant_Base* servant = 0; diff --git a/CIAO/ciao/Dynamic_Component_Activator.h b/CIAO/ciao/Dynamic_Component_Activator.h index 6c45fe287c4..2d037c0b3e0 100644 --- a/CIAO/ciao/Dynamic_Component_Activator.h +++ b/CIAO/ciao/Dynamic_Component_Activator.h @@ -73,10 +73,10 @@ namespace CIAO CORBA::Boolean cleanup_in_progress, CORBA::Boolean remaining_activations); - void add_servant_map (PortableServer::ObjectId &oid, + void add_servant_to_map (PortableServer::ObjectId &oid, Dynamic_Component_Servant_Base* servant); - void delete_servant_map (PortableServer::ObjectId &oid); + void delete_servant_from_map (PortableServer::ObjectId &oid); private: /// Pointer to our ORB diff --git a/CIAO/ciao/Port_Activator.h b/CIAO/ciao/Port_Activator.h index f3914d7d786..ddbc66954ad 100644 --- a/CIAO/ciao/Port_Activator.h +++ b/CIAO/ciao/Port_Activator.h @@ -45,9 +45,7 @@ namespace CIAO Sink }; - Port_Activator (const char *oid, - const char *name, - Type t); + Port_Activator (const char *oid, const char *name, Type t); virtual ~Port_Activator (void); @@ -69,8 +67,7 @@ namespace CIAO virtual PortableServer::Servant activate ( const PortableServer::ObjectId &oid) = 0; - virtual void deactivate ( - const PortableServer::Servant servant) = 0; + virtual void deactivate (const PortableServer::Servant servant) = 0; protected: /// The object ID that is used to activate the servant within the diff --git a/CIAO/ciao/Port_Activator_T.h b/CIAO/ciao/Port_Activator_T.h index bf159c89b4e..42d25a63dd7 100644 --- a/CIAO/ciao/Port_Activator_T.h +++ b/CIAO/ciao/Port_Activator_T.h @@ -55,8 +55,7 @@ namespace CIAO PortableServer::Servant activate ( const PortableServer::ObjectId &oid); - void deactivate ( - const PortableServer::Servant servant); + void deactivate (const PortableServer::Servant servant); private: /// The executor diff --git a/CIAO/ciao/Servant_Impl_Base.cpp b/CIAO/ciao/Servant_Impl_Base.cpp index 30072e85e8d..ab97d3c0463 100644 --- a/CIAO/ciao/Servant_Impl_Base.cpp +++ b/CIAO/ciao/Servant_Impl_Base.cpp @@ -2,7 +2,7 @@ #include "Servant_Impl_Base.h" #include "StandardConfigurator_Impl.h" -#include "Container_Base.h" +#include "Session_Container.h" namespace CIAO { @@ -22,35 +22,30 @@ namespace CIAO // Operations for CCMObject interface. ::Components::PrimaryKeyBase * - Servant_Impl_Base::get_primary_key ( - ) + Servant_Impl_Base::get_primary_key (void) { throw ::Components::NoKeyAvailable (); } CORBA::IRObject_ptr - Servant_Impl_Base::get_component_def ( - ) + Servant_Impl_Base::get_component_def (void) { throw CORBA::NO_IMPLEMENT (); } void - Servant_Impl_Base::configuration_complete ( - ) + Servant_Impl_Base::configuration_complete (void) { // CIAO to-do } void - Servant_Impl_Base::remove ( - ) + Servant_Impl_Base::remove (void) { try { // Removing Facets - Components::FacetDescriptions_var facets = - this->get_all_facets (); + Components::FacetDescriptions_var facets = this->get_all_facets (); CORBA::ULong const facet_len = facets->length (); for (CORBA::ULong i = 0; i < facet_len; ++i) @@ -112,16 +107,13 @@ namespace CIAO } ::Components::ConnectionDescriptions * - Servant_Impl_Base::get_connections ( - const char * /* name */ - ) + Servant_Impl_Base::get_connections (const char * /* name */) { throw CORBA::NO_IMPLEMENT (); } ::Components::ComponentPortDescription * - Servant_Impl_Base::get_all_ports ( - ) + Servant_Impl_Base::get_all_ports (void) { OBV_Components::ComponentPortDescription *cps = 0; ACE_NEW_RETURN (cps, @@ -154,9 +146,7 @@ namespace CIAO } CORBA::Object_ptr - Servant_Impl_Base::provide_facet ( - const char *name - ) + Servant_Impl_Base::provide_facet (const char *name) { if (0 == name) { @@ -175,8 +165,7 @@ namespace CIAO Components::FacetDescriptions * Servant_Impl_Base::get_named_facets ( - const ::Components::NameList & names - ) + const ::Components::NameList & names) { Components::FacetDescriptions *retval = 0; ACE_NEW_RETURN (retval, @@ -203,8 +192,7 @@ namespace CIAO } ::Components::FacetDescriptions * - Servant_Impl_Base::get_all_facets ( - ) + Servant_Impl_Base::get_all_facets (void) { ::Components::FacetDescriptions *tmp = 0; ACE_NEW_RETURN (tmp, @@ -229,8 +217,7 @@ namespace CIAO ::Components::ConsumerDescriptions * - Servant_Impl_Base::get_all_consumers ( - ) + Servant_Impl_Base::get_all_consumers (void) { ::Components::ConsumerDescriptions *tmp = 0; ACE_NEW_THROW_EX (tmp, @@ -256,9 +243,7 @@ namespace CIAO ::Components::EventConsumerBase_ptr - Servant_Impl_Base::get_consumer ( - const char *sink_name - ) + Servant_Impl_Base::get_consumer (const char *sink_name) { if (0 == sink_name) { @@ -278,8 +263,7 @@ namespace CIAO ::Components::ConsumerDescriptions * Servant_Impl_Base::get_named_consumers ( - const ::Components::NameList & names - ) + const ::Components::NameList & names) { Components::ConsumerDescriptions *retval = 0; ACE_NEW_RETURN (retval, @@ -307,8 +291,7 @@ namespace CIAO ::Components::EmitterDescriptions * Servant_Impl_Base::get_named_emitters ( - const ::Components::NameList & /* names */ - ) + const ::Components::NameList & /* names */) { throw CORBA::NO_IMPLEMENT (); } @@ -348,16 +331,14 @@ namespace CIAO ::Components::ReceptacleDescriptions * Servant_Impl_Base::get_named_receptacles ( - const ::Components::NameList & /* names */ - ) + const ::Components::NameList & /* names */) { throw ::CORBA::NO_IMPLEMENT (); } ::Components::PublisherDescriptions * Servant_Impl_Base::get_named_publishers ( - const ::Components::NameList & /* names */ - ) + const ::Components::NameList & /* names */) { throw ::CORBA::NO_IMPLEMENT (); } diff --git a/CIAO/ciao/Session_Container.cpp b/CIAO/ciao/Session_Container.cpp new file mode 100644 index 00000000000..ff5050b2ae9 --- /dev/null +++ b/CIAO/ciao/Session_Container.cpp @@ -0,0 +1,548 @@ +// $Id$ + +#include "Session_Container.h" +#include "CIAO_common.h" +#include "ace/DLL.h" +#include "tao/Utils/PolicyList_Destroyer.h" +#include "ace/OS_NS_stdio.h" +#include "Servant_Activator.h" +#include "ciao/Deployment_CoreC.h" + +#if !defined (__ACE_INLINE__) +# include "Session_Container.inl" +#endif /* __ACE_INLINE__ */ + +namespace CIAO +{ + /////////////////////////////////////////////////////////////// + + ACE_Atomic_Op <ACE_SYNCH_MUTEX, unsigned long> + Session_Container::serial_number_ (0); + + Session_Container::Session_Container (CORBA::ORB_ptr o, + Container_Impl *container_impl, + bool static_config_flag, + const Static_Config_EntryPoints_Maps* maps) + : Container (o, container_impl), + number_ (0), + static_config_flag_ (static_config_flag), + static_entrypts_maps_ (maps), + sa_ (0) + { + } + + Session_Container::~Session_Container (void) + { + if (! CORBA::is_nil (this->component_poa_.in ())) + { + this->component_poa_->destroy (1, 1); + } + + if (! CORBA::is_nil (this->facet_cons_poa_.in ())) + { + this->facet_cons_poa_->destroy (1, 1); + } + + if (! CORBA::is_nil (this->home_servant_poa_.in ())) + { + this->home_servant_poa_->destroy (1, 1); + } + + delete this->sa_; + } + + int + Session_Container::init (const char *name, + const CORBA::PolicyList *more_policies) + { + CIAO_TRACE ("Session_Container::init"); + + char buffer[MAXPATHLEN]; + + if (name == 0) + { + this->number_ = ++Session_Container::serial_number_; + ACE_OS::sprintf (buffer, + "CIAO::Session_Container-%ld", + this->number_); + name = buffer; + } + + CORBA::Object_var poa_object = + this->orb_->resolve_initial_references("RootPOA"); + + if (CORBA::is_nil (poa_object.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + -1); + } + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + this->create_component_POA (name, + more_policies, + root_poa.in ()); + + ACE_CString port_poa_name (name); + port_poa_name += ":Port_POA"; + this->create_facet_consumer_POA (port_poa_name.c_str (), + more_policies, + root_poa.in ()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + poa_manager->activate (); + + return 0; + } + + void + Session_Container::create_component_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root) + { + CIAO_TRACE ("Session_Container::create_component_POA"); + + // Set up proper poa policies here. Default policies seems to be + // fine for session container. If you add some other default + // policies here, then you need to "add" more_policies below + // instead of simply assigning more_policies to the init policy + // list. + CORBA::PolicyList policies (0); + + if (p != 0) + { + policies = *p; + } + + PortableServer::POAManager_var poa_manager = + root->the_POAManager (); + + this->component_poa_ = + root->create_POA (name, + poa_manager.in (), + policies); + } + + void + Session_Container::create_facet_consumer_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root) + { + CIAO_TRACE ("Session_Container::create_facet_consumer_POA"); + + PortableServer::POAManager_var poa_manager = root->the_POAManager (); + + CORBA::ULong p_length = 0; + if (p != 0) + { + p_length = p->length (); + } + + TAO::Utils::PolicyList_Destroyer policies (p_length + 3); + policies.length (p_length + 3); + + policies[0] = + root->create_id_assignment_policy (PortableServer::USER_ID); + + // Servant Manager Policy + policies[1] = + root->create_request_processing_policy + (PortableServer::USE_SERVANT_MANAGER); + + // Servant Retention Policy + policies[2] = + root->create_servant_retention_policy (PortableServer::RETAIN); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + policies[i+3] = (*p)[i]; + } + + this->facet_cons_poa_ = + root->create_POA (name, + poa_manager.in (), + policies); + + ACE_NEW_THROW_EX (this->sa_, + Servant_Activator (this->orb_.in ()), + CORBA::NO_MEMORY ()); + + this->facet_cons_poa_->set_servant_manager ( + this->sa_ + ); + } + + CORBA::Object_ptr + Session_Container::install_servant (PortableServer::Servant p, + Container::OA_Type t) + { + CIAO_TRACE ("Session_Container::install_servant"); + + PortableServer::POA_ptr tmp = 0; + + if (t == Container::Component) + { + tmp = this->component_poa_.in (); + } + else + { + tmp = this->facet_cons_poa_.in (); + } + + PortableServer::ObjectId_var oid = + tmp->activate_object (p); + + CORBA::Object_var objref = + tmp->id_to_reference (oid.in ()); + + return objref._retn (); + } + + CORBA::Object_ptr + Session_Container::install_component (PortableServer::Servant p, + PortableServer::ObjectId_out oid) + { + CIAO_TRACE ("Session_Container::install_component"); + PortableServer::ObjectId_var id = + this->component_poa_->activate_object (p); + + CORBA::Object_var objref = + this->component_poa_->id_to_reference (id.in ()); + + oid = id._retn (); + + return objref._retn (); + } + + + //@@ Apparently we need to be cautious when handling the exception + // thrown here. We should make sure that new DnC interfaces + // NodeApplication/NodeApplicationManager etc will cache the new + // exceptions--> rethrow of new exceptions is needed. + // --Tao + Components::CCMHome_ptr + Session_Container::ciao_install_home (const char *exe_dll_name, + const char *exe_entrypt, + const char *sv_dll_name, + const char *sv_entrypt, + const char *ins_name) + { + CIAO_TRACE ("Session_Container::ciao_install_home"); + + HomeFactory hcreator = 0; + ServantFactory screator = 0; + + if (this->static_config_flag_ == false) + { + ACE_DLL executor_dll, servant_dll; + + if (exe_dll_name == 0 || sv_dll_name == 0) + { + ACE_CString exception; + + if (exe_dll_name == 0) + { + exception = "Null component executor DLL name"; + } + + if (sv_dll_name == 0) + { + exception = "Null component servant DLL name"; + } + + ACE_ERROR ((LM_ERROR, + "CIAO (%P|%t) Container_Base.cpp -" + "Session_Container::ciao_install_home -" + "ERROR: %s\n", + exception.c_str ())); + + throw Deployment::UnknownImplId ( + "Session_Container::ciao_install_home", + exception.c_str ()); + } + + if (executor_dll.open (exe_dll_name, + ACE_DEFAULT_SHLIB_MODE, + 0) != 0) + { + ACE_CString error ("Failed to open executor DLL: "); + error += exe_dll_name; + + ACE_ERROR ((LM_ERROR, + "CIAO (%P|%t) Container_Base.cpp -" + "Session_Container::ciao_install_home -" + "ERROR in opening the executor DLL [%s] \n", + exe_dll_name)); + + throw Deployment::UnknownImplId + ("Session_Container::ciao_install_home", + error.c_str ()); + } + + if (servant_dll.open (sv_dll_name, + ACE_DEFAULT_SHLIB_MODE, + 0) != 0) + { + ACE_CString error ("Failed to open executor DLL: "); + error += sv_dll_name; + + ACE_ERROR ((LM_ERROR, + "CIAO (%P|%t) Container_Base.cpp -" + "Session_Container::ciao_install_home -" + "ERROR in opening the servant DLL [%s] \n", + sv_dll_name)); + + throw Deployment::UnknownImplId + ("Session_Container::ciao_install_home", + error.c_str ()); + } + + if (exe_entrypt == 0 || sv_entrypt == 0) + { + ACE_CString error ("Entry point is null for "); + + if (exe_entrypt == 0) + { + ACE_ERROR ((LM_ERROR, + "CIAO (%P|%t) Container_Base.cpp -" + "Session_Container::ciao_install_home -" + "ERROR in opening the executor entry point " + "for executor DLL [%s] \n", + exe_dll_name)); + error += exe_dll_name; + } + else + { + ACE_ERROR ((LM_ERROR, + "CIAO (%P|%t) Container_Base.cpp -" + "Session_Container::ciao_install_home -" + "ERROR in opening the servant entry point " + "for servant DLL [%s] \n", + sv_dll_name)); + error += sv_dll_name; + } + + throw Deployment::ImplEntryPointNotFound + ("Session_Container::ciao_install_home", + error.c_str ()); + } + + // We have to do this casting in two steps because the C++ + // standard forbids casting a pointer-to-object (including + // void*) directly to a pointer-to-function. + void *void_ptr = executor_dll.symbol (exe_entrypt); + ptrdiff_t tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr); + hcreator = reinterpret_cast<HomeFactory> (tmp_ptr); + + void_ptr = servant_dll.symbol (sv_entrypt); + tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr); + screator = reinterpret_cast<ServantFactory> (tmp_ptr); + } + else + { + if (static_entrypts_maps_ == 0 + || static_entrypts_maps_->home_creator_funcptr_map_ == 0 + || static_entrypts_maps_->home_servant_creator_funcptr_map_ == 0) + { + throw Deployment::ImplEntryPointNotFound (); + } + + ACE_CString exe_entrypt_str (exe_entrypt); + static_entrypts_maps_->home_creator_funcptr_map_->find (exe_entrypt_str, + hcreator); + + ACE_CString sv_entrypt_str (sv_entrypt); + static_entrypts_maps_->home_servant_creator_funcptr_map_->find ( + sv_entrypt_str, + screator + ); + } + + if (hcreator == 0 || screator == 0) + { + ACE_CString error ("Entry point "); + + if (hcreator == 0) + { + error += exe_entrypt; + error += " invalid in dll "; + error += exe_dll_name; + } + else + { + error += sv_entrypt; + error += " invalid in dll "; + error += sv_dll_name; + } + + throw Deployment::ImplEntryPointNotFound + ("SessionContainer::ciao_install_home", + error.c_str ()); + } + + Components::HomeExecutorBase_var home_executor = hcreator (); + + if (CORBA::is_nil (home_executor.in ())) + { + throw Deployment::InstallationFailure + ("SessionContainer::ciao_install_home", + "Executor entrypoint failed to create a home."); + } + + PortableServer::Servant home_servant = screator (home_executor.in (), + this, + ins_name); + + if (home_servant == 0) + { + throw Deployment::InstallationFailure + ("SessionContainer::ciao_install_home", + "Servant entrypoing failed to create a home."); + } + + PortableServer::ServantBase_var safe (home_servant); + + CORBA::Object_var objref = + this->install_servant (home_servant, + Container::Component); + + Components::CCMHome_var homeref = + Components::CCMHome::_narrow (objref.in ()); + + return homeref._retn (); + } + + void + Session_Container::ciao_uninstall_home (Components::CCMHome_ptr homeref) + { + CIAO_TRACE ("Session_Container::ciao_uninstall_home"); + + this->uninstall (homeref, + Container::Component); + } + + void + Session_Container::uninstall (CORBA::Object_ptr objref, + Container::OA_Type t) + { + CIAO_TRACE ("Session_Container::uninstall"); + + PortableServer::POA_ptr tmp = 0; + + if (t == Container::Component) + { + tmp = this->component_poa_.in (); + } + else + { + tmp = this->facet_cons_poa_.in (); + } + + PortableServer::ObjectId_var oid = + tmp->reference_to_id (objref); + + tmp->deactivate_object (oid.in ()); + } + + void + Session_Container::uninstall (PortableServer::Servant svt, + Container::OA_Type t) + { + CIAO_TRACE ("Session_Container::uninstall"); + PortableServer::POA_ptr tmp = 0; + + if (t == Container::Component) + { + tmp = this->component_poa_.in (); + } + else + { + tmp = this->facet_cons_poa_.in (); + } + + PortableServer::ObjectId_var oid = tmp->servant_to_id (svt); + + tmp->deactivate_object (oid.in ()); + } + + void + Session_Container::uninstall_component (Components::CCMObject_ptr objref, + PortableServer::ObjectId_out oid) + { + CIAO_TRACE ("Session_Container::uninstall_component"); + + PortableServer::ObjectId_var id = + this->component_poa_->reference_to_id (objref); + + this->component_poa_->deactivate_object (id.in ()); + + oid = id._retn (); + } + + void + Session_Container::add_servant_to_map (PortableServer::ObjectId &, + Dynamic_Component_Servant_Base*) + { + CIAO_TRACE ("Session_Container::add_servant_to_map"); + } + + void + Session_Container::deactivate_facet (const PortableServer::ObjectId &) + { + CIAO_TRACE ("Session_Container::deactivate_facet"); + } + + void + Session_Container::delete_servant_from_map (PortableServer::ObjectId &) + { + CIAO_TRACE ("Session_Container::delete_servant_from_map"); + } + + CORBA::Object_ptr + Session_Container::get_home_objref (PortableServer::Servant) + { + CIAO_TRACE ("Session_Container::get_home_objref"); + throw CORBA::NO_IMPLEMENT (); + } + + CORBA::Object_ptr + Session_Container::generate_reference (const char *obj_id, + const char *repo_id, + Container::OA_Type t) + { + CIAO_TRACE ("Session_Container::generate_reference"); + + PortableServer::POA_ptr tmp = 0; + + if (t == Container::Component) + { + tmp = this->component_poa_.in (); + } + else + { + tmp = this->facet_cons_poa_.in (); + } + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId (obj_id); + + CORBA::String_var str = + PortableServer::ObjectId_to_string (oid.in ()); + + if (t == Container::Facet_Consumer) + { + //if (CIAO::debug_level () > 9) + // ACE_DEBUG ((LM_DEBUG, "STRING in container is %s\n", + // str.in ())); + } + + CORBA::Object_var objref = + tmp->create_reference_with_id (oid.in (), repo_id); + + return objref._retn (); + } +} diff --git a/CIAO/ciao/Session_Container.h b/CIAO/ciao/Session_Container.h new file mode 100644 index 00000000000..3e716e429b9 --- /dev/null +++ b/CIAO/ciao/Session_Container.h @@ -0,0 +1,192 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Session_Container.h + * + * $Id$ + * + * Header file for CIAO's container implementations + * + * @author Nanbor Wang <nanbor@cs.wustl.edu> + * @author Gan Deng <dengg@dre.vanderbilt.edu> + */ +//============================================================================= + + +#ifndef CIAO_SESSION_CONTAINER_H +#define CIAO_SESSION_CONTAINER_H + +#include /**/ "ace/pre.h" + +#include "ciao/Container_Base.h" + +#include "tao/PortableServer/PortableServer.h" +#include "tao/PortableServer/Servant_Base.h" + +#include "tao/ORB.h" + +#include "ace/Hash_Map_Manager_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace CIAO +{ + class Session_Container; + class Servant_Activator; + + typedef ::Components::HomeExecutorBase_ptr (*HomeFactory) (void); + typedef ::PortableServer::Servant (*ServantFactory) + (::Components::HomeExecutorBase_ptr p, + ::CIAO::Session_Container *c, + const char *ins_name + ); + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + HomeFactory, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> HOMECREATOR_FUNCPTR_MAP; + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + ServantFactory, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> HOMESERVANTCREATOR_FUNCPTR_MAP; + + struct Static_Config_EntryPoints_Maps + { + /// Map of home creator entry point name and func ptr + HOMECREATOR_FUNCPTR_MAP* home_creator_funcptr_map_; + + /// Map of home servant creator entry point name and func ptr + HOMESERVANTCREATOR_FUNCPTR_MAP* home_servant_creator_funcptr_map_; + }; + + class CIAO_SERVER_Export Session_Container : public Container + { + public: + Session_Container (CORBA::ORB_ptr o, + Container_Impl *container_impl, + bool static_config_flag = false, + const Static_Config_EntryPoints_Maps* static_entrypts_maps =0); + + virtual ~Session_Container (void); + + /// Initialize the container with a name. + virtual int init (const char *name = 0, + const CORBA::PolicyList *more_policies = 0); + + /** + * @brief Simply installing a home executor into the component. + * + * This operation install a home executor into the component. It + * requires the name of the DLLs to executor and the servant glue + * code, and the entry points to the respective DLLs. Currently, + * we don't try to manage the lifetime of DLL objects, but we + * should at some later point. + * + * @retval Home objref of the installed home. + */ + virtual Components::CCMHome_ptr ciao_install_home ( + const char *exe_dll_name, + const char *exe_entrypt, + const char *sv_dll_name, + const char *sv_entrypt, + const char *ins_name); + + /// Uninstall a servant for component or home. + virtual void ciao_uninstall_home (Components::CCMHome_ptr homeref); + + /// Uninstall a servant for component. + virtual void uninstall_component (::Components::CCMObject_ptr objref, + PortableServer::ObjectId_out oid); + + /// Install a servant for component or home. + virtual CORBA::Object_ptr install_servant (PortableServer::Servant p, + Container::OA_Type t); + + /// Install a component servant. + CORBA::Object_ptr install_component (PortableServer::Servant p, + PortableServer::ObjectId_out oid); + + /// Get an object reference to a component or home from the servant. + virtual CORBA::Object_ptr get_objref (PortableServer::Servant p); + + /// Uninstall a servant for component or home. + void uninstall (CORBA::Object_ptr objref, Container::OA_Type t); + + /// Uninstall a servant for component or home. + void uninstall (PortableServer::Servant svt, Container::OA_Type t); + + virtual void add_servant_to_map (PortableServer::ObjectId &oid, + Dynamic_Component_Servant_Base* servant); + + virtual void delete_servant_from_map (PortableServer::ObjectId &oid); + + // @@Jai, could yo please add documentation? + /* + * @@Jai, you may want to consider moving these away from the + * container interface. I know what you are going to say + * :-). Consider using dynamic_cast <> to access + * add_servant_to_map, delete_servant_from_map and + * deactivate_facet from the Swapping_Conatiner's interface. It + * would make the base container interface much cleaner. + */ + virtual void deactivate_facet (const PortableServer::ObjectId &oid); + + virtual CORBA::Object_ptr get_home_objref (PortableServer::Servant p); + + /// Analog of the POA method that creates an object reference from + /// an object id string. + CORBA::Object_ptr generate_reference (const char *obj_id, + const char *repo_id, + Container::OA_Type t); + + /// Return the servant activator factory that activates the + /// servants for facets and consumers. + Servant_Activator *ports_servant_activator (void) const; + + private: + + /// Create POA for the component. + /** + * This is the POA that is returned to the component applications + * if they need one. + */ + void create_component_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root); + + /// Create POA for the facets and consumers alone. + void create_facet_consumer_POA (const char *name, + const CORBA::PolicyList *p, + PortableServer::POA_ptr root); + + /// Not allowed to be + Session_Container (void); + + protected: + unsigned long number_; + + /// Static variable to store the highest number we have given out until + /// now + static ACE_Atomic_Op <ACE_SYNCH_MUTEX, unsigned long> serial_number_; + + const bool static_config_flag_; + const Static_Config_EntryPoints_Maps* static_entrypts_maps_; + + /// The servant activator factory used to activate facets and + /// consumer servants. + Servant_Activator *sa_; + }; +} + +#if defined (__ACE_INLINE__) +# include "Session_Container.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* CIAO_SESSION_CONTAINER_H */ diff --git a/CIAO/ciao/Container_Base.inl b/CIAO/ciao/Session_Container.inl index 1c6bc7a075c..1c6bc7a075c 100644 --- a/CIAO/ciao/Container_Base.inl +++ b/CIAO/ciao/Session_Container.inl diff --git a/CIAO/ciao/Swapping_Container.cpp b/CIAO/ciao/Swapping_Container.cpp index 8d5331a33cc..700f09bc0c0 100644 --- a/CIAO/ciao/Swapping_Container.cpp +++ b/CIAO/ciao/Swapping_Container.cpp @@ -5,6 +5,7 @@ #include "ace/DLL.h" #include "tao/Utils/PolicyList_Destroyer.h" #include "ace/OS_NS_stdio.h" +#include "ciao/Deployment_CoreC.h" #if !defined (__ACE_INLINE__) # include "Swapping_Container.inl" @@ -75,8 +76,6 @@ namespace CIAO more_policies, root_poa.in ()); - - this->create_home_servant_POA ("home servant POA", more_policies, root_poa.in ()); @@ -92,18 +91,18 @@ namespace CIAO } void - Swapping_Container::add_servant_map + Swapping_Container::add_servant_to_map (PortableServer::ObjectId &oid, Dynamic_Component_Servant_Base* servant) { - this->dsa_->add_servant_map (oid, servant); + this->dsa_->add_servant_to_map (oid, servant); } void - Swapping_Container::delete_servant_map + Swapping_Container::delete_servant_from_map (PortableServer::ObjectId &oid) { - this->dsa_->delete_servant_map (oid); + this->dsa_->delete_servant_from_map (oid); } void @@ -119,7 +118,6 @@ namespace CIAO PortableServer::POAManager_var poa_manager = root->the_POAManager (); - this->home_servant_poa_ = root->create_POA (name, poa_manager.in (), @@ -127,8 +125,7 @@ namespace CIAO } void - Swapping_Container::create_connections_POA ( - PortableServer::POA_ptr root) + Swapping_Container::create_connections_POA (PortableServer::POA_ptr root) { PortableServer::POAManager_var poa_manager = root->the_POAManager (); @@ -220,7 +217,7 @@ namespace CIAO CORBA::Object_ptr Swapping_Container::install_servant (PortableServer::Servant p, - Container::OA_Type t) + Container::OA_Type t) { PortableServer::POA_ptr tmp = 0; @@ -231,11 +228,9 @@ namespace CIAO else tmp = this->facet_cons_poa_.in (); - PortableServer::ObjectId_var oid - = tmp->activate_object (p); + PortableServer::ObjectId_var oid = tmp->activate_object (p); - CORBA::Object_var objref - = tmp->id_to_reference (oid.in ()); + CORBA::Object_var objref = tmp->id_to_reference (oid.in ()); return objref._retn (); } diff --git a/CIAO/ciao/Swapping_Container.h b/CIAO/ciao/Swapping_Container.h index 4d5b188526a..fe149ab8c6a 100644 --- a/CIAO/ciao/Swapping_Container.h +++ b/CIAO/ciao/Swapping_Container.h @@ -23,9 +23,7 @@ #include "tao/ORB.h" #include "tao/PortableServer/PortableServer.h" #include "tao/PortableServer/Servant_Base.h" -#include "ciao/CCM_ContainerC.h" -#include "ciao/Container_Base.h" -#include "ciao/Deployment_CoreC.h" +#include "ciao/Session_Container.h" #include "ciao/Dynamic_Component_Activator.h" #include "ciao/CIAO_Server_Export.h" #include "ciao/Servant_Activator.h" @@ -59,10 +57,10 @@ namespace CIAO virtual CORBA::Object_ptr get_home_objref (PortableServer::Servant p); - virtual void add_servant_map (PortableServer::ObjectId &oid, + virtual void add_servant_to_map (PortableServer::ObjectId &oid, Dynamic_Component_Servant_Base* servant); - virtual void delete_servant_map (PortableServer::ObjectId &oid); + virtual void delete_servant_from_map (PortableServer::ObjectId &oid); virtual void deactivate_facet (const PortableServer::ObjectId &oid); diff --git a/CIAO/ciao/Swapping_Servant_Home_Impl_T.cpp b/CIAO/ciao/Swapping_Servant_Home_Impl_T.cpp index 6004e28d83a..fbc804ca1aa 100644 --- a/CIAO/ciao/Swapping_Servant_Home_Impl_T.cpp +++ b/CIAO/ciao/Swapping_Servant_Home_Impl_T.cpp @@ -42,7 +42,7 @@ namespace CIAO try { - this->container_->delete_servant_map (oid); + this->container_->delete_servant_from_map (oid); } catch (const CORBA::Exception& ex) { @@ -151,7 +151,7 @@ namespace CIAO this, this->container_); - this->container_->add_servant_map (oid, svt); + this->container_->add_servant_to_map (oid, svt); this->dynamic_servant_map_.bind (oid.in (), svt); |