summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-08-03 14:11:51 +0000
committernobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-08-03 14:11:51 +0000
commit336bdc564b8dc4507a33fa3687aeacefb46a51ae (patch)
treee2a387d966cd8fd80b71a2099c86b12bb434566c
parent9a1683d857cf2faa51729dc871a9618ae9ee3533 (diff)
downloadATCD-336bdc564b8dc4507a33fa3687aeacefb46a51ae.tar.gz
This commit was manufactured by cvs2svn to create branch 'RTCIAO-0'.
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.cpp126
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.mpc23
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h201
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Assembly_Service_Impl.h63
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.cpp353
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h135
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.cpp121
-rw-r--r--TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.h126
-rw-r--r--TAO/CIAO/tools/ComponentServer/ComponentServer.cpp182
-rw-r--r--TAO/CIAO/tools/ComponentServer/ComponentServer.mpc13
-rw-r--r--TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp261
-rw-r--r--TAO/CIAO/tools/Daemon/Daemon.mpc31
-rw-r--r--TAO/CIAO/tools/Daemon/Daemon_Commands.h163
-rw-r--r--TAO/CIAO/tools/Daemon/Daemon_Impl.h104
-rw-r--r--TAO/CIAO/tools/Daemon/README104
-rw-r--r--TAO/CIAO/tools/Daemon/Softpkg_Commands.h89
-rw-r--r--TAO/CIAO/tools/Daemon/controller_i.h119
-rw-r--r--TAO/CIAO/tools/ServerActivator/ServerActivator.cpp181
-rw-r--r--TAO/CIAO/tools/ServerActivator/ServerActivator.mpc11
-rw-r--r--TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.cpp262
-rw-r--r--TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.mpc40
-rw-r--r--TAO/CIAO/tools/Simple_Component_Server/Simple_Server_i.h70
-rw-r--r--TAO/CIAO/tools/Simple_Component_Server/sample_client.cpp84
-rw-r--r--TAO/CIAO/tools/XML_Helpers/Cascadable_DocHandler.h252
-rw-r--r--TAO/CIAO/tools/XML_Helpers/XMLHelpers.mpc21
-rw-r--r--TAO/CIAO/tools/XML_Helpers/svc.conf.xml58
-rw-r--r--TAO/CIAO/tools/tools.mwc2
27 files changed, 3195 insertions, 0 deletions
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.cpp b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.cpp
new file mode 100644
index 00000000000..661c95c585a
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.cpp
@@ -0,0 +1,126 @@
+// $Id$
+
+#include "CCM_DeploymentC.h"
+#include "Assembly_ServiceC.h"
+#include "Client_init.h"
+#include "ace/Get_Opt.h"
+#include "ace/streams.h"
+
+const char *ior = "file://test.ior";
+const char *cad = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "a:k:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'a':
+ cad = get_opts.opt_arg ();
+ break;
+
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s \n"
+ "-a <assembly descriptor (.cad)>\n"
+ "-k <Assembly_Manager ior> \n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ if (cad == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Must specify an assembly descriptor using -a flag.\n"),
+ -1);
+
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CIAO::Client_init (orb.in ());
+
+ CORBA::Object_var tmp =
+ orb->string_to_object(ior ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Assembly_Service_var as_svc
+ = CIAO::Assembly_Service::_narrow (tmp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ::Components::Deployment::AssemblyFactory_var factory =
+ as_svc->get_assemblyfactory (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (factory.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Nil ServerActivator reference <%s>\n",
+ ior),
+ 1);
+ }
+
+
+ ACE_DEBUG ((LM_DEBUG, "Try creating an Assembly with %s\n", cad));
+
+ Components::Cookie_var ck =
+ factory->create_assembly (cad
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Components::Deployment::Assembly_var assembly =
+ factory->lookup (ck.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ assembly->build (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "Press <enter> to tear down the assembly\n"));
+ char dummy [256];
+ cin.getline (dummy, 256);
+
+ assembly->tear_down (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ factory->destroy (ck.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ as_svc->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught:");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.mpc b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.mpc
new file mode 100644
index 00000000000..1249f2429f4
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.mpc
@@ -0,0 +1,23 @@
+project(Assembly_Manager): ciao_server, acexml, iortable {
+
+ libs += CIAO_XML_Helpers
+ libpaths += ../XML_Helpers
+ after += XML_Helpers
+
+ Source_Files {
+ Assembly_ServiceC.cpp
+ Assembly_ServiceS.cpp
+ Assembly_Impl.cpp
+ Assembly_Visitors.cpp
+ Deployment_Configuration.cpp
+ Assembly_Manager.cpp // Main
+ Assembly_Service_Impl.cpp
+ }
+}
+
+project(Assembly_Deployer) : ciao_server {
+ Source_Files {
+ Assembly_ServiceC.cpp
+ Assembly_Deployer.cpp
+ }
+} \ No newline at end of file
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h
new file mode 100644
index 00000000000..bcb48e687cb
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h
@@ -0,0 +1,201 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Assembly_Impl.h
+ *
+ * $Id$
+ *
+ * This file contains implementations for
+ * Components::Deployment::AssemblyFactory and
+ * Components::Deployment::Assembly interface.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_ASSEMBLY_IMPL_H
+#define CIAO_ASSEMBLY_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Active_Map_Manager_T.h"
+#include "CCM_DeploymentS.h"
+#include "../XML_Helpers/Assembly_Spec.h"
+#include "Deployment_Configuration.h"
+#include "Assembly_Visitors.h"
+
+namespace CIAO
+{
+ /**
+ * @class AssemblyFactory_Impl
+ *
+ * @brief Servant implementation for Components::Deployment::AssemblyFactory
+ *
+ * This class implements the Components::Deployment::AssemblyFactory
+ * interface as defined by the CCM spcification. As the interface
+ * implies, this is actually part of the deployment interface and is
+ * used to manage the lifecycle of containers running on the server.
+ */
+ class AssemblyFactory_Impl
+ : public virtual POA_Components::Deployment::AssemblyFactory,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ /// Constructor
+ AssemblyFactory_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p);
+
+ /// Destructor
+ virtual ~AssemblyFactory_Impl (void);
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /// Initialize the AssemblyFactory with a configuration file.
+ /// @sa CIAO::Deployment_Configuration
+ int init (const char *config_file
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Components::Deployment::Assembly defined attributes/operations.
+ virtual ::Components::Cookie * create_assembly (const char * assembly_loc
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::Deployment::InvalidLocation,
+ Components::CreateFailure));
+
+ virtual ::Components::Deployment::Assembly_ptr lookup (Components::Cookie * c
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::Deployment::InvalidAssembly));
+
+ virtual void destroy (Components::Cookie * c
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::Deployment::InvalidAssembly,
+ Components::RemoveFailure));
+
+ protected:
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// Keep a list of managed Assembly objects.
+ ACE_Active_Map_Manager<Components::Deployment::Assembly_var> assembly_map_;
+
+ /// Deployment Configuration Info.
+ CIAO::Deployment_Configuration deployment_config_;
+ };
+
+ /**
+ * @class Assembly_Impl
+ *
+ * @brief Servant implementation for Components::Deployment::Assembly
+ *
+ * This class implements the Components::Deployment::Assembly
+ * interface as defined by the CCM spcification. As the interface
+ * implies, this is actually part of the deployment interface and is
+ * used to manage the lifecycle of containers running on the server.
+ */
+ class Assembly_Impl
+ : public virtual POA_Components::Deployment::Assembly,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ /// Constructor
+ Assembly_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ Assembly_Spec *spec,
+ Deployment_Configuration &config);
+
+ /// Destructor
+ virtual ~Assembly_Impl (void);
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /**
+ * Initialize the Assembly with an Assembly_Spec and a reference
+ * to a Deployment_Configuration object. The Assembly class
+ * assumes the ownership of Assembly_Spec.
+ */
+ int init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Components::Deployment::Assembly defined attributes/operations.
+
+ virtual void build (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::CreateFailure));
+
+ virtual void tear_down (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::RemoveFailure));
+
+ virtual ::Components::Deployment::AssemblyState
+ get_state (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ /**
+ * Connection establishment helper functions
+ */
+ /// @{
+ void make_connection (Assembly_Connection::Connect_Info *info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+ CORBA::Object_ptr
+ resolve_interface (Assembly_Connection::IF_Resolver_Info *info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+ Components::CCMObject_ptr
+ resolve_component (Assembly_Connection::IF_Resolver_Info *info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+ Components::CCMHome_ptr
+ resolve_home (Assembly_Connection::IF_Resolver_Info *info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+ Components::EventConsumerBase_ptr
+ resolve_consumer (Assembly_Connection::IF_Resolver_Info *info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+ /// @}
+
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// Current State
+ ::Components::Deployment::AssemblyState state_;
+
+ /// <Debug> My instance number.
+ CORBA::ULong serial_number_;
+
+ /// <Debug> instance counter.
+ static CORBA::ULong assembly_count_;
+
+ /// Deployment Configuration Info.
+ Deployment_Configuration &deployment_config_;
+
+ /// Assembly Specification.
+ Assembly_Spec *assembly_spec_;
+
+ Assembly_Context assembly_context_;
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "Assembly_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_ASSEMBLY_IMPL_H */
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Service_Impl.h b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Service_Impl.h
new file mode 100644
index 00000000000..e03989f0de5
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Service_Impl.h
@@ -0,0 +1,63 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Assembly_Service_Impl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_ASSEMBLY_SERVICE_IMPL_H
+#define CIAO_ASSEMBLY_SERVICE_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "Assembly_ServiceS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace CIAO
+{
+ class Assembly_Service_Impl
+ : public virtual POA_CIAO::Assembly_Service,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ /// Constructor
+ Assembly_Service_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ Components::Deployment::AssemblyFactory_ptr f);
+
+ /// Destructor
+ virtual ~Assembly_Service_Impl (void);
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ virtual ::Components::Deployment::AssemblyFactory_ptr
+ get_assemblyfactory (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// Cached AssemblyFactory reference.
+ Components::Deployment::AssemblyFactory_var factory_;
+ };
+}
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_ASSEMBLY_IMPL_H */
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.cpp b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.cpp
new file mode 100644
index 00000000000..93ef3894e69
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.cpp
@@ -0,0 +1,353 @@
+// $Id$
+
+#include "Assembly_Visitors.h"
+#include "../XML_Helpers/XML_Utils.h"
+
+#if !defined (__ACE_INLINE__)
+# include "Assembly_Visitors.inl"
+#endif /* __ACE_INLINE__ */
+
+CIAO::Assembly_Builder_Visitor::~Assembly_Builder_Visitor (void)
+{
+}
+
+int
+CIAO::Assembly_Builder_Visitor::visit_Container
+(CIAO::Assembly_Placement::Container *c
+ ACE_ENV_ARG_DECL)
+{
+ ACE_DEBUG ((LM_DEBUG, "partitioning %s\n", c->id ()));
+
+ // This can only happen when we hit a partitioning (root) node.
+ CIAO::Assembly_Placement::Container::ITERATOR iter (*c);
+ CIAO::Assembly_Placement::Node *node = 0;
+
+ while (iter.next (node))
+ {
+ int retv = node->accept (*this
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (retv != 0)
+ return -1;
+ iter.advance ();
+ }
+ return 0;
+}
+
+int
+CIAO::Assembly_Builder_Visitor::visit_hostcollocation
+(CIAO::Assembly_Placement::hostcollocation *hc
+ ACE_ENV_ARG_DECL)
+{
+ ACE_DEBUG ((LM_DEBUG, "hostcollocation %s\n", hc->id ()));
+
+
+
+ CIAO::Assembly_Placement::Container::ITERATOR iter (*hc);
+ CIAO::Assembly_Placement::Node *node = 0;
+
+ while (iter.next (node))
+ {
+ int retv = node->accept (*this
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (retv != 0)
+ return -1;
+ iter.advance ();
+ }
+ return 0;
+}
+
+int
+CIAO::Assembly_Builder_Visitor::visit_processcollocation
+(CIAO::Assembly_Placement::processcollocation *pc
+ ACE_ENV_ARG_DECL)
+{
+ ACE_DEBUG ((LM_DEBUG, "processcollocation %s\n", pc->id ()));
+
+ if (pc->destination () != 0)
+ {
+ ACE_CString desti_string (pc->destination ());
+ ssize_t endpos = desti_string.find ('|');
+
+ ACE_CString destination_host =
+ desti_string.substring (0, endpos);
+
+ Components::Deployment::ServerActivator_var activator =
+ this->deployment_config_.get_activator (destination_host.c_str ());
+
+ if (CORBA::is_nil (activator.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR, "Fail to acquire ServerActivator (%s)\n",
+ pc->destination ()),
+ -1);
+
+ Components::ConfigValues server_config;
+ // @@ Nothing to config yet.
+
+ if (endpos != ACE_CString::npos)
+ {
+ ACE_CString svcconf = desti_string.substring (endpos + 1);
+ server_config.length (1);
+
+ Components::ConfigValue *item = new OBV_Components::ConfigValue ();
+ item->name (CORBA::string_dup ("CIAO-svcconf-id"));
+ item->value () <<= CORBA::string_dup (svcconf.c_str ());
+ server_config[0] = item;
+ }
+
+ this->compserv_ =
+ activator->create_component_server (server_config
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ this->context_.component_servers_.enqueue_tail (this->compserv_);
+
+ Components::ConfigValues container_config;
+ // @@ Should we get the config value from Softpkg_Info?
+ this->container_ =
+ this->compserv_->create_container (container_config
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+ }
+
+ CIAO::Assembly_Placement::Container::ITERATOR iter (*pc);
+ CIAO::Assembly_Placement::Node *node = 0;
+
+ while (iter.next (node))
+ {
+ int retv = node->accept (*this
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (retv != 0)
+ return -1;
+ iter.advance ();
+ }
+ return 0;
+}
+
+int
+CIAO::Assembly_Builder_Visitor::visit_homeplacement
+(CIAO::Assembly_Placement::homeplacement *hp
+ ACE_ENV_ARG_DECL)
+{
+ ACE_DEBUG ((LM_DEBUG, "homeplacement %s\n", hp->id ()));
+
+ // @@ Create and register home before creating components.
+ ACE_CString csd_file;
+
+ if (this->impl_idref_map_.find (hp->componentfileref (),
+ csd_file) != 0)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Unable to find implementation reference: %s",
+ hp->componentfileref ()),
+ -1);
+
+ CIAO::Softpkg_Handler::Softpkg_Info info;
+ info.csd_path_ = csd_file.c_str ();
+
+ if (CIAO::XML_Utils::parse_softpkg (&info) == 0)
+ {
+ // info.dump (); // For debug purpose.
+
+ // install home
+ Components::ConfigValues home_config;
+ // Setting home config value here:
+ home_config.length (2);
+
+ Components::ConfigValue *item = new OBV_Components::ConfigValue ();
+ item->name (CORBA::string_dup ("CIAO-servant-UUID"));
+ item->value () <<= CORBA::string_dup (info.servant_UUID_.c_str ());
+ home_config[0] = item;
+
+ item = new OBV_Components::ConfigValue ();
+ item->name (CORBA::string_dup ("CIAO-servant-entrypt"));
+ item->value () <<= CORBA::string_dup (info.servant_entrypt_.c_str ());
+ home_config[1] = item;
+
+ Components::Deployment::Container_var container
+ = this->get_current_container (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (CORBA::is_nil (container.in ()))
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Unable to acquire a reference to ServerActivator\n"),
+ -1);
+
+ Components::CCMHome_var home =
+ container->install_home (info.executor_UUID_.c_str (),
+ info.executor_entrypt_.c_str (),
+ home_config
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ Components::KeylessCCMHome_var klhome =
+ Components::KeylessCCMHome::_narrow (home.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (CORBA::is_nil (klhome.in ()))
+ return -1;
+
+ // register home with context
+ if (this->context_.installed_homes_.bind (hp->id (),
+ home) != 0)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Failed to register home\n"),
+ -1);
+ // Save the home for component instantiation.
+ this->home_ = klhome;
+
+ // @@ Register home according to register spec.
+ // @@ Not implemented yet.
+ }
+
+ CIAO::Assembly_Placement::Container::ITERATOR iter (*hp);
+ CIAO::Assembly_Placement::Node *node = 0;
+
+ while (iter.next (node))
+ {
+ int retv = node->accept (*this
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (retv != 0)
+ return -1;
+ iter.advance ();
+ }
+
+ // Reset current home
+ this->home_ = 0;
+ return 0;
+}
+
+int
+CIAO::Assembly_Builder_Visitor::visit_componentinstantiation
+(CIAO::Assembly_Placement::componentinstantiation *ci
+ ACE_ENV_ARG_DECL)
+{
+ // @@ instantiation and register component.
+ ACE_DEBUG ((LM_DEBUG, "ComponentInstantiation %s\n", ci->id ()));
+
+ Components::CCMObject_var comp
+ = this->home_->create_component (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ this->context_.instantiated_components_.bind (ci->id (),
+ comp);
+
+ // Registering component.
+ CIAO::Assembly_Placement::componentinstantiation::REGISTRATION_QUEUE::ITERATOR
+ iter (ci->register_info_);
+
+ while (!iter.done ())
+ {
+ CIAO::Assembly_Placement::componentinstantiation::Register_Info *info;
+ iter.next (info);
+
+ this->register_component (info,
+ comp.in ()
+ ACE_ENV_ARG_PARAMETER);
+
+ iter.advance ();
+ }
+ return 0;
+}
+
+Components::Deployment::Container_ptr
+CIAO::Assembly_Builder_Visitor::get_current_container (ACE_ENV_SINGLE_ARG_DECL)
+{
+ if (CORBA::is_nil (this->compserv_.in ()))
+ {
+ Components::Deployment::ServerActivator_var activator =
+ this->deployment_config_.get_default_activator ();
+
+ if (CORBA::is_nil (activator.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR, "Fail to acquire default ServerActivator\n"),
+ 0);
+
+ Components::ConfigValues server_config;
+ // @@ Nothing to config yet.
+
+ this->compserv_ =
+ activator->create_component_server (server_config
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ this->context_.component_servers_.enqueue_tail (this->compserv_);
+
+ Components::ConfigValues container_config;
+ // @@ Should we get the config value from Softpkg_Info?
+ this->container_ =
+ this->compserv_->create_container (container_config
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+
+ return Components::Deployment::Container::_duplicate
+ (this->container_.in ());
+}
+
+void
+CIAO::Assembly_Builder_Visitor::register_component
+(Assembly_Placement::componentinstantiation::Register_Info *i,
+ Components::CCMObject_ptr c
+ ACE_ENV_ARG_DECL)
+{
+ CORBA::Object_ptr reg_obj;
+
+ // Extract the right interface to register:
+ switch (i->type_)
+ {
+ case CIAO::Assembly_Placement::componentinstantiation::COMPONENT:
+ reg_obj = c;
+ break;
+
+ case CIAO::Assembly_Placement::componentinstantiation::PROVIDESID:
+ reg_obj = c->provide_facet (i->port_id_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ break;
+
+ case CIAO::Assembly_Placement::componentinstantiation::CONSUMESID:
+ reg_obj = c->get_consumer (i->port_id_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ break;
+
+ default:
+ ACE_THROW (CORBA::INTERNAL ());
+ }
+
+ // Now actually register the interface
+ switch (i->method_)
+ {
+ case CIAO::Assembly_Placement::componentinstantiation::NAMINGSERVICE:
+ ACE_THROW (CORBA::NO_IMPLEMENT ());
+
+ case CIAO::Assembly_Placement::componentinstantiation::IORFILE:
+ {
+ CORBA::String_var ior
+ = this->orb_->object_to_string (reg_obj
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ FILE* ior_output_file_ =
+ ACE_OS::fopen (i->name_.c_str (), "w");
+
+ if (ior_output_file_)
+ {
+ ACE_OS::fprintf (ior_output_file_,
+ "%s",
+ ior.in ());
+ ACE_OS::fclose (ior_output_file_);
+ }
+ }
+ break;
+
+ default:
+ ACE_THROW (CORBA::INTERNAL ());
+ }
+}
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h
new file mode 100644
index 00000000000..fa3f5072cab
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h
@@ -0,0 +1,135 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Assembly_Visitors.h
+ *
+ * $Id$
+ *
+ * This file contains implementations for various visitors that
+ * traverse and process CIAO::Assembly_Spec.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_ASSEMBLY_VISITOR_H
+#define CIAO_ASSEMBLY_VISITOR_H
+#include /**/ "ace/pre.h"
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "CCM_DeploymentS.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "../XML_Helpers/Assembly_Spec.h"
+#include "Deployment_Configuration.h"
+
+namespace CIAO
+{
+ /**
+ * @typedef Assembly_Context
+ *
+ * This is a structure for collecting information of a running Assembly.
+ */
+ typedef struct _assembly_context
+ {
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Components::CCMHome_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> HOME_MAP;
+ HOME_MAP installed_homes_;
+
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Components::CCMObject_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> COMP_MAP;
+ COMP_MAP instantiated_components_;
+
+ typedef ACE_Unbounded_Queue<Components::Deployment::ComponentServer_var> SERVER_QUEUE;
+ SERVER_QUEUE component_servers_;
+ } Assembly_Context;
+
+ /**
+ * @class Assembly_Builder_Visitor
+ *
+ * @brief A visitor implementation that "build" up the application
+ * ACE_Hash_Map_Manager_Exby visiting nodes in an Assembly_Spec
+ */
+ class Assembly_Builder_Visitor : public CIAO::Assembly_Placement::Visitor
+ {
+ public:
+ /// Constructor
+ Assembly_Builder_Visitor (CORBA::ORB_ptr o,
+ Assembly_Context &context,
+ CIAO::ID_IMPL_MAP &idmap,
+ Deployment_Configuration &config);
+
+ /// Destructor
+ virtual ~Assembly_Builder_Visitor (void);
+
+ virtual int visit_Container (Assembly_Placement::Container *c
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int visit_hostcollocation (Assembly_Placement::hostcollocation *hc
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int visit_processcollocation (Assembly_Placement::processcollocation *pc
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int visit_homeplacement (Assembly_Placement::homeplacement *hp
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int visit_componentinstantiation (Assembly_Placement::componentinstantiation *ci
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ Components::Deployment::Container_ptr
+ get_current_container (void);
+
+ protected:
+ /// Registering a component using the info specified in @c i .
+ void register_component (Assembly_Placement::componentinstantiation::Register_Info *i,
+ Components::CCMObject_ptr c
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ /// Current Component Server.
+ Components::Deployment::ComponentServer_var compserv_;
+
+ /// Current Container. (This shouldn't be necessary because the
+ /// component server supposedly should be able to figure out if a
+ /// component home can be installed in the same container based on
+ /// its configvalue. However, our component server don't do that
+ /// yet, so we just install all home in a process into one single
+ /// container.)
+ Components::Deployment::Container_var container_;
+
+ /// Current Component Home. We only support keyless home
+ /// operations for now.
+ Components::KeylessCCMHome_var home_;
+
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Context to build on.
+ Assembly_Context &context_;
+
+ /// Context to build on.
+ CIAO::ID_IMPL_MAP &impl_idref_map_;
+
+ /// Deployment Configuration Info.
+ Deployment_Configuration &deployment_config_;
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "Assembly_Visitors.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_ASSEMBLY_VISITOR_H */
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.cpp b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.cpp
new file mode 100644
index 00000000000..a665612e77a
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.cpp
@@ -0,0 +1,121 @@
+// $Id$
+
+#include "Deployment_Configuration.h"
+
+#if !defined (__ACE_INLINE__)
+# include "Deployment_Configuration.inl"
+#endif /* __ACE_INLINE__ */
+
+#define NAME_BUFSIZE 1024
+
+CIAO::Deployment_Configuration::Deployment_Configuration (CORBA::ORB_ptr o)
+ : orb_ (CORBA::ORB::_duplicate (o))
+{
+}
+
+CIAO::Deployment_Configuration::~Deployment_Configuration (void)
+{
+}
+
+int
+CIAO::Deployment_Configuration::init (const char *filename)
+{
+ // @@ We should change to use ACE_Configuration here.
+
+ if (filename == 0)
+ return -1;
+
+ FILE *inf = ACE_OS::fopen (filename, "r");
+
+ if (inf == NULL)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Fail to open activator map data file: %s.\n",
+ filename),
+ -1);
+
+ char destination[NAME_BUFSIZE], ior[NAME_BUFSIZE];
+
+ int first = 1;
+
+ while (fscanf (inf, "%s %s", destination, ior ) != EOF)
+ {
+ this->deployment_info_.bind (destination, ior);
+
+ if (first)
+ {
+ this->default_activator_.IOR_ = ior;
+ first = 0;
+ }
+ }
+
+ return 0;
+}
+
+const char *
+CIAO::Deployment_Configuration::get_activator_ior (const char *name)
+{
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ CIAO::Deployment_Configuration::Activator_Info> *entry;
+
+ if (this->deployment_info_.find (ACE_CString (name),
+ entry) != 0)
+ return 0; // no valid name found.
+
+ return entry->int_id_.IOR_.c_str ();
+}
+
+const char *
+CIAO::Deployment_Configuration::get_default_activator_ior (void)
+{
+ if (this->default_activator_.IOR_.length () == 0)
+ return 0;
+ return this->default_activator_.IOR_.c_str ();
+}
+
+Components::Deployment::ServerActivator_ptr
+CIAO::Deployment_Configuration::get_activator (const char *name
+ ACE_ENV_ARG_DECL)
+{
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ CIAO::Deployment_Configuration::Activator_Info> *entry;
+
+ if (this->deployment_info_.find (ACE_CString (name),
+ entry) != 0)
+ return 0; // no valid name found.
+
+ if (CORBA::is_nil (entry->int_id_.activator_.in ()))
+ {
+ CORBA::Object_var temp = this->orb_->string_to_object
+ (entry->int_id_.IOR_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ entry->int_id_.activator_ =
+ Components::Deployment::ServerActivator::_narrow (temp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ return Components::Deployment::ServerActivator::_duplicate
+ (entry->int_id_.activator_.in ());
+}
+
+Components::Deployment::ServerActivator_ptr
+CIAO::Deployment_Configuration::get_default_activator (void)
+{
+ if (CORBA::is_nil (this->default_activator_.activator_.in ()))
+ {
+ CORBA::Object_var temp = this->orb_->string_to_object
+ (this->default_activator_.IOR_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ this->default_activator_.activator_ =
+ Components::Deployment::ServerActivator::_narrow (temp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ return Components::Deployment::ServerActivator::_duplicate
+ (this->default_activator_.activator_.in ());
+}
diff --git a/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.h b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.h
new file mode 100644
index 00000000000..fc6e8e6a6d1
--- /dev/null
+++ b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.h
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Deployment_Configuration.h
+ *
+ * $Id$
+ *
+ * The Deployment_Configuration provides abstraction for the
+ * deployment mechanisms.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_DEPLOYMENT_CONFIGURATION_H
+#define CIAO_DEPLOYMENT_CONFIGURATION_H
+#include /**/ "ace/pre.h"
+
+#include "ace/Hash_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "CCM_DeploymentC.h"
+
+namespace CIAO
+{
+ /**
+ * @class Deployment_Configuration
+ *
+ * @brief A class that provides strategies on deployment topology
+ *
+ * This class provides strategies on how the Assembly framework
+ * should deploy an assembly. This is achieved by providing
+ * mappings from deployment destination names to actually CIAO daemon
+ * IORs, and the strategy for which default CIAO daemon a deployment
+ * mechanism should use.
+ *
+ * This is a trivial implementation of the deployment configuration
+ * strategy. We can enhance this class later on to provide
+ * different deployment location strategies.
+ */
+ class Deployment_Configuration
+ {
+ public:
+ typedef struct _activator_info
+ {
+ _activator_info (const char *ior = 0)
+ {
+ IOR_ = ior;
+ }
+
+ ACE_CString IOR_;
+ Components::Deployment::ServerActivator_var activator_;
+ } Activator_Info;
+
+ Deployment_Configuration (CORBA::ORB_ptr o);
+
+ /// Destructor
+ virtual ~Deployment_Configuration (void);
+
+ /**
+ * Init method takes the filename to a configuration file which
+ * has a simple line format of name, ior string delimited by a
+ * space in each line.
+ *
+ * name IOR-string
+ *
+ * @retval 0 on success.
+ * @retval -1 otherwise.
+ */
+ int init (const char *filename);
+
+ /**
+ * @retval 0 if no valid name were found.
+ */
+ virtual const char *get_activator_ior (const char *name);
+
+ /**
+ * Return the default ServerActivator the Assembly mechanism
+ * should use to deploy a component. In this implementation, the
+ * first entry in the deployment configuration data file is always
+ * the entry for default activator.
+ *
+ * @retval 0 if no valid daemon is configured.
+ */
+ virtual const char *get_default_activator_ior (void);
+
+ /**
+ * @retval nil if no valid name were found.
+ */
+ virtual Components::Deployment::ServerActivator_ptr
+ get_activator (const char *name);
+
+ /**
+ * Return the reference to the default ServerActivator the
+ * Assembly mechanism should use to deploy a component.
+ *
+ * @retval nil if no valid daemon is configured.
+ */
+ virtual Components::Deployment::ServerActivator_ptr
+ get_default_activator (void);
+
+ protected:
+ CORBA::ORB_var orb_;
+
+ ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Activator_Info,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> deployment_info_;
+
+ Activator_Info default_activator_;
+ };
+
+}
+
+#if defined (__ACE_INLINE__)
+# include "Deployment_Configuration.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_DEPLOYMENT_CONFIGURATION_H */
diff --git a/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp b/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp
new file mode 100644
index 00000000000..974080b3856
--- /dev/null
+++ b/TAO/CIAO/tools/ComponentServer/ComponentServer.cpp
@@ -0,0 +1,182 @@
+// $Id$
+
+/**
+ * @file ComponentServer.cpp
+ *
+ * @brief CIAO's ComponentServer implementation
+ *
+ */
+
+#include "ComponentServer_Impl.h"
+#include "CIAO_ServersC.h"
+#include "Server_init.h"
+#include "ace/SString.h"
+#include "ace/Get_Opt.h"
+
+char *ior_file_name_ = 0;
+char *callback_ior_ = 0;
+int use_callback = 1;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "nk:o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'n':
+ use_callback = 0;
+ break;
+
+ case 'o': // get the file name to write to
+ ior_file_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'k': // get the activator callback IOR
+ callback_ior_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-n Don't not try to callback ServerActivator (testing)\n"
+ "-o <ior_output_file>\n"
+ "-k <activator_callback_ior>\n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ if (use_callback && callback_ior_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "Callback IOR to ServerActivator is required.\n"),
+ -1);
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Server_init (orb.in ());
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ // Get reference to Root POA.
+ CORBA::Object_var obj
+ = orb->resolve_initial_references ("RootPOA"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POA_var poa
+ = PortableServer::POA::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Activate POA manager
+ PortableServer::POAManager_var mgr
+ = poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ mgr->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::ComponentServer_Impl *comserv_servant;
+
+ ACE_NEW_RETURN (comserv_servant,
+ CIAO::ComponentServer_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ PortableServer::ServantBase_var safe_servant (comserv_servant);
+
+ // @@ We need to call ComponentServer servant's init method.
+ // But it's not sure to me where exactly we can get the
+ // ConfigValues needed by the init method at this moment.
+
+ // comserv_servant->init (config ACE_ENV_ARG_PARAMETER);
+
+ // Configuring ComponentServer.
+ PortableServer::ObjectId_var cs_oid
+ = poa->activate_object (comserv_servant
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ obj = poa->id_to_reference (cs_oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Components::Deployment::ComponentServer_var comserv_obj =
+ Components::Deployment::ComponentServer::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (comserv_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR, "Unable to activate ComponentServer object\n"), -1);
+
+
+ Components::Deployment::ServerActivator_var activator;
+ Components::ConfigValues_var config;
+
+ if (use_callback)
+ {
+ obj = orb->string_to_object (callback_ior_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Activator_Callback_var act_callback
+ = ::CIAO::Activator_Callback::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Components::ConfigValues_out config_out (config.out ());
+
+ activator
+ = act_callback->register_component_server (comserv_obj.in (),
+ config_out
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ comserv_servant->set_objref (activator.in (),
+ config.in (),
+ comserv_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var str = orb->object_to_string (comserv_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+
+ CIAO::Utility::write_IOR (ior_file_name_, str.in ());
+ ACE_DEBUG ((LM_INFO, "ComponentServer IOR: %s\n", str.in ()));
+
+ // End Deployment part
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Running ComponentServer...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "server::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/ComponentServer/ComponentServer.mpc b/TAO/CIAO/tools/ComponentServer/ComponentServer.mpc
new file mode 100644
index 00000000000..85bf8876504
--- /dev/null
+++ b/TAO/CIAO/tools/ComponentServer/ComponentServer.mpc
@@ -0,0 +1,13 @@
+// $Id$
+
+project(ComponentServer): ciao_server, iortable {
+ Source_Files {
+ ComponentServer.cpp
+ }
+}
+
+project(ComponentServer_test_client) : ciao_server {
+ Source_Files {
+ ComponentServer_test_client.cpp
+ }
+}
diff --git a/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp b/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp
new file mode 100644
index 00000000000..bf6b12e8ba7
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/CIAO_Daemon.cpp
@@ -0,0 +1,261 @@
+// $Id$
+
+/**
+ * @file CIAO_Daemon.cpp
+ *
+ * @brief CIAO's server activator implementation
+ *
+ * ServerActivator is the bootstraping mechanism to create new
+ * component servers on the localhost. We currently depend on
+ * starting the ServerActivator process on some specific port of all
+ * the hosts that have ServerActivator install to function properly.
+ */
+
+#include "ServerActivator_Impl.h"
+#include "ComponentInstallation_Impl.h"
+#include "Daemon_Impl.h"
+#include "Server_init.h"
+#include "tao/IORTable/IORTable.h"
+#include "ace/SString.h"
+#include "ace/Read_Buffer.h"
+#include "ace/Get_Opt.h"
+
+char *ior_file_name_ = "daemon.ior";
+char *comserv_path_ = "../ComponentServer/ComponentServer";
+CORBA::ULong spawn_wait_ = 5;
+char *installation_datafile_ = "CIAO_Installation_Data.ini";
+char *section_name_ = 0;
+char *default_svcconf_ = 0;
+char *svcconf_config_ = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "i:n:o:d:s:c:m:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o': // get the file name to write to
+ ior_file_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'n': // get the path name to the component server
+ comserv_path_ = get_opts.opt_arg ();
+ break;
+
+ case 'd': // time to wait before we consider a ComponentServer
+ // fails to start.
+ spawn_wait_ = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'i': // get the name for the ComponentInstallation data file
+ installation_datafile_ = get_opts.opt_arg ();
+ break;
+
+ case 's': // get the section name to use in ComponentInstallation data file
+ section_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'c': // get the default svc.conf filename for ComponentServer
+ default_svcconf_ = get_opts.opt_arg ();
+ break;
+
+ case 'm': // get the svc.conf map configuration filename
+ svcconf_config_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-n <component server pathname>\n"
+ "-o <ior_output_file>\n"
+ "-d <time (in second) to wait for component server>\n"
+ "-i <installation data filename>\n"
+ "-s <section name to use in installation data file>\n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+write_IOR(const char* ior)
+{
+ FILE* ior_output_file_ =
+ ACE_OS::fopen (ior_file_name_, "w");
+
+ if (ior_output_file_)
+ {
+ ACE_OS::fprintf (ior_output_file_,
+ "%s",
+ ior);
+ ACE_OS::fclose (ior_output_file_);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Server_init (orb.in ());
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ // Get reference to Root POA.
+ CORBA::Object_var obj
+ = orb->resolve_initial_references ("RootPOA"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POA_var poa
+ = PortableServer::POA::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::Object_var table_object =
+ orb->resolve_initial_references ("IORTable"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ IORTable::Table_var adapter =
+ IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (adapter.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR, "Nil IORTable\n"), -1);
+ }
+
+ // Create and install the CIAO Daemon servant
+
+ CIAO::Daemon_Impl *daemon_servant = 0;
+ ACE_NEW_RETURN (daemon_servant,
+ CIAO::Daemon_Impl ("CIAODaemon",
+ orb.in (),
+ poa.in ()),
+ -1);
+ PortableServer::ServantBase_var safe_daemon (daemon_servant);
+ // Implicit activation
+ CIAO::Daemon_var daemon = daemon_servant->_this ();
+
+ // Create and install the ComponentInstallation servant
+
+ CIAO::ComponentInstallation_Impl *installation_servant = 0;
+
+ ACE_NEW_RETURN (installation_servant,
+ CIAO::ComponentInstallation_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ installation_servant->init (installation_datafile_,
+ section_name_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::ServantBase_var safe_installation (installation_servant);
+
+ Components::Deployment::ComponentInstallation_var installation
+ = installation_servant->_this ();
+
+ CORBA::String_var str = orb->object_to_string (installation.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("ComponentInstallation", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (daemon_servant->bind ("ComponentInstallation", installation.in ()) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Failed to register ComponentInstallation with CIAO Daemon\n"),
+ -1);
+
+ // Create and install the ServerActivator servant
+
+ CIAO::ServerActivator_Impl *activator_servant = 0;
+
+ ACE_NEW_RETURN (activator_servant,
+ CIAO::ServerActivator_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ activator_servant->init (comserv_path_,
+ spawn_wait_,
+ str.in (),
+ default_svcconf_,
+ svcconf_config_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::ServantBase_var safe_activator (activator_servant);
+
+ Components::Deployment::ServerActivator_ptr activator
+ = activator_servant->_ciao_get_objref ();
+
+ str = orb->object_to_string (activator
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("ServerActivator", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (daemon_servant->bind ("ServerActivator", activator) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Failed to register ServerActivator with CIAO Daemon\n"),
+ -1);
+
+ // Now register daemon with IOR table and write its IOR.
+ str = orb->object_to_string (daemon.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("CIAODaemon", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ write_IOR (str.in ());
+ ACE_DEBUG ((LM_INFO, "CIAODaemon IOR: %s\n", str.in ()));
+
+ // Activate POA manager
+ PortableServer::POAManager_var mgr
+ = poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ mgr->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // End Deployment part
+
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO_Daemon is running...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "CIAO_Daemon::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO_Daemon has closed\n"));
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/Daemon/Daemon.mpc b/TAO/CIAO/tools/Daemon/Daemon.mpc
new file mode 100644
index 00000000000..e90eb7c982d
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/Daemon.mpc
@@ -0,0 +1,31 @@
+project(CIAO_Daemon): ciao_server, iortable {
+ IDL_Files {
+ Daemon.idl
+ }
+
+ Source_Files {
+ DaemonC.cpp
+ DaemonS.cpp
+ Daemon_Impl.cpp
+ CIAO_Daemon.cpp
+ }
+}
+
+project(DaemonController) : ciao_server, acexml {
+
+ libs += CIAO_XML_Helpers
+ libpaths += ../XML_Helpers
+ after += XML_Helpers
+
+ IDL_Files {
+ Daemon.idl
+ }
+
+ Source_Files {
+ DaemonC.cpp
+ DaemonController.cpp
+ controller_i.cpp
+ Daemon_Commands.cpp
+ Softpkg_Commands.cpp
+ }
+}
diff --git a/TAO/CIAO/tools/Daemon/Daemon_Commands.h b/TAO/CIAO/tools/Daemon/Daemon_Commands.h
new file mode 100644
index 00000000000..28630b506f3
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/Daemon_Commands.h
@@ -0,0 +1,163 @@
+// -*- C++ -*-
+// $Id$
+
+/**
+ * @file Daemon_Commands.h
+ *
+ * @brief Controller command implementations for general Daemon command
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+
+#ifndef CIAO_DAEMON_COMMANDS_H
+#define CIAO_DAEMON_COMMANDS_H
+#include /**/ "ace/pre.h"
+
+#include "controller_i.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+namespace CIAO
+{
+ namespace Daemon_i
+ {
+ /**
+ * @class CMD_Install
+ *
+ * @brief Daemon command to install a component implementation.
+ */
+ class CMD_Install : public Command_Base
+ {
+ public:
+ CMD_Install (controller *c);
+
+ virtual ~CMD_Install ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ private:
+ CORBA::String_var component_name_;
+ CORBA::String_var location_;
+ };
+
+ /**
+ * @class CMD_Get_IOR
+ *
+ * @brief Daemon command that returns the IOR of some service
+ * available on a daemon.
+ */
+ class CMD_Get_IOR : public Command_Base
+ {
+ public:
+ CMD_Get_IOR (controller *c);
+
+ virtual ~CMD_Get_IOR ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ private:
+ CORBA::String_var service_name_;
+ CORBA::String_var filename_;
+ };
+
+ /**
+ * @class CMD_Uninstall
+ *
+ * @brief Daemon command to uninstall a component implementation.
+ */
+ class CMD_Uninstall : public Command_Base
+ {
+ public:
+ CMD_Uninstall (controller *c);
+
+ virtual ~CMD_Uninstall ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ private:
+ CORBA::String_var component_name_;
+ };
+
+ /**
+ * @class CMD_Shutdown
+ *
+ * @brief Daemon command to shutdown the daemon process.
+ */
+ class CMD_Shutdown : public Command_Base
+ {
+ public:
+ CMD_Shutdown (controller *c);
+
+ virtual ~CMD_Shutdown ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ };
+
+ /**
+ * @class CMD_Shutdown
+ *
+ * @brief Daemon command to replace an component implementation with another one.
+ */
+ class CMD_Replace : public Command_Base
+ {
+ public:
+ CMD_Replace (controller *c);
+
+ virtual ~CMD_Replace ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ private:
+ CORBA::String_var component_name_;
+ CORBA::String_var location_;
+ };
+
+ /**
+ * @class CMD_Shutdown
+ *
+ * @brief Daemon command for quering the location of an installed component.
+ */
+ class CMD_Query : public Command_Base
+ {
+ public:
+ CMD_Query (controller *c);
+
+ virtual ~CMD_Query ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ private:
+ CORBA::String_var component_name_;
+ };
+ }
+}
+
+
+#if defined (__ACE_INLINE__)
+# include "Daemon_Commands.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_DAEMON_COMMAND_H */
diff --git a/TAO/CIAO/tools/Daemon/Daemon_Impl.h b/TAO/CIAO/tools/Daemon/Daemon_Impl.h
new file mode 100644
index 00000000000..853b91468fc
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/Daemon_Impl.h
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Daemon_Impl.h
+ *
+ * $Id$
+ *
+ * This file contains servant implementation for CIAO's daemon process control
+ * interface.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_DAEMON_IMPL_H
+#define CIAO_DAEMON_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "DaemonS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Synch.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "ace/Functor.h"
+
+namespace CIAO
+{
+ /**
+ * @class Daemon_Impl
+ *
+ * @brief Servant implementation CIAO's daemon process control interface
+ *
+ * This class implements the CIAO:Daemon interface. We use this interface
+ * to acquire the
+ */
+ class Daemon_Impl
+ : public virtual POA_CIAO::Daemon,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+
+ /// Constructor
+ Daemon_Impl (const char *name,
+ CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p);
+
+ /// Destructor
+ virtual ~Daemon_Impl (void);
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /// CIAO::Daemon defined attributes/operations.
+
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::Object_ptr get_service (const char * svc_name
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ CIAO::NotFound));
+
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /**
+ * @name CIAO::Daemon_Impl internal operations using the
+ * canonical ACE_Map methods
+ */
+ //@{
+ int bind (const char *orb_id, CORBA::Object_ptr obj);
+ int unbind (const char *orb_id);
+ //@}
+
+ protected:
+ typedef ACE_Hash_Map_Manager_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX> Table;
+ typedef Table::iterator Iterator;
+
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// My Canonical name.
+ CORBA::String_var name_;
+
+ /// Internal object hash table.
+ Table table_;
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "Daemon_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_DAEMON_IMPL_H */
diff --git a/TAO/CIAO/tools/Daemon/README b/TAO/CIAO/tools/Daemon/README
new file mode 100644
index 00000000000..2d2a435d779
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/README
@@ -0,0 +1,104 @@
+$Id$
+
+CIAO_Daemon:
+============
+
+This directory contains CIAO's per-host daemon process implementation
+- CIAO_Daemon. It includes implementations for two major CCM
+interfaces, namely, ComponentImplementation and ServerActivation.
+ComponentInstallation interfaces must be available per-host so all
+ComponentServer running on the same host can query it to acquire
+component impolementations they need. Likewise, ServerActivator
+interacts with CCM's Assembly framework and is responsible to start up
+new ComponentServer processes on this host.
+
+The Daemon process registers three simple ObjectKey, "CIAODaemon",
+"ComponentInstallation", and "ServerActivator" to the IORTable, so if you
+start up the CIAO_Daemon process on a fixed endpoint like:
+
+ CIAO_Daemon -ORBEndpoint iiop://hostname:13000
+
+You can get to any of the three interfaces using one of the following
+IOR:
+
+ corbaloc:iiop:hostname:13000/CIAODaemon
+ corbaloc:iiop:hostname:13000/ComponentInstallation
+ corbaloc:iiop:hostname:13000/ServerActivator
+
+
+Other command line flags supported by ServerActivator include:
+
+ * -o <filename> : Specify the filename where CIAO_Daemon
+ writes the IOR of the Daemon interface to. By
+ default, it writes to "daemon.ior".
+ DaemonController uses the IOR to get the object
+ refrence to interact with the Daemon process.
+
+ * -n <pathname> : Specify the pathname to a ComponentServer
+ program that ServerActivator uses to
+ startup a ComponentServer process.
+
+ * -d <second> : Specify the time, in second, ServerActivator will
+ wait for the ComponentServer to callback to notify
+ ServerActivator their IOR. ServerActivator
+ considers the activation fails if the
+ ComponentServer does not call back in time.
+
+ * -i : Specify the name of the datafile ComponentInstallation
+ interface uses to keep the persistent installation data. By
+ default, CIAO_Daemon uses the file
+ "CIAO_Installation_Data.ini". This file (even if empty) must
+ exist before the process starts.
+
+ * -s : Specify the Section name within the persistent data file the
+ ComponentInstallation uses to retrieve and backup the
+ installation data. Changing this name allows us to switch
+ among various sets of component implementations easily just
+ by restarting the daemon process. By default, CIAO_Daemon
+ uses the name "ComponentInstallation" if this flag is not
+ specified.
+
+ * -c <svcconf name>: Specify the default svcconf filename for ComponentServer
+
+ * -m <svcconf map>: Specify the svc.conf map configuration file.
+ This file contains the (hint, svc.conf filename)
+ tuples (two strings delimited by a comma).
+
+DaemonController:
+=================
+
+This is a small command line utility program for interacting with the
+CIAO_Daemon process. It offers two major function groups thru 6
+commands:
+
+ * General daemon process control:
+
+ - get_ior: use this command to query the IOR of any service
+ interfaces running on the daemon process and store the IOR into
+ a specified file.
+
+ - shutdown: use this command to shutdown the daemon process.
+
+
+ * ComponentInstallation related control:
+
+ - install: to install a new location of a component
+ implementation
+
+ - uninstall: to remove a location of a component implementation
+
+ - replace: to replace an existing compoment implementaion
+ location with a new one
+
+ - query: to query the location of a component implementation
+
+This program uses resolve_initial_references ("CIAODaemon") to acqurie
+the daemon control interface, so you must provide the reference to the
+program somehow. For example:
+
+ DaemonController -ORBInitRef CIAODaemon=file://daemon.ior <command> [command options]
+
+To check the parameter required for each of the commands listed above,
+just append the -h command option flag, such as:
+
+ DaemonController -ORBInitRef CIAODaemon=file://daemon.ior install -h
diff --git a/TAO/CIAO/tools/Daemon/Softpkg_Commands.h b/TAO/CIAO/tools/Daemon/Softpkg_Commands.h
new file mode 100644
index 00000000000..8acad9845c8
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/Softpkg_Commands.h
@@ -0,0 +1,89 @@
+// -*- C++ -*-
+// $Id$
+
+/**
+ * @file Softpkg_Commands.h
+ *
+ * @brief Controller commands implementations for creating and
+ * removing component server for a single home in a softpkg.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+
+#ifndef CIAO_SOFTPKG_COMMANDS_H
+#define CIAO_SOFTPKG_COMMANDS_H
+#include /**/ "ace/pre.h"
+
+#include "controller_i.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+namespace CIAO
+{
+ namespace Daemon_i
+ {
+ /**
+ * @class CMD_Start_Home
+ *
+ * @brief Daemon command to start up a component server for hosting
+ * a component home as specified in a softpkg descriptor.
+ */
+ class CMD_Start_Home : public Command_Base
+ {
+ public:
+ CMD_Start_Home (controller *c);
+
+ virtual ~CMD_Start_Home ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+
+ void print_usage (const char *name) const;
+
+ private:
+ CORBA::String_var softpkg_filename_;
+
+ CORBA::String_var home_ior_filename_;
+
+ CORBA::String_var com_server_ior_filename_;
+ };
+
+ /**
+ * @class CMD_End_Home
+ *
+ * @brief Daemon command to end a component server that hosts a component home.
+ */
+ class CMD_End_Home : public Command_Base
+ {
+ public:
+ CMD_End_Home (controller *c);
+
+ virtual ~CMD_End_Home ();
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+
+ void print_usage (const char *name) const;
+
+ private:
+ CORBA::String_var com_server_ior_;
+ };
+ }
+}
+
+
+#if defined (__ACE_INLINE__)
+# include "Softpkg_Commands.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_SOFTPKG_COMMANDS_H */
diff --git a/TAO/CIAO/tools/Daemon/controller_i.h b/TAO/CIAO/tools/Daemon/controller_i.h
new file mode 100644
index 00000000000..6eaff5f944f
--- /dev/null
+++ b/TAO/CIAO/tools/Daemon/controller_i.h
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+// $Id$
+
+/**
+ * @file controller_i.h
+ *
+ * @brief Controller command implementations for CIAO's daemon controller.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+
+#ifndef CIAO_CONTROLLER_I_H
+#define CIAO_CONTROLLER_I_H
+#include /**/ "ace/pre.h"
+
+#include "DaemonC.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace CIAO
+{
+ namespace Daemon_i
+ {
+ class Command_Base;
+
+ /**
+ * @class controller
+ *
+ * @brief Daemon Controller.
+ */
+ class controller
+ {
+ public:
+ controller (void);
+
+ ~controller (void);
+
+ int parse_args (int argc, char *argv[] ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ int init (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+
+ int fini (void);
+
+ void print_usage (void);
+
+ int write_IOR (const char *ior,
+ const char *filename);
+
+ /// Does not increase reference count.
+ Daemon_ptr daemon ();
+ CORBA::ORB_ptr orb ();
+
+ protected:
+ CORBA::ORB_var orb_;
+
+ Command_Base *cmd_;
+
+ Daemon_var daemon_;
+ };
+
+ /**
+ * @class Command
+ *
+ * @brief Abstract base for CIAO daemon controller supported commands.
+ */
+ class Command
+ {
+ public:
+ Command (controller *c);
+
+ virtual ~Command () = 0;
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) = 0;
+
+ protected:
+ controller *controller_;
+ };
+
+ /**
+ * @class Command_Base
+ *
+ * @brief Abstract base for CIAO daemon controller supported commands.
+ */
+ class Command_Base
+ {
+ public:
+ Command_Base (controller *c);
+
+ virtual ~Command_Base () = 0;
+
+ virtual int parse_args (int argc,
+ char *argv[]
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;
+
+ virtual int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) = 0;
+
+ protected:
+ controller *controller_;
+ };
+ }
+}
+
+
+#if defined (__ACE_INLINE__)
+# include "controller_i.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_CONTROLLER_I_H */
diff --git a/TAO/CIAO/tools/ServerActivator/ServerActivator.cpp b/TAO/CIAO/tools/ServerActivator/ServerActivator.cpp
new file mode 100644
index 00000000000..e7747afb208
--- /dev/null
+++ b/TAO/CIAO/tools/ServerActivator/ServerActivator.cpp
@@ -0,0 +1,181 @@
+// $Id$
+
+/**
+ * @file Server_Activator.cpp
+ *
+ * @brief CIAO's server activator implementation
+ *
+ * ServerActivator is the bootstraping mechanism to create new
+ * component servers on the localhost. We currently depend on
+ * starting the ServerActivator process on some specific port of all
+ * the hosts that have ServerActivator install to function properly.
+ */
+
+#include "ServerActivator_Impl.h"
+#include "tao/IORTable/IORTable.h"
+#include "ace/SString.h"
+#include "ace/Read_Buffer.h"
+#include "ace/Get_Opt.h"
+
+char *ior_file_name_ = 0;
+char *comserv_path_ = "../ComponentServer/ComponentServer";
+char *installation_ior_ = 0;
+CORBA::ULong spawn_wait_ = 5;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "n:o:d:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o': // get the file name to write to
+ ior_file_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'n': // get the path name to the component server
+ comserv_path_ = get_opts.opt_arg ();
+ break;
+
+ case 'd': // get the path name to the component server
+ spawn_wait_ = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'i': // get the ior to a ComponentInstallation interface
+ installation_ior_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ "-n <component server pathname>"
+ "-o <ior_output_file>"
+ "-d <time (in second) to wait for component server>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ if (installation_ior_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "An IOR to a ComponentInstallation interface is needed."
+ " Specified with \"-i <ior>\"\n"),
+ -1);
+
+ return 0;
+}
+
+int
+write_IOR(const char* ior)
+{
+ FILE* ior_output_file_ =
+ ACE_OS::fopen (ior_file_name_, "w");
+
+ if (ior_output_file_)
+ {
+ ACE_OS::fprintf (ior_output_file_,
+ "%s",
+ ior);
+ ACE_OS::fclose (ior_output_file_);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ // Get reference to Root POA.
+ CORBA::Object_var obj
+ = orb->resolve_initial_references ("RootPOA"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POA_var poa
+ = PortableServer::POA::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Activate POA manager
+ PortableServer::POAManager_var mgr
+ = poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ mgr->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::ServerActivator_Impl *activator_servant;
+
+ ACE_NEW_RETURN (activator_servant,
+ CIAO::ServerActivator_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ activator_servant->init (comserv_path_,
+ spawn_wait_,
+ installation_ior_,
+ 0,
+ 0
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::ServantBase_var safe_servant (activator_servant);
+
+ CORBA::String_var str = orb->object_to_string (activator_servant->_ciao_get_objref ()
+ ACE_ENV_ARG_PARAMETER);
+
+ CORBA::Object_var table_object =
+ orb->resolve_initial_references ("IORTable"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ IORTable::Table_var adapter =
+ IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (adapter.in ()))
+ {
+ ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
+ }
+ else
+ {
+ adapter->bind ("ServerActivator", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ write_IOR (str.in ());
+ ACE_DEBUG ((LM_INFO, "ServerActivator IOR: %s\n", str.in ()));
+
+ // End Deployment part
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Running ServerActivator...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "server::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/ServerActivator/ServerActivator.mpc b/TAO/CIAO/tools/ServerActivator/ServerActivator.mpc
new file mode 100644
index 00000000000..4cb3912033d
--- /dev/null
+++ b/TAO/CIAO/tools/ServerActivator/ServerActivator.mpc
@@ -0,0 +1,11 @@
+project(ServerActivator): ciao_server, iortable {
+ Source_Files {
+ ServerActivator.cpp
+ }
+}
+
+project(ServerActivator_test_client) : ciao_server {
+ Source_Files {
+ ServerActivator_test_client.cpp
+ }
+}
diff --git a/TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.cpp b/TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.cpp
new file mode 100644
index 00000000000..7fc55d10f6a
--- /dev/null
+++ b/TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.cpp
@@ -0,0 +1,262 @@
+// $Id$
+
+/**
+ * @file Simple_Component_Server.cpp
+ *
+ * This file contains a simple
+ */
+
+#include "ciao/Container_Base.h"
+#include "ace/SString.h"
+#include "ace/Read_Buffer.h"
+#include "ace/Get_Opt.h"
+#include "Simple_Server_i.h"
+
+//#include "ciao/HomeRegistrar_i.h"
+
+char *ior_filename = 0;
+//char *home_registrar_ior = 0;
+char *component_list_ = 0;
+int create_component = 0; // If we need to create a cached component.
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "ci:o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'c': // Create cached component
+ create_component = 1;
+ break;
+
+ case 'o': // get the server IOR output filename
+ ior_filename = get_opts.opt_arg ();
+ break;
+
+ case 'i': // get component configuration
+ component_list_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-c instantiate the component"
+ "-i <component config file>\n"
+ "-o <server_ior_output_file>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+write_IOR(const char *ior)
+{
+ if (ior_filename == 0 || ior == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "A valid filename and an IOR string are required for saving IOR\n"),
+ -1);
+
+
+ FILE* ior_output_file_ =
+ ACE_OS::fopen (ior_filename, "w");
+
+ if (ior_output_file_ == NULL)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to open <%s> for writing\n", ior_filename),
+ -1);
+
+ ACE_OS::fprintf (ior_output_file_,
+ "%s",
+ ior);
+
+ ACE_OS::fclose (ior_output_file_);
+
+ return 0;
+}
+
+int breakdown (char *source,
+ int len,
+ char *list[])
+{
+ ACE_Tokenizer line (source);
+ line.delimiter_replace ('|', 0);
+
+ int cntr = 0;
+ char *p;
+ for (p = line.next ();
+ p && cntr < len;
+ ++cntr, p=line.next ())
+ // @@ More memory leaks?
+ list[cntr] = ACE::strnew (p);
+
+ return cntr;
+}
+
+Components::CCMHome_ptr
+install_homes (CIAO::Session_Container &container,
+ CORBA::ORB_ptr orb
+ ACE_ENV_ARG_DECL)
+{
+ ACE_UNUSED_ARG (orb);
+
+ if (component_list_ == 0)
+ ACE_THROW (CORBA::BAD_PARAM ());
+
+ FILE* config_file =
+ ACE_OS::fopen (component_list_, "r");
+
+ if (config_file)
+ {
+ ACE_Read_Buffer ior_buffer (config_file);
+ char *data = 0;
+
+ if ((data = ior_buffer.read ('\n')) != 0)
+ {
+ char *items[10];
+ auto_ptr<char> an_entry (data);
+ int len = breakdown (an_entry.get (),
+ 10,
+ items);
+
+ if (len < 4) // we only need the first 4 fields now.
+ {
+ ACE_DEBUG ((LM_DEBUG, "Error parsing configuration file\n"));
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+ }
+
+ // len should be at least such and such long so we have all
+ // the information we need. These items are separate with
+ // character '|'.
+
+ // 0 -> DLL path to home executor
+ // 1 -> entry point for home executor factory
+ // 2 -> DLL path to servant glue code
+ // 3 -> entry point for servant glue code factory
+
+ // we are not using these until we support HomeFinder.
+
+ // 4 -> Repository ID for home interface
+ // 5 -> Repository ID for managed component
+ // 6 -> Canonical Name of home interface.
+
+ Components::CCMHome_var home =
+ container.ciao_install_home (items[0],
+ items[1],
+ items[2],
+ items[3]
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (CORBA::is_nil (home.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "Fail to create home\n"));
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+ }
+ return home._retn ();
+ }
+ }
+ ACE_OS::fclose (config_file);
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ // Get reference to Root POA.
+ CORBA::Object_var obj
+ = orb->resolve_initial_references ("RootPOA"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POA_var poa
+ = PortableServer::POA::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Activate POA manager
+ PortableServer::POAManager_var mgr
+ = poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ mgr->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Start Deployment part
+
+ CIAO::Session_Container container (orb.in ());
+ container.init ();
+
+ // install component
+
+ Components::CCMHome_var home =
+ install_homes (container,
+ orb.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Simple_Server_i *servant = 0;
+ ACE_NEW_RETURN (servant,
+ CIAO::Simple_Server_i (orb.in (),
+ poa.in (),
+ home.in ()),
+ -1);
+ PortableServer::ServantBase_var safe_daemon (servant);
+ // Implicit activation
+ CIAO::Simple_Server_var server = servant->_this ();
+
+ CORBA::String_var str;
+ Components::CCMObject_var temp;
+
+ if (create_component != 0)
+ {
+ temp = server->get_component (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ str = orb->object_to_string (temp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ else
+ {
+ str = orb->object_to_string (server.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ write_IOR (str.in ());
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Running the simple generic server...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "server::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.mpc b/TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.mpc
new file mode 100644
index 00000000000..eb1f0b5c800
--- /dev/null
+++ b/TAO/CIAO/tools/Simple_Component_Server/Simple_Component_Server.mpc
@@ -0,0 +1,40 @@
+project (Simple_Server_Stub) : taolib_with_idl, ciao_client {
+ sharedname = CIAO_Simple_Server_Stub
+ idlflags += -Wb,stub_export_include=Simple_Server_Stub_Export.h -Wb,stub_export_macro=CIAO_SIMPLE_SERVER_STUB_Export
+ dynamicflags = CIAO_SIMPLE_SERVER_STUB_BUILD_DLL
+
+ IDL_Files {
+ Simple_Server.idl
+ }
+
+ Source_Files {
+ Simple_ServerC.cpp
+ }
+}
+
+project (Simple_Component_Server) : ciao_server {
+ after += Simple_Server_Stub
+ libs += CIAO_Simple_Server_Stub
+ exename = Simple_Component_Server
+
+ Source_Files {
+ Simple_ServerS.cpp
+ Simple_Server_i.cpp
+ Simple_Component_Server.cpp
+ }
+}
+
+// Use the following settings as a blueprint for creating client project.
+project (Simple_Component_Server_test_client) : ciao_server {
+ after += Simple_Server_Stub
+ libs += CIAO_Simple_Server_Stub
+ libpaths += $(CIAO_ROOT)/tools/Simple_Component_Server
+ exename = sample_client
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ sample_client.cpp
+ }
+}
diff --git a/TAO/CIAO/tools/Simple_Component_Server/Simple_Server_i.h b/TAO/CIAO/tools/Simple_Component_Server/Simple_Server_i.h
new file mode 100644
index 00000000000..02c4972c4d7
--- /dev/null
+++ b/TAO/CIAO/tools/Simple_Component_Server/Simple_Server_i.h
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Simple_Server_i.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_SIMPLE_SERVER_I_H
+#define CIAO_SIMPLE_SERVER_I_H
+#include /**/ "ace/pre.h"
+
+#include "Simple_ServerS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace CIAO
+{
+ class Simple_Server_i
+ : public virtual POA_CIAO::Simple_Server,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ /// Constructor
+ Simple_Server_i (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ Components::CCMHome_ptr h);
+
+ /// Destructor
+ virtual ~Simple_Server_i (void);
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ virtual Components::CCMHome_ptr
+ get_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual Components::CCMObject_ptr
+ get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// Cached CCMHome reference.
+ Components::CCMHome_var home_;
+
+ /// Cached CCMObject reference.
+ Components::CCMObject_var component_;
+ };
+}
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_SIMPLE_SERVER_H */
diff --git a/TAO/CIAO/tools/Simple_Component_Server/sample_client.cpp b/TAO/CIAO/tools/Simple_Component_Server/sample_client.cpp
new file mode 100644
index 00000000000..959c1f56ead
--- /dev/null
+++ b/TAO/CIAO/tools/Simple_Component_Server/sample_client.cpp
@@ -0,0 +1,84 @@
+// $Id$
+
+#include "tools/Simple_Component_Server/Simple_ServerC.h"
+#include "ace/Get_Opt.h"
+#include "ace/Read_Buffer.h"
+#include "ace/streams.h"
+
+// @@ Include component stub file here:
+//#include "helloC.h"
+
+char *ior = 0;
+int shutdown_server = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "i:s");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 's': // Shutdown server when exit?
+ shutdown_server = 1;
+ break;
+
+ case 'i': // get component configuration
+ ior = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-i <simple server ior>\n"
+ "-s shutdown server when exit\n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv ACE_ENV_ARG_PARAMETER);
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ CORBA::Object_var obj
+ = orb->string_to_object (ior ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Simple_Server_var cserve
+ = CIAO::Simple_Server::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ /// @@ Use cserve->get_home () or cserve->get_component ()
+ /// and do your stuff to test the component here.
+
+ if (shutdown_server != 0)
+ cserve->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Who is the culprit \n");
+ cerr << "Uncaught CORBA exception" << endl;
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/XML_Helpers/Cascadable_DocHandler.h b/TAO/CIAO/tools/XML_Helpers/Cascadable_DocHandler.h
new file mode 100644
index 00000000000..6bb7b0f1428
--- /dev/null
+++ b/TAO/CIAO/tools/XML_Helpers/Cascadable_DocHandler.h
@@ -0,0 +1,252 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Cascadable_DocHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef CIAO_XMLHELPERS_CASCADABLE_DOCHANDLER_H
+#define CIAO_XMLHELPERS_CASCADABLE_DOCHANDLER_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/DefaultHandler.h"
+#include "ACEXML/common/XMLReader.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace CIAO
+{
+ namespace XMLHelpers
+ {
+ /**
+ * @class Cascadable_DocHandler
+ *
+ * @brief A helper class for implementing cascadable XML Document Handler.
+ *
+ * This class is available as a convenience base class for writing
+ * cascadable XML Document DefaultHandler. This class implement
+ * the basic functionality for DocHandlers that can be cascaded
+ * together to handling nested XML tags. Users can write specific
+ * handlers to handle specific XML elements so they can be
+ * composed together to handle complex XML definitions. This
+ * class utilize the "Interpreter" design pattern as described in
+ * GoF.
+ *
+ * Application writers should extend this class to implement a
+ * handler that interpret a specific XML element. There are just
+ * a few rules to use the Cascadable_DocHandler.
+ *
+ * 1. A Cascadable_DocHandler determines whether a new
+ * Cascadable_DocHandler should be used to handle a subelement
+ * in its startElement method. When it encounter a subelement
+ * that requires a different implementation of
+ * Cascadable_DocHandler, it should create the new
+ * Cascadable_DocHandler, and then invoke the @c push_handler
+ * method to inform the @c parser to use the new handler (this
+ * in effect switches all four handlers the parse uses to the
+ * new handler.)
+ *
+ * 2. A Cascadable_DocHandler determines whether it has done
+ * handling an element structure in @a endElement method, it
+ * invoke the pop_handler method of its parent handler. The
+ * pop_handler in turn invokes the endElement eventhandler of
+ * the parent handler so it has a chance to harvest the parse
+ * result from the child handler.
+ *
+ * See the Handler-Interaction.png for how handlers interact with
+ * each other.
+ *
+ * @sa ACEXML_DefaultHandler
+ * @sa DocHandler_Context
+ */
+ class Cascadable_DocHandler : public ACEXML_DefaultHandler
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Cascadable_DocHandler (ACEXML_XMLReader *parser,
+ Cascadable_DocHandler *parent,
+ const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /**
+ * destructor.
+ */
+ virtual ~Cascadable_DocHandler (void);
+
+ /**
+ * Destroy method.
+ */
+ virtual void destroy ();
+
+ /**
+ * THIS function should be called by the @c startElement method
+ * of the parent Handler to replace it (the current *Handlers)
+ * the parser is using with the this Handler. This method will
+ * also invoke the startElement operations of this Handler.
+ *
+ * @@ I haven't figured out what should happen if an exception
+ * occurs in push_handler. It can either restore the original
+ * handler, or let the user decide what to do.
+ */
+ void push_handler (Cascadable_DocHandler *new_handler,
+ ACEXML_Attributes *atts
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /**
+ * This function should be called at the end of @c endElement
+ * method of this Handler to restore the Handler's used by the
+ * parser. This method aldo invokes the @c endElement method of
+ * the parent Handler before restoring the parser Handlers.
+ * This allows the parent handler to have a chance to harvest
+ * the parse result from this Handler. @c pop_handler will
+ * eventually invoke the @c destroy method of child handler.
+ * Since @c pop_handler should be invoked from child handler's
+ * @c endElement method, care should be taken to avoid accessing
+ * free'ed memory after calling parent's @c pop_handler method.
+ */
+ void pop_handler (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /**
+ * Accessors for the element Context we are in. Make copy if
+ * you need to store the return strings for later use.
+ */
+ const ACEXML_Char *namespaceURI (void) const;
+ const ACEXML_Char *localName (void) const;
+ const ACEXML_Char *qName (void) const;
+
+ /**
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /**
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ protected:
+ /**
+ * Print out an error/warning message
+ */
+ virtual void print_warning (const ACEXML_Char *level,
+ ACEXML_SAXParseException &exception
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Element tag information.
+ */
+ ACEXML_Char *namespaceURI_;
+ ACEXML_Char *localName_;
+ ACEXML_Char *qName_;
+
+ /// Pointer to the parser that send us events.
+ ACEXML_XMLReader *parser_;
+
+ /// Pointer to the parent event handler that handles the parent
+ /// element.
+ Cascadable_DocHandler *parent_;
+
+ /// Pointer to the child event handler that handles a sub-element.
+ Cascadable_DocHandler *child_;
+
+ private:
+ /// No implement
+ Cascadable_DocHandler ();
+
+ /// Pointer to Locator.
+ ACEXML_Locator* locator_;
+ };
+
+ /**
+ * @class Skip_DocHandler
+ *
+ * @brief This DocHandler ignore and skip over a specific tag.
+ */
+ class Skip_DocHandler : public Cascadable_DocHandler
+ {
+ public:
+ /// Constructor.
+ Skip_DocHandler (ACEXML_XMLReader *parser,
+ Cascadable_DocHandler *parent,
+ const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /// Destructor
+ virtual ~Skip_DocHandler ();
+
+ /**
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /**
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ protected:
+ long element_count_;
+ };
+
+ }
+}
+
+#if defined (__ACE_INLINE__)
+# include "Cascadable_DocHandler.i"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_XMLHELPERS_CASCADABLE_DOCHANDLER_H */
diff --git a/TAO/CIAO/tools/XML_Helpers/XMLHelpers.mpc b/TAO/CIAO/tools/XML_Helpers/XMLHelpers.mpc
new file mode 100644
index 00000000000..5699408b442
--- /dev/null
+++ b/TAO/CIAO/tools/XML_Helpers/XMLHelpers.mpc
@@ -0,0 +1,21 @@
+project(XML_Helpers): acelib, acexml {
+ sharedname=CIAO_XML_Helpers
+ dynamicflags += CIAO_XML_HELPERS_BUILD_DLL
+
+ Source_Files {
+ XML_Utils.cpp
+ Softpkg_Handlers.cpp
+ Cascadable_DocHandler.cpp
+ Assembly_Spec.cpp
+ Assembly_Handlers.cpp
+ }
+}
+
+project(Helper_Test): aceexe, acexml {
+ libs += CIAO_XML_Helpers
+ after += XML_Helpers
+
+ Source_Files {
+ main.cpp
+ }
+}
diff --git a/TAO/CIAO/tools/XML_Helpers/svc.conf.xml b/TAO/CIAO/tools/XML_Helpers/svc.conf.xml
new file mode 100644
index 00000000000..059b0447a56
--- /dev/null
+++ b/TAO/CIAO/tools/XML_Helpers/svc.conf.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!-- This is a test XML file. Most of the stuff here don't make any sense at all -->
+<!DOCTYPE ACE_Svc_Conf PUBLIC 'GOODSAM' '../../../../ACEXML/apps/svcconf/svcconf.dtd'
+ [
+ <!NOTATION goody PUBLIC 'NBC' 'http://hardcoreace.com/'>
+ <!NOTATION frodo PUBLIC 'ABC'>
+ <!NOTATION bilbo SYSTEM "C:/ACE-GUIDELINE">
+ <!ENTITY ccm 'CCM_App'>
+ <!ENTITY pippin PUBLIC 'GOTO' 'http://taozen.com/' NDATA goody>
+ <!ENTITY sam PUBLIC 'SHIRE' 'http://taozen.com/'>
+ <!ENTITY gandolf SYSTEM 'D:/RINGS.DOT'>
+ <!ELEMENT GOOBEGONE EMPTY>
+ <!ELEMENT POOPOO ANY>
+ <!ELEMENT HOHOHO ((BOOBOO, GOOBEGONE)?, (GOOBEGONE|POOPOO)*)+>
+ <!ELEMENT BOOBOO (#PCDATA | BOOBOO)*>
+ <!ATTLIST GOOBEGONE
+ ohmy CDATA #REQUIRED
+ testing IDREF #IMPLIED>
+ ]>
+
+<ACE_Svc_Conf>
+<static id="ACE_Service_Manager" params="-d -p 4911"/>
+
+<dynamic id="Test_Task" type="service_object"> &#65; &amp;
+ <initializer path="CCM_App" init="_make_Test_Task" params="-p 3000" />
+</dynamic>
+
+<streamdef>
+ <dynamic id="CCM_App" type="stream" status="active">
+ <initializer path="CCM_App" init="make_stream"/>
+ </dynamic>
+ <module>
+ <dynamic id="Device_Adapter" type="module">
+ <initializer path="CCM_App" init="make_da"/>
+ </dynamic>
+ <dynamic id="Event_Analyzer" type="module">
+ <initializer path="CCM_App" init="make_ea"/>
+ </dynamic>
+ <dynamic id="Multicast_Router" type="module">
+ <initializer path="CCM_App" init="make_mr" params="-p 3001"/>
+ </dynamic>
+ </module>
+</streamdef>
+
+<stream id="&ccm;">
+ <module>
+ <remove id="Device_Adapter"/>
+ <!-- <remove id="Event_Analyzer"/> -->
+ <!-- <remove id="Multicast_Router"/> -->
+ <![CDATA[Only a text string.
+Do you &amp;expect something more? &#65;]]>
+<!-- Noticed that the "&amp;" in the above CDATA section can not be escaped. -->
+ </module>
+</stream>
+
+<!-- remove CCM_App -->
+<remove id="Test_&amp;Task&#x61;bc"/>
+</ACE_Svc_Conf>
diff --git a/TAO/CIAO/tools/tools.mwc b/TAO/CIAO/tools/tools.mwc
new file mode 100644
index 00000000000..bb521631565
--- /dev/null
+++ b/TAO/CIAO/tools/tools.mwc
@@ -0,0 +1,2 @@
+workspace {
+} \ No newline at end of file