summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-03-18 05:19:21 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-03-18 05:19:21 +0000
commit824c2a400ce6f496577bb489f13e5f6302fd0f8f (patch)
treee928ff87f688a79293eb01330dd4d03ca72c2156
parent441f9bd4194ce88b82b43441324e3eada7ec5540 (diff)
downloadATCD-824c2a400ce6f496577bb489f13e5f6302fd0f8f.tar.gz
*** empty log message ***
-rw-r--r--TAO/CIAO/ChangeLog13
-rw-r--r--TAO/CIAO/ciao/Container_Base.cpp42
-rw-r--r--TAO/CIAO/ciao/Container_Base.h13
-rw-r--r--TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp140
-rw-r--r--TAO/CIAO/examples/handcrafted/Hello/hello_servants.h23
5 files changed, 200 insertions, 31 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog
index 67dcaed73f8..13210e8d0ce 100644
--- a/TAO/CIAO/ChangeLog
+++ b/TAO/CIAO/ChangeLog
@@ -1,3 +1,16 @@
+Mon Mar 17 23:10:47 2003 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * ciao/Container_Base.cpp:
+ * ciao/Container_Base.h:
+ * examples/handcrafted/Hello/hello_servants.cpp:
+ * examples/handcrafted/Hello/hello_servants.h: Added support for
+ SessionComponent specific operations,
+ ccm_{activate,passivate,remove}. These changes still need to be
+ propagated to the CIDL templates.
+
+ We also need to review how Deployment::Container and CCMHome
+ manage the lifecyles of homes, components, and facet servants.
+
Sun Mar 16 21:57:10 2003 Nanbor Wang <nanbor@cs.wustl.edu>
* docs/templates/CIAO_Glue_Session_Template.h:
diff --git a/TAO/CIAO/ciao/Container_Base.cpp b/TAO/CIAO/ciao/Container_Base.cpp
index 5f26da8d305..1ed84f5e973 100644
--- a/TAO/CIAO/ciao/Container_Base.cpp
+++ b/TAO/CIAO/ciao/Container_Base.cpp
@@ -87,7 +87,7 @@ CIAO::Session_Container::init (const char *name
return 0;
}
-CORBA::Object_ptr
+ACE_INLINE CORBA::Object_ptr
CIAO::Session_Container::install_servant (PortableServer::Servant p
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
@@ -102,9 +102,27 @@ CIAO::Session_Container::install_servant (PortableServer::Servant p
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
- p->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ return objref._retn ();
+}
+
+CORBA::Object_ptr
+CIAO::Session_Container::install_component (PortableServer::Servant p,
+ PortableServer::ObjectId_out oid
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableServer::ObjectId_var id
+ = this->poa_->activate_object (p
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ CORBA::Object_var objref
+ = this->poa_->id_to_reference (id
+ ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
+ oid = id._retn ();
+
return objref._retn ();
}
@@ -158,6 +176,8 @@ CIAO::Session_Container::ciao_install_home (const char *exe_dll_name,
if (home_servant == 0)
ACE_THROW_RETURN (Components::Deployment::InstallationFailure (), 0);
+ PortableServer::ServantBase_var safe (home_servant);
+
CORBA::Object_var objref = this->install_servant (home_servant
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
@@ -206,3 +226,21 @@ CIAO::Session_Container::uninstall (PortableServer::Servant svt
this->poa_->deactivate_object (oid
ACE_ENV_ARG_PARAMETER);
}
+
+void
+CIAO::Session_Container::uninstall_component (CORBA::Object_ptr objref,
+ PortableServer::ObjectId_out oid
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableServer::ObjectId_var id
+ = this->poa_->reference_to_id (objref
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ this->poa_->deactivate_object (id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ oid = id._retn ();
+}
diff --git a/TAO/CIAO/ciao/Container_Base.h b/TAO/CIAO/ciao/Container_Base.h
index 23be45bf84d..105b5677534 100644
--- a/TAO/CIAO/ciao/Container_Base.h
+++ b/TAO/CIAO/ciao/Container_Base.h
@@ -120,6 +120,13 @@ namespace CIAO
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((CORBA::SystemException));
+ // Install a component servant.
+ CORBA::Object_ptr install_component (PortableServer::Servant p,
+ PortableServer::ObjectId_out oid
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
// Get an object reference to a component or home from the servant.
CORBA::Object_ptr get_objref (PortableServer::Servant p
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
@@ -135,6 +142,12 @@ namespace CIAO
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((CORBA::SystemException));
+ // Uninstall a servant for component or home.
+ void uninstall_component (CORBA::Object_ptr objref,
+ PortableServer::ObjectId_out oid
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
protected:
long number_;
diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp
index 9121b602679..92034185784 100644
--- a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp
+++ b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.cpp
@@ -124,7 +124,8 @@ CIAO_HelloWorld_Servant::CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr exe,
if (! CORBA::is_nil (temp.in ()))
{
- temp->set_session_context (this->context_.in ());
+ temp->set_session_context (this->context_.in ()
+ ACE_ENV_ARG_PARAMETER);
}
}
ACE_CATCHANY
@@ -137,6 +138,22 @@ CIAO_HelloWorld_Servant::CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr exe,
CIAO_HelloWorld_Servant::~CIAO_HelloWorld_Servant (void)
{
+ ACE_TRY_NEW_ENV;
+ {
+ Components::SessionComponent_var temp =
+ Components::SessionComponent::_narrow (this->executor_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (! CORBA::is_nil (temp.in ()))
+ temp->ccm_remove (ACE_ENV_SINGLE_ARG_PARAMETER);
+ }
+ ACE_CATCHANY
+ {
+ // @@ Ignore any exceptions? What happens if
+ // set_session_context throws an CCMException?
+ }
+ ACE_ENDTRY;
}
// Operations for supported interfaces.
@@ -505,21 +522,28 @@ CIAO_HelloWorld_Servant::_get_component (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
}
-HelloWorld_ptr
-CIAO_HelloWorld_Servant::_ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
+void
+CIAO_HelloWorld_Servant::_ciao_activate (ACE_ENV_SINGLE_ARG_DECL)
{
- CORBA::Object_var obj
- = this->container_->install_servant (this
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- HelloWorld_var ho = HelloWorld::_narrow (obj
+ Components::SessionComponent_var temp =
+ Components::SessionComponent::_narrow (this->executor_.in ()
ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
+ ACE_CHECK;
- return ho._retn ();
+ if (! CORBA::is_nil (temp.in ()))
+ temp->ccm_activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+}
+void
+CIAO_HelloWorld_Servant::_ciao_deactivate (ACE_ENV_SINGLE_ARG_DECL)
+{
+ Components::SessionComponent_var temp =
+ Components::SessionComponent::_narrow (this->executor_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (! CORBA::is_nil (temp.in ()))
+ temp->ccm_passivate (ACE_ENV_SINGLE_ARG_PARAMETER);
}
////////////////////////////////////////////////////////////////
@@ -548,6 +572,69 @@ CIAO_HelloHome_Servant::create_component (ACE_ENV_SINGLE_ARG_DECL)
return this->create (ACE_ENV_SINGLE_ARG_PARAMETER);
}
+HelloWorld_ptr
+CIAO_HelloHome_Servant::_ciao_activate_component (CCM_HelloWorld_ptr exe
+ ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ CORBA::Object_var hobj= this->container_->get_objref (this
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ ::Components::CCMHome_var home = ::Components::CCMHome::_narrow (hobj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ CIAO_HelloWorld_Servant *svt = new CIAO_HelloWorld_Servant (exe,
+ home.in (),
+ this->container_);
+ PortableServer::ServantBase_var safe (svt);
+ PortableServer::ObjectId_var oid;
+
+ CORBA::Object_var objref
+ = this->container_->install_component (svt,
+ oid.out ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ svt->_ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ HelloWorld_var ho = HelloWorld::_narrow (objref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ if (this->component_map_.bind (oid.in (), svt) == 0)
+ {
+ // @@ what should happen if bind fail?
+ safe._retn ();
+ }
+ return ho._retn ();
+}
+
+void
+CIAO_HelloHome_Servant::_ciao_deactivate_component (HelloWorld_ptr comp
+ ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableServer::ObjectId_var oid;
+
+ this->container_->uninstall_component (comp,
+ oid.out ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ CIAO_HelloWorld_Servant *servant = 0;
+ if (this->component_map_.unbind (oid.in (), servant) == 0)
+ {
+ PortableServer::ServantBase_var safe (servant);
+ servant->_ciao_deactivate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+ }
+ // What happen if unbind failed?
+
+}
+
// Operations for Implicit Home interface
::HelloWorld_ptr
CIAO_HelloHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL)
@@ -565,18 +652,8 @@ CIAO_HelloHome_Servant::create (ACE_ENV_SINGLE_ARG_DECL)
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
- CORBA::Object_var hobj= this->container_->get_objref (this
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- ::Components::CCMHome_var home = ::Components::CCMHome::_narrow (hobj.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- CIAO_HelloWorld_Servant *svt = new CIAO_HelloWorld_Servant (hw.in (),
- home.in (),
- this->container_);
- return svt->_ciao_activate_component (ACE_ENV_ARG_PARAMETER);
+ return this->_ciao_activate_component (hw.in ()
+ ACE_ENV_ARG_PARAMETER);
}
// Operations for CCMHome interface
@@ -602,11 +679,22 @@ CIAO_HelloHome_Servant::remove_component (Components::CCMObject_ptr comp
ACE_THROW_SPEC ((CORBA::SystemException,
Components::RemoveFailure))
{
+ HelloWorld_var hw = HelloWorld::_narrow (comp
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (CORBA::is_nil (hw.in ()))
+ ACE_THROW (CORBA::INTERNAL ()); // What is the right exception to throw here?
+
+ hw->remove (ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
// Removing the object reference? get the servant from the POA with
// the objref, and call remove() on the component, deactivate the
// component, and then remove-ref the servant?
- this->container_->uninstall (comp
- ACE_ENV_ARG_PARAMETER);
+
+ this->_ciao_deactivate_component (hw.in ()
+ ACE_ENV_ARG_PARAMETER);
}
diff --git a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h
index 8bfe575cc28..f0dc62fb296 100644
--- a/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h
+++ b/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h
@@ -25,6 +25,8 @@
#include "helloEC.h"
#include "ciao/Container_Base.h"
#include "tao/LocalObject.h"
+#include "tao/PortableServer/Key_Adapters.h"
+#include "ace/Hash_Map_Manager_T.h"
class CIAO_HelloWorld_Servant;
@@ -230,9 +232,8 @@ public:
// CIAO specific operations.
- // Activate the object in the container_
- HelloWorld_ptr _ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException));
+ void _ciao_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ void _ciao_deactivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
protected:
// My Executor.
@@ -281,12 +282,28 @@ public:
ACE_THROW_SPEC ((CORBA::SystemException,
Components::RemoveFailure));
+ // Activate the object in the container_
+ HelloWorld_ptr _ciao_activate_component (CCM_HelloWorld_ptr exe
+ ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void _ciao_deactivate_component (HelloWorld_ptr comp
+ ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
protected:
// My Executor.
CCM_HelloHome_var executor_;
// My Container
CIAO::Session_Container *container_;
+
+ // Components this home manages.
+ ACE_Hash_Map_Manager_Ex <PortableServer::ObjectId,
+ CIAO_HelloWorld_Servant*,
+ TAO_ObjectId_Hash,
+ ACE_Equal_To<PortableServer::ObjectId>,
+ ACE_SYNCH_MUTEX> component_map_;
};
extern "C" HELLO_SERVANT_Export ::PortableServer::Servant