diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-01-13 06:34:05 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-01-13 06:34:05 +0000 |
commit | 04d656477a72b96849d0944adb947e8f5204fb2d (patch) | |
tree | d4050fb7626824f21c691fdea0e6c94aac3d1064 | |
parent | c456d332e42ed240ca17ad9b44986a9977639cc9 (diff) | |
download | ATCD-04d656477a72b96849d0944adb947e8f5204fb2d.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/CIAO/ChangeLog | 33 | ||||
-rw-r--r-- | TAO/CIAO/ciao/CCM_Base.idl | 3 | ||||
-rw-r--r-- | TAO/CIAO/ciao/Component_Base.idl | 3 | ||||
-rw-r--r-- | TAO/CIAO/ciao/Container_Base.cpp | 16 | ||||
-rw-r--r-- | TAO/CIAO/ciao/Container_Base.h | 9 | ||||
-rw-r--r-- | TAO/CIAO/ciao/Container_Base.inl | 10 | ||||
-rw-r--r-- | TAO/CIAO/ciao/Cookies.cpp | 7 | ||||
-rw-r--r-- | TAO/CIAO/ciao/Cookies.h | 3 | ||||
-rw-r--r-- | TAO/CIAO/ciao/HomeRegistrar_i.cpp | 4 | ||||
-rw-r--r-- | TAO/CIAO/ciao/HomeRegistrar_i.inl | 6 | ||||
-rw-r--r-- | TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp | 619 | ||||
-rw-r--r-- | TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h | 338 | ||||
-rw-r--r-- | TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl | 421 | ||||
-rw-r--r-- | TAO/CIAO/docs/templates/Executor.idl | 96 | ||||
-rw-r--r-- | TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp | 193 | ||||
-rw-r--r-- | TAO/CIAO/examples/handcrafted/Hello/hello_servants.h | 39 |
16 files changed, 1515 insertions, 285 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index 39bbf886930..9204772023a 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,36 @@ +Mon Jan 13 00:27:03 2003 Nanbor Wang <nanbor@cs.wustl.edu> + + * docs/templates/CIAO_Glue_Session_Template.cpp: + * docs/templates/CIAO_Glue_Session_Template.h: + * docs/templates/CIAO_Glue_Session_Template.inl: Filled in a great + more generated code. This is almost done, finally. + + * docs/templates/CIAO_Glue_Session_Template.cpp: + * docs/templates/CIAO_Glue_Session_Template.h: + * docs/templates/CIAO_Glue_Session_Template.inl: + * docs/templates/Executor.idl: Changed to lead template comments + with '##' instead of # to diffentiate them from preprocessor + directives that we should generate. + + * ciao/HomeRegistrar_i.inl: + * ciao/HomeRegistrar_i.cpp: Fixed incorrect uses of exception macros. + + * ciao/Cookies.h: + * ciao/Cookies.cpp: Added a new insert method which "encode" an + Active_Objref_Map key into the Cookie. + + * ciao/Container_Base.inl: + * ciao/Container_Base.cpp: + * ciao/Container_Base.h: Added a new get_objref method which + basically allow us to get the component reference using POA's + servant_to_reference operation. Added a new inline file and + fixed some incorrect uses of exception macros. + + * ciao/Component_Base.idl: + * ciao/CCM_Base.idl: Based on Components 1.1 RTF + Receptacles::disconnect operations now return the disconnected + object reference instead of void. + Fri Jan 10 12:03:00 2003 Boris S Kolpackov <boris@isis-server.isis.vanderbilt.edu> * tools/CCIDL: diff --git a/TAO/CIAO/ciao/CCM_Base.idl b/TAO/CIAO/ciao/CCM_Base.idl index 0ca68432410..cadc9c98aee 100644 --- a/TAO/CIAO/ciao/CCM_Base.idl +++ b/TAO/CIAO/ciao/CCM_Base.idl @@ -125,7 +125,8 @@ module Components AlreadyConnected, ExceededConnectionLimit); - void disconnect (in FeatureName name, in Cookie ck) + // @@ Changed to return the previously connected object reference -- basef on RTF 1.1. + Object disconnect (in FeatureName name, in Cookie ck) raises (InvalidName, InvalidConnection, CookieRequired, diff --git a/TAO/CIAO/ciao/Component_Base.idl b/TAO/CIAO/ciao/Component_Base.idl index e51f463d93f..2a9a8d124d2 100644 --- a/TAO/CIAO/ciao/Component_Base.idl +++ b/TAO/CIAO/ciao/Component_Base.idl @@ -136,7 +136,8 @@ module Components { AlreadyConnected, ExceededConnectionLimit); - void disconnect (in FeatureName name, in Cookie ck) + // @@ Changed to return the previously connected object reference -- basef on RTF 1.1. + Object disconnect (in FeatureName name, in Cookie ck) raises (InvalidName, InvalidConnection, CookieRequired, diff --git a/TAO/CIAO/ciao/Container_Base.cpp b/TAO/CIAO/ciao/Container_Base.cpp index 65fc382b7a6..0c1a2c4cccc 100644 --- a/TAO/CIAO/ciao/Container_Base.cpp +++ b/TAO/CIAO/ciao/Container_Base.cpp @@ -3,6 +3,10 @@ #include "Container_Base.h" #include "ace/DLL.h" +#if !defined (__ACE_INLINE__) +# include "ciao/Container_Base.inl" +#endif /* __ACE_INLINE__ */ + //////////////////////////////////////////////////////////////// CIAO::Container::Container (CORBA::ORB_ptr o) @@ -37,7 +41,7 @@ CIAO::Session_Container::~Session_Container () int CIAO::Session_Container::init (const char *name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { char buffer[MAXPATHLEN]; @@ -84,7 +88,7 @@ CIAO::Session_Container::init (const char *name CORBA::Object_ptr CIAO::Session_Container::install_servant (PortableServer::Servant p - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { PortableServer::ObjectId_var oid @@ -108,7 +112,7 @@ CIAO::Session_Container::_ciao_install_home (const char *exe_dll_name, const char *exe_entrypt, const char *sv_dll_name, const char *sv_entrypt - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::Deployment::UnknownImplId, Components::Deployment::ImplEntryPointNotFound, @@ -167,7 +171,7 @@ CIAO::Session_Container::_ciao_install_home (const char *exe_dll_name, void CIAO::Session_Container::uninstall (CORBA::Object_ptr objref - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { PortableServer::ObjectId_var oid @@ -181,7 +185,7 @@ CIAO::Session_Container::uninstall (CORBA::Object_ptr objref void CIAO::Session_Container::uninstall (PortableServer::Servant svt - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { PortableServer::ObjectId_var oid @@ -195,7 +199,7 @@ CIAO::Session_Container::uninstall (PortableServer::Servant svt void CIAO::Session_Container::debug_uninstall (CORBA::Object_ptr objref - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { PortableServer::ObjectId_var oid diff --git a/TAO/CIAO/ciao/Container_Base.h b/TAO/CIAO/ciao/Container_Base.h index b4dc8ca350d..ccb45753b0c 100644 --- a/TAO/CIAO/ciao/Container_Base.h +++ b/TAO/CIAO/ciao/Container_Base.h @@ -98,6 +98,11 @@ namespace CIAO ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); + // Get an object reference to a component or home from the servant. + virtual CORBA::Object_ptr get_objref (PortableServer::Servant p + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Uninstall a servant for component or home. virtual void uninstall (CORBA::Object_ptr objref ACE_ENV_ARG_DECL_WITH_DEFAULTS) @@ -126,5 +131,9 @@ namespace CIAO ACE_ENV_ARG_DECL_WITH_DEFAULTS); } +#if defined (__ACE_INLINE__) +# include "ciao/Container_Base.inl" +#endif /* __ACE_INLINE__ */ + #include "ace/post.h" #endif /* CIAO_CONTAINER_BASE_H */ diff --git a/TAO/CIAO/ciao/Container_Base.inl b/TAO/CIAO/ciao/Container_Base.inl new file mode 100644 index 00000000000..f829fa65218 --- /dev/null +++ b/TAO/CIAO/ciao/Container_Base.inl @@ -0,0 +1,10 @@ +// $Id$ -*- C++ -*- + +ACE_INLINE CORBA::Object_ptr +CIAO::Session_Container::get_objref (PortableServer::Servant p + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->the_POA ()->servant_to_reference (p + ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/CIAO/ciao/Cookies.cpp b/TAO/CIAO/ciao/Cookies.cpp index a8d3faf4baf..b334330ffc1 100644 --- a/TAO/CIAO/ciao/Cookies.cpp +++ b/TAO/CIAO/ciao/Cookies.cpp @@ -20,6 +20,13 @@ CIAO::Map_Key_Cookie::Map_Key_Cookie (const ACE_Active_Map_Manager_Key &key) // } int +CIAO::Map_Key_Cookie::insert (ACE_Active_Map_Manager_Key &key) +{ + this->cookieValue ().length (ACE_Active_Map_Manager_Key::size ()); + key.encode (this->cookieValue ().get_buffer (0)); +} + +int CIAO::Map_Key_Cookie::extract (ACE_Active_Map_Manager_Key &key) { if (this->cookieValue ().length () != ACE_Active_Map_Manager_Key::size ()) diff --git a/TAO/CIAO/ciao/Cookies.h b/TAO/CIAO/ciao/Cookies.h index 02061e9b1e6..0e304f7bff2 100644 --- a/TAO/CIAO/ciao/Cookies.h +++ b/TAO/CIAO/ciao/Cookies.h @@ -44,6 +44,9 @@ namespace CIAO /// Destroy the @c Cookie ~Map_Key_Cookie (void); + /// Insert the @c ACE_Active_Map_Manager_Key + int insert (ACE_Active_Map_Manager_Key &key); + /// Extract the @c ACE_Active_Map_Manager_Key int extract (ACE_Active_Map_Manager_Key &key); diff --git a/TAO/CIAO/ciao/HomeRegistrar_i.cpp b/TAO/CIAO/ciao/HomeRegistrar_i.cpp index bb8a69edb70..5fb7b3f0a0c 100644 --- a/TAO/CIAO/ciao/HomeRegistrar_i.cpp +++ b/TAO/CIAO/ciao/HomeRegistrar_i.cpp @@ -17,7 +17,7 @@ CIAO::HomeRegistrar_Impl::~HomeRegistrar_Impl () ::Components::CCMHome_ptr CIAO::HomeRegistrar_Impl::find_home_impl (const char *name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::HomeNotFound)) { @@ -54,7 +54,7 @@ CIAO::HomeRegistrar_Impl::register_home (const char * home_repo_id, const char * comp_repo_id, const char * home_name, CORBA::Object_ptr objref - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, CIAO::AlreadyBound, CIAO::InvalidName, diff --git a/TAO/CIAO/ciao/HomeRegistrar_i.inl b/TAO/CIAO/ciao/HomeRegistrar_i.inl index e7060f3bdaf..94b373d29e9 100644 --- a/TAO/CIAO/ciao/HomeRegistrar_i.inl +++ b/TAO/CIAO/ciao/HomeRegistrar_i.inl @@ -2,7 +2,7 @@ ::Components::CCMHome_ptr CIAO::HomeRegistrar_Impl::find_home_by_component_type (const char * comp_repid - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::HomeNotFound)) { @@ -12,7 +12,7 @@ CIAO::HomeRegistrar_Impl::find_home_by_component_type (const char * comp_repid ::Components::CCMHome_ptr CIAO::HomeRegistrar_Impl::find_home_by_home_type (const char * home_repid - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::HomeNotFound)) { @@ -22,7 +22,7 @@ CIAO::HomeRegistrar_Impl::find_home_by_home_type (const char * home_repid ::Components::CCMHome_ptr CIAO::HomeRegistrar_Impl::find_home_by_name (const char * home_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::HomeNotFound)) { diff --git a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp index 8aa8c7c713f..6c86c575953 100644 --- a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp +++ b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp @@ -13,34 +13,631 @@ #endif /* __ACE_INLINE__ */ ////////////////////////////////////////////////////////////////// -// EventConsumer Glue Code implementation -// @@ We are assuming that these consumers are declared under the same +// Facet Glue Code implementation +// @@ We are assuming that these facets are declared under the same // module as the component (thus, we are placing this glue code // here under the same namespace. If they are not, we will // either be generating them in separate namespaces, or include // some other CIDL generated files to get the glue code // implementation. +////////////////////////////////////////////////////////////////// + +##foreach [facet type] in (all facet interface types in the original IDL) + +// get_component implementation. +CORBA::Object_ptr +[ciao module name]::[facet type]_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionContext_var sc = + ::Components::SessionContext::_narrow (this->ctx_); + + if (! CORBA::is_nil(sc.in ())) + return sc->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ::Components::EntityContext_var ec = + ::Components::EntityContext::_narrow (this->ctx_); + + if (! CORBA::is_nil(ec.in ())) + return ec->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class TAO::Utils::Servant_Var<[facet type]>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate TAO::Utils::Servant_Var<[facet type]>; +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + +##end foreach [facet type] + + + +////////////////////////////////////////////////////////////////// +// Component specific context implementation +////////////////////////////////////////////////////////////////// + +void * +[ciao module name]::[component name]_Context::_tao_QueryInterface (ptr_arith_t type) +{ + void *retv = 0; + + if (type == ACE_reinterpret_cast ( + ptr_arith_t, + &CCM_[component name]_Context::_tao_class_id) + ) + { + retv = ACE_reinterpret_cast (void*, this); // Does this look right? + } + else if (type == ACE_reinterpret_cast ( + ptr_arith_t, + &::Components::SessionContext::_tao_class_id) + ) + { + retv = + ACE_reinterpret_cast ( + void *, + ACE_static_cast ( + Components::SessionContext_ptr, + this + ) + ); + } + else if (type == ACE_reinterpret_cast ( + ptr_arith_t, + &::Components::CCMContext::_tao_class_id) + ) + { + retv = + ACE_reinterpret_cast ( + void *, + ACE_static_cast ( + Components::CCMContext_ptr, + this + ) + ); + } + else if (type == ACE_reinterpret_cast ( + ptr_arith_t, + &CORBA::Object::_tao_class_id) + ) + { + retv = + ACE_reinterpret_cast ( + void *, + ACE_static_cast (CORBA::Object_ptr, this) + ); + } + + if (retv != 0) + { + this->_add_ref (); + } + + return retv; +} + +const char* +[ciao module name]::[component name]_Context::_interface_repository_id (void) const +{ + // replay to + return CCM_[component]_Context::_interface_repository_id (); +} + +##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: +## if ([receptacle name] is a multiplex ('uses multiple') receptacle) + // [receptacle name]Connections typedef'ed as a sequence of + // struct [receptacle name]Connection. +[receptacle name]Connections * +[ciao module name]::[component name]_Context::get_connections_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ Strategized locking here. + + [receptacle name]Connections_var retv = + new [receptacle name]Connections (this->ciao_muses_[receptacle name]_.current_size ()); + + CORBA::Long i = 0; + CIAO::Active_Objref_Map::iterator end = this->ciso_muses_[receptacle name]_.end (); + for (CIAO::Active_Objref_Map::iterator iter = this->ciso_muses_[receptacle name]_.begin (); + iter != end; + ++iter) + { + CIAO::Active_Objref_Map::ENTRY &entry = *iter; + retv[i].objref = [uses type]::_narrow (entry.in_id_.in ()); + retv[i].ck = new CIAO::Map_Key_Cookie (entry.ext_id_); + ++i; + } + + return retv._retn (); +} +## endif [receptacle name] +##end foreach [receptacle name] with [uses type] + +##foreach [event name] with [eventtype] in (list of all event sources) generate: +void +[ciao module name]::[component name]_Context::push_[event name] ([eventtype]_ptr ev ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +## if [event name] belongs to an 'emits' port + this->ciao_emits_[event name]_consumer_->push_[event name] (ev + ACE_ENV_ARG_PARAMETER); +## else [event name] belongs to a 'publishes' port + CIAO::Active_Objref_Map::iterator end = this->ciao_publishes_[event name]_map_.end (); + for (CIAO::Active_Objref_Map::iterator iter = this->ciao_publishes_[event name]_map_.begin (); + iter != end; + ++iter) + { + CIAO::Active_Objref_Map::ENTRY &entry = *iter; + [eventtype]Consumer_var c = [eventtype]Consumer::_narrow (entry.in_id_.in ()); + c->push_[event name] (ev + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +## endif [event name] +} + +##end foreach [event name] with [eventtype] + + +// Operations for ::Components::SessionContext interface +CORBA::Object_ptr +[ciao module name]::[component name]_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ How do I check for IllegalState here? When it's not in a + // callback operation... + // ACE_THROW_RETURN (::Components::IllegalState (), 0); + + if (CORBA::is_nil (this->component_.in ())) + { + CORBA::Object_var obj = this->container_->get_objref (this->servant_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->component_ = [component name]::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (this->component_.in ())) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); // This should not happen... + } + return [component name]::_duplicate (this->component_.in ()); +} + +////////////////////////////////////////////////////////////////// +// Component Servant Glue code implementation +////////////////////////////////////////////////////////////////// + +##foreach [operation] in all supported interfaces of own component and all inherited components + + // Generate the [operation] here. + + +##end + +// Operations for provides interfaces. +##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: + +[facet type]_ptr +[ciao module name]::[component name]_Servant::provide_[facet name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (this->provide_[facet name]_.in ())) + { + CCM_[facet type]_var fexe = this->executor_->get_[facet name] (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (fexe.in ())) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + // @@ What's the auto_ptr for servant? + TAO::Utils::Servant_Var<[facet type]_Servant> svt = + new [facet type]_Servant (fexe.in (), + this->context_); + + CORBA::Object_var obj = this->container_->_install_servant (svc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + [facet type]_var fo = [facet type]::_narrow (obj + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->provide_[facet name]_ = fo; + } + + return [facet type]::_duplicate (this->provide_[facet name]_.in ()); +} +##end foreach [facet name] with [facet type] -#foreach [event type] in (all eventtype-s defined in the original IDL) +// Operations for consumers interfaces. +##foreach [consumer name] with [eventtype] in (list of all consumers) generate: + +// EventConsumer Glue Code implementation // Inherit from ::Compopnents::EventBConsumerBase void -[ciao module name]::[event type]Consumer_Servant::push_event (EventBase_ptr ev - ACE_ENV_ARG_DECL) +[ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::push_event (EventBase_ptr ev + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, ::Components::BadEventType)) { -# foreach [type] in ([event type] and all its parent eventtype, if any) - - [type] *ev_type = [type]::_downcast (ev); + [eventtype] *ev_type = [eventtype]::_downcast (ev); if (ev_type != 0) { - this->push_[type] (ev ACE_ENV_ARG); + this->push_[eventtype] (ev ACE_ENV_ARG); return; } -# end foreach [type] + + // @@ This include the case when we receive a parent eventtype of [eventtype] ACE_THROW (::Components::BadEventType ()); +} + +// get_component implementation. +[eventtype]Consumer_ptr +[ciao module name]::[component name]_Servant::get_consumer_[consumer name] (ACE_ENV_SINGLE_ARG) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + [eventtype]Consumer_var consumes_[consumer name]_; + + if (CORBA::is_nil (this->consumes_[consumer name]_.in ())) + { + TAO::Utils::Servant_Var<[eventtype]Consumer_[consumer name]_Servant> svt = + new [eventtype]Consumer_[consumer name]_Servant (this->executor_, + this->context_); + + CORBA::Object_var obj = this->container_->_install_servant (svt.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + [eventtype]Consumer_var eco = [eventtype]Consumer::_narrow (obj + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->consumes_[consumer name]_ = eco; + } + + return [eventtype]Consumer::_duplicate (this->consumes_[consumer name]_.in ()); +} + +##end foreach [consumer name] with [eventtype] + +// Operations for Navigation interface +CORBA::Object_ptr +[ciao module name]::[component name]_Servant::provide_facet (const char * name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException , + Components::InvalidName)) +{ + if (name == 0) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + // We simply iterate thru all the facets this component provides + // now. We can also use a hash map along with perfect hashing + // (i.e., gperf) if we need faster performance since all the provided + // interfaces are static to a component definition. + +##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: + if (ACE_OS_String::strcmp (name, "[facet name]") == 0) + return this->provide_[facet name] (ACE_ENV_SINGLE_ARG_PARAMETER); +##end foreach [facet name] with [facet type] + + ACE_THROW_RETURN (::Components::InvalidName (), 0); +} + +::Components::FacetDescriptions * +[ciao module name]::[component name]_Servant::get_all_facets (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::FacetDescriptions_var collection + = new ::Components::FacetDescriptions (#99); // #99 = number of all provided + // facets including those inherited + // from parent component(s). + + ::Components::FacetDescription_var x; + CORBA::ULong i = 0; + +##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: + + x = new ::OBV_Components::FacetDescription; + + x->Name ((const char *)"[facet name]"); + x->type_id ((const char *) "[facet type's repo id]"); // + x->facet_ref (this->provide_[facet name] (ACE_ENV_SINGLE_ARG_PARAMETER)); + + collection[i] = x; + ++i; +##end foreach [facet name] with [facet type] + + return collection._retn (); + +} + +::Components::FacetDescriptions * +[ciao module name]::[component name]_Servant::get_named_facets (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + ::Components::FacetDescriptions_var collection + = new ::Components::FacetDescriptions (names.length ()); + + ::Components::FacetDescription_var x; + CORBA::ULong i = 0; + for (; i < names.length (); ++i) + { + // We probably need a more efficient way, e.g., a hash map, to handle all these. +##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: + if (ACE_OS_String::strcmp (names[i].in (), "[facet name]") == 0) + { + x = new ::OBV_Components::FacetDescription; + + x->Name ((const char *)"[facet name]"); + x->type_id ((const char *) "[facet type's repo id]"); // + x->facet_ref (this->provide_facet ("[facet name]" ACE_ENV_ARG_PARAMETER)); + + collection[i] = x; + } +##end foreach [facet name] with [facet type] + ACE_THROW_RETURN (::Components::InvalidName (), 0); + } + return collection._retn (); +} + +CORBA::Boolean +[ciao module name]::[component name]_Servant::same_component (CORBA::Object_ptr object_ref + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Object_var me = this->context_->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return me->_is_equivalent (object_ref + ACE_ENV_ARG_PARAMETER); +} + +// Operations for Receptacles interface +::Components::Cookie_ptr +[ciao module name]::[component name]_Servant::connect (const char * name, + CORBA::Object_ptr connection + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::AlreadyConnected, + Components::ExceededConnectionLimit)) +{ + // @@ to-do +} + +CORBA::Object_ptr +[ciao module name]::[component name]_Servant::disconnect (const char * name, + Components::Cookie_ptr ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection, + Components::CookieRequired, + Components::NoConnection)) +{ + // @@ to-do +} + +::Components::ConnectionDescriptions * +[ciao module name]::[component name]_Servant::get_connections (const char * name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ to-do +} + +::Components::ReceptacleDescriptions * +[ciao module name]::[component name]_Servant::get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do +} + +::Components::ReceptacleDescriptions * +[ciao module name]::[component name]_Servant::get_named_receptacles (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ to-do +} + +// Operations for Events interface +::Components::EventConsumerBase_ptr +[ciao module name]::[component name]_Servant::get_consumer (const char * sink_name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ to-do +} + +::Components::Cookie_ptr +[ciao module name]::[component name]_Servant::subscribe (const char * publisher_name, + Components::EventConsumerBase_ptr subscriber + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::AlreadyConnected, + Components::InvalidConnection)) +{ + // @@ to-do +} + +void +[ciao module name]::[component name]_Servant::unsubscribe (const char * publisher_name, + Components::Cookie_ptr ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::InvalidConnection)) +{ + // @@ to-do +} + +void +[ciao module name]::[component name]_Servant::connect_consumer (const char * emitter_name, + Components::EventConsumerBase_ptr consumer + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::AlreadyConnected, + Components::InvalidConnection)) +{ + // @@ to-do +} + +::Components::EventConsumerBase_ptr +[ciao module name]::[component name]_Servant::disconnect_consumer (const char * source_name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName, + Components::NoConnection)) +{ + // @@ to-do +} + +::Components::ConsumerDescriptions * +[ciao module name]::[component name]_Servant::get_all_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do +} + +::Components::ConsumerDescriptions * +[ciao module name]::[component name]_Servant::get_named_consumers (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ to-do +} + +::Components::EmitterDescriptions * +[ciao module name]::[component name]_Servant::get_all_emitters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do +} + +::Components::EmitterDescriptions * +[ciao module name]::[component name]_Servant::get_named_emitters (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ to-do +} + +::Components::PublisherDescriptions * +[ciao module name]::[component name]_Servant::get_all_publishers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do +} + +::Components::PublisherDescriptions * +[ciao module name]::[component name]_Servant::get_named_publishers (const Components::NameList & names + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidName)) +{ + // @@ to-do +} + +// Operations for CCMObject interface +::CORBA::IRObject_ptr +[ciao module name]::[component name]_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do: Connect to an IfR? + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +::Components::CCMHome_ptr +[ciao module name]::[component name]_Servant::get_ccm_home (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->context_->get_CCM_home (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +::Components::PrimaryKeyBase * +[ciao module name]::[component name]_Servant::get_primary_key (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::NoKeyAvailable)) +{ + // This is a keyless component. + ACE_THROW_RETURN (::Components::NoKeyAvailable (), 0); +} + +void +[ciao module name]::[component name]_Servant::configuration_complete (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::InvalidConfiguration)) +{ + // @@ to-do +} + +void +[ciao module name]::[component name]_Servant::remove (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::RemoveFailure)) +{ + // @@ to-do +} + +::Components::ComponentPortDescription * +[ciao module name]::[component name]_Servant::get_all_ports (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ to-do +} + +// get_component implementation. +CORBA::Object_ptr +[ciao module name]::[component name]_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ::Components::SessionContext_var sc = + ::Components::SessionContext::_narrow (this->context_); + + if (! CORBA::is_nil(sc.in ())) + return sc->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + // @@ Do we need to try the following case here? We are afterall implementing + // a session component here. + ::Components::EntityContext_var ec = + ::Components::EntityContext::_narrow (this->context_); + + if (! CORBA::is_nil(ec.in ())) + return ec->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); +} + +[component name]_ptr +[ciao module name]::[component name]_Servant::_ciao_activate_component (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); + + return ho._retn (); } -#end foreach [event type] diff --git a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h index e6bec1d9c21..dcec96f6d37 100644 --- a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h +++ b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.h @@ -5,8 +5,8 @@ // @file CIAO_Glue_Session_Template.h // // This is a pseudo-meta generic servant implementations template -// for CCIDL. It demonstrates how a servant implementation for a -// session component should look like. +// for CIAO's CIDL compiler. It demonstrates how a servant +// implementation for a session component should look like. // // The generated filename for files using this template shoule be // [idl-basename]GS.h GS --> GlueSession @@ -30,14 +30,18 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +/// @@@ Notice that all component and interface names may need to be +/// fully qualified as we are creating a new namespace for the CIAO's +/// container glue code. -#if component is defined withing a [module name] + +##if component is defined withing a [module name] namespace CIAO_GLUE_[module_name] { -#else +##else namespace CIAO_GLUE { -#endif +##endif ////////////////////////////////////////////////////////////////// // Facet Glue Code implementation @@ -48,61 +52,33 @@ namespace CIAO_GLUE // some other CIDL generated files to get the glue code // implementation. -#foreach [facet type] in (all facet interface types in the original IDL) +##foreach [facet type] in (all facet interface types in the original IDL) class [SERVANT]_Export [facet type]_Servant : : public virtual POA_[facet type], // full skeleton name here public virtual PortableServer::RefCountServantBase { public: // Constructor and destructor. - [facet type]_Servant (CCM_[facet type]_ptr executor); + [facet type]_Servant (CCM_[facet type]_ptr executor, + ::Components::CCMContext_ptr ctx_); ~[facet tyep]_Servant (); -# foreach [operation] in (all facet operations) +## foreach [operation] in (all facet operations) // Generate operation decls. -# end foreach [operation] - - protected: - CCM_[facet type]_var executor_; - }; -#end foreach [facet type] - - ////////////////////////////////////////////////////////////////// - // EventConsumer Glue Code implementation - // @@ We are assuming that these consumers are declared under the same - // module as the component (thus, we are placing this glue code - // here under the same namespace. If they are not, we will - // either be generating them in separate namespaces, or include - // some other CIDL generated files to get the glue code - // implementation. +## end foreach [operation] -#foreach [event type] in (all eventtype-s defined in the original IDL) - class [SERVANT]_Export [event type]Consumer_Servant : - : public virtual POA_[event type]Consumer, // full skeleton name here - public virtual PortableServer::RefCountServantBase - { - public: - // Constructor and destructor. - [event type]Consumer_Servant (CCM_[event type]Consumer_ptr executor); - ~[event type]Consumer_Servant (); - -# foreach [type] in ([event type] and all its parent eventtype, if any) - void push_[type] ([type]_ptr evt - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + // get_component implementation. + virtual CORBA::Object_ptr _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); -# end [type] - - // Inherit from ::Compopnents::EventBConsumerBase - void push_event (EventBase_ptr ev - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - ::Components::BadEventType)); - protected: - CCM_[event type]Consumer_var executor_; + // Facet executor. + CCM_[facet type]_var executor_; + + // Context object. + ::Components::CCMContext_var ctx_; }; -#end foreach [event type] +##end foreach [facet type] ////////////////////////////////////////////////////////////////// @@ -120,7 +96,9 @@ namespace CIAO_GLUE friend class [component name]_Servant; // Ctor. - [component name]_Context (); + [component name]_Context (::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c, + [component name]_Servant *sv); // Dtor. virtual ~[component name]_Context (); @@ -136,19 +114,22 @@ namespace CIAO_GLUE // Operations for [component name] event source, and // receptacles defined in CCM_[component name]_Context. -#foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: -# if [receptacle name] is a simplex receptacle ('uses') - [uses type]_ptr get_connection_[receptacle name] (); -# else ([receptacle name] is a multiplex ('uses multiple') receptacle) +##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: +## if [receptacle name] is a simplex receptacle ('uses') + [uses type]_ptr get_connection_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + ACE_THROW_SPEC ((CORBA::SystemException)); +## else ([receptacle name] is a multiplex ('uses multiple') receptacle) // [receptacle name]Connections typedef'ed as a sequence of // struct [receptacle name]Connection. - [receptacle name]Connections *get_connections_[receptacle name] (); -# endif [receptacle name] -#end foreach [receptacle name] with [uses type] + [receptacle name]Connections *get_connections_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + ACE_THROW_SPEC ((CORBA::SystemException)); +## endif [receptacle name] +##end foreach [receptacle name] with [uses type] -#foreach [event name] with [eventtype] in (list of all event sources) generate: - void push_[event name] ([eventtype]_ptr ev); -#end foreach [event name] with [eventtype] +##foreach [event name] with [eventtype] in (list of all event sources) generate: + void push_[event name] ([eventtype]_ptr ev ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +##end foreach [event name] with [eventtype] // Operations for ::Components::CCMContext virtual ::Components::Principal_ptr get_caller_principal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) @@ -176,57 +157,83 @@ namespace CIAO_GLUE // We need to generate, in protected section, stuff that manage // connections and consumers of this component. -#foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: -# if [receptacle name] is a simplex receptacle ('uses') +##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: +## if [receptacle name] is a simplex receptacle ('uses') // Simplex [receptacle name] connection management operations - void connect_[receptacle name] ([uses type]_ptr c) - raises (::Components::AlreadyConnected, - ::Components::InvalidConnection); - [uses type]_ptr disconnect_[receptacle name] () - raises (::Components::NoConnection); + void connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SytemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)); + [uses type]_ptr disconnect_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SEPC ((CORBA::SystemException, + ::Components::NoConnection)); // Simplex [receptacle name] connection [uses type]_var ciao_uses_[receptacle name]_; -# else ([receptacle name] is a multiplex ('uses multiple') receptacle) +## else ([receptacle name] is a multiplex ('uses multiple') receptacle) // Multiplex [receptacle name] connection management operations - ::Components::Cookie_ptr connect_[receptacle name] ([uses type]_ptr c) - raises (::Components::ExceedConnectionLimit, - ::Components::InvalidConnection); - [uses type]_ptr disconnect_[receptacle name] (::Components::Cookie_ptr ck) - raises (::Components::InvalidConnection); + ::Components::Cookie_ptr connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceedConnectionLimit, + ::Components::InvalidConnection)); + [uses type]_ptr disconnect_[receptacle name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); // Multiplex [receptacle name] connections CIAO::Active_Objref_Map ciao_muses_[receptacle name]_; -# endif [receptacle name] -#end foreach [receptacle name] with [uses type] +## endif [receptacle name] +##end foreach [receptacle name] with [uses type] // Operations for emits interfaces. -#foreach [emit name] with [eventtype] in (list of all emitters) generate: - void connect_[emit name] ([eventtype]Consumer_ptr c) - raises (::Components::AlreadyConnected); +##foreach [emit name] with [eventtype] in (list of all emitters) generate: + void connect_[emit name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected)); - [eventtype]Consumer_ptr disconnect_[emit name] () - raises (::Components::NoConnection); + [eventtype]Consumer_ptr disconnect_[emit name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)); [eventtype]Consumer_var ciao_emits_[emit name]_consumer_; -#end foreach [emit name] with [eventtype] +##end foreach [emit name] with [eventtype] // Operations for publishes interfaces. -#foreach [publish name] with [eventtype] in (list of all publishers) generate: +##foreach [publish name] with [eventtype] in (list of all publishers) generate: ::Components::Cookie_ptr - subscribe_[publish name] ([eventtype]Consumer_ptr c) - raises (::Components::ExceededConnectionLimit); + subscribe_[publish name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)); [eventtype]Consumer_ptr - unsubscribe_[publish name] (::Components::Cookie_ptr ck) - raises (::Components::InvalidConnection); + unsubscribe_[publish name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); CIAO::Active_Objref_Map ciao_publishes_[publish name]_map_; -#end foreach [publish name] with [eventtype] - // Other CCMContext specific operations seem quite straightforward - // to me. Well, so far. +##end foreach [publish name] with [eventtype] + + protected: + /// Cached component home reference. + ::Components::CCMHome_var home_; + + /// session container + ::CIAO::Session_Container *container_; + + /// Reference back to owner. + [component name]_Servant *servant_; + + /// @@ Cached component reference. + [component name]_var component_; + }; ////////////////////////////////////////////////////////////////// @@ -237,68 +244,124 @@ namespace CIAO_GLUE { public: // Ctor. - [component name]_Servant (CCM_[component name]_ptr executor); + [component name]_Servant (CCM_[component name]_ptr executor, + ::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c); // Dtor. ~[component name]_Servant (void); -#foreach [operation] in all supported interfaces of own component and all inherited components +##foreach [operation] in all supported interfaces of own component and all inherited components // Generate the [operation] here. -#end +##end // Operations for provides interfaces. -#foreach [facet name] with [facet type] in (list of all provided interfaces) generate: - [facet type]_ptr provide_[facet name] (); -#end foreach [facet name] with [facet type] +##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: + [facet type]_ptr provide_[facet name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +##end foreach [facet name] with [facet type] // Operations for receptacles interfaces. -#foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: -# if [receptacle name] is a simplex receptacle ('uses') +##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: +## if [receptacle name] is a simplex receptacle ('uses') // Simplex [receptacle name] connection management operations - void connect_[receptacle name] ([uses type]_ptr c) - raises (::Components::AlreadyConnected, - ::Components::InvalidConnection); - [uses type]_ptr disconnect_[receptacle name] () - raises (::Components::NoConnection); - [uses type]_ptr get_connection_[receptacle name] (); -# else ([receptacle name] is a multiplex ('uses multiple') receptacle) + void connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)); + [uses type]_ptr disconnect_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)); + [uses type]_ptr get_connection_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +## else ([receptacle name] is a multiplex ('uses multiple') receptacle) // Multiplex [receptacle name] connection management operations - ::Components::Cookie_ptr connect_[receptacle name] ([uses type]_ptr c) - raises (::Components::ExceedConnectionLimit, - ::Components::InvalidConnection); - [uses type]_ptr disconnect_[receptacle name] (::Components::Cookie_ptr ck) - raises (::Components::InvalidConnection); - [receptacle name]Connections *get_connections_[receptacle name] (); -# endif [receptacle name] -#end foreach [receptacle name] with [uses type] + ::Components::Cookie_ptr connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceedConnectionLimit, + ::Components::InvalidConnection)); + [uses type]_ptr disconnect_[receptacle name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); + [receptacle name]Connections *get_connections_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +## endif [receptacle name] +##end foreach [receptacle name] with [uses type] // Operations for consumers interfaces. -#foreach [consumer name] with [eventtype] in (list of all consumers) generate: - [eventtype]Consumer_ptr get_consumer_[consumer name] (); -#end foreach [facet name] with [eventtype] +##foreach [consumer name] with [eventtype] in (list of all consumers) generate: + + // First we need to generate the event sink specific servant + class [SERVANT]_Export [eventtype]Consumer_[consumer name]_Servant : + : public virtual POA_[eventtype]Consumer, // full skeleton name here + public virtual PortableServer::RefCountServantBase + { + public: + // Constructor and destructor. + [event type]Consumer_[consumer name]_Servant (CCM_[component name]_ptr executor, + CCM_[component name]_Context_ptr c); + ~[event type]Consumer-[consumer name]_Servant (); + +## foreach [type] in ([eventtype] and all its parent eventtype, if any) + void push_[type] ([type]_ptr evt + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +## end [type] + + // Inherit from ::Compopnents::EventBConsumerBase + void push_event (EventBase_ptr ev + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::BadEventType)); + + // get_component implementation. + virtual CORBA::Object_ptr _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + // Consumer Executor + CCM_[component name]_var executor_; + + // Context object. + CCM_[component name]_Context_var ctx_; + }; + + [eventtype]Consumer_ptr get_consumer_[consumer name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +##end foreach [consumer name] with [eventtype] // Operations for emits interfaces. -#foreach [emit name] with [eventtype] in (list of all emitters) generate: - void connect_[emit name] ([eventtype]Consumer_ptr c) - raises (::Components::AlreadyConnected); +##foreach [emit name] with [eventtype] in (list of all emitters) generate: + void connect_[emit name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException + ::Components::AlreadyConnected)); - [eventtype]Consumer_ptr disconnect_[emit name] () - raises (::Components::NoConnection); -#end foreach [emit name] with [eventtype] + [eventtype]Consumer_ptr disconnect_[emit name] (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)); +##end foreach [emit name] with [eventtype] // Operations for publishes interfaces. -#foreach [publish name] with [eventtype] in (list of all publishers) generate: +##foreach [publish name] with [eventtype] in (list of all publishers) generate: ::Components::Cookie_ptr - subscribe_[publish name] ([eventtype]Consumer_ptr c) - raises (::Components::ExceededConnectionLimit); + subscribe_[publish name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)); [eventtype]Consumer_ptr - unsubscribe_[publish name] (::Components::Cookie_ptr ck) - raises (::Components::InvalidConnection); -#end foreach [publish name] with [eventtype] + unsubscribe_[publish name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); +##end foreach [publish name] with [eventtype] // Operations for Navigation interface virtual CORBA::Object_ptr provide_facet (const char * name @@ -324,9 +387,9 @@ namespace CIAO_GLUE Components::InvalidConnection, Components::AlreadyConnected, Components::ExceededConnectionLimit)); - virtual void disconnect (const char * name, - Components::Cookie_ptr ck - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + virtual CORBA::Object_ptr disconnect (const char * name, + Components::Cookie_ptr ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::InvalidConnection, @@ -410,6 +473,16 @@ namespace CIAO_GLUE virtual ::Components::ComponentPortDescription * get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); + // get_component implementation. + virtual CORBA::Object_ptr _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // CIAO specific operations. + + // Activate the object in the container_ + [component name]_ptr _ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + protected: // My Executor. CCM_[component name]_var executor_; @@ -417,14 +490,17 @@ namespace CIAO_GLUE // My Run-time Context. CCM_[component name]_Context_var context_; + // Managing container. + ::CIAO::Session_Container *container_; + // Cached provided interfaces. -#foreach [facet name] with [facet type] in (list of all provided interfaces) generate: +##foreach [facet name] with [facet type] in (list of all provided interfaces) generate: [facet type]_var provide_[facet name]_; -#end foreach [facet name] with [facet type] +##end foreach [facet name] with [facet type] -#foreach [consumer name] with [eventtype] in (list of all consumers) generate: +##foreach [consumer name] with [eventtype] in (list of all consumers) generate: [eventtype]Consumer_var consumes_[consumer name]_; -#end foreach [consumer name] with [eventtype] +##end foreach [consumer name] with [eventtype] }; diff --git a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl index 72f2a5403f6..6a3a9db1ce3 100644 --- a/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl +++ b/TAO/CIAO/docs/templates/CIAO_Glue_Session_Template.inl @@ -14,12 +14,15 @@ // either be generating them in separate namespaces, or include // some other CIDL generated files to get the glue code // implementation. +////////////////////////////////////////////////////////////////// -#foreach [facet type] in (all facet interface types in the original IDL) +##foreach [facet type] in (all facet interface types in the original IDL) // Constructor and destructor. ACE_INLINE -[ciao module name]::[facet type]_Servant::[facet type]_Servant (CCM_[facet type]_ptr executor) - : executor_ (CCM_[facet type]::_duplicate (executor)) +[ciao module name]::[facet type]_Servant::[facet type]_Servant (CCM_[facet type]_ptr executor, + ::Components::CCMContext_ptr c) + : executor_ (CCM_[facet type]::_duplicate (executor)), + ctx_ (c) { } @@ -29,16 +32,331 @@ ACE_INLINE } -# foreach [operation] in (all facet operations) +## foreach [operation] in (all facet operations) + +// This is only a guideline... we always relay the operation to underlying +// executor. + ACE_INLINE [operation return_type] [ciao module name]::[facet type]_Servant::[operation] ([operation args]) { // Simply relay to executor. May not need to return the result... - return this->operation ([operation args]); + return this->executor_->operation ([operation args]); } -# end foreach [operation] -#end foreach [facet type] +## end foreach [operation] +##end foreach [facet type] + + +////////////////////////////////////////////////////////////////// +// Component specific context implementation +////////////////////////////////////////////////////////////////// + +ACE_INLINE +[ciao module name]::[component name]_Context::[component name]_Context (::Components::CCMHome_ptr home, + ::CIAO::Session_Container *c, + [component name]_Servant *sv) + : home_ (::Components::CCMHome::_duplicate (h)), + container_ (c), + servant_ (sv) +{ + +} + +ACE_INLINE +[ciao module name]::[component name]_Context::~[component name]_Context () +{ +} + +##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: + +## if [receptacle name] is a simplex receptacle ('uses') + +ACE_INLINE [uses type]_ptr +[ciao module name]::[component name]_Context::get_connection_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return [uses type]::_duplicate (this->ciao_uses_[receptacle name]_.in ()); +} + +// Simplex [receptacle name] connection management operations +ACE_INLINE void +[ciao module name]::[component name]_Context::connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)) +{ + if (! CORBA::is_nil (this->ciao_uses_[receptacle name]_.in ())) + ACE_THROW (::Components::AlreadyConnected ()); + + // When do we throw InvalidConnection exception? + this->ciao_uses_[receptacle name]_ = [uses type]::_duplicate (c); +} + +ACE_INLINE [uses type]_ptr +[ciao module name]::[component name]_Context::disconnect_[receptacle name] () + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)) +{ + if (CORBA::is_nil (this->ciao_uses_[receptacle name]_.in ())) + ACE_THROW (::Components::NoConnection ()); + + return this->ciao_uses_[receptacle name]_.retn (); +} + +## else ([receptacle name] is a multiplex ('uses multiple') receptacle) +// Multiplex [receptacle name] connection management operations +ACE_INLINE ::Components::Cookie_ptr +[ciao module name]::[component name]_Context::connect_[receptacle name] ([uses type]_ptr c) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceedConnectionLimit, + ::Components::InvalidConnection)) +{ + if (CORBA::is_nil (c)) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + CIAO::Active_Objref_Map::key_type key; + this->ciao_muses_[receptacle name]_.bind (c, + key); + + ::Components::Cookie_var retv = new CIAO::Map_Key_Cookie (key); + return retv._retn (); +} + +ACE_INLINE [uses type]_ptr +[ciao module name]::[component name]_Context::disconnect_[receptacle name] (::Components::Cookie_ptr ck) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)) +{ + [uses type]_var retv; + + if (ck == 0 || + this->ciao_muses_[receptacle name]_.unbind (ck, + retv) != 0) + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + + return retv._retn (); +} + +## endif [receptacle name] +##end foreach [receptacle name] with [uses type] + +// Operations for emits interfaces. +##foreach [emit name] with [eventtype] in (list of all emitters) generate: + +ACE_INLINE void +[ciao module name]::[component name]_Context::connect_[emit name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected)) +{ + if (CORBA::is_nil (c)) + ACE_THROW (CORBA::BAD_PARAM ()); + + if (! CORBA::is_nil (this->ciao_emits_[emit name]_consumer_.in ())) + ACE_THROW (::Components::AlreadyConnected ()); + + this->ciao_emits_[emit name]_consumer_ = c; +} + +ACE_INLINE [eventtype]Consumer_ptr +[ciao module name]::[component name]_Context::disconnect_[emit name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)) +{ + if (CORBA::is_nil (this->ciao_emits_[emit name]_consumer_.in ())) + ACE_THROW (::Components::NoConnection ()); + + return this->ciao_emits_[emit name]_consumer_._retn (); +} + +##end foreach [emit name] with [eventtype] + + // Operations for publishes interfaces. +##foreach [publish name] with [eventtype] in (list of all publishers) generate: +ACE_INLINE ::Components::Cookie_ptr +[ciao module name]::[component name]_Context::subscribe_[publish name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)) +{ + if (CORBA::is_nil (c)) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + CIAO::Active_Objref_Map::key_type key; + this->ciao_publishes_[publish name]_map_.bind (c, + key); + + ::Components::Cookie_var retv = new CIAO::Map_Key_Cookie (key); + return retv._retn (); +} + +ACE_INLINE [eventtype]Consumer_ptr +unsubscribe_[publish name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)); +{ + [eventtype]Consumer_var retv; + + if (ck == 0 || + this->ciao_publishes_[publish name]_map_.unbind (ck, + retv) != 0) + ACE_THROW_RETURN (::Components::InvalidConnection (), 0); + + return retv._retn (); +} + +##end foreach [publish name] with [eventtype] + +// Operations for ::Components::CCMContext +ACE_INLINE ::Components::Principal_ptr +[ciao module name]::[component name]_Context::get_caller_principal (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ We don't support Security in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE ::Components::CCMHome_ptr +[ciao module name]::[component name]_Context::get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return ::Components::CCMHome::_duplicate (this->home_.in ()); +} + +ACE_INLINE CORBA::Boolean +[ciao module name]::[component name]_Context::get_rollback_only (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE ::Components::Transaction::UserTransaction_ptr +[ciao module name]::[component name]_Context::get_user_transaction (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE CORBA::Boolean +[ciao module name]::[component name]_Context::is_caller_in_role (const char * role + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG (role); + + // @@ We don't support Transaction in CIAO yet. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +ACE_INLINE void +[ciao module name]::[component name]_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::IllegalState)) +{ + // @@ We don't support Transaction in CIAO yet. + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +////////////////////////////////////////////////////////////////// +// 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 [component name]_Context (h, c, this); +} + +ACE_INLINE +[ciao module name]::[component name]_Servant::~[component name]_Servant (void) +{ +} + +##foreach [operation] in all supported interfaces of own component and all inherited components + +// This is only a guideline... we always relay the operation to underlying +// executor. + +ACE_INLINE [operation return_type] +[ciao module name]::[component name]_Servant::[operation] ([operation args]) +{ + // Simply relay to executor. May not need to return the result... + return this->executor_->operation ([operation args]); +} + +##end + +##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: +## if [receptacle name] is a simplex receptacle ('uses') + // Simplex [receptacle name] connection management operations +ACE_INLINE void +[ciao module name]::[component name]_Servant::connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::AlreadyConnected, + ::Components::InvalidConnection)) +{ + this->context_->connect_[receptacle name] (c ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE [uses type]_ptr +[ciao module name]::[component name]_Servant::disconnect_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)) +{ + return this->context_->disconnect_[receptacle name] (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE [uses type]_ptr +[ciao module name]::[component name]_Servant::get_connection_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->context_->get_connection_[receptacle name] (ACE_ENV_SINGLE_ARG_PARAMETER); +} +## else ([receptacle name] is a multiplex ('uses multiple') receptacle) + + // Multiplex [receptacle name] connection management operations +ACE_INLINE ::Components::Cookie_ptr +[ciao module name]::[component name]_Servant::connect_[receptacle name] ([uses type]_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceedConnectionLimit, + ::Components::InvalidConnection)) +{ + return this->context_->connect_[receptacle name] (c + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE [uses type]_ptr +[ciao module name]::[component name]_Servant::disconnect_[receptacle name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)) +{ + return this->context_->disconnect_[receptacle name] (ck + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE [receptacle name]Connections * +[ciao module name]::[component name]_Servant::get_connections_[receptacle name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->context_->get_connections_[receptacle name] (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +## endif [receptacle name] +##end foreach [receptacle name] with [uses type] ////////////////////////////////////////////////////////////////// // EventConsumer Glue Code implementation @@ -48,28 +366,97 @@ ACE_INLINE [operation return_type] // either be generating them in separate namespaces, or include // some other CIDL generated files to get the glue code // implementation. +////////////////////////////////////////////////////////////////// + +##foreach [consumer name] with [eventtype] in (list of all consumers) generate: -#foreach [event type] in (all eventtype-s defined in the original IDL) // Constructor and destructor. ACE_INLINE -[ciao module name]::[event type]Consumer_Servant::[event type]Consumer_Servant (CCM_[event type]Consumer_ptr executor) - : executor_ (CCM_[event type]Consumer::_duplicate (executor)) +[ciao module name]::[component name]_Servant::[event type]Consumer_[consumer name]_Servant::[event type]Consumer_[consumer name]_Servant + (CCM_[component name]_ptr executor, + CCM_[component name]_Context_ptr c) + : executor_ (CCM_[event type]Consumer::_duplicate (executor)), + ctx_ (CCM_[component name]_Context::_duplicate (c)) { } ACE_INLINE -[ciao module name]::[event type]Consumer_Servant::~[event type]Consumer_Servant () +[ciao module name]::[component name]_Servant::[event type]Consumer_[consumer name]_Servant::~[event type]Consumer_[consumer name]_Servant () +{ +} + +ACE_INLINE CORBA::Object_ptr +[ciao module name]::[component name]_Servant::[event type]Consumer_[consumer name]_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { + return this->ctx_->get_CCM_Object (ACE_ENV_SINGLE_ARG_PARAMETER); } -# foreach [type] in ([event type] and all its parent eventtype, if any) ACE_INLINE void -[ciao module name]::[event type]Consumer_Servant::push_[type] ([type]_ptr evt - ACE_ENV_ARG_DECL_WITH_DEFAULTS) +[ciao module name]::[component name]_Servant::[event type]Consumer_[consumer name]_Servant::push_[eventtype] + ([eventtype]_ptr evt + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - this->executor_->push_[type] (evt ACE_ENV_ARG); + this->executor_->push_[consumer name] (evt ACE_ENV_ARG); } -# end [type] -#end foreach [event type] +## foreach [type] in (all parents of eventtype, if any, not including EventConsumerBase) +ACE_INLINE void +[ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::push_[type] + ([type]_ptr evt + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ Problem, there's no way to handle this case. + + // this->executor_->push_[consumer name] (evt ACE_ENV_ARG); + ACE_THROW (::CORBA::BAD_PARAM ()); +} +## end [type] + +##end foreach [consumer name] + + // Operations for emits interfaces. +##foreach [emit name] with [eventtype] in (list of all emitters) generate: +ACE_INLINE void +[ciao module name]::[component name]_Servant::connect_[emit name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException + ::Components::AlreadyConnected)) +{ + this->context_->connect_[emit name] (c + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE [eventtype]Consumer_ptr +[ciao module name]::[component name]_Servant::disconnect_[emit name] (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::NoConnection)) +{ + return this->context_->disconnect_[emit name] (ACE_ENV_SINGLE_ARG_PARAMETER); +} +##end foreach [emit name] with [eventtype] + + // Operations for publishes interfaces. +##foreach [publish name] with [eventtype] in (list of all publishers) generate: +ACE_INLINE ::Components::Cookie_ptr +[ciao module name]::[component name]_Servant::subscribe_[publish name] ([eventtype]Consumer_ptr c + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::ExceededConnectionLimit)) +{ + return this->context_->subscribe_[publish name] (c + ACE_ENV_ARG_PARAMATER); +} + +ACE_INLINE [eventtype]Consumer_ptr +[ciao module name]::[component name]_Servant::unsubscribe_[publish name] (::Components::Cookie_ptr ck + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + ::Components::InvalidConnection)) +{ + return this->context_->unsubscribe_[publish name] (ck + ACE_ENV_ARG_PARAMETER); +} +##end foreach [publish name] with [eventtype] diff --git a/TAO/CIAO/docs/templates/Executor.idl b/TAO/CIAO/docs/templates/Executor.idl index 2dc944801fe..83fe3cb383d 100644 --- a/TAO/CIAO/docs/templates/Executor.idl +++ b/TAO/CIAO/docs/templates/Executor.idl @@ -22,9 +22,9 @@ // internal/callback interfaces #include "[component_idl].idl" // Original component IDL definition -#if there are module definitions, preserve them all +##if there are module definitions, preserve them all module [module_name] { -#endif +##endif //////////////////////////////////////////////////////////////////// //// * Iterate thru all facet ('provides' interface) interface types @@ -33,13 +33,13 @@ module [module_name] { //// specify that in CCIDL? I haven't figured that out. Perhaps //// allowing CCIDL to compile files that contain no component //// definition? -#foreach [facet_interface_type] in (types of all facets) generate: +##foreach [facet_interface_type] in (types of all facets) generate: local interface CCM_[facet_interface_type] : [facet_interface_type] { }; -#end foreach [facet_interface_type] +##end foreach [facet_interface_type] //////////////////////////////////////////////////////////////////// //// * Iterate thru all event ('emits', "publishes', or 'consumes') types @@ -50,14 +50,14 @@ module [module_name] { //// allowing CCIDL to compile files that contain no component //// definition? -#foreach [eventtype] in (all eventtypes) generate: +##foreach [eventtype] in (all eventtypes) generate: local interface CCM_[eventtype]Consumer { void push (in [eventtype] ev); }; -#end foreach [eventtype] +##end foreach [eventtype] //////////////////////////////////////////////////////////////////// @@ -65,26 +65,26 @@ module [module_name] { //// Notice that there's no distinction between entity and session //// components in executor mappings. -#foreach [component basename] in (all component definitions) generate: +##foreach [component basename] in (all component definitions) generate: // Component Main Executor Interface. We currently do not // support Executor-based implementation. local interface CCM_[component basename]_Executor : -# if [component basename] inherits from [parent component name] +## if [component basename] inherits from [parent component name] CCM_[parent component name]_Executor -# else +## else ::Components:EnterpriseComponent -# endif -# foreach [interface name] in (all component supported interfaces) generate: +## endif +## foreach [interface name] in (all component supported interfaces) generate: , [interface name] -# end foreach [interface name] +## end foreach [interface name] { -# foreach [attribute definition] in (attributes defined in [component basename]) generate: +## foreach [attribute definition] in (attributes defined in [component basename]) generate: [attribute definition]; -# end foreach [attribute definition] +## end foreach [attribute definition] }; @@ -93,83 +93,83 @@ module [module_name] { local interface CCM_[component basename] : -# if [component basename] inherits from [parent component name] +## if [component basename] inherits from [parent component name] CCM_[parent component name] -# else +## else ::Components:EnterpriseComponent -# endif -# foreach [interface name] in (all component supported interfaces) generate: +## endif +## foreach [interface name] in (all component supported interfaces) generate: , [interface name] -# end foreach [interface name] +## end foreach [interface name] { -# foreach [attribute definition] in (attributes defined in [component basename]) generate: +## foreach [attribute definition] in (attributes defined in [component basename]) generate: [attribute definition]; -# end foreach [attribute definition] +## end foreach [attribute definition] -# foreach [facet name] with [facet type] in (list of all provided interfaces) generate: +## foreach [facet name] with [facet type] in (list of all provided interfaces) generate: CCM_[facet type] get_[facet name] (); -# end foreach [facet name] with [facet type] +## end foreach [facet name] with [facet type] -# foreach [event name] with [eventtype] in (list of all event sinks) generate: +## foreach [event name] with [eventtype] in (list of all event sinks) generate: void push_[event name] (in [eventtype] ev); -# end foreach [event name] with [eventtype] +## end foreach [event name] with [eventtype] }; // Component Context Interface local interface CCM_[component basename]_Context : -# if [component basename] inherits from [parent component name] +## if [component basename] inherits from [parent component name] CCM_[parent component name]_Context -# else +## else ::Components:CCMContext -# endif +## endif { -# foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: -# if [receptacle name] is a simplex receptacle ('uses') +## foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate: +## if [receptacle name] is a simplex receptacle ('uses') [uses type] get_connection_[receptacle name] (); -# else ([receptacle name] is a multiplex ('uses multiple') receptacle) +## else ([receptacle name] is a multiplex ('uses multiple') receptacle) // [receptacle name]Connections typedef'ed as a sequence of // struct [receptacle name]Connection. [receptacle name]Connections get_connections_[receptacle name] (); -# endif [receptacle name] -# end foreach [receptacle name] with [uses type] +## endif [receptacle name] +## end foreach [receptacle name] with [uses type] -# foreach [event name] with [eventtype] in (list of all event sources) generate: +## foreach [event name] with [eventtype] in (list of all event sources) generate: void push_[event name] (in [eventtype] ev); -# end foreach [event name] with [eventtype] +## end foreach [event name] with [eventtype] }; -#end foreach [component basename] +##end foreach [component basename] //////////////////////////////////////////////////////////////////// //// * Iterate thru all home definitions in the IDL files. -#foreach [home basename] in (all home definitions) generate: +##foreach [home basename] in (all home definitions) generate: local interface CCM_[home basename]Explicit : -# if [home basename] inherits from [parent home name] +## if [home basename] inherits from [parent home name] CCM_[parent home name]Explicit -# else +## else ::Components:HomeExecutorBase -# endif -# foreach [interface name] in (all home supported interfaces) generate: +## endif +## foreach [interface name] in (all home supported interfaces) generate: , [interface name] -# end foreach [interface name] +## end foreach [interface name] { }; local interface CCM_[home basename]Implicit { -# if [home basename] is a keyless home +## if [home basename] is a keyless home ::Components::EnterpriseComponent create () raises (::Components::CCMException); -# else [home basename] is key'ed home with [key type] +## else [home basename] is key'ed home with [key type] // We do not support key'ed home at the moment but we might // as well generate the mapping. ::Components::EnterpriseComponent create (in [key type] key) @@ -180,7 +180,7 @@ module [module_name] { void remove (in [key type] key) raises (::Components::CCMException); -# endif (key'ed or keyless home) +## endif (key'ed or keyless home) }; local interface CCM_[home basename] @@ -189,8 +189,8 @@ module [module_name] { { }; -#end foreach [home basename] +##end foreach [home basename] -#if there are module definitions, preserve them all +##if there are module definitions, preserve them all }; -#endif +##endif diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp index 60b193299f8..fa5d9125de2 100644 --- a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp +++ b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp @@ -5,7 +5,12 @@ // @@: Denote stuff that need to be fixed later. // @@@: Denote stuff that need to be fixed now. -CIAO_HelloWorld_Context::CIAO_HelloWorld_Context () +CIAO_HelloWorld_Context::CIAO_HelloWorld_Context (::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c, + CIAO_HelloWorld_Servant *sv) + : home_ (::Components::CCMHome::_duplicate (h)), + container_ (c), + servant_ (sv) { } @@ -86,7 +91,7 @@ CIAO_HelloWorld_Context::_interface_repository_id (void) const // Operations for ::Components::CCMContext ::Components::Principal_ptr -CIAO_HelloWorld_Context::get_caller_principal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Context::get_caller_principal (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // @@ We don't support Security in CIAO yet. @@ -94,15 +99,14 @@ CIAO_HelloWorld_Context::get_caller_principal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFA } ::Components::CCMHome_ptr -CIAO_HelloWorld_Context::get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Context::get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { - // @@@ Where to get a home reference? - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + return ::Components::CCMHome::_duplicate (this->home_.in ()); } CORBA::Boolean -CIAO_HelloWorld_Context::get_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Context::get_rollback_only (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::IllegalState)) { @@ -111,7 +115,7 @@ CIAO_HelloWorld_Context::get_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULT } ::Components::Transaction::UserTransaction_ptr -CIAO_HelloWorld_Context::get_user_transaction (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Context::get_user_transaction (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::IllegalState)) { @@ -121,7 +125,7 @@ CIAO_HelloWorld_Context::get_user_transaction (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFA CORBA::Boolean CIAO_HelloWorld_Context::is_caller_in_role (const char * role - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_UNUSED_ARG (role); @@ -131,7 +135,7 @@ CIAO_HelloWorld_Context::is_caller_in_role (const char * role } void -CIAO_HelloWorld_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::IllegalState)) { @@ -142,21 +146,40 @@ CIAO_HelloWorld_Context::set_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULT // Operations for ::Components::SessionContext interface CORBA::Object_ptr -CIAO_HelloWorld_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Context::get_CCM_object (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::IllegalState)) { - // @@@ Where do we get the CCM Object reference? From the container? - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + // @@ How do I check for IllegalState here? When it's not in a + // callback operation... + // ACE_THROW_RETURN (::Components::IllegalState (), 0); + + if (CORBA::is_nil (this->component_.in ())) + { + CORBA::Object_var obj = this->container_->get_objref (this->servant_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + this->component_ = HelloWorld::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (CORBA::is_nil (this->component_.in ())) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); // This should not happen... + } + return HelloWorld::_duplicate (this->component_.in ()); } //////////////////////////////////////////////////////////////// /////////////////// CIAO_HelloWorld_Servant //////////////////// -CIAO_HelloWorld_Servant::CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr exe) - : executor_ (CCM_HelloWorld::_duplicate (exe)) +CIAO_HelloWorld_Servant::CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr exe, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c) + : executor_ (CCM_HelloWorld::_duplicate (exe)), + container_ (c) { - this->context_ = new CIAO_HelloWorld_Context (); + this->context_ = new CIAO_HelloWorld_Context (h, c, this); } CIAO_HelloWorld_Servant::~CIAO_HelloWorld_Servant (void) @@ -167,7 +190,7 @@ CIAO_HelloWorld_Servant::~CIAO_HelloWorld_Servant (void) // Explicit opereations and attribute operations. char * CIAO_HelloWorld_Servant::sayhello (const char * username - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { if (this->executor_.in () == 0) @@ -189,7 +212,7 @@ CIAO_HelloWorld_Servant::sayhello (const char * username // Operations for Navigation interface CORBA::Object_ptr CIAO_HelloWorld_Servant::provide_facet (const char * name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException , Components::InvalidName)) { @@ -205,16 +228,31 @@ CIAO_HelloWorld_Servant::provide_facet (const char * name } ::Components::FacetDescriptions * -CIAO_HelloWorld_Servant::get_all_facets (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_all_facets (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { + ::Components::FacetDescriptions_var collection + = new ::Components::FacetDescriptions (1); + + ::Components::FacetDescription_var x + = new ::OBV_Components::FacetDescription; + + + x->Name ((const char *)"a_name"); + x->type_id ("repo id"); + x->facet_ref (CORBA::Object::_nil ()); + + CORBA::ULong i = 0; + collection[i] = x; + + return collection._retn (); // No facet for this component. - return new ::Components::FacetDescriptions; + // return new ::Components::FacetDescriptions; } ::Components::FacetDescriptions * CIAO_HelloWorld_Servant::get_named_facets (const Components::NameList & names - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException , Components::InvalidName)) { @@ -229,7 +267,7 @@ CIAO_HelloWorld_Servant::get_named_facets (const Components::NameList & names CORBA::Boolean CIAO_HelloWorld_Servant::same_component (CORBA::Object_ptr object_ref - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_UNUSED_ARG (object_ref); @@ -244,7 +282,7 @@ CIAO_HelloWorld_Servant::same_component (CORBA::Object_ptr object_ref ::Components::Cookie * CIAO_HelloWorld_Servant::connect (const char * name, CORBA::Object_ptr connection - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::InvalidConnection, @@ -259,10 +297,10 @@ CIAO_HelloWorld_Servant::connect (const char * name, ACE_THROW_RETURN (::Components::InvalidName (), 0); } -void +CORBA::Object_ptr CIAO_HelloWorld_Servant::disconnect (const char * name, Components::Cookie * ck - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::InvalidConnection, @@ -272,12 +310,12 @@ CIAO_HelloWorld_Servant::disconnect (const char * name, ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (ck); - ACE_THROW (::Components::InvalidName ()); + ACE_THROW_RETURN (::Components::InvalidName (), 0); } ::Components::ConnectionDescriptions * CIAO_HelloWorld_Servant::get_connections (const char * name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName)) { @@ -287,7 +325,7 @@ CIAO_HelloWorld_Servant::get_connections (const char * name } ::Components::ReceptacleDescriptions * -CIAO_HelloWorld_Servant::get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // No receptacles. Return an empty sequence. @@ -296,7 +334,7 @@ CIAO_HelloWorld_Servant::get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAU ::Components::ReceptacleDescriptions * CIAO_HelloWorld_Servant::get_named_receptacles (const Components::NameList & names - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName)) { @@ -312,7 +350,7 @@ CIAO_HelloWorld_Servant::get_named_receptacles (const Components::NameList & nam // Operations for Events interface ::Components::EventConsumerBase_ptr CIAO_HelloWorld_Servant::get_consumer (const char * sink_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName)) { @@ -324,7 +362,7 @@ CIAO_HelloWorld_Servant::get_consumer (const char * sink_name ::Components::Cookie * CIAO_HelloWorld_Servant::subscribe (const char * publisher_name, Components::EventConsumerBase_ptr subscriber - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::AlreadyConnected, @@ -339,7 +377,7 @@ CIAO_HelloWorld_Servant::subscribe (const char * publisher_name, void CIAO_HelloWorld_Servant::unsubscribe (const char * publisher_name, Components::Cookie * ck - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::InvalidConnection)) @@ -353,7 +391,7 @@ CIAO_HelloWorld_Servant::unsubscribe (const char * publisher_name, void CIAO_HelloWorld_Servant::connect_consumer (const char * emitter_name, Components::EventConsumerBase_ptr consumer - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::AlreadyConnected, @@ -367,7 +405,7 @@ CIAO_HelloWorld_Servant::connect_consumer (const char * emitter_name, ::Components::EventConsumerBase_ptr CIAO_HelloWorld_Servant::disconnect_consumer (const char * source_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::NoConnection)) @@ -378,7 +416,7 @@ CIAO_HelloWorld_Servant::disconnect_consumer (const char * source_name } ::Components::ConsumerDescriptions * -CIAO_HelloWorld_Servant::get_all_consumers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_all_consumers (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { return new ::Components::ConsumerDescriptions; @@ -386,7 +424,7 @@ CIAO_HelloWorld_Servant::get_all_consumers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULT ::Components::ConsumerDescriptions * CIAO_HelloWorld_Servant::get_named_consumers (const Components::NameList & names - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName)) { @@ -400,7 +438,7 @@ CIAO_HelloWorld_Servant::get_named_consumers (const Components::NameList & names } ::Components::EmitterDescriptions * -CIAO_HelloWorld_Servant::get_all_emitters (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_all_emitters (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { return new ::Components::EmitterDescriptions; @@ -408,7 +446,7 @@ CIAO_HelloWorld_Servant::get_all_emitters (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS ::Components::EmitterDescriptions * CIAO_HelloWorld_Servant::get_named_emitters (const Components::NameList & names - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName)) { @@ -422,7 +460,7 @@ CIAO_HelloWorld_Servant::get_named_emitters (const Components::NameList & names } ::Components::PublisherDescriptions * -CIAO_HelloWorld_Servant::get_all_publishers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_all_publishers (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { return new ::Components::PublisherDescriptions; @@ -430,7 +468,7 @@ CIAO_HelloWorld_Servant::get_all_publishers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAUL ::Components::PublisherDescriptions * CIAO_HelloWorld_Servant::get_named_publishers (const Components::NameList & names - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName)) { @@ -445,22 +483,22 @@ CIAO_HelloWorld_Servant::get_named_publishers (const Components::NameList & name // Operations for CCMObject interface ::CORBA::IRObject_ptr -CIAO_HelloWorld_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); } ::Components::CCMHome_ptr -CIAO_HelloWorld_Servant::get_ccm_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_ccm_home (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // @@@ How? Should we cache the home reference here? - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + return this->context_->get_CCM_home (ACE_ENV_SINGLE_ARG_PARAMETER); } ::Components::PrimaryKeyBase * -CIAO_HelloWorld_Servant::get_primary_key (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_primary_key (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::NoKeyAvailable)) { @@ -469,7 +507,7 @@ CIAO_HelloWorld_Servant::get_primary_key (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) } void -CIAO_HelloWorld_Servant::configuration_complete (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::configuration_complete (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidConfiguration)) { @@ -478,7 +516,7 @@ CIAO_HelloWorld_Servant::configuration_complete (ACE_ENV_SINGLE_ARG_DECL_WITH_DE } void -CIAO_HelloWorld_Servant::remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::remove (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { @@ -488,7 +526,7 @@ CIAO_HelloWorld_Servant::remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) } ::Components::ComponentPortDescription * -CIAO_HelloWorld_Servant::get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloWorld_Servant::get_all_ports (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // No port, no nothing. @@ -496,6 +534,41 @@ CIAO_HelloWorld_Servant::get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) } +CORBA::Object_ptr +CIAO_HelloWorld_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL) +{ + ::Components::SessionContext_var sc = + ::Components::SessionContext::_narrow (this->context_); + + if (! CORBA::is_nil(sc.in ())) + return sc->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ::Components::EntityContext_var ec = + ::Components::EntityContext::_narrow (this->context_); + + if (! CORBA::is_nil(ec.in ())) + return ec->get_CCM_object (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); +} + +HelloWorld_ptr +CIAO_HelloWorld_Servant::_ciao_activate_component (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); + + HelloWorld_var ho = HelloWorld::_narrow (obj + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return ho._retn (); + +} + //////////////////////////////////////////////////////////////// //////////////////// CIAO_HelloHome_Servant //////////////////// @@ -515,7 +588,7 @@ CIAO_HelloHome_Servant::~CIAO_HelloHome_Servant (void) // Operations for KeylessHome interface ::Components::CCMObject_ptr -CIAO_HelloHome_Servant::create_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloHome_Servant::create_component (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::CreateFailure)) { @@ -524,7 +597,7 @@ CIAO_HelloHome_Servant::create_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) // Operations for Implicit Home interface ::HelloWorld_ptr -CIAO_HelloHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::CreateFailure)) { @@ -539,23 +612,23 @@ CIAO_HelloHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - PortableServer::Servant svt = new CIAO_HelloWorld_Servant (hw.in ()); - - CORBA::Object_var obj - = this->container_->install_servant (svt - ACE_ENV_ARG_PARAMETER); + CORBA::Object_var hobj= this->container_->get_objref (this + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - HelloWorld_var ho = HelloWorld::_narrow (obj - ACE_ENV_ARG_PARAMETER); + ::Components::CCMHome_var home = ::Components::CCMHome::_narrow (hobj.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); - return ho._retn (); + CIAO_HelloWorld_Servant *svt = new CIAO_HelloWorld_Servant (hw.in (), + home.in (), + this->container_); + return svt->_ciao_activate_component (ACE_ENV_ARG_PARAMETER); } // Operations for CCMHome interface ::CORBA::IRObject_ptr -CIAO_HelloHome_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloHome_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // @@ Not implemented yet. @@ -563,7 +636,7 @@ CIAO_HelloHome_Servant::get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS } ::CORBA::IRObject_ptr -CIAO_HelloHome_Servant::get_home_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) +CIAO_HelloHome_Servant::get_home_def (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // @@ Not implemented yet. @@ -572,7 +645,7 @@ CIAO_HelloHome_Servant::get_home_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) void CIAO_HelloHome_Servant::remove_component (Components::CCMObject_ptr comp - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { @@ -588,7 +661,7 @@ CIAO_HelloHome_Servant::remove_component (Components::CCMObject_ptr comp extern "C" HELLO_SERVANT_Export ::PortableServer::Servant createHelloHome_Servant (::Components::HomeExecutorBase_ptr p, CIAO::Session_Container *c - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL) { if (p == 0) return 0; diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h index 498ad7b61f7..7eb82080ce3 100644 --- a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h +++ b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h @@ -25,13 +25,17 @@ #include "helloEC.h" #include "ciao/Container_Base.h" +class CIAO_HelloWorld_Servant; + class HELLO_SERVANT_Export CIAO_HelloWorld_Context : public virtual CCM_HelloWorld_Context, public virtual ::Components::SessionContext { public: // Ctor. - CIAO_HelloWorld_Context (); + CIAO_HelloWorld_Context (::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c, + CIAO_HelloWorld_Servant *sv); // Dtor. virtual ~CIAO_HelloWorld_Context (); @@ -69,6 +73,15 @@ public: virtual CORBA::Object_ptr get_CCM_object (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Components::IllegalState)); + +protected: + ::Components::CCMHome_var home_; + + ::CIAO::Session_Container *container_; + + CIAO_HelloWorld_Servant *servant_; + + HelloWorld_var component_; }; class HELLO_SERVANT_Export CIAO_HelloWorld_Servant @@ -80,7 +93,9 @@ class HELLO_SERVANT_Export CIAO_HelloWorld_Servant { public: // Ctor. - CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr executor_); + CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr executor, + ::Components::CCMHome_ptr h, + ::CIAO::Session_Container *c); // Dtor. ~CIAO_HelloWorld_Servant (void); @@ -125,9 +140,9 @@ public: Components::InvalidConnection, Components::AlreadyConnected, Components::ExceededConnectionLimit)); - virtual void disconnect (const char * name, - Components::Cookie * ck - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + virtual CORBA::Object_ptr disconnect (const char * name, + Components::Cookie * ck + ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException, Components::InvalidName, Components::InvalidConnection, @@ -211,12 +226,26 @@ public: virtual ::Components::ComponentPortDescription * get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); + // From Servant_Base + + // get_component implementation. + virtual CORBA::Object_ptr _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + + // CIAO specific operations. + + // Activate the object in the container_ + HelloWorld_ptr _ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + protected: // My Executor. CCM_HelloWorld_var executor_; // My Run-time Context. CCM_HelloWorld_Context_var context_; + + // Managing container. + ::CIAO::Session_Container *container_; }; |