diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-03-18 18:06:12 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-03-18 18:06:12 +0000 |
commit | 7ba53db93beb1c9a77eb105421dc88811608282c (patch) | |
tree | c7848429a0f245dfb3eeb63c82ba49100edbd273 | |
parent | 824c2a400ce6f496577bb489f13e5f6302fd0f8f (diff) | |
download | ATCD-7ba53db93beb1c9a77eb105421dc88811608282c.tar.gz |
*** empty log message ***
15 files changed, 708 insertions, 349 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index 13210e8d0ce..c601a85ae76 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,25 @@ +Tue Mar 18 12:03:29 2003 Nanbor Wang <nanbor@cs.wustl.edu> + + * examples/handcrafted/Hello/hello_servants.cpp: + * examples/handcrafted/Hello/hello_servants.h: Renamed various + "_ciao_deactivate*" operations to "ciao_passivate*" to be more + consistent with the CCM opertions. + + * docs/templates/CIAO_Glue_Session_Template.cpp: + * docs/templates/CIAO_Glue_Session_Template.h: + * docs/templates/CIAO_Glue_Session_Template.inl: + * examples/handcrafted/Display/GPS/GPS_svnt.cpp: + * examples/handcrafted/Display/GPS/GPS_svnt.h: + * examples/handcrafted/Display/GPS/GPS_svnt.inl: + * examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.cpp: + * examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.h: + * examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.inl: + * examples/handcrafted/Display/RateGen/RateGen_svnt.cpp: + * examples/handcrafted/Display/RateGen/RateGen_svnt.h: + * examples/handcrafted/Display/RateGen/RateGen_svnt.inl: + Propagated the SessionComponent opertion support to CIDL + templates and the multiple component example "generated" files. + Mon Mar 17 23:10:47 2003 Nanbor Wang <nanbor@cs.wustl.edu> * ciao/Container_Base.cpp: diff --git a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp index 7a2c05c3d4d..0b8f01329a8 100644 --- a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp +++ b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp @@ -275,6 +275,54 @@ CORBA::Object_ptr // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// +[ciao module name]::[component name]_Servant::[component name]_Servant (CCM_[component name]_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (CCM_[component name]::_duplicate (exe)), + container_ (c) +{ + this->context_ = new [ciao module name]::[component name]_Context (h, c, this); + + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (exe + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->set_session_context (this->context_ + ACE_ENV_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; +} + +[ciao module name]::[component name]_Servant::~[component name]_Servant (void) +{ + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; + this->context_->_remove_ref (); +} + // Operations for provides interfaces. ##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: @@ -992,24 +1040,30 @@ CORBA::Object_ptr ACE_THROW_RETURN (CORBA::INTERNAL (), 0); } -[component name]_ptr -[ciao module name]::[component name]_Servant::_ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL) +void +[ciao module name]::[component name]_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - CORBA::Object_var obj - = this->container_->install_servant (this - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - - [component name]_var ho - = [component name]::_narrow (obj - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - // @@ Call ccm_activate here. + if (! CORBA::is_nil (temp.in ())) + temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER); +} - return ho._retn (); +void +[ciao module name]::[component name]_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (! CORBA::is_nil (temp.in ())) + temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); } ////////////////////////////////////////////////////////////////// @@ -1017,31 +1071,70 @@ CORBA::Object_ptr ////////////////////////////////////////////////////////////////// [component name]_ptr -[ciao module name]::[home name]_Servant::_ciao_create_helper (::Components::EnterpriseComponent_ptr com - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)) +[ciao module name]::[home name]_Servant::_ciao_activate_component (CCM_[component name]_ptr exe + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { - CCM_[component name]_var hw = CCM_[component name]::_narrow (com - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - - // Acquiring the home reference and pass it to the component servant CORBA::Object_var hobj = this->container_->get_objref (this ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - [home name]_var home - = [home name]::_narrow (hobj.in () - ACE_ENV_ARG_PARAMETER); + ::Components::CCMHome_var home + = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); [ciao module name]::[component name]_Servant *svt = - new [ciao module name]::[component name]_Servant (hw.in (), + new [ciao module name]::[component name]_Servant (exe, home.in (), this->container_); - return svt->_ciao_activate_component (ACE_ENV_ARG_PARAMETER); + PortableServer::ServantBase_var safe (svt); + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref + = this->container_->install_component (svt, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + [component name]_var ho + = [component name]::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->component_map_.bind (oid.in (), svt) == 0) + { + // @@ what should happen if bind fail? + safe._retn (); + } + return ho._retn (); +} + +void +[ciao module name]::[home name]_Servant::_ciao_passivate_component ([component name]_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + [ciao module name]::[component name]_Servant *servant = 0; + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + // What happen if unbind failed? + } // Operations for Implicit Home interface @@ -1053,12 +1146,17 @@ CORBA::Object_ptr if (this->executor_.in () == 0) ACE_THROW_RETURN (CORBA::INTERNAL (), 0); - Components::EnterpriseComponent_var com = + Components::EnterpriseComponent_var _ciao_ec = this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return this->_ciao_create_helper (com - ACE_ENV_ARG_PARAMETER); + CCM_[component name]_var _ciao_comp + = CCM_[component name]::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } // Operations for CCMHome interface @@ -1068,15 +1166,23 @@ void ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { - if (CORBA::is_nil (comp)) + [component name]_var _ciao_comp + = [component name]::_narrow (comp + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (_ciao_comp.in ())) ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here? - comp->remove (ACE_ENV_ARG_PARAMETER); + // @@ It seems to me that we need to make sure this is a component + // generated by this home before calling remove on this component. + _ciao_comp->remove (ACE_ENV_ARG_PARAMETER); ACE_CHECK; + // Removing the object reference? get the servant from the POA with // the objref, and call remove() on the component, deactivate the // component, and then remove-ref the servant? - this->container_->uninstall (comp - ACE_ENV_ARG_PARAMETER); + this->_ciao_passivate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } diff --git a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h index dae90ae5981..359d9f367ac 100644 --- a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h +++ b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h @@ -25,6 +25,7 @@ // that component implementations use #include "ciao/Container_Base.h" //Source in the container interface definitions #include "tao/LocalObject.h" +#include "tao/PortableServer/Key_Adapters.h" #include "ace/Active_Map_Manager_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -558,9 +559,12 @@ namespace CIAO_GLUE // CIAO specific operations. // Activate the object in the container_ - [component name]_ptr - _ciao_activate_component - (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + void + _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); protected: @@ -693,17 +697,28 @@ namespace CIAO_GLUE protected: // Helper method for factory operations. - [component name]_ptr - _ciao_create_helper (::Components::EnterpriseComponent_ptr c - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)); + [component name]_ptr + _ciao_activate_component (CCM_[component name]_ptr exe + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component ([component name]_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); // My Executor. CCM_[home name]_var executor_; // My Container CIAO::Session_Container *container_; + + // Components this home manages. + ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId, + [component name]_Servant*, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> component_map_; }; extern "C" [SERVANT]_Export ::PortableServer::Servant diff --git a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl index 9c7373f92f8..9c816d06688 100644 --- a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl +++ b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl @@ -163,42 +163,6 @@ ACE_INLINE void // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// -ACE_INLINE -[ciao module name]::[component name]_Servant::[component name]_Servant (CCM_[component name]_ptr exe, - ::Components::CCMHome_ptr h, - ::CIAO::Session_Container *c) - : executor_ (CCM_[component name]::_duplicate (exe)), - container_ (c) -{ - this->context_ = new [ciao module name]::[component name]_Context (h, c, this); - - ACE_TRY_NEW_ENV - { - Components::SessionComponent_var scom = - Components::SessionComponent::_narrow (exe - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (! CORBA::is_nil (scom.in ())) - { - scom->set_session_context (this->context_ - ACE_ENV_ARG_PARAMETER); - } - } - ACE_CATCHANY - { - // @@ Ignore any exceptions? What happens if - // set_session_context throws an CCMException? - } - ACE_ENDTRY; -} - -ACE_INLINE -[ciao module name]::[component name]_Servant::~[component name]_Servant (void) -{ - this->context_->_remove_ref (); -} - ##foreach [operation] in all supported interfaces of own component and all inherited components and attribute accessors/mutators // This is only a guideline... we always relay the operation to underlying @@ -411,12 +375,17 @@ ACE_INLINE [component name]_ptr ::Components::CreateFailure, ....)) { - Components::EnterpriseComponent_var com = + Components::EnterpriseComponent_var _ciao_ec = this->executor_->[factory name] (.... ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return this->_ciao_create_helper (com - ACE_ENV_ARG_PARAMETER); + CCM_[component name]_var _ciao_comp + = CCM_[component name]::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } ##end foreach [factory name] diff --git a/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.cpp b/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.cpp index 1d63cee7a86..c59557712f9 100644 --- a/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.cpp +++ b/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.cpp @@ -42,7 +42,7 @@ CIAO_GLUE_HUDisplay::GPS_Context::push_Ready (HUDisplay::tick_ptr ev } // Operations for publishes interfaces. -ACE_INLINE ::Components::Cookie_ptr +::Components::Cookie_ptr CIAO_GLUE_HUDisplay::GPS_Context::subscribe_Ready (HUDisplay::tickConsumer_ptr c ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -59,7 +59,7 @@ CIAO_GLUE_HUDisplay::GPS_Context::subscribe_Ready (HUDisplay::tickConsumer_ptr c return retv._retn (); } -ACE_INLINE HUDisplay::tickConsumer_ptr +HUDisplay::tickConsumer_ptr CIAO_GLUE_HUDisplay::GPS_Context::unsubscribe_Ready (::Components::Cookie_ptr ck ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -109,6 +109,54 @@ CIAO_GLUE_HUDisplay::GPS_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL) // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// +CIAO_GLUE_HUDisplay::GPS_Servant::GPS_Servant (HUDisplay::CCM_GPS_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (HUDisplay::CCM_GPS::_duplicate (exe)), + container_ (c) +{ + this->context_ = new CIAO_GLUE_HUDisplay::GPS_Context (h, c, this); + + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (exe + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->set_session_context (this->context_ + ACE_ENV_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; +} + +CIAO_GLUE_HUDisplay::GPS_Servant::~GPS_Servant (void) +{ + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; + this->context_->_remove_ref (); +} + // Operations for provides interfaces. HUDisplay::position_ptr CIAO_GLUE_HUDisplay::GPS_Servant::provide_MyLocation (ACE_ENV_SINGLE_ARG_DECL) @@ -644,21 +692,30 @@ CIAO_GLUE_HUDisplay::GPS_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_RETURN (CORBA::INTERNAL (), 0); } -HUDisplay::GPS_ptr -CIAO_GLUE_HUDisplay::GPS_Servant::_ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL) +void +CIAO_GLUE_HUDisplay::GPS_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - CORBA::Object_var obj - = this->container_->install_servant (this - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - HUDisplay::GPS_var ho = HUDisplay::GPS::_narrow (obj - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + if (! CORBA::is_nil (temp.in ())) + temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER); +} - return ho._retn (); +void +CIAO_GLUE_HUDisplay::GPS_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (! CORBA::is_nil (temp.in ())) + temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); } ////////////////////////////////////////////////////////////////// @@ -666,30 +723,70 @@ CIAO_GLUE_HUDisplay::GPS_Servant::_ciao_activate_component (ACE_ENV_SINGLE_ARG_D ////////////////////////////////////////////////////////////////// HUDisplay::GPS_ptr -CIAO_GLUE_HUDisplay::GPSHome_Servant::_ciao_create_helper (::Components::EnterpriseComponent_ptr com - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)) +CIAO_GLUE_HUDisplay::GPSHome_Servant::_ciao_activate_component (HUDisplay::CCM_GPS_ptr exe + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { - HUDisplay::CCM_GPS_var hw = HUDisplay::CCM_GPS::_narrow (com - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - - // Acquiring the home reference and pass it to the component servant - CORBA::Object_var hobj= this->container_->get_objref (this - ACE_ENV_ARG_PARAMETER); + CORBA::Object_var hobj + = this->container_->get_objref (this + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - HUDisplay::GPSHome_var home = HUDisplay::GPSHome::_narrow (hobj.in () - ACE_ENV_ARG_PARAMETER); + ::Components::CCMHome_var home + = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); CIAO_GLUE_HUDisplay::GPS_Servant *svt = - new CIAO_GLUE_HUDisplay::GPS_Servant (hw.in (), + new CIAO_GLUE_HUDisplay::GPS_Servant (exe, home.in (), this->container_); + PortableServer::ServantBase_var safe (svt); + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref + = this->container_->install_component (svt, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + HUDisplay::GPS_var ho + = HUDisplay::GPS::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->component_map_.bind (oid.in (), svt) == 0) + { + // @@ what should happen if bind fail? + safe._retn (); + } + return ho._retn (); +} + +void +CIAO_GLUE_HUDisplay::GPSHome_Servant::_ciao_passivate_component (HUDisplay::GPS_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CIAO_GLUE_HUDisplay::GPS_Servant *servant = 0; + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + // What happen if unbind failed? - return svt->_ciao_activate_component (ACE_ENV_ARG_PARAMETER); } // Operations for Implicit Home interface @@ -701,12 +798,17 @@ CIAO_GLUE_HUDisplay::GPSHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL) if (this->executor_.in () == 0) ACE_THROW_RETURN (CORBA::INTERNAL (), 0); - Components::EnterpriseComponent_var com = + Components::EnterpriseComponent_var _ciao_ec = this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return this->_ciao_create_helper (com - ACE_ENV_ARG_PARAMETER); + HUDisplay::CCM_GPS_var _ciao_comp + = HUDisplay::CCM_GPS::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } // Operations for CCMHome interface @@ -716,15 +818,23 @@ CIAO_GLUE_HUDisplay::GPSHome_Servant::remove_component (Components::CCMObject_pt ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { - if (CORBA::is_nil (comp)) + HUDisplay::GPS_var _ciao_comp + = HUDisplay::GPS::_narrow (comp + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (_ciao_comp.in ())) ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here? - comp->remove (ACE_ENV_ARG_PARAMETER); + // @@ It seems to me that we need to make sure this is a component + // generated by this home before calling remove on this component. + _ciao_comp->remove (ACE_ENV_ARG_PARAMETER); ACE_CHECK; + // Removing the object reference? get the servant from the POA with // the objref, and call remove() on the component, deactivate the // component, and then remove-ref the servant? - this->container_->uninstall (comp - ACE_ENV_ARG_PARAMETER); + this->_ciao_passivate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } diff --git a/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.h b/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.h index fbd9c9c808d..c69ae90c669 100644 --- a/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.h +++ b/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.h @@ -2,7 +2,7 @@ // =========================================================== // -// @file CIAO_Glue_Session_Template.h +// @file GPS_svnt.h // // This is a pseudo-meta generic servant implementations template // for CIAO's CIDL compiler. It demonstrates how a servant @@ -25,18 +25,13 @@ // that component implementations use #include "ciao/Container_Base.h" //Source in the container interface definitions #include "tao/LocalObject.h" +#include "tao/PortableServer/Key_Adapters.h" #include "ace/Active_Map_Manager_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -/// @@@ Notice that all component and interface names need to be -/// fully qualified as we are creating a new namespace for the CIAO's -/// container glue code. -/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - namespace CIAO_GLUE_HUDisplay { // Facet glue code has already been defined in ../HUDisplay_svnt.* @@ -370,10 +365,13 @@ namespace CIAO_GLUE_HUDisplay ACE_THROW_SPEC ((CORBA::SystemException)); // CIAO specific operations. - // Activate the object in the container_ - HUDisplay::GPS_ptr - _ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + void + _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); protected: @@ -444,16 +442,27 @@ namespace CIAO_GLUE_HUDisplay protected: // Helper method for factory operations. HUDisplay::GPS_ptr - _ciao_create_helper (::Components::EnterpriseComponent_ptr c - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)); + _ciao_activate_component (HUDisplay::CCM_GPS_ptr exe + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component (HUDisplay::GPS_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); // My Executor. HUDisplay::CCM_GPSHome_var executor_; // My Container CIAO::Session_Container *container_; + + // Components this home manages. + ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId, + GPS_Servant*, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> component_map_; }; extern "C" GPS_SVNT_Export ::PortableServer::Servant diff --git a/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.inl b/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.inl index 02747acbd91..3b666decea6 100644 --- a/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.inl +++ b/TAO/CIAO/examples/handcrafted/Display/GPS/GPS_svnt.inl @@ -6,13 +6,6 @@ // @@ Notice: [ciao module name] can expand to either CIAO_GLUE or // CIAO_GLUE_[module name] as defined in the header file. -/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -/// @@@ Notice that all component and interface names need to be -/// fully qualified as we are creating a new namespace for the CIAO's -/// container glue code. -/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - ////////////////////////////////////////////////////////////////// // Component specific context implementation ////////////////////////////////////////////////////////////////// @@ -92,42 +85,6 @@ CIAO_GLUE_HUDisplay::GPS_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL) // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// -ACE_INLINE -CIAO_GLUE_HUDisplay::GPS_Servant::GPS_Servant (HUDisplay::CCM_GPS_ptr exe, - ::Components::CCMHome_ptr h, - ::CIAO::Session_Container *c) - : executor_ (HUDisplay::CCM_GPS::_duplicate (exe)), - container_ (c) -{ - this->context_ = new CIAO_GLUE_HUDisplay::GPS_Context (h, c, this); - - ACE_TRY_NEW_ENV - { - Components::SessionComponent_var scom = - Components::SessionComponent::_narrow (exe - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (! CORBA::is_nil (scom.in ())) - { - scom->set_session_context (this->context_ - ACE_ENV_ARG_PARAMETER); - } - } - ACE_CATCHANY - { - // @@ Ignore any exceptions? What happens if - // set_session_context throws an CCMException? - } - ACE_ENDTRY; -} - -ACE_INLINE -CIAO_GLUE_HUDisplay::GPS_Servant::~GPS_Servant (void) -{ - this->context_->_remove_ref (); -} - ////////////////////////////////////////////////////////////////// // EventConsumer Glue Code implementation // @@ We are assuming that these consumers are declared under the same diff --git a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.cpp b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.cpp index d82b03b8827..7108bd83e92 100644 --- a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.cpp +++ b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.cpp @@ -85,6 +85,54 @@ CIAO_GLUE_HUDisplay::NavDisplay_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// +CIAO_GLUE_HUDisplay::NavDisplay_Servant::NavDisplay_Servant (HUDisplay::CCM_NavDisplay_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (HUDisplay::CCM_NavDisplay::_duplicate (exe)), + container_ (c) +{ + this->context_ = new CIAO_GLUE_HUDisplay::NavDisplay_Context (h, c, this); + + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (exe + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->set_session_context (this->context_ + ACE_ENV_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; +} + +CIAO_GLUE_HUDisplay::NavDisplay_Servant::~NavDisplay_Servant (void) +{ + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; + this->context_->_remove_ref (); +} + // Operations for provides interfaces. // Operations for consumers interfaces. @@ -577,22 +625,30 @@ CIAO_GLUE_HUDisplay::NavDisplay_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL ACE_THROW_RETURN (CORBA::INTERNAL (), 0); } -HUDisplay::NavDisplay_ptr -CIAO_GLUE_HUDisplay::NavDisplay_Servant::_ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL) +void +CIAO_GLUE_HUDisplay::NavDisplay_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - CORBA::Object_var obj - = this->container_->install_servant (this - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - HUDisplay::NavDisplay_var ho - = HUDisplay::NavDisplay::_narrow (obj - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + if (! CORBA::is_nil (temp.in ())) + temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER); +} - return ho._retn (); +void +CIAO_GLUE_HUDisplay::NavDisplay_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionComponent_var temp = + ::Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (! CORBA::is_nil (temp.in ())) + temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); } ////////////////////////////////////////////////////////////////// @@ -600,31 +656,70 @@ CIAO_GLUE_HUDisplay::NavDisplay_Servant::_ciao_activate_component (ACE_ENV_SINGL ////////////////////////////////////////////////////////////////// HUDisplay::NavDisplay_ptr -CIAO_GLUE_HUDisplay::NavDisplayHome_Servant::_ciao_create_helper (::Components::EnterpriseComponent_ptr com - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)) +CIAO_GLUE_HUDisplay::NavDisplayHome_Servant::_ciao_activate_component (HUDisplay::CCM_NavDisplay_ptr exe + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { - HUDisplay::CCM_NavDisplay_var hw - = HUDisplay::CCM_NavDisplay::_narrow (com - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - - // Acquiring the home reference and pass it to the component servant - CORBA::Object_var hobj= this->container_->get_objref (this - ACE_ENV_ARG_PARAMETER); + CORBA::Object_var hobj + = this->container_->get_objref (this + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - HUDisplay::NavDisplayHome_var home - = HUDisplay::NavDisplayHome::_narrow (hobj.in () - ACE_ENV_ARG_PARAMETER); + ::Components::CCMHome_var home + = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); CIAO_GLUE_HUDisplay::NavDisplay_Servant *svt = - new CIAO_GLUE_HUDisplay::NavDisplay_Servant (hw.in (), + new CIAO_GLUE_HUDisplay::NavDisplay_Servant (exe, home.in (), this->container_); - return svt->_ciao_activate_component (ACE_ENV_ARG_PARAMETER); + PortableServer::ServantBase_var safe (svt); + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref + = this->container_->install_component (svt, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + HUDisplay::NavDisplay_var ho + = HUDisplay::NavDisplay::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->component_map_.bind (oid.in (), svt) == 0) + { + // @@ what should happen if bind fail? + safe._retn (); + } + return ho._retn (); +} + +void +CIAO_GLUE_HUDisplay::NavDisplayHome_Servant::_ciao_passivate_component (HUDisplay::NavDisplay_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CIAO_GLUE_HUDisplay::NavDisplay_Servant *servant = 0; + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + // What happen if unbind failed? + } // Operations for Implicit Home interface @@ -636,12 +731,17 @@ CIAO_GLUE_HUDisplay::NavDisplayHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL) if (this->executor_.in () == 0) ACE_THROW_RETURN (CORBA::INTERNAL (), 0); - Components::EnterpriseComponent_var com = + Components::EnterpriseComponent_var _ciao_ec = this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return this->_ciao_create_helper (com - ACE_ENV_ARG_PARAMETER); + HUDisplay::CCM_NavDisplay_var _ciao_comp + = HUDisplay::CCM_NavDisplay::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } // Operations for CCMHome interface @@ -651,15 +751,23 @@ CIAO_GLUE_HUDisplay::NavDisplayHome_Servant::remove_component (Components::CCMOb ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { - if (CORBA::is_nil (comp)) + HUDisplay::NavDisplay_var _ciao_comp + = HUDisplay::NavDisplay::_narrow (comp + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (_ciao_comp.in ())) ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here? - comp->remove (ACE_ENV_ARG_PARAMETER); + // @@ It seems to me that we need to make sure this is a component + // generated by this home before calling remove on this component. + _ciao_comp->remove (ACE_ENV_ARG_PARAMETER); ACE_CHECK; + // Removing the object reference? get the servant from the POA with // the objref, and call remove() on the component, deactivate the // component, and then remove-ref the servant? - this->container_->uninstall (comp - ACE_ENV_ARG_PARAMETER); + this->_ciao_passivate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } diff --git a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.h b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.h index 67416b10b0e..db60be1bbe8 100644 --- a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.h +++ b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.h @@ -25,18 +25,13 @@ // that component implementations use #include "ciao/Container_Base.h" //Source in the container interface definitions #include "tao/LocalObject.h" +#include "tao/PortableServer/Key_Adapters.h" #include "ace/Active_Map_Manager_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -/// @@@ Notice that all component and interface names need to be -/// fully qualified as we are creating a new namespace for the CIAO's -/// container glue code. -/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - namespace CIAO_GLUE_HUDisplay { @@ -380,9 +375,12 @@ namespace CIAO_GLUE_HUDisplay // CIAO specific operations. // Activate the object in the container_ - HUDisplay::NavDisplay_ptr - _ciao_activate_component - (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + void + _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); protected: @@ -449,16 +447,27 @@ namespace CIAO_GLUE_HUDisplay protected: // Helper method for factory operations. HUDisplay::NavDisplay_ptr - _ciao_create_helper (::Components::EnterpriseComponent_ptr c - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)); + _ciao_activate_component (HUDisplay::CCM_NavDisplay_ptr exe + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component (HUDisplay::NavDisplay_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); // My Executor. HUDisplay::CCM_NavDisplayHome_var executor_; // My Container CIAO::Session_Container *container_; + + // Components this home manages. + ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId, + NavDisplay_Servant*, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> component_map_; }; extern "C" NAVDISPLAY_SVNT_Export ::PortableServer::Servant diff --git a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.inl b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.inl index 085bc85e4ce..5596f1675f2 100644 --- a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.inl +++ b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_svnt.inl @@ -92,42 +92,6 @@ CIAO_GLUE_HUDisplay::NavDisplay_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_D // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// -ACE_INLINE -CIAO_GLUE_HUDisplay::NavDisplay_Servant::NavDisplay_Servant (HUDisplay::CCM_NavDisplay_ptr exe, - ::Components::CCMHome_ptr h, - ::CIAO::Session_Container *c) - : executor_ (HUDisplay::CCM_NavDisplay::_duplicate (exe)), - container_ (c) -{ - this->context_ = new CIAO_GLUE_HUDisplay::NavDisplay_Context (h, c, this); - - ACE_TRY_NEW_ENV - { - Components::SessionComponent_var scom = - Components::SessionComponent::_narrow (exe - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (! CORBA::is_nil (scom.in ())) - { - scom->set_session_context (this->context_ - ACE_ENV_ARG_PARAMETER); - } - } - ACE_CATCHANY - { - // @@ Ignore any exceptions? What happens if - // set_session_context throws an CCMException? - } - ACE_ENDTRY; -} - -ACE_INLINE -CIAO_GLUE_HUDisplay::NavDisplay_Servant::~NavDisplay_Servant (void) -{ - this->context_->_remove_ref (); -} - // Simplex [receptacle name] connection management operations ACE_INLINE void CIAO_GLUE_HUDisplay::NavDisplay_Servant::connect_GPSLocation (HUDisplay::position_ptr c diff --git a/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.cpp b/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.cpp index fcb6f489528..b5e640f3f9e 100644 --- a/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.cpp +++ b/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.cpp @@ -45,7 +45,7 @@ CIAO_GLUE_HUDisplay::RateGen_Context::push_Pulse (HUDisplay::tick_ptr ev } // Operations for publishes interfaces. -ACE_INLINE ::Components::Cookie_ptr +::Components::Cookie_ptr CIAO_GLUE_HUDisplay::RateGen_Context::subscribe_Pulse (HUDisplay::tickConsumer_ptr c ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -62,7 +62,7 @@ CIAO_GLUE_HUDisplay::RateGen_Context::subscribe_Pulse (HUDisplay::tickConsumer_p return retv._retn (); } -ACE_INLINE HUDisplay::tickConsumer_ptr +HUDisplay::tickConsumer_ptr CIAO_GLUE_HUDisplay::RateGen_Context::unsubscribe_Pulse (::Components::Cookie_ptr ck ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -112,6 +112,54 @@ CIAO_GLUE_HUDisplay::RateGen_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL) // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// +CIAO_GLUE_HUDisplay::RateGen_Servant::RateGen_Servant (HUDisplay::CCM_RateGen_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (HUDisplay::CCM_RateGen::_duplicate (exe)), + container_ (c) +{ + this->context_ = new CIAO_GLUE_HUDisplay::RateGen_Context (h, c, this); + + ACE_TRY_NEW_ENV + { + Components::SessionComponent_var scom = + Components::SessionComponent::_narrow (exe + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (scom.in ())) + scom->set_session_context (this->context_ + ACE_ENV_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; +} + +CIAO_GLUE_HUDisplay::RateGen_Servant::~RateGen_Servant (void) +{ + ACE_TRY_NEW_ENV; + { + Components::SessionComponent_var temp = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (! CORBA::is_nil (temp.in ())) + temp->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER); + } + ACE_CATCHANY + { + // @@ Ignore any exceptions? What happens if + // set_session_context throws an CCMException? + } + ACE_ENDTRY; + this->context_->_remove_ref (); +} + // Operations for provides interfaces. // Operations for consumers interfaces. @@ -509,21 +557,28 @@ CIAO_GLUE_HUDisplay::RateGen_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_RETURN (CORBA::INTERNAL (), 0); } -HUDisplay::RateGen_ptr -CIAO_GLUE_HUDisplay::RateGen_Servant::_ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) +void +CIAO_GLUE_HUDisplay::RateGen_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) { - CORBA::Object_var obj - = this->container_->install_servant (this - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + Components::SessionComponent_var temp = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - HUDisplay::RateGen_var ho = HUDisplay::RateGen::_narrow (obj - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + if (! CORBA::is_nil (temp.in ())) + temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER); +} - return ho._retn (); +void +CIAO_GLUE_HUDisplay::RateGen_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) +{ + Components::SessionComponent_var temp = + Components::SessionComponent::_narrow (this->executor_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (! CORBA::is_nil (temp.in ())) + temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); } ////////////////////////////////////////////////////////////////// @@ -531,29 +586,68 @@ CIAO_GLUE_HUDisplay::RateGen_Servant::_ciao_activate_component (ACE_ENV_SINGLE_A ////////////////////////////////////////////////////////////////// HUDisplay::RateGen_ptr -CIAO_GLUE_HUDisplay::RateGenHome_Servant::_ciao_create_helper (::Components::EnterpriseComponent_ptr com - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)) +CIAO_GLUE_HUDisplay::RateGenHome_Servant::_ciao_activate_component (HUDisplay::CCM_RateGen_ptr exe + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { - HUDisplay::CCM_RateGen_var hw = HUDisplay::CCM_RateGen::_narrow (com - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - - // Acquiring the home reference and pass it to the component servant CORBA::Object_var hobj= this->container_->get_objref (this ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - HUDisplay::RateGenHome_var home = HUDisplay::RateGenHome::_narrow (hobj.in () - ACE_ENV_ARG_PARAMETER); + ::Components::CCMHome_var home = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); CIAO_GLUE_HUDisplay::RateGen_Servant *svt = - new CIAO_GLUE_HUDisplay::RateGen_Servant (hw.in (), + new CIAO_GLUE_HUDisplay::RateGen_Servant (exe, home.in (), this->container_); - return svt->_ciao_activate_component (ACE_ENV_ARG_PARAMETER); + PortableServer::ServantBase_var safe (svt); + PortableServer::ObjectId_var oid; + + CORBA::Object_var objref + = this->container_->install_component (svt, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + HUDisplay::RateGen_var ho + = HUDisplay::RateGen::_narrow (objref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->component_map_.bind (oid.in (), svt) == 0) + { + // @@ what should happen if bind fail? + safe._retn (); + } + return ho._retn (); +} + +void +CIAO_GLUE_HUDisplay::RateGenHome_Servant::_ciao_passivate_component (HUDisplay::RateGen_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableServer::ObjectId_var oid; + + this->container_->uninstall_component (comp, + oid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CIAO_GLUE_HUDisplay::RateGen_Servant *servant = 0; + if (this->component_map_.unbind (oid.in (), servant) == 0) + { + PortableServer::ServantBase_var safe (servant); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + // What happen if unbind failed? + } // Operations for Implicit Home interface @@ -565,12 +659,17 @@ CIAO_GLUE_HUDisplay::RateGenHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL) if (this->executor_.in () == 0) ACE_THROW_RETURN (CORBA::INTERNAL (), 0); - Components::EnterpriseComponent_var com = + Components::EnterpriseComponent_var _ciao_ec = this->executor_->create (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return this->_ciao_create_helper (com - ACE_ENV_ARG_PARAMETER); + HUDisplay::CCM_RateGen_var _ciao_comp + = HUDisplay::CCM_RateGen::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } // Operations for CCMHome interface @@ -580,15 +679,23 @@ CIAO_GLUE_HUDisplay::RateGenHome_Servant::remove_component (Components::CCMObjec ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { - if (CORBA::is_nil (comp)) + HUDisplay::RateGen_var _ciao_comp + = HUDisplay::RateGen::_narrow (comp + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (_ciao_comp.in ())) ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here? - comp->remove (ACE_ENV_ARG_PARAMETER); + // @@ It seems to me that we need to make sure this is a component + // generated by this home before calling remove on this component. + _ciao_comp->remove (ACE_ENV_ARG_PARAMETER); ACE_CHECK; + // Removing the object reference? get the servant from the POA with // the objref, and call remove() on the component, deactivate the // component, and then remove-ref the servant? - this->container_->uninstall (comp - ACE_ENV_ARG_PARAMETER); + this->_ciao_passivate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } diff --git a/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.h b/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.h index 2e7c5fb055e..1c6be65344a 100644 --- a/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.h +++ b/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.h @@ -22,6 +22,7 @@ // that component implementations use #include "ciao/Container_Base.h" //Source in the container interface definitions #include "tao/LocalObject.h" +#include "tao/PortableServer/Key_Adapters.h" #include "ace/Active_Map_Manager_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -285,8 +286,12 @@ namespace CIAO_GLUE_HUDisplay // CIAO specific operations. // Activate the object in the container_ - HUDisplay::RateGen_ptr - _ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + void + _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); protected: @@ -356,17 +361,28 @@ namespace CIAO_GLUE_HUDisplay protected: // Helper method for factory operations. - HUDisplay::RateGen_ptr - _ciao_create_helper (::Components::EnterpriseComponent_ptr c - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::CreateFailure)); + HUDisplay::RateGen_ptr + _ciao_activate_component (HUDisplay::CCM_RateGen_ptr exe + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void + _ciao_passivate_component (HUDisplay::RateGen_ptr comp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); // My Executor. HUDisplay::CCM_RateGenHome_var executor_; // My Container CIAO::Session_Container *container_; + + // Components this home manages. + ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId, + RateGen_Servant*, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_SYNCH_MUTEX> component_map_; }; extern "C" RATEGEN_SVNT_Export ::PortableServer::Servant diff --git a/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.inl b/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.inl index 8990e71c950..19053f69747 100644 --- a/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.inl +++ b/TAO/CIAO/examples/handcrafted/Display/RateGen/RateGen_svnt.inl @@ -93,42 +93,6 @@ CIAO_GLUE_HUDisplay::RateGen_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL // Component Servant Glue code implementation ////////////////////////////////////////////////////////////////// -ACE_INLINE -CIAO_GLUE_HUDisplay::RateGen_Servant::RateGen_Servant (HUDisplay::CCM_RateGen_ptr exe, - ::Components::CCMHome_ptr h, - ::CIAO::Session_Container *c) - : executor_ (HUDisplay::CCM_RateGen::_duplicate (exe)), - container_ (c) -{ - this->context_ = new CIAO_GLUE_HUDisplay::RateGen_Context (h, c, this); - - ACE_TRY_NEW_ENV - { - Components::SessionComponent_var scom = - Components::SessionComponent::_narrow (exe - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (! CORBA::is_nil (scom.in ())) - { - scom->set_session_context (this->context_ - ACE_ENV_ARG_PARAMETER); - } - } - ACE_CATCHANY - { - // @@ Ignore any exceptions? What happens if - // set_session_context throws an CCMException? - } - ACE_ENDTRY; -} - -ACE_INLINE -CIAO_GLUE_HUDisplay::RateGen_Servant::~RateGen_Servant (void) -{ - this->context_->_remove_ref (); -} - ACE_INLINE void CIAO_GLUE_HUDisplay::RateGen_Servant::start (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) @@ -216,13 +180,18 @@ CIAO_GLUE_HUDisplay::RateGenHome_Servant::new_RateGen (CORBA::Long hertz ACE_THROW_SPEC ((CORBA::SystemException, ::Components::CreateFailure)) { - Components::EnterpriseComponent_var com = + Components::EnterpriseComponent_var _ciao_ec = this->executor_->new_RateGen (hertz ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return this->_ciao_create_helper (com - ACE_ENV_ARG_PARAMETER); + HUDisplay::CCM_RateGen_var _ciao_comp + = HUDisplay::CCM_RateGen::_narrow (_ciao_ec.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->_ciao_activate_component (_ciao_comp.in () + ACE_ENV_ARG_PARAMETER); } // Operations for KeylessHome interface diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp index 92034185784..bd88c85b2f1 100644 --- a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp +++ b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp @@ -123,10 +123,8 @@ CIAO_HelloWorld_Servant::CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr exe, ACE_TRY_CHECK; if (! CORBA::is_nil (temp.in ())) - { - temp->set_session_context (this->context_.in () - ACE_ENV_ARG_PARAMETER); - } + temp->set_session_context (this->context_.in () + ACE_ENV_ARG_PARAMETER); } ACE_CATCHANY { @@ -535,7 +533,7 @@ CIAO_HelloWorld_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO_HelloWorld_Servant::_ciao_deactivate (ACE_ENV_SINGLE_ARG_DECL) +CIAO_HelloWorld_Servant::_ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) { Components::SessionComponent_var temp = Components::SessionComponent::_narrow (this->executor_.in () @@ -613,8 +611,8 @@ CIAO_HelloHome_Servant::_ciao_activate_component (CCM_HelloWorld_ptr exe } void -CIAO_HelloHome_Servant::_ciao_deactivate_component (HelloWorld_ptr comp - ACE_ENV_SINGLE_ARG_DECL) +CIAO_HelloHome_Servant::_ciao_passivate_component (HelloWorld_ptr comp + ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { PortableServer::ObjectId_var oid; @@ -628,7 +626,7 @@ CIAO_HelloHome_Servant::_ciao_deactivate_component (HelloWorld_ptr comp if (this->component_map_.unbind (oid.in (), servant) == 0) { PortableServer::ServantBase_var safe (servant); - servant->_ciao_deactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + servant->_ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; } // What happen if unbind failed? @@ -690,11 +688,11 @@ CIAO_HelloHome_Servant::remove_component (Components::CCMObject_ptr comp ACE_CHECK; // Removing the object reference? get the servant from the POA with - // the objref, and call remove() on the component, deactivate the + // the objref, and call remove() on the component, passivate the // component, and then remove-ref the servant? - this->_ciao_deactivate_component (hw.in () - ACE_ENV_ARG_PARAMETER); + this->_ciao_passivate_component (hw.in () + ACE_ENV_ARG_PARAMETER); } diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h index f0dc62fb296..b83866b583c 100644 --- a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h +++ b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h @@ -233,7 +233,7 @@ public: // CIAO specific operations. void _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); - void _ciao_deactivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void _ciao_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); protected: // My Executor. @@ -282,16 +282,16 @@ public: ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)); +protected: // Activate the object in the container_ HelloWorld_ptr _ciao_activate_component (CCM_HelloWorld_ptr exe ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - void _ciao_deactivate_component (HelloWorld_ptr comp + void _ciao_passivate_component (HelloWorld_ptr comp ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); -protected: // My Executor. CCM_HelloHome_var executor_; |