summaryrefslogtreecommitdiff
path: root/modules/CIAO/docs/templates
diff options
context:
space:
mode:
Diffstat (limited to 'modules/CIAO/docs/templates')
-rw-r--r--modules/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp1126
-rw-r--r--modules/CIAO/docs/templates/CIAO_Glue_Session_Template.h694
-rw-r--r--modules/CIAO/docs/templates/CIAO_Glue_Session_Template.inl471
-rw-r--r--modules/CIAO/docs/templates/Executor.idl246
-rw-r--r--modules/CIAO/docs/templates/cidl_template.cidl31
5 files changed, 2568 insertions, 0 deletions
diff --git a/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp b/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp
new file mode 100644
index 00000000000..aedbcd3769b
--- /dev/null
+++ b/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.cpp
@@ -0,0 +1,1126 @@
+// $Id$
+
+// The generated filename for files using this template shoule be
+// [idl-basename]GS.cpp GS --> GlueSession
+
+// @@ Notice: [ciao module name] can expand to either CIAO_GLUE or
+// CIAO_GLUE_[module name] as defined in the header file.
+
+/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+/// @@@ Notice that all component and interface names need to be
+/// fully qualified as we are creating a new namespace for the CIAO's
+/// container glue code.
+/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+#include "[idl-basename]_svnt.h"
+#include "Cookies.h"
+
+#if !defined (__ACE_INLINE__)
+# include "[idl-basename]_svnt.inl"
+#endif /* __ACE_INLINE__ */
+
+//////////////////////////////////////////////////////////////////
+// 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_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::SessionContext_var sc =
+ ::Components::SessionContext::_narrow (this->ctx_.in ());
+
+ if (! CORBA::is_nil(sc.in ()))
+ return sc->get_CCM_object ();
+
+ ::Components::EntityContext_var ec =
+ ::Components::EntityContext::_narrow (this->ctx_.in ());
+
+ if (! CORBA::is_nil(ec.in ()))
+ return ec->get_CCM_object ();
+
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+}
+
+##end foreach [facet type]
+
+
+
+//////////////////////////////////////////////////////////////////
+// Component specific context implementation
+//////////////////////////////////////////////////////////////////
+
+##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_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ Strategized locking here.
+
+ [receptacle name]Connections_var retv =
+ new [receptacle name]Connections (this->ciao_muses_[receptacle name]_.current_size ());
+
+ CORBA::ULong i = 0;
+ ACE_Active_Map_Manager<[uses type]_var>::iterator
+ end = this->ciso_muses_[receptacle name]_.end ();
+ for (ACE_Active_Map_Manager<[uses type]_var>::iterator
+ iter = this->ciso_muses_[receptacle name]_.begin ();
+ iter != end;
+ ++iter)
+ {
+ ACE_Active_Map_Manager<[uses type]_var>::ENTRY &entry = *iter;
+ retv[i]->objref = [uses type]::_narrow (entry.int_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] *ev)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+## if [event name] belongs to an 'emits' port
+ this->ciao_emits_[event name]_consumer_->push_[event name] (ev);
+
+## else [event name] belongs to a 'publishes' port
+ ACE_Active_Map_Manager<[eventtype]Consumer_var>::iterator
+ end = this->ciao_publishes_[event name]_map_.end ();
+ for (ACE_Active_Map_Manager<[eventtype]Consumer_var>::iterator
+ iter = this->ciao_publishes_[event name]_map_.begin ();
+ iter != end;
+ ++iter)
+ {
+ ACE_Active_Map_Manager<[eventtype]Consumer_var>::ENTRY &entry = *iter;
+ [eventtype]Consumer_var c
+ = [eventtype]Consumer::_narrow (entry.int_id_.in ());
+ c->push_[eventtype] (ev);
+ }
+## endif [event name]
+}
+
+##end foreach [event name] with [eventtype]
+
+
+// Operations for publishes interfaces.
+##foreach [publish name] with [eventtype] in (list of all publishers) generate:
+::Components::Cookie *
+[ciao module name]::[component name]_Context::subscribe_[publish name] ([eventtype]Consumer_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceededConnectionLimit))
+{
+ if (CORBA::is_nil (c))
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0);
+
+ [eventtype]Consumer_var sub
+ = [eventtype]Consumer::_duplicate (c);
+
+ ACE_Active_Map_Manager_Key key;
+ this->ciao_publishes_[publish name]_map_.bind (sub.in (),
+ key);
+
+ sub._retn (); // Release ownership to map.
+
+ ::Components::Cookie_var retv = new CIAO::Map_Key_Cookie (key);
+ return retv._retn ();
+}
+
+[eventtype]Consumer_ptr
+[ciao module name]::[component name]_Context::unsubscribe_[publish name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection))
+{
+ [eventtype]Consumer_var retv;
+
+ ACE_Active_Map_Manager_Key key;
+ if (ck == 0 ||
+ CIAO::Map_Key_Cookie::extract (ck, key) == -1)
+ ACE_THROW_RETURN (::Components::InvalidConnection (), 0);
+
+ if (this->ciao_publishes_[publish name]_map_.unbind (key,
+ retv) != 0)
+ ACE_THROW_RETURN (::Components::InvalidConnection (), 0);
+
+ return retv._retn ();
+}
+
+##end foreach [publish name] with [eventtype]
+
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+
+## if [receptacle name] is a simplex receptacle ('uses')
+
+[uses type]_ptr
+[ciao module name]::[component name]_Context::get_connection_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return [uses type]::_duplicate (this->ciao_uses_[receptacle name]_.in ());
+}
+
+// Simplex [receptacle name] connection management operations
+void
+[ciao module name]::[component name]_Context::connect_[receptacle name] ([uses type]_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::AlreadyConnected,
+ ::Components::InvalidConnection))
+{
+ if (! CORBA::is_nil (this->ciao_uses_[receptacle name]_.in ()))
+ throw ::Components::AlreadyConnected ();
+
+ if (CORBA::is_nil (c))
+ throw ::Components::InvalidConnection ();
+
+ // When do we throw InvalidConnection exception?
+ this->ciao_uses_[receptacle name]_ = [uses type]::_duplicate (c);
+}
+
+[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 ()))
+ 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
+::Components::Cookie *
+[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 (::Components::InvalidConnection (), 0);
+
+ [uses type]_var conn
+ = [uses type]::_duplicate (c);
+
+ ACE_Active_Map_Manager_Key key;
+ this->ciao_muses_[receptacle name]_.bind (conn.in (),
+ key);
+
+ conn._retn (); // Releases ownership to the map.
+
+ ::Components::Cookie_var retv = new CIAO::Map_Key_Cookie (key);
+ return retv._retn ();
+}
+
+[uses type]_ptr
+[ciao module name]::[component name]_Context::disconnect_[receptacle name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection))
+{
+ [uses type]_var retv;
+
+ ACE_Active_Map_Manager_Key key;
+ if (ck == 0 ||
+ CIAO::Map_Key_Cookie::extract (ck, key) == -1)
+ ACE_THROW_RETURN (::Components::InvalidConnection (), 0);
+
+ if (this->ciao_muses_[receptacle name]_.unbind (key,
+ retv) != 0)
+ ACE_THROW_RETURN (::Components::InvalidConnection (), 0);
+
+ return retv._retn ();
+}
+
+## endif [receptacle name]
+##end foreach [receptacle name] with [uses type]
+
+// Operations for ::Components::SessionContext interface
+CORBA::Object_ptr
+[ciao module name]::[component name]_Context::get_CCM_object ()
+ 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_);
+
+ this->component_ = [component name]::_narrow (obj.in ());
+
+ 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
+//////////////////////////////////////////////////////////////////
+
+[ciao module name]::[component name]_Servant::[component name]_Servant (CCM_[component name]_ptr exe,
+ ::Components::CCMHome_ptr h,
+ ::CIAO::Session_Container *c)
+ : executor_ (CCM_[component name]::_duplicate (exe)),
+ container_ (c)
+{
+ this->context_ = new [ciao module name]::[component name]_Context (h, c, this);
+
+ try
+ {
+ Components::SessionComponent_var scom =
+ Components::SessionComponent::_narrow (exe);
+
+ if (! CORBA::is_nil (scom.in ()))
+ scom->set_session_context (this->context_);
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ // @@ Ignore any exceptions? What happens if
+ // set_session_context throws an CCMException?
+ }
+}
+
+[ciao module name]::[component name]_Servant::~[component name]_Servant (void)
+{
+ try
+ {
+ Components::SessionComponent_var scom =
+ Components::SessionComponent::_narrow (this->executor_.in ());
+
+ if (! CORBA::is_nil (scom.in ()))
+ scom->ccm_remove ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ // @@ Ignore any exceptions? What happens if
+ // set_session_context throws an CCMException?
+ }
+ this->context_->_remove_ref ();
+}
+
+// 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_THROW_SPEC ((CORBA::SystemException))
+{
+ if (CORBA::is_nil (this->provide_[facet name]_.in ()))
+ {
+ CCM_[facet type]_var fexe = this->executor_->get_[facet name] ();
+
+ if (CORBA::is_nil (fexe.in ()))
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+
+ [ciao module name]::[facet type]_Servant *svt =
+ new [ciao module name]::[facet type]_Servant (fexe.in (),
+ this->context_);
+ PortableServer::ServantBase_var safe_servant (svt);
+
+ CORBA::Object_var obj = this->container_->install_servant (svt);
+
+ [facet type]_var fo = [facet type]::_narrow (obj.in ());
+
+ this->provide_[facet name]_ = fo;
+ }
+
+ return [facet type]::_duplicate (this->provide_[facet name]_.in ());
+}
+##end foreach [facet name] with [facet type]
+
+// 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]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::push_event (EventBase *ev)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::BadEventType))
+{
+ [eventtype]_var ev_type = [eventtype]::_downcast (ev);
+ if (ev_type != 0)
+ {
+ this->push_[eventtype] (ev_type.in ());
+ return;
+ }
+
+ // @@ This include the case when we receive a parent eventtype of [eventtype]
+
+ throw ::Components::BadEventType ();
+}
+
+// get_component implementation.
+[eventtype]Consumer_ptr
+[ciao module name]::[component name]_Servant::get_consumer_[consumer name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ if (CORBA::is_nil (this->consumes_[consumer name]_.in ()))
+ {
+ [ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant *svt =
+ new [ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant (this->executor_.in (),
+ this->context_);
+ PortableServer::ServantBase_var safe_servant (svt);
+
+ CORBA::Object_var obj = this->container_->install_servant (svt);
+
+ [eventtype]Consumer_var eco = [eventtype]Consumer::_narrow (obj.in ());
+
+ 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_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] ();
+##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_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).
+ collection->length (#99);
+
+ ::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] ());
+
+ collection[i] = x._retn ();
+ ++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_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ ::Components::FacetDescriptions_var collection
+ = new ::Components::FacetDescriptions (names.length ());
+ collection->length (names.length ());
+
+ ::Components::FacetDescription_var x;
+ CORBA::ULong i = 0;
+ for (; i < names.length (); ++i)
+ {
+ x = new ::OBV_Components::FacetDescription;
+
+ // 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:
+ (else) if (ACE_OS_String::strcmp (names[i].in (), "[facet name]") == 0)
+ {
+ x->Name ((const char *)"[facet name]");
+ x->type_id ((const char *) "[facet type's repo id]"); //
+ x->facet_ref (this->provide_[facet name] ());
+ }
+##end foreach [facet name] with [facet type]
+ else
+ ACE_THROW_RETURN (::Components::InvalidName (), 0);
+
+ collection[i] = x._retn ();
+ }
+ return collection._retn ();
+}
+
+CORBA::Boolean
+[ciao module name]::[component name]_Servant::same_component (CORBA::Object_ptr object_ref)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ if (CORBA::is_nil (object_ref))
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0);
+
+ CORBA::Object_var the_other = object_ref->_get_component ();
+
+ CORBA::Object_var me = this->context_->get_CCM_object ();
+
+ return me->_is_equivalent (object_ref);
+}
+
+// Operations for Receptacles interface
+::Components::Cookie *
+[ciao module name]::[component name]_Servant::connect (const char * name,
+ CORBA::Object_ptr connection)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection,
+ Components::AlreadyConnected,
+ Components::ExceededConnectionLimit))
+{
+ // @@ We can omit this if clause if there's no receptacle in this component.
+ if (name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+ if (ACE_OS_String::strcmp (name, "[receptacle name]") == 0)
+ {
+ [uses type]_var _ciao_conn =
+ [uses type]::_narrow (connection);
+
+ if (CORBA::is_nil (_ciao_conn.in ()))
+ ACE_THROW_RETURN (::Components::InvalidConnection (), 0);
+
+## if [receptacle name] is a simplex receptacle ('uses')
+ this->connect_[receptacle name] (_caio_conn.in ());
+ return 0;
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ return this->connect_[receptacle name] (_ciao_conn.in ());
+## endif [receptacle name]
+ }
+##end foreach [receptacle name] with [uses type]
+
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+/*
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+## if [receptacle name] is a simplex receptacle ('uses')
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+## endif [receptacle name]
+##end foreach [receptacle name] with [uses type]
+*/
+
+CORBA::Object_ptr
+[ciao module name]::[component name]_Servant::disconnect (const char * name,
+ Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection,
+ Components::CookieRequired,
+ Components::NoConnection))
+{
+ // @@ We can omit this if clause if there's no receptacle in this component.
+ if (name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+ if (ACE_OS_String::strcmp (name, "[receptacle name]") == 0)
+## if [receptacle name] is a simplex receptacle ('uses')
+ return this->disconnect_[receptacle name] ();
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ return this->connect_[receptacle name] (ck);
+## endif [receptacle name]
+##end foreach [receptacle name] with [uses type]
+
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+::Components::ConnectionDescriptions *
+[ciao module name]::[component name]_Servant::get_connections (const char * name)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ // @@ We can omit this if clause if there's no receptacle in this component.
+ if (name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+ if (ACE_OS_String::strcmp (name, "[receptacle name]") == 0)
+ {
+## if [receptacle name] is a simplex receptacle ('uses')
+ ::Components::ConnectionDescriptions_var retv =
+ new ::Components::ConnectionDescriptions (1);
+ retv->length (1);
+
+ retv[0] = new OBV_Components::ConnectionDescription;
+ retv[0]->ck = 0;
+ retv[0]->objref = this->get_connection_[receptacle name] ();
+
+ return retv._retn ();
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ // @@ Return type does not match here. We can not return directly.
+ return this->get_connections_[receptacle name] ();
+## endif [receptacle name]
+ }
+##end foreach [receptacle name] with [uses type]
+
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+::Components::ReceptacleDescriptions *
+[ciao module name]::[component name]_Servant::get_all_receptacles ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::ReceptacleDescriptions_var retv =
+ new ::Components::ReceptacleDescriptions (#99); // #99 is number of receptacles
+ // this component has.
+ retv->length (#99);
+ CORBA::ULong i = 0;
+
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+ retv[i] = new OBV_Components::ReceptacleDescription;
+
+ retv[i]->Name ((const char *) "[receptacle name]");
+ retv[i]->type_id ((const char *) "[uses type repo id]");
+## if [receptacle name] is a simplex receptacle ('uses')
+ retv[i]->is_multiple (0);
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ retv[i]->is_multiple (1);
+## endif [receptacle name]
+ retv[i]->connections (*this->get_connections ("[receptacle name]"));
+ ++i;
+##end foreach [receptacle name] with [uses type]
+
+ return retv._retn ();
+}
+
+::Components::ReceptacleDescriptions *
+[ciao module name]::[component name]_Servant::get_named_receptacles (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ ::Components::ReceptacleDescriptions_var retv =
+ new ::Components::ReceptacleDescriptions (names.length ());
+ retv->length (names.length ());
+
+ CORBA::ULong i = 0;
+ for (; i < names.length (); ++i)
+ {
+ retv[i] = new ::OBV_Components::ReceptacleDescription;
+##foreach [receptacle name] with [uses type] in (list of all 'uses' interfaces) generate:
+ (else) if (ACE_OS_String::strcmp (names[i].in (), "[receptacle name]") == 0)
+ {
+ retv[i]->Name ((const char *) "[receptacle name]");
+ retv[i]->type_id ((const char *) "[uses type repo id]");
+## if [receptacle name] is a simplex receptacle ('uses')
+ retv[i]->is_multiple (0);
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ retv[i]->is_multiple (1);
+## endif [receptacle name]
+ retv[i]->connections (*this->get_connections ("[receptacle name]"));
+ }
+##end foreach [receptacle name] with [uses type]
+ else
+ ACE_THROW_RETURN (::Components::InvalidName (), 0);
+ }
+ return retv._retn ();
+}
+
+// Operations for Events interface
+::Components::EventConsumerBase_ptr
+[ciao module name]::[component name]_Servant::get_consumer (const char * sink_name)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ // @@ We can omit this if clause if there's no event sinks in this component.
+ if (sink_name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [consumer name] with [eventtype] in (list of all consumers) generate:
+ if (ACE_OS_String::strcmp (sink_name, "[consumer name]") == 0)
+ return this->get_consumer_[consumer name] ();
+##end foreach [consumer name] with [eventtype]
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+::Components::Cookie *
+[ciao module name]::[component name]_Servant::subscribe (const char * publisher_name,
+ Components::EventConsumerBase_ptr subscriber)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection,
+ Components::ExceededConnectionLimit))
+{
+ // @@ We can omit this if clause if there's no publisher in this component.
+ if (publisher_name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [publish name] with [eventtype] in (list of all publishers) generate:
+ if (ACE_OS_String::strcmp (publisher_name, "[publish name]") == 0)
+ {
+ [eventtype]Consumer_var _ciao_consumer =
+ [eventtype]Consumer::_narrow (subscriber);
+
+ if (CORBA::is_nil (_ciao_consumer.in ()))
+ ACE_THROW_RETURN (Components::InvalidConnection (), 0);
+
+ return this->subscribe_[publish name] (_ciao_consumer.in ());
+ }
+##end foreach [publish name] with [eventtype]
+
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+::Components::EventConsumerBase_ptr
+[ciao module name]::[component name]_Servant::unsubscribe (const char * publisher_name,
+ Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection))
+{
+ // @@ We can omit this if clause if there's no publisher in this component.
+ if (publisher_name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [publish name] with [eventtype] in (list of all publishers) generate:
+ if (ACE_OS_String::strcmp (publisher_name, "[publish name]") == 0)
+ {
+ return this->unsubscribe_[publish name] (ck);
+ }
+##end foreach [publish name] with [eventtype]
+
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+void
+[ciao module name]::[component name]_Servant::connect_consumer (const char * emitter_name,
+ Components::EventConsumerBase_ptr consumer)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::AlreadyConnected,
+ Components::InvalidConnection))
+{
+ // @@ We can omit this if clause if there's no emitter in this component.
+ if (emitter_name == 0)
+ throw Components::InvalidName ();
+
+##foreach [emit name] with [eventtype] in (list of all emitters) generate:
+ if (ACE_OS_String::strcmp (emitter_name, "[emit name]") == 0)
+ {
+ [eventtype]Consumer_var _ciao_consumer =
+ [eventtype]Consumer::_narrow (consumer);
+
+ if (CORBA::is_nil (_ciao_consumer.in ()))
+ throw Components::InvalidConnection;
+
+ this->connect_[emit name] (_ciao_consumer.in ());
+ return;
+ }
+##end foreach [emit name] with [eventtype]
+
+ throw Components::InvalidName ();
+}
+
+::Components::EventConsumerBase_ptr
+[ciao module name]::[component name]_Servant::disconnect_consumer (const char * source_name)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::NoConnection))
+{
+ // @@ We can omit this if clause if there's no emitter in this component.
+ if (source_name == 0)
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+
+##foreach [emit name] with [eventtype] in (list of all emitters) generate:
+ if (ACE_OS_String::strcmp (source_name, "[emit name]") == 0)
+ {
+ return this->disconnect_[emit name] ();
+ }
+##end foreach [emit name] with [eventtype]
+
+ ACE_THROW_RETURN (Components::InvalidName (), 0);
+}
+
+::Components::ConsumerDescriptions *
+[ciao module name]::[component name]_Servant::get_all_consumers ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::ConsumerDescriptions_var retv =
+ new ::Components::ConsumerDescriptions (#99); // #99 is the number of consumers
+ // this component has.
+ retv->length (#99);
+
+ CORBA::ULong i = 0;
+##foreach [consumer name] with [eventtype] in (list of all consumers) generate:
+ retv[i] = new OBV_Components::ConsumerDescription;
+ retv[i]->Name ("[consumer name]");
+ retv[i]->type_id ("[eventtype]Consumer repo id");
+ [eventtype]Consumer_var c
+ = this->get_consumer_[consumer name] ();
+
+ retv[i]->consumer (c.in ());
+
+ i++;
+##end foreach [consumer name] with [eventtype]
+
+ return retv._retn ();
+}
+
+::Components::ConsumerDescriptions *
+[ciao module name]::[component name]_Servant::get_named_consumers (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ ::Components::ConsumerDescriptions_var retv =
+ new ::Components::ConsumerDescriptions (names.length ());
+ retv->length (names.length ());
+
+ CORBA::ULong i = 0;
+ for (; i < names.length (); ++i)
+ {
+ retv[i] = new OBV_Components::ConsumerDescription;
+
+##foreach [consumer name] with [eventtype] in (list of all consumers) generate:
+ (else) if (ACE_OS_String::strcmp (names[i].in (), "[consumer name]") == 0)
+ {
+ retv[i]->Name ("[consumer name]");
+ retv[i]->type_id ("[eventtype]Consumer repo id");
+ [eventtype]Consumer_var c =
+ this->get_consumer_[consumer name] ();
+
+ retv[i]->consumer (c.in ());
+ }
+##end foreach [consumer name] with [eventtype]
+ else
+ ACE_THROW_RETURN (::Components::InvalidName (), 0);
+ }
+ return retv._retn ();
+}
+
+::Components::EmitterDescriptions *
+[ciao module name]::[component name]_Servant::get_all_emitters ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::EmitterDescriptions_var retv =
+ new ::Components::EmitterDescriptions (#99); // #99 is the number of emitters
+ // this component has.
+ retv->length (#99);
+
+ CORBA::ULong i = 0;
+##foreach [emit name] with [eventtype] in (list of all emitters) generate:
+ retv[i] = new OBV_Components::EmitterDescription;
+ retv[i]->Name ("[emit name]");
+ retv[i]->type_id ("[eventtype]Consumer repo id");
+ retv[i]->consumer ([eventtype]Consumer::_duplicate (this->context_->ciao_emits_[emit name]_consumer_));
+
+ i++;
+##end foreach [emitter name] with [eventtype]
+
+ return retv._retn ();
+}
+
+::Components::EmitterDescriptions *
+[ciao module name]::[component name]_Servant::get_named_emitters (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ ::Components::EmitterDescriptions_var retv =
+ new ::Components::EmitterDescriptions (names.length ());
+ retv->length (names.length ());
+
+ CORBA::ULong i = 0;
+ for (; i < names.length (); ++i)
+ {
+ retv[i] = new OBV_Components::EmitterDescription;
+
+##foreach [emit name] with [eventtype] in (list of all emitters) generate:
+ (else) if (ACE_OS_String::strcmp (names[i].in (), "[emit name]") == 0)
+ {
+ retv[i]->Name ("[emit name]");
+ retv[i]->type_id ("[eventtype]Consumer repo id");
+ retv[i]->consumer ([eventtype]Consumer::_duplicate (this->context_->ciao_emits_[emit name]_consumer_.in ()));
+ }
+##end foreach [consumer name] with [eventtype]
+ else
+ ACE_THROW_RETURN (::Components::InvalidName (), 0);
+ }
+ return retv._retn ();
+}
+
+::Components::PublisherDescriptions *
+[ciao module name]::[component name]_Servant::get_all_publishers ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ to-do
+
+ // Need to add interfaces in the Context class to gather the information.
+ // Or we can just relay it to the Context object.
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+::Components::PublisherDescriptions *
+[ciao module name]::[component name]_Servant::get_named_publishers (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName))
+{
+ // @@ to-do
+
+ // Need to add interfaces in the Context class to gather the information.
+ // Or we can just relay it to the Context object.
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+// Operations for CCMObject interface
+::CORBA::IRObject_ptr
+[ciao module name]::[component name]_Servant::get_component_def ()
+ 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_THROW_SPEC ((CORBA::SystemException))
+{
+ return this->context_->get_CCM_home ();
+}
+
+::Components::PrimaryKeyBase *
+[ciao module name]::[component name]_Servant::get_primary_key ()
+ 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_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidConfiguration))
+{
+ // @@ to-do
+ // No-op. Don't know how to pass this info to monolithic executor.
+}
+
+void
+[ciao module name]::[component name]_Servant::remove ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::RemoveFailure))
+{
+ // @@ to-do
+ // Need to figure out what to do here. E.g., tear down the all the connections
+ // this component has?
+}
+
+::Components::ComponentPortDescription *
+[ciao module name]::[component name]_Servant::get_all_ports ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::ComponentPortDescription_var retv =
+ new OBV_Components::ComponentPortDescription;
+
+ ::Components::FacetDescriptions_var facets_desc
+ = this->get_all_facets ();
+
+ ::Components::ReceptacleDescriptions_var receptacle_desc
+ = get_all_receptacles ();
+
+ ::Components::ConsumerDescriptions_var consumer_desc
+ = this->get_all_consumers ();
+
+ ::Components::EmitterDescriptions_var emitter_desc
+ = this->get_all_emitters ();
+
+ ::Components::PublisherDescriptions_var publisher_desc
+ = this->get_all_publishers ();
+
+ retv->facets (facets_desc.in());
+ retv->receptacles (receptacle_desc.in());
+ retv->consumers (consumer_desc.in());
+ retv->emitters (emitter_desc.in());
+ retv->publishers (publisher_desc.in());
+
+ return retv._retn();
+}
+
+// get_component implementation.
+CORBA::Object_ptr
+[ciao module name]::[component name]_Servant::_get_component ()
+ 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 ();
+
+ // @@ 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_THROW_RETURN (CORBA::INTERNAL (), 0);
+}
+
+void
+[ciao module name]::[component name]_Servant::_ciao_activate ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::SessionComponent_var temp =
+ ::Components::SessionComponent::_narrow (this->executor_.in ());
+
+ if (! CORBA::is_nil (temp.in ()))
+ temp->ccm_activate ();
+}
+
+void
+[ciao module name]::[component name]_Servant::_ciao_passivate ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ::Components::SessionComponent_var temp =
+ ::Components::SessionComponent::_narrow (this->executor_.in ());
+
+ if (! CORBA::is_nil (temp.in ()))
+ temp->ccm_passivate ();
+}
+
+//////////////////////////////////////////////////////////////////
+// Component Home Glue code implementation
+//////////////////////////////////////////////////////////////////
+
+[component name]_ptr
+[ciao module name]::[home name]_Servant::_ciao_activate_component (CCM_[component name]_ptr exe)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ CORBA::Object_var hobj
+ = this->container_->get_objref (this);
+
+ ::Components::CCMHome_var home
+ = ::Components::CCMHome::_narrow (hobj.in ());
+
+ [ciao module name]::[component name]_Servant *svt =
+ new [ciao module name]::[component name]_Servant (exe,
+ home.in (),
+ this->container_);
+ PortableServer::ServantBase_var safe (svt);
+ PortableServer::ObjectId_var oid;
+
+ CORBA::Object_var objref
+ = this->container_->install_component (svt,
+ oid.out ());
+
+ svt->_ciao_activate ();
+
+ [component name]_var ho
+ = [component name]::_narrow (objref.in ());
+
+ if (this->component_map_.bind (oid.in (), svt) == 0)
+ {
+ // @@ what should happen if bind fail?
+ safe._retn ();
+ }
+ return ho._retn ();
+}
+
+void
+[ciao module name]::[home name]_Servant::_ciao_passivate_component ([component name]_ptr comp)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableServer::ObjectId_var oid;
+
+ this->container_->uninstall_component (comp,
+ oid.out ());
+
+ [ciao module name]::[component name]_Servant *servant = 0;
+ if (this->component_map_.unbind (oid.in (), servant) == 0)
+ {
+ PortableServer::ServantBase_var safe (servant);
+ servant->_ciao_passivate ();
+ }
+ // What happen if unbind failed?
+
+}
+
+// Operations for Implicit Home interface
+[component name]_ptr
+[ciao module name]::[home name]_Servant::create ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::CreateFailure))
+{
+ if (this->executor_.in () == 0)
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+
+ Components::EnterpriseComponent_var _ciao_ec =
+ this->executor_->create ();
+
+ CCM_[component name]_var _ciao_comp
+ = CCM_[component name]::_narrow (_ciao_ec.in ());
+
+ return this->_ciao_activate_component (_ciao_comp.in ());
+}
+
+// Operations for CCMHome interface
+void
+[ciao module name]::[home name]_Servant::remove_component (Components::CCMObject_ptr comp)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::RemoveFailure))
+{
+ [component name]_var _ciao_comp
+ = [component name]::_narrow (comp);
+
+ if (CORBA::is_nil (_ciao_comp.in ()))
+ throw CORBA::INTERNAL (); // What is the right exception to throw here?
+
+ // @@ It seems to me that we need to make sure this is a component
+ // generated by this home before calling remove on this component.
+ _ciao_comp->remove ();
+
+
+ // Removing the object reference? get the servant from the POA with
+ // the objref, and call remove() on the component, deactivate the
+ // component, and then remove-ref the servant?
+ this->_ciao_passivate_component (_ciao_comp.in ());
+}
+
+extern "C" [SERVANT]_Export ::PortableServer::Servant
+create[home name]_Servant (::Components::HomeExecutorBase_ptr p,
+ CIAO::Session_Container *c);
+{
+ if (p == 0)
+ return 0;
+
+ CCM_[home name]_var x
+ = CCM_[home name]::_narrow (p);
+
+ if (CORBA::is_nil (x.in ()))
+ return 0;
+
+ return new [ciao module name]::[home name]_Servant (x.in (),
+ c);
+}
diff --git a/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.h b/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.h
new file mode 100644
index 00000000000..25c7813db53
--- /dev/null
+++ b/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.h
@@ -0,0 +1,694 @@
+// $Id$
+
+// ===========================================================
+//
+// @file CIAO_Glue_Session_Template.h
+//
+// This is a pseudo-meta generic servant implementations template
+// 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]_svnt.h
+//
+// @author Nanbor Wang <nanbor@cs.wustl.edu>
+//
+// ===========================================================
+
+#ifndef CIAO_GLUE_SESSION_[idl-basename]_SVNT_H
+#define CIAO_GLUE_SESSION_[idl-basename]_SVNT_H
+#include /**/ "ace/pre.h"
+
+#include "[idl-name]S.h" // Source in the skeletons for component
+ // client-view equivalent interfaces
+#include "[idl-name]EC.h" // Source in the executor mapping
+ // that component implementations use
+#include "ciao/Container_Base.h" //Source in the container interface definitions
+#include "tao/LocalObject.h"
+#include "tao/PortableServer/Key_Adapters.h"
+#include "ace/Active_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+/// @@@ Notice that all component and interface names need to be
+/// fully qualified as we are creating a new namespace for the CIAO's
+/// container glue code.
+/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+##if component is defined withing a [module name]
+namespace CIAO_GLUE_[module_name]
+##else
+namespace CIAO_GLUE
+##endif
+{
+
+ //////////////////////////////////////////////////////////////////
+ // 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)
+ class [SERVANT]_Export [facet type]_Servant :
+ : public virtual POA_[facet type] // full skeleton name here
+ {
+ public:
+ // Constructor and destructor.
+ [facet type]_Servant (CCM_[facet type]_ptr executor,
+ ::Components::CCMContext_ptr ctx);
+ ~[facet tyep]_Servant ();
+
+## foreach [operation] in (all facet operations)
+ // Generate operation decls.
+## end foreach [operation]
+
+ // get_component implementation.
+ virtual CORBA::Object_ptr
+ _get_component ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ // Facet executor.
+ CCM_[facet type]_var executor_;
+
+ // Context object.
+ ::Components::CCMContext_var ctx_;
+ };
+##end foreach [facet type]
+
+
+ //////////////////////////////////////////////////////////////////
+ // Component specific context implementation
+ class [SERVANT]_Export [component name]_Context :
+ public virtual CCM_[component name]_Context,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+ // We will allow the the servant glue code we generate to access
+ // our states.
+ friend class [component name]_Servant;
+
+ // Ctor.
+ [component name]_Context (::Components::CCMHome_ptr home,
+ ::CIAO::Session_Container *c,
+ [component name]_Servant *sv);
+
+ // Dtor.
+ virtual ~[component name]_Context ();
+
+ // 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] ()
+ 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] ();
+ 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] *ev)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+##end foreach [event name] with [eventtype]
+
+ // Operations for ::Components::CCMContext
+ virtual ::Components::Principal_ptr
+ get_caller_principal ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::CCMHome_ptr
+ get_CCM_home ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::Boolean
+ get_rollback_only ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::IllegalState));
+
+ virtual ::Components::Transaction::UserTransaction_ptr
+ get_user_transaction ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::IllegalState));
+
+ virtual CORBA::Boolean
+ is_caller_in_role (const char * role)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void
+ set_rollback_only ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::IllegalState));
+
+ // Operations for ::Components::SessionContext interface
+ virtual CORBA::Object_ptr
+ get_CCM_object ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::IllegalState));
+ protected:
+ // 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')
+ // Simplex [receptacle name] connection management operations
+ void
+ connect_[receptacle name] ([uses type]_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::AlreadyConnected,
+ ::Components::InvalidConnection));
+
+ [uses type]_ptr
+ disconnect_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::NoConnection));
+
+ // Simplex [receptacle name] connection
+ [uses type]_var ciao_uses_[receptacle name]_;
+
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ // Multiplex [receptacle name] connection management operations
+ ::Components::Cookie *
+ connect_[receptacle name] ([uses type]_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceedConnectionLimit,
+ ::Components::InvalidConnection));
+
+ [uses type]_ptr
+ disconnect_[receptacle name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection));
+
+ // Multiplex [receptacle name] connections
+
+ ACE_Active_Map_Manager<[uses type]_var> ciao_muses_[receptacle name]_;
+## 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)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::AlreadyConnected));
+
+ [eventtype]Consumer_ptr
+ disconnect_[emit name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::NoConnection));
+
+ [eventtype]Consumer_var ciao_emits_[emit name]_consumer_;
+##end foreach [emit name] with [eventtype]
+
+ // Operations for publishes interfaces.
+##foreach [publish name] with [eventtype] in (list of all publishers) generate:
+ ::Components::Cookie *
+ subscribe_[publish name] ([eventtype]Consumer_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceededConnectionLimit));
+
+ [eventtype]Consumer_ptr
+ unsubscribe_[publish name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection));
+
+ ACE_Active_Map_Manager<[eventtype]Consumer_var> ciao_publishes_[publish name]_map_;
+##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_;
+
+ };
+
+ //////////////////////////////////////////////////////////////////
+ // Component Servant Glue code implementation
+ class [SERVANT]_Export [component name]_Servant
+ : public virtual POA_[component name] // full skeleton name here
+ {
+ public:
+ // Ctor.
+ [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 and attribute accessors/mutators
+
+ // Generate the [operation] here.
+
+##end
+
+ // Operations for provides interfaces.
+##foreach [facet name] with [facet type] in (list of all provided interfaces) generate:
+ virtual [facet type]_ptr
+ provide_[facet name] ()
+ 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')
+ // Simplex [receptacle name] connection management operations
+ virtual void
+ connect_[receptacle name] ([uses type]_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::AlreadyConnected,
+ ::Components::InvalidConnection));
+
+ virtual [uses type]_ptr
+ disconnect_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::NoConnection));
+
+ virtual [uses type]_ptr
+ get_connection_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+ // Multiplex [receptacle name] connection management operations
+ virtual ::Components::Cookie *
+ connect_[receptacle name] ([uses type]_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceedConnectionLimit,
+ ::Components::InvalidConnection));
+
+ virtual [uses type]_ptr
+ disconnect_[receptacle name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection));
+
+ virtual [receptacle name]Connections *
+ get_connections_[receptacle name] ()
+ 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:
+
+ // 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:
+ // 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)
+ virtual void push_[type] ([type] *evt)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+## end [type]
+
+ // Inherit from ::Compopnents::EventConsumerBase
+ virtual void push_event (::Components::EventBase *ev)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::BadEventType));
+
+ // get_component implementation.
+ virtual CORBA::Object_ptr
+ _get_component ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ // Executor
+ CCM_[component name]_var executor_;
+
+ // Context object.
+ CCM_[component name]_Context_var ctx_;
+ };
+
+ virtual [eventtype]Consumer_ptr
+ get_consumer_[consumer name] ()
+ 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:
+ virtual void
+ connect_[emit name] ([eventtype]Consumer_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ ::Components::AlreadyConnected));
+
+ virtual [eventtype]Consumer_ptr
+ disconnect_[emit name] ()
+ 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:
+ virtual ::Components::Cookie *
+ subscribe_[publish name] ([eventtype]Consumer_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceededConnectionLimit));
+
+ virtual [eventtype]Consumer_ptr
+ unsubscribe_[publish name] (::Components::Cookie *ck)
+ 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)
+ ACE_THROW_SPEC ((CORBA::SystemException ,
+ Components::InvalidName)) ;
+
+ virtual ::Components::FacetDescriptions *
+ get_all_facets ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::FacetDescriptions *
+ get_named_facets (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException ,
+ Components::InvalidName));
+
+ virtual CORBA::Boolean
+ same_component (CORBA::Object_ptr object_ref)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ // Operations for Receptacles interface
+ virtual ::Components::Cookie *
+ connect (const char * name,
+ CORBA::Object_ptr connection)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection,
+ Components::AlreadyConnected,
+ Components::ExceededConnectionLimit));
+
+ virtual CORBA::Object_ptr
+ disconnect (const char * name,
+ Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection,
+ Components::CookieRequired,
+ Components::NoConnection));
+
+ virtual ::Components::ConnectionDescriptions *
+ get_connections (const char * name)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName));
+
+ virtual ::Components::ReceptacleDescriptions *
+ get_all_receptacles ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::ReceptacleDescriptions *
+ get_named_receptacles (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName));
+
+ // Operations for Events interface
+ virtual ::Components::EventConsumerBase_ptr
+ get_consumer (const char * sink_name)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName));
+
+ virtual ::Components::Cookie *
+ subscribe (const char * publisher_name,
+ Components::EventConsumerBase_ptr subscriber)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection,
+ Components::ExceededConnectionLimit));
+
+ virtual ::Components::EventConsumerBase_ptr
+ unsubscribe (const char * publisher_name,
+ Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::InvalidConnection));
+
+ virtual void
+ connect_consumer (const char * emitter_name,
+ Components::EventConsumerBase_ptr consumer)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::AlreadyConnected,
+ Components::InvalidConnection));
+
+ virtual ::Components::EventConsumerBase_ptr
+ disconnect_consumer (const char * source_name)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName,
+ Components::NoConnection));
+
+ virtual ::Components::ConsumerDescriptions *
+ get_all_consumers ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::ConsumerDescriptions *
+ get_named_consumers (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName));
+
+ virtual ::Components::EmitterDescriptions *
+ get_all_emitters ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::EmitterDescriptions *
+ get_named_emitters (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName));
+
+ virtual ::Components::PublisherDescriptions *
+ get_all_publishers ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::PublisherDescriptions *
+ get_named_publishers (const Components::NameList & names)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidName));
+
+ // Operations for CCMObject interface
+ virtual ::CORBA::IRObject_ptr
+ get_component_def ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::CCMHome_ptr
+ get_ccm_home ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::Components::PrimaryKeyBase *
+ get_primary_key ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::NoKeyAvailable));
+
+ virtual void
+ configuration_complete ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidConfiguration));
+
+ virtual void
+ remove ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::RemoveFailure));
+
+ virtual ::Components::ComponentPortDescription *
+ get_all_ports ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ // get_component implementation.
+ virtual CORBA::Object_ptr
+ _get_component ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ // CIAO specific operations.
+
+ // Activate the object in the container_
+ void
+ _ciao_activate ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void
+ _ciao_passivate ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ // My Executor.
+ CCM_[component name]_var executor_;
+
+ // My Run-time Context.
+ [component name]_Context *context_;
+
+ // Managing container.
+ ::CIAO::Session_Container *container_;
+
+ // Cached provided interfaces.
+##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]
+
+##foreach [consumer name] with [eventtype] in (list of all consumers) generate:
+ [eventtype]Consumer_var consumes_[consumer name]_;
+##end foreach [consumer name] with [eventtype]
+
+ };
+
+
+ //////////////////////////////////////////////////////////////////
+ // Component Home Glue code implementation
+
+ // Foreach component home
+ class [SERVANT]_Export [home name]_Servant :
+ public virtual POA_[home name] // full skeleton name here
+ {
+ public:
+ // Ctor.
+ [home name]_Servant (CCM_[home name]_ptr exe,
+ CIAO::Session_Container *c);
+
+ // Dtor.
+ ~[home name]_Servant (void);
+
+ // User defined and inherited operations
+##foreach [operation] in (all explicit operations in [home basename] including its parents)
+
+ // The operation decl here.
+
+## end foreach opeartion
+
+ // Factory operations
+##foreach [factory name] in (all factory operations in [home basename] including its parents)
+ // for factory operations inherit from parent home(s), they should return
+ // the corresponding component types their homes manage
+ virtual [component name]_ptr
+ [factory name] (....)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::CreateFailure,
+ ....));
+##end foreach [factory name]
+
+ // Finder operations
+##foreach [finder name] in (all finder operations in [home basename] including its parents)
+ // for finder operations inherit from parent home(s), they should return
+ // the corresponding component types their homes manage
+ virtual [component name]_ptr
+ [finder name] (....)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::FinderFailure,
+ ....));
+##end foreach [finder name]
+
+## if [home name] is a keyless home
+
+ // Operations for KeylessHome interface
+ virtual ::Components::CCMObject_ptr
+ create_component ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::CreateFailure));
+
+## else [home basename] is keyed home with [key type]
+
+ // We do not support key'ed home at the moment but we might
+ // as well generate the mapping.
+ virtual [component name]_ptr create ([key type] *key)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::CreationFailure,
+ ::Components::DuplicateKeyValue,
+ ::Components::InvalidKey));
+
+ virtual [component name]_ptr
+ find_by_primary_key ([key type] *key)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::FinderFailure,
+ ::Components::UnknownKeyValue,
+ ::Components::InvalidKey));
+
+ virtual void remove ([key type] *key)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::RemoveFailure,
+ ::Components::UnknownKeyValue,
+ ::Components::InvalidKey));
+
+ virtual [key type] *
+ get_primary_key ([component name]_ptr comp)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+## endif (keyed or keyless home)
+
+ // Operations for Implicit Home interface
+ virtual [component name]_ptr
+ create ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::CreateFailure));
+
+ // Operations for CCMHome interface
+ virtual ::CORBA::IRObject_ptr
+ get_component_def ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::CORBA::IRObject_ptr
+ get_home_def ()
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void remove_component (Components::CCMObject_ptr comp)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::RemoveFailure));
+
+ protected:
+ // Helper method for factory operations.
+ [component name]_ptr
+ _ciao_activate_component (CCM_[component name]_ptr exe)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void
+ _ciao_passivate_component ([component name]_ptr comp)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ // My Executor.
+ CCM_[home name]_var executor_;
+
+ // My Container
+ CIAO::Session_Container *container_;
+
+ // Components this home manages.
+ ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId,
+ [component name]_Servant*,
+ TAO_ObjectId_Hash,
+ ACE_Equal_To<PortableServer::ObjectId>,
+ ACE_SYNCH_MUTEX> component_map_;
+ };
+
+}
+
+extern "C" [SERVANT]_Export ::PortableServer::Servant
+create[home name]_Servant (::Components::HomeExecutorBase_ptr p,
+ CIAO::Session_Container *c);
+
+#if defined (__ACE_INLINE__)
+# include "[idl-name]_svnt.inl"
+#endif /* __ACE_INLINE__ */
+
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_GLUE_SESSION_[idl-basename]_SVNT_H */
diff --git a/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.inl b/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.inl
new file mode 100644
index 00000000000..1cb07a064ae
--- /dev/null
+++ b/modules/CIAO/docs/templates/CIAO_Glue_Session_Template.inl
@@ -0,0 +1,471 @@
+// $Id$ -*- C++ -*-
+
+// The generated filename for files using this template shoule be
+// [idl-basename]GS.i GS --> GlueSession
+
+// @@ Notice: [ciao module name] can expand to either CIAO_GLUE or
+// CIAO_GLUE_[module name] as defined in the header file.
+
+/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+/// @@@ Notice that all component and interface names need to be
+/// fully qualified as we are creating a new namespace for the CIAO's
+/// container glue code.
+/// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+//////////////////////////////////////////////////////////////////
+// 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)
+// Constructor and destructor.
+ACE_INLINE
+[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_ (Components::CCMContext::_duplicate (c))
+{
+}
+
+ACE_INLINE
+[ciao module name]::[facet type]_Servant::~[facet tyep]_Servant ()
+{
+}
+
+
+## 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->executor_->operation ([operation args]);
+}
+## 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,
+ [ciao module name]::[component name]_Servant *sv)
+ : home_ (::Components::CCMHome::_duplicate (home)),
+ container_ (c),
+ servant_ (sv)
+{
+
+}
+
+ACE_INLINE
+[ciao module name]::[component name]_Context::~[component name]_Context ()
+{
+}
+
+// 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_THROW_SPEC ((CORBA::SystemException,
+ ::Components::AlreadyConnected))
+{
+ if (CORBA::is_nil (c))
+ throw CORBA::BAD_PARAM ();
+
+ if (! CORBA::is_nil (this->ciao_emits_[emit name]_consumer_.in ()))
+ 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_THROW_SPEC ((CORBA::SystemException,
+ ::Components::NoConnection))
+{
+ if (CORBA::is_nil (this->ciao_emits_[emit name]_consumer_.in ()))
+ throw ::Components::NoConnection ();
+
+ return this->ciao_emits_[emit name]_consumer_._retn ();
+}
+
+##end foreach [emit name] with [eventtype]
+
+// Operations for ::Components::CCMContext
+ACE_INLINE ::Components::Principal_ptr
+[ciao module name]::[component name]_Context::get_caller_principal ()
+ 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_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_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_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_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_THROW_SPEC ((CORBA::SystemException,
+ Components::IllegalState))
+{
+ // @@ We don't support Transaction in CIAO yet.
+ throw CORBA::NO_IMPLEMENT ();
+}
+
+//////////////////////////////////////////////////////////////////
+// Component Servant Glue code implementation
+//////////////////////////////////////////////////////////////////
+
+##foreach [operation] in all supported interfaces of own component and all inherited components and attribute accessors/mutators
+
+// This is only a guideline... we always relay the operation to underlying
+// 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_THROW_SPEC ((CORBA::SystemException,
+ ::Components::AlreadyConnected,
+ ::Components::InvalidConnection))
+{
+ this->context_->connect_[receptacle name] (c);
+}
+
+ACE_INLINE [uses type]_ptr
+[ciao module name]::[component name]_Servant::disconnect_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::NoConnection))
+{
+ return this->context_->disconnect_[receptacle name] ();
+}
+
+ACE_INLINE [uses type]_ptr
+[ciao module name]::[component name]_Servant::get_connection_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return this->context_->get_connection_[receptacle name] ();
+}
+## else ([receptacle name] is a multiplex ('uses multiple') receptacle)
+
+// Multiplex [receptacle name] connection management operations
+ACE_INLINE ::Components::Cookie *
+[ciao module name]::[component name]_Servant::connect_[receptacle name] ([uses type]_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceedConnectionLimit,
+ ::Components::InvalidConnection))
+{
+ return this->context_->connect_[receptacle name] (c);
+}
+
+ACE_INLINE [uses type]_ptr
+[ciao module name]::[component name]_Servant::disconnect_[receptacle name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection))
+{
+ return this->context_->disconnect_[receptacle name] (ck);
+}
+
+ACE_INLINE [receptacle name]Connections *
+[ciao module name]::[component name]_Servant::get_connections_[receptacle name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return this->context_->get_connections_[receptacle name] ();
+}
+
+## endif [receptacle name]
+##end foreach [receptacle name] with [uses 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.
+//////////////////////////////////////////////////////////////////
+
+##foreach [consumer name] with [eventtype] in (list of all consumers) generate:
+
+// Constructor and destructor.
+ACE_INLINE
+[ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::[eventtype]Consumer_[consumer name]_Servant
+ (CCM_[component name]_ptr executor,
+ CCM_[component name]_Context_ptr c)
+ : executor_ (CCM_[component name]::_duplicate (executor)),
+ ctx_ (CCM_[component name]_Context::_duplicate (c))
+{
+}
+
+ACE_INLINE
+[ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::~[eventtype]Consumer_[consumer name]_Servant ()
+{
+}
+
+ACE_INLINE CORBA::Object_ptr
+[ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::_get_component ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return this->ctx_->get_CCM_object ();
+}
+
+ACE_INLINE void
+[ciao module name]::[component name]_Servant::[eventtype]Consumer_[consumer name]_Servant::push_[eventtype]
+ ([eventtype] *evt)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ this->executor_->push_[consumer name] (evt);
+}
+
+## 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] *evt)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ Problem, there's no way to handle this case.
+
+ // this->executor_->push_[consumer name] (evt ACE_ENV_ARG);
+ 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_THROW_SPEC ((CORBA::SystemException
+ ::Components::AlreadyConnected))
+{
+ this->context_->connect_[emit name] (c);
+}
+
+ACE_INLINE [eventtype]Consumer_ptr
+[ciao module name]::[component name]_Servant::disconnect_[emit name] ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::NoConnection))
+{
+ return this->context_->disconnect_[emit name] ();
+}
+##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 *
+[ciao module name]::[component name]_Servant::subscribe_[publish name] ([eventtype]Consumer_ptr c)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::ExceededConnectionLimit))
+{
+ return this->context_->subscribe_[publish name] (c);
+}
+
+ACE_INLINE [eventtype]Consumer_ptr
+[ciao module name]::[component name]_Servant::unsubscribe_[publish name] (::Components::Cookie *ck)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::InvalidConnection))
+{
+ return this->context_->unsubscribe_[publish name] (ck);
+}
+##end foreach [publish name] with [eventtype]
+
+//////////////////////////////////////////////////////////////////
+// Component Home Glue code implementation
+//////////////////////////////////////////////////////////////////
+
+ACE_INLINE
+[ciao module name]::[home name]_Servant::[home name]_Servant (CCM_[home name]_ptr exe,
+ CIAO::Session_Container *c)
+ : executor_ (CCM_[home name]::_duplicate (exe)),
+ container_ (c)
+{
+}
+
+ACE_INLINE
+[ciao module name]::[home name]_Servant::~[home name]_Servant (void)
+{
+}
+
+##foreach [operation] in (all explicit operations in [home basename] including its parents)
+
+// The operation impl here. This can simply be relayed to the underlying executor...
+
+## end foreach opeartion
+
+##foreach [factory name] in (all factory operations in [home basename] including its parents)
+// for factory operations inherit from parent home(s), they should return
+// the corresponding component types their homes manage
+ACE_INLINE [component name]_ptr
+[ciao module name]::[home name]_Servant::[factory name] (....)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::CreateFailure,
+ ....))
+{
+ Components::EnterpriseComponent_var _ciao_ec =
+ this->executor_->[factory name] (....);
+
+ CCM_[component name]_var _ciao_comp
+ = CCM_[component name]::_narrow (_ciao_ec.in ());
+
+ return this->_ciao_activate_component (_ciao_comp.in ());
+}
+##end foreach [factory name]
+
+##foreach [finder name] in (all finder operations in [home basename] including its parents)
+// for finder operations inherit from parent home(s), they should return
+// the corresponding component types their homes manage
+ACE_INLINE [component name]_ptr
+[ciao module name]::[home name]_Servant::[finder name] (....)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::FinderFailure,
+ ....))
+{
+ Components::EnterpriseComponent_var com =
+ this->executor_->[finder name] (....);
+
+ // Do we create a new object reference referring to the same object,
+ // or do we try to create a different objref referring to the same object?
+ return this->_ciao_create_helper (com);
+}
+##end foreach [finder name]
+
+## if [home name] is a keyless home
+
+// Operations for KeylessHome interface
+ACE_INLINE ::Components::CCMObject_ptr
+[ciao module name]::[home name]_Servant::create_component ()
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::CreateFailure))
+{
+ // Simply forward to the create method.
+ return this->create ();
+}
+
+## else [home basename] is keyed home with [key type]
+
+// We do not support key'ed home at the moment but we might
+// as well generate the mapping.
+ACE_INLINE [component name]_ptr
+[ciao module name]::[home name]_Servant::create ([key type] *key)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::CreationFailure,
+ ::Components::DuplicateKeyValue,
+ ::Components::InvalidKey))
+{
+ // @@ TO-DO when we suppor keyed home.
+
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+ACE_INLINE [component name]_ptr
+[ciao module name]::[home name]_Servant::find_by_primary_key ([key type] *key)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::FinderFailure,
+ ::Components::UnknownKeyValue,
+ ::Components::InvalidKey))
+{
+ // @@ TO-DO when we suppor keyed home.
+
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+
+ACE_INLINE void
+[ciao module name]::[home name]_Servant::remove ([key type] *key)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Components::RemoveFailure,
+ ::Components::UnknownKeyValue,
+ ::Components::InvalidKey))
+{
+ // @@ TO-DO when we suppor keyed home.
+
+ throw CORBA::NO_IMPLEMENT ();
+}
+
+ACE_INLINE [key type] *
+[ciao module name]::[home name]_Servant::get_primary_key ([component name]_ptr comp)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ TO-DO when we suppor keyed home.
+
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+## endif (keyed or keyless home)
+
+
+// Operations for CCMHome interface
+ACE_INLINE ::CORBA::IRObject_ptr
+[ciao module name]::[home name]_Servant::get_component_def ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ TO-DO. Contact IfR?
+
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
+
+ACE_INLINE CORBA::IRObject_ptr
+[ciao module name]::[home name]_Servant::get_home_def ()
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ TO-DO. Contact IfR?
+
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+}
diff --git a/modules/CIAO/docs/templates/Executor.idl b/modules/CIAO/docs/templates/Executor.idl
new file mode 100644
index 00000000000..259bffac0df
--- /dev/null
+++ b/modules/CIAO/docs/templates/Executor.idl
@@ -0,0 +1,246 @@
+// $Id$
+
+// ===========================================================
+//
+// @file Executor.idl
+//
+// The purpose of this IDL file is to serve as a template for the CIDL
+// generated equivalent executor file. The CIDL will generate this
+// file directly which, in turn, gets compiled by the TAO IDL compiler
+// to generate the C++ mappings for the stuff defined in this file
+// into a set of [idl-name]EC.{h,inl,cpp} files.
+//
+// This intermediate step is necessary because component implemenetors
+// will need to extend these executor definitions (thru inheritance)
+// to implemenet more complex executor implementations, such as those
+// that support session component interface. (This is necessary to
+// properly support C++ mapping for features such as interface
+// narrowing.)
+//
+// What are missing in the template for executor mappings are the
+// exception specifications for most operations.
+//
+// @author Nanbor Wang <nanbor@cs.wustl.edu>
+//
+// ===========================================================
+
+#ifndef [component_idl]E_IDL
+#define [component_idl]E_IDL
+
+#include "CCM_Container.idl" // Found in $(CIAO_ROOT)/ciao
+ // For various definitions of container
+ // internal/callback interfaces
+#include "[component_idl].idl" // Original component IDL definition
+// @@ We may need to include other *E.idl here.... Can't figure out
+// if we can do this automagically or not.
+
+##if there are module definitions, preserve them all
+module [module_name] {
+##endif
+
+////////////////////////////////////////////////////////////////////
+//// * Iterate thru all supported interface types
+//// It's possible that we need to put some of the common supported
+//// interface definitions into a separate compilation unit. How do we
+//// specify that in CCIDL? I haven't figured that out. Perhaps
+//// allowing CCIDL to compile files that contain no component
+//// definition?
+##foreach [interface_type] in (types of all supported interface) generate:
+
+ local interface CCM_[interface_type] : [interface_type]
+ {
+ };
+
+##end foreach [interface_type]
+
+////////////////////////////////////////////////////////////////////
+//// * Iterate thru all facet ('provides' interface) interface types
+//// It's possible that we need to put some of the common facet
+//// definitions into a separate compilation unit. How do we
+//// 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:
+
+ local interface CCM_[facet_interface_type] : [facet_interface_type]
+ {
+ };
+
+##end foreach [facet_interface_type]
+
+////////////////////////////////////////////////////////////////////
+//// * Iterate thru all event ('emits', "publishes', or 'consumes') types
+//// It's possible that we need to put some of the EventConsumer
+//// definitions into a separate compilation unit. Like in the case
+//// of facets interface mappings, how do we
+//// specify that in CCIDL? I haven't figured that out. Perhaps
+//// allowing CCIDL to compile files that contain no component
+//// definition?
+
+##foreach [eventtype] in (all eventtypes) generate:
+
+ local interface CCM_[eventtype]Consumer
+ {
+ void push (in [eventtype] ev);
+ };
+
+##end foreach [eventtype]
+
+
+////////////////////////////////////////////////////////////////////
+//// * Iterate thru all component definitions in the IDL files.
+//// Notice that there's no distinction between entity and session
+//// components in executor mappings.
+
+##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]
+ CCM_[parent component name]_Executor
+## else
+ ::Components::EnterpriseComponent
+## endif
+## foreach [interface name] in (all component supported interfaces) generate:
+ , [interface name]
+## end foreach [interface name]
+
+ {
+## foreach [attribute definition] in (attributes defined in [component basename]) generate:
+ [attribute definition];
+## end foreach [attribute definition]
+
+ };
+
+ // Monolithic component executor.
+ // For implementing monolithic component call back interface.
+
+ local interface CCM_[component basename]
+ :
+## if [component basename] inherits from [parent component name]
+ CCM_[parent component name]
+## else
+ ::Components::EnterpriseComponent
+## endif
+## foreach [interface name] in (all component supported interfaces) generate:
+ , [interface name]
+## end foreach [interface name]
+
+ {
+## foreach [attribute definition] in (attributes defined in [component basename]) generate:
+ [attribute definition];
+## end foreach [attribute definition]
+
+## 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]
+
+## 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]
+
+ };
+
+ /**
+ * Component Context Interface
+ *
+ * Notice that we are taking a shortcut here to inherit the
+ * component-specific context from SessionContext directly instead
+ * of CCMContext.
+ */
+ local interface CCM_[component basename]_Context
+ :
+## if [component basename] inherits from [parent component name]
+ CCM_[parent component name]_Context
+## else
+ ::Components::SessionContext
+## endif
+ {
+
+## 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)
+ // [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]
+
+## 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 [component basename]
+
+
+////////////////////////////////////////////////////////////////////
+//// * Iterate thru all home definitions in the IDL files.
+
+##foreach [home basename] in (all home definitions) generate:
+
+ local interface CCM_[home basename]Explicit
+ :
+## if [home basename] inherits from [parent home name]
+ CCM_[parent home name]Explicit
+## else
+ ::Components::HomeExecutorBase
+## endif
+## foreach [interface name] in (all home supported interfaces) generate:
+ , [interface name]
+## end foreach [interface name]
+ {
+##foreach [operation] in (all explicit operations defined in [home basename])
+
+ // The operation decl here.
+
+## end foreach opeartion
+
+##foreach [factory name] in (all factory operations defined in [home basename])
+ ::Components::EnterpriseComponent [factory name] (....)
+ raise (Components::CreateFailure, ....);
+##end foreach [factory name]
+
+##foreach [finder name] in (all finder operations defined in [home basename])
+ ::Components::EnterpriseComponent [finder name] (....)
+ raise (Components::FinderFailure, ....);
+##end foreach [finder name]
+ };
+
+ local interface CCM_[home basename]Implicit
+ {
+## if [home basename] is a keyless home
+ ::Components::EnterpriseComponent create ()
+ raises (::Components::CCMException);
+## 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)
+ raises (::Components::CCMException);
+
+ ::Components::EnterpriseComponent find_by_primary_key (in [key type] key)
+ raises (::Components::CCMException);
+
+ void remove (in [key type] key)
+ raises (::Components::CCMException);
+## endif (key'ed or keyless home)
+ };
+
+ local interface CCM_[home basename]
+ : CCM_[home basename]Explicit,
+ CCM_[home basename]Implicit
+ {
+ };
+
+##end foreach [home basename]
+
+##if there are module definitions, preserve them all
+};
+##endif
+
+#endif /* [component_idl]E_IDL */
diff --git a/modules/CIAO/docs/templates/cidl_template.cidl b/modules/CIAO/docs/templates/cidl_template.cidl
new file mode 100644
index 00000000000..3d359708f32
--- /dev/null
+++ b/modules/CIAO/docs/templates/cidl_template.cidl
@@ -0,0 +1,31 @@
+// $Id$ -*- C++ -*-
+
+/**
+ * @file cidl_template.cidl
+ *
+ * This file show an example cidl file.
+ */
+
+// @@ We do not support import (yet).
+//import [component module];
+
+// [idl-basename] contains the IDL3 definitions for component(s) and
+// home(s) and the interfaces that they need.
+
+#include "[idl-basename].idl"
+
+// We only support a simple session implementation definition, for
+// now. @@ What is the relation of various names here and the
+// generated names we used in the glue code?
+composition session [composition name]
+{
+ home executor [home executor name]
+ {
+ implement [home name];
+ manages [component executor name];
+ };
+};
+
+
+// @@ We should also generate somet sort of implementaion template for
+// users. E.g., a set of [idl-basename]_impl.* and the MPC files(?).