diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2009-12-09 12:38:18 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2009-12-09 12:38:18 +0000 |
commit | 7e0aa678ccb2ac1912954a8c3e86795ce7b7a947 (patch) | |
tree | 39e502147e78b579665f24f09977fd5f1ef1e523 | |
parent | 28cf9a7679ba94c0ccb9d4e9219c530ddcebe9e0 (diff) | |
download | ATCD-7e0aa678ccb2ac1912954a8c3e86795ce7b7a947.tar.gz |
Wed Dec 9 12:37:33 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl>
* tests/IDL_Test/Local_Facet:
Removed
* tests/CIAO_ComponentServer/Local_Facet:
New test for testing local facets
* ciao/ComponentServer/CIAO_ComponentServer.idl
* ciao/ComponentServer/CIAO_Container_Impl.cpp
* ciao/ComponentServer/CIAO_Container_Impl.h
* ciao/Containers/Container_Base.idl
* ciao/Containers/Session/Session_Container.cpp
* ciao/Containers/Session/Session_Container.h
Added support to connect local facets by William Otte
* ciao/Servants/Servant_Impl_Base.cpp:
* ciao/Servants/Servant_Impl_Base.h:
Made several methods pure virtual instead of not implemented
-rw-r--r-- | CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl | 13 | ||||
-rw-r--r-- | CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp | 19 | ||||
-rw-r--r-- | CIAO/ciao/ComponentServer/CIAO_Container_Impl.h | 10 | ||||
-rw-r--r-- | CIAO/ciao/Containers/Container_Base.idl | 14 | ||||
-rw-r--r-- | CIAO/ciao/Containers/Session/Session_Container.cpp | 142 | ||||
-rw-r--r-- | CIAO/ciao/Containers/Session/Session_Container.h | 14 | ||||
-rw-r--r-- | CIAO/ciao/Servants/Servant_Impl_Base.cpp | 68 | ||||
-rw-r--r-- | CIAO/ciao/Servants/Servant_Impl_Base.h | 19 |
8 files changed, 220 insertions, 79 deletions
diff --git a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl b/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl index 14290ae6683..4cb7c9beadc 100644 --- a/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl +++ b/CIAO/ciao/ComponentServer/CIAO_ComponentServer.idl @@ -59,6 +59,19 @@ module CIAO /// Returns a sequence of all homeless components. ::Components::CCMObjectSeq get_components (); + + void connect_local_facet (in ::Components::CCMObject provider_ref, + in string provider_port, + in ::Components::CCMObject user_ref, + in string user_port) + raises (::Components::InvalidConnection, + ::Components::AlreadyConnected); + + void disconnect_local_facet (in ::Components::CCMObject provider_ref, + in string provider_port, + in ::Components::CCMObject user_ref, + in string user_port) + raises (::Components::InvalidConnection); }; }; }; diff --git a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp b/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp index 7dc58e41c55..49f7738a0d6 100644 --- a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp +++ b/CIAO/ciao/ComponentServer/CIAO_Container_Impl.cpp @@ -467,5 +467,24 @@ namespace CIAO CIAO_TRACE ("CIAO_Container_i::_default_POA"); return PortableServer::POA::_duplicate (this->poa_.in ()); } + + void CIAO_Container_i::connect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port) + { + CIAO_TRACE ("CIAO_Container_i::connect_local_facet"); + this->container_->connect_local_facet (provider, provider_port, user, user_port); + + } + + void CIAO_Container_i::disconnect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port) + { + CIAO_TRACE ("CIAO_Container_i::connect_local_facet"); + this->container_->disconnect_local_facet (provider, provider_port, user, user_port); + } } } diff --git a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h b/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h index a2b9fb13f18..9d1b1ec3c51 100644 --- a/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h +++ b/CIAO/ciao/ComponentServer/CIAO_Container_Impl.h @@ -71,6 +71,16 @@ namespace CIAO virtual void passivate_component (::Components::CCMObject_ptr comp); virtual PortableServer::POA_ptr _default_POA (void); + + virtual void connect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port); + + virtual void disconnect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port); private: /// Keep a pointer to the managing ORB serving this servant. diff --git a/CIAO/ciao/Containers/Container_Base.idl b/CIAO/ciao/Containers/Container_Base.idl index 01a79b71a15..8c29b6817a3 100644 --- a/CIAO/ciao/Containers/Container_Base.idl +++ b/CIAO/ciao/Containers/Container_Base.idl @@ -7,6 +7,7 @@ #include "tao/PortableServer/PortableServer_include.pidl" #include "ccm/CCM_Home.idl" +#include "ccm/CCM_Base.idl" #include "ciao/Containers/CIAO_Servant_Activator.idl" module CIAO @@ -57,7 +58,20 @@ module CIAO void passivate_component (in Components::CCMObject name); void uninstall_component (in Components::CCMObject compptr); + + void connect_local_facet (in ::Components::CCMObject provider_ref, + in string provider_port, + in ::Components::CCMObject user_ref, + in string user_port) + raises (::Components::InvalidConnection, + ::Components::AlreadyConnected); + void disconnect_local_facet (in ::Components::CCMObject provider_ref, + in string provider_port, + in ::Components::CCMObject user_ref, + in string user_port) + raises (::Components::InvalidConnection); + // *** Methods used by component specific container portions Object install_servant (in PortableServer::Servant svnt, in Container_Types::OA_Type type, diff --git a/CIAO/ciao/Containers/Session/Session_Container.cpp b/CIAO/ciao/Containers/Session/Session_Container.cpp index ed3151558a4..cda9d1adde7 100644 --- a/CIAO/ciao/Containers/Session/Session_Container.cpp +++ b/CIAO/ciao/Containers/Session/Session_Container.cpp @@ -340,7 +340,7 @@ namespace CIAO { CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::install_home - Error: Entry point " - "invalid in dll [%C]", + "invalid in dll [%C]\n", primary_artifact)); throw Components::Deployment::ImplEntryPointNotFound (); } @@ -349,7 +349,7 @@ namespace CIAO { CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::install_home - Error: Entry point " - "invalid in dll [%C]", + "invalid in dll [%C]\n", servant_artifact)); throw Components::Deployment::ImplEntryPointNotFound (); } @@ -541,7 +541,7 @@ namespace CIAO { CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::install_home - Error: Entry point " - "invalid in dll [%C]", + "invalid in dll [%C]\n", primary_artifact)); throw Components::Deployment::ImplEntryPointNotFound (); } @@ -550,7 +550,7 @@ namespace CIAO { CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::install_home - Error: Entry point " - "invalid in dll [%C]", + "invalid in dll [%C]\n", servant_artifact)); throw Components::Deployment::ImplEntryPointNotFound (); } @@ -606,6 +606,140 @@ namespace CIAO } void + Session_Container::connect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port) + { + CIAO_TRACE ("Session_Container::connect_local_facet"); + + if (!provider_port || !user_port) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::connect_local_facet - " + "Nil port name provided to connect local facet, throwing exception\n")); + throw ::Components::InvalidConnection (); + } + + try + { + PortableServer::Servant srv_tmp = + this->component_poa_->reference_to_servant (provider); + + CIAO_DEBUG ((LM_TRACE, CLINFO "Session_Container::connect_local_facet - " + "Successfully fetched provider servant from POA\n")); + + CIAO::Servant_Impl_Base *prov_serv = + dynamic_cast<CIAO::Servant_Impl_Base *> (srv_tmp); + + if (!prov_serv) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::connect_local_facet - " + "Unable to cast to provider servant implementation\n")); + throw ::Components::InvalidConnection (); + } + + srv_tmp = this->component_poa_->reference_to_servant (user); + CIAO_DEBUG ((LM_TRACE, CLINFO "Session_Container::connect_local_facet - " + "Successfully fetched user servant from POA\n")); + + CIAO::Servant_Impl_Base *user_serv = + dynamic_cast<CIAO::Servant_Impl_Base *> (srv_tmp); + + if (!user_serv) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::connect_local_facet - " + "Unable to cast to provider servant implementation\n")); + throw ::Components::InvalidConnection (); + } + + ::CORBA::Object_ptr exec = prov_serv->get_facet_executor (provider_port); + + // Note: Spec says that facet executor provided by component MAY BE NIL + if (!::CORBA::is_nil (exec)) + { + user_serv->connect (user_port, exec); + } + else + { + throw ::Components::InvalidConnection (); + } + } + catch (const ::Components::InvalidConnection &) + { + throw; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::connect_local_facet - " + "Attempting to connect components not managed by this container.\n")); + throw ::Components::InvalidConnection (); + } + } + + void + Session_Container::disconnect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port) + { + CIAO_TRACE ("Session_Container::disconnect_local_facet"); + + try + { + PortableServer::Servant srv_tmp = this->component_poa_->reference_to_servant (provider); + CIAO_DEBUG ((LM_TRACE, CLINFO "Session_Container::disconnect_local_facet - " + "Successfully fetched provider servant from POA\n")); + + CIAO::Servant_Impl_Base *prov_serv = + dynamic_cast<CIAO::Servant_Impl_Base *> (srv_tmp); + + if (!prov_serv) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::disconnect_local_facet - " + "Unable to cast to provider servant implementation\n")); + throw ::Components::InvalidConnection (); + } + + srv_tmp = this->component_poa_->reference_to_servant (user); + CIAO_DEBUG ((LM_TRACE, CLINFO "Session_Container::disconnect_local_facet - " + "Successfully fetched user servant from POA\n")); + + CIAO::Servant_Impl_Base *user_serv = + dynamic_cast<CIAO::Servant_Impl_Base *> (srv_tmp); + + if (!user_serv) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::disconnect_local_facet - " + "Unable to cast to provider servant implementation\n")); + throw ::Components::InvalidConnection (); + } + + ::CORBA::Object_ptr exec = prov_serv->get_facet_executor (provider_port); + + // Note: Spec says that facet executor provided by component MAY BE NIL + if (!::CORBA::is_nil (exec)) + { + user_serv->disconnect (user_port, 0); + } + else + { + throw ::Components::InvalidConnection (); + } + } + catch (const ::Components::InvalidConnection &) + { + throw; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "Session_Container::disconnect_local_facet - " + "Attempting to connect components not managed by this container.\n")); + throw ::Components::InvalidConnection (); + } + + } + + void Session_Container::activate_component (Components::CCMObject_ptr compref) { CIAO_TRACE("Session_Container::activate_component"); diff --git a/CIAO/ciao/Containers/Session/Session_Container.h b/CIAO/ciao/Containers/Session/Session_Container.h index 96d3df67df3..0f1f51f0fd2 100644 --- a/CIAO/ciao/Containers/Session/Session_Container.h +++ b/CIAO/ciao/Containers/Session/Session_Container.h @@ -128,8 +128,18 @@ namespace CIAO const char *servant_artifact, const char *servant_entrypoint, const char *name); - - /// Activate component + + virtual void connect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port); + + virtual void disconnect_local_facet (::Components::CCMObject_ptr provider, + const char * provider_port, + ::Components::CCMObject_ptr user, + const char * user_port); + + /// Activate component virtual void activate_component (Components::CCMObject_ptr compref); virtual void passivate_component (Components::CCMObject_ptr compref); diff --git a/CIAO/ciao/Servants/Servant_Impl_Base.cpp b/CIAO/ciao/Servants/Servant_Impl_Base.cpp index fe54673b3fc..785bc481070 100644 --- a/CIAO/ciao/Servants/Servant_Impl_Base.cpp +++ b/CIAO/ciao/Servants/Servant_Impl_Base.cpp @@ -200,7 +200,7 @@ namespace CIAO ::Components::FacetDescription *tmp = this->lookup_facet_description (names[i]); - if (0 == tmp) + if (!tmp) { throw Components::InvalidName (); } @@ -300,7 +300,7 @@ namespace CIAO ::Components::ConsumerDescription *tmp = this->lookup_consumer_description (names[i]); - if (0 == tmp) + if (!tmp) { throw Components::InvalidName (); } @@ -431,7 +431,7 @@ namespace CIAO Servant_Impl_Base::lookup_facet_description (const char *port_name) { CIAO_TRACE("Servant_Impl_Base::lookup_facet_description"); - if (0 == port_name) + if (!port_name) { /// Calling function will throw InvalidName after getting this. return 0; @@ -647,67 +647,5 @@ namespace CIAO CIAO_TRACE("Servant_Impl_Base::_default_POA (void)"); return PortableServer::POA::_duplicate (container_->the_POA ()); } - - ::Components::Cookie * - Servant_Impl_Base::subscribe (const char *, - ::Components::EventConsumerBase_ptr) - { - CIAO_TRACE ("Servant_Impl_Base::subscribe"); - throw CORBA::NO_IMPLEMENT (); - } - - - ::Components::EventConsumerBase_ptr - Servant_Impl_Base::unsubscribe (const char *, - ::Components::Cookie *) - { - CIAO_TRACE ("Servant_Impl_Base::unsubscribe"); - throw CORBA::NO_IMPLEMENT (); - } - - void - Servant_Impl_Base::connect_consumer (const char *, - ::Components::EventConsumerBase_ptr) - { - CIAO_TRACE ("Servant_Impl_Base::connect_consumer"); - throw CORBA::NO_IMPLEMENT (); - } - - ::Components::EventConsumerBase_ptr - Servant_Impl_Base::disconnect_consumer (const char *) - { - CIAO_TRACE ("Servant_Impl_Base::disconnect_consumer"); - throw CORBA::NO_IMPLEMENT (); - } - - ::Components::EmitterDescriptions * - Servant_Impl_Base::get_all_emitters (void) - { - CIAO_TRACE ("Servant_Impl_Base::get_all_emitters"); - throw CORBA::NO_IMPLEMENT (); - } - - ::Components::PublisherDescriptions * - Servant_Impl_Base::get_all_publishers (void) - { - CIAO_TRACE ("Servant_Impl_Base::get_all_publishers"); - throw CORBA::NO_IMPLEMENT (); - } - - ::Components::Cookie * - Servant_Impl_Base::connect (const char *, - ::CORBA::Object_ptr) - { - CIAO_TRACE ("Servant_Impl_Base::connect"); - throw CORBA::NO_IMPLEMENT (); - } - - ::CORBA::Object_ptr - Servant_Impl_Base::disconnect (const char *, - ::Components::Cookie *) - { - CIAO_TRACE ("Servant_Impl_Base::disconnect"); - throw CORBA::NO_IMPLEMENT (); - } } diff --git a/CIAO/ciao/Servants/Servant_Impl_Base.h b/CIAO/ciao/Servants/Servant_Impl_Base.h index 584c27bdb06..6bf83fa964a 100644 --- a/CIAO/ciao/Servants/Servant_Impl_Base.h +++ b/CIAO/ciao/Servants/Servant_Impl_Base.h @@ -151,27 +151,30 @@ namespace CIAO virtual PortableServer::POA_ptr _default_POA (void); virtual ::Components::Cookie * subscribe (const char * publisher_name, - ::Components::EventConsumerBase_ptr subscriber); + ::Components::EventConsumerBase_ptr subscriber) = 0; virtual ::Components::EventConsumerBase_ptr unsubscribe (const char * publisher_name, - ::Components::Cookie * ck); + ::Components::Cookie * ck) = 0; virtual void connect_consumer (const char * emitter_name, - ::Components::EventConsumerBase_ptr consumer); + ::Components::EventConsumerBase_ptr consumer) = 0; - virtual ::Components::EventConsumerBase_ptr disconnect_consumer (const char * source_name); + virtual ::Components::EventConsumerBase_ptr disconnect_consumer ( + const char * source_name) = 0; - virtual ::Components::EmitterDescriptions * get_all_emitters (void); + virtual ::Components::EmitterDescriptions * get_all_emitters (void) = 0; - virtual ::Components::PublisherDescriptions * get_all_publishers (void); + virtual ::Components::PublisherDescriptions * get_all_publishers (void) = 0; virtual ::Components::Cookie * connect (const char * name, - ::CORBA::Object_ptr connection); + ::CORBA::Object_ptr connection) = 0; virtual ::CORBA::Object_ptr disconnect (const char * name, - ::Components::Cookie * ck); + ::Components::Cookie * ck) = 0; + virtual ::CORBA::Object_ptr get_facet_executor (const char *name) = 0; + protected: void add_facet (const char *port_name, ::CORBA::Object_ptr port_ref); |