diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-04 22:27:43 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-04 22:27:43 +0000 |
commit | 09e0571acdf0b862e3ec2f40c9f7d3c64ff3b36f (patch) | |
tree | 8d9a6fdd1ba38a6492a47cde96b3564ae6ab2619 | |
parent | 8fd2fff19c2c2a36611af3b4def8e714904358fa (diff) | |
download | ATCD-09e0571acdf0b862e3ec2f40c9f7d3c64ff3b36f.tar.gz |
backup
20 files changed, 860 insertions, 35 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index a7220c27815..546c59bc208 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,25 @@ +Fri Apr 04 16:26:16 2003 Nanbor Wang <nanbor@cs.wustl.edu> + + M examples/handcrafted/Display/CIAO_Installation_Data.ini + M examples/handcrafted/Display/NavDisplay/NavDisplay_exec.cpp + A tools/Assembly_Deployer/Assembly_Deployer.cpp + M tools/Assembly_Deployer/Assembly_Deployer.mpc + M tools/Assembly_Deployer/Assembly_Impl.cpp + M tools/Assembly_Deployer/Assembly_Impl.h + M tools/Assembly_Deployer/Assembly_Impl.inl + A tools/Assembly_Deployer/Assembly_Manager.cpp + A tools/Assembly_Deployer/Assembly_Visitors.h + A tools/Assembly_Deployer/Assembly_Visitors.inl + A tools/Assembly_Deployer/Deployment_Configuration.cpp + A tools/Assembly_Deployer/Deployment_Configuration.h + A tools/Assembly_Deployer/Deployment_Configuration.inl + M tools/Daemon/Daemon.mpc + M tools/Daemon/DaemonController.dsp + M tools/XML_Helpers/Assembly_Handlers.cpp + M tools/XML_Helpers/Assembly_Spec.cpp + M tools/XML_Helpers/Assembly_Spec.h + M tools/XML_Helpers/Assembly_Spec.inl + Thu Apr 03 15:08:20 2003 Nanbor Wang <nanbor@cs.wustl.edu> * ciao/Assembly_Impl.*: diff --git a/TAO/CIAO/examples/handcrafted/Display/CIAO_Installation_Data.ini b/TAO/CIAO/examples/handcrafted/Display/CIAO_Installation_Data.ini index 386a8c633ec..cc1a16affd5 100644 --- a/TAO/CIAO/examples/handcrafted/Display/CIAO_Installation_Data.ini +++ b/TAO/CIAO/examples/handcrafted/Display/CIAO_Installation_Data.ini @@ -2,7 +2,7 @@ DCE:75309233-0E0A-4cfb-B186-3E99F69B1D40=GPS_svnt DCE:82C2B032-37F0-4315-A59F-7020D3264E4D=RateGen_exec DCE:93D254CF-9538-44e8-BB98-AABCD134ADD3=RateGen_svnt -DCE:CDC06FCA-50FC-43ca-8ECC-BEFBD33FEE78=NavDisplay_svnt DCE:8E6C468D-A39F-46b4-962B-265F1AA8D538=NavDisplay_exec -DCE:D7984625-8561-431d-9927-4E498B317C02=NavDisplayGUI_exec +DCE:CDC06FCA-50FC-43ca-8ECC-BEFBD33FEE78=NavDisplay_svnt DCE:3148F760-F2ED-4204-A775-6B972C10E8CB=GPS_exec +DCE:D7984625-8561-431d-9927-4E498B317C02=NavDisplayGUI_exec diff --git a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_exec.cpp b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_exec.cpp index d68570cf158..52c8670ad5d 100644 --- a/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_exec.cpp +++ b/TAO/CIAO/examples/handcrafted/Display/NavDisplay/NavDisplay_exec.cpp @@ -25,10 +25,13 @@ MyImpl::NavDisplay_exec_impl::push_Refresh (HUDisplay::tick_ptr ev = this->context_->get_connection_GPSLocation (ACE_ENV_ARG_PARAMETER); ACE_CHECK; + if (CORBA::is_nil (loc.in ())) + ACE_THROW (CORBA::BAD_INV_ORDER ()); + CORBA::Long position = loc->pos (ACE_ENV_ARG_PARAMETER); ACE_CHECK; - ACE_DEBUG ((LM_DEBUG, "DISPLAY: Current Location is: %d\n")); + ACE_DEBUG ((LM_DEBUG, "DISPLAY: Current Location is: %d\n", position)); } // Operations from Components::SessionComponent 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..6d16f7cc7c0 --- /dev/null +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.cpp @@ -0,0 +1,117 @@ +// $Id$ + +#include "CCM_DeploymentC.h" +#include "Client_init.h" +#include "ace/Get_Opt.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; + + ::Components::Deployment::AssemblyFactory_var factory = + ::Components::Deployment::AssemblyFactory::_narrow(tmp.in () + ACE_ENV_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; + + 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 index 0d417a3aa0d..3bea7c9d71e 100644 --- a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.mpc +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Deployer.mpc @@ -1,9 +1,23 @@ -project(Assembly_Manager): server, ciao_server { +project(Assembly_Manager): ciao_server, acexml { libs += TAO_IORTable libpaths += $(TAO_ROOT)/tao/IORTable Source_Files { + Assembly_Impl.cpp + Assembly_Visitors.cpp Deployment_Configuration.cpp + Assembly_Manager.cpp // Main + ../XML_Helpers/XML_Utils.cpp + ../XML_Helpers/Softpkg_Handlers.cpp + ../XML_Helpers/Cascadable_DocHandler.cpp + ../XML_Helpers/Assembly_Spec.cpp + ../XML_Helpers/Assembly_Handlers.cpp } } + +project(Assembly_Deployer) : ciao_server { + Source_Files { + Assembly_Deployer.cpp + } +}
\ No newline at end of file diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.cpp b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.cpp index e09564cd4b5..ce3550ebb97 100644 --- a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.cpp +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.cpp @@ -3,6 +3,8 @@ #include "Assembly_Impl.h" //#include "ACtive_Objref_Map.h" #include "Cookies.h" +#include "../XML_Helpers/Assembly_Spec.h" +#include "../XML_Helpers/XML_Utils.h" #if !defined (__ACE_INLINE__) # include "Assembly_Impl.inl" @@ -20,17 +22,11 @@ CIAO::AssemblyFactory_Impl::_default_POA (void) } int -CIAO::AssemblyFactory_Impl::init (ACE_ENV_ARG_DECL) +CIAO::AssemblyFactory_Impl::init (const char *init_file + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - // @@ Initialize AssemblyFactory and create the internal container - // implementation that actually interacts with installed - // homes/components. - - // We will probably need two ORBs in this process. One for the - // deployment framework, and one for the actual components. - - return 0; + return this->deployment_config_.init (init_file); } ::Components::Cookie * @@ -40,12 +36,21 @@ CIAO::AssemblyFactory_Impl::create_assembly (const char * assembly_loc Components::Deployment::InvalidLocation, Components::CreateFailure)) { - ACE_UNUSED_ARG (assembly_loc); + CIAO::Assembly_Spec *assembly_spec; + ACE_NEW_RETURN (assembly_spec, + CIAO::Assembly_Spec, + 0); + + if (CIAO::XML_Utils::parse_componentassembly (assembly_loc, + assembly_spec) != 0) + ACE_THROW_RETURN (Components::Deployment::InvalidLocation (), 0); CIAO::Assembly_Impl *servant = 0; ACE_NEW_RETURN (servant, CIAO::Assembly_Impl (this->orb_.in (), - this->poa_.in ()), + this->poa_.in (), + assembly_spec, + this->deployment_config_), 0); PortableServer::ServantBase_var save_servant (servant); @@ -80,7 +85,7 @@ CIAO::AssemblyFactory_Impl::create_assembly (const char * assembly_loc ::Components::Deployment::Assembly_ptr CIAO::AssemblyFactory_Impl::lookup (Components::Cookie * c - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::Deployment::InvalidAssembly)) { @@ -101,7 +106,7 @@ CIAO::AssemblyFactory_Impl::lookup (Components::Cookie * c void CIAO::AssemblyFactory_Impl::destroy (Components::Cookie * c - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::Deployment::InvalidAssembly, Components::RemoveFailure)) @@ -135,6 +140,8 @@ CIAO::AssemblyFactory_Impl::destroy (Components::Cookie * c this->poa_->deactivate_object (oid ACE_ENV_ARG_PARAMETER); + + this->orb_->shutdown (); } @@ -142,10 +149,13 @@ CORBA::ULong CIAO::Assembly_Impl::assembly_count_ = 0; CIAO::Assembly_Impl::~Assembly_Impl () { - // @@ remove all Containers? + // @@ tearing down everything? + ACE_DEBUG ((LM_DEBUG, "CIAO::Assembly_Impl::~Assembly_Impl %d\n", this->serial_number_)); + + delete this->assembly_spec_; } PortableServer::POA_ptr @@ -155,7 +165,7 @@ CIAO::Assembly_Impl::_default_POA (void) } int -CIAO::Assembly_Impl::init (ACE_ENV_ARG_DECL) +CIAO::Assembly_Impl::init (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { // @@ Initialize Assembly and create the internal container @@ -174,8 +184,19 @@ CIAO::Assembly_Impl::build (ACE_ENV_SINGLE_ARG_DECL) ACE_DEBUG ((LM_DEBUG, "CIAO::Assembly_Impl::build %d\n", this->serial_number_)); + if (this->state_ == Components::Deployment::INSERVICE) + return; // We are running already. - // @@ Well, we need to actually buid something here. + ACE_DEBUG ((LM_DEBUG, "------------------------------------\n")); + + CIAO::Assembly_Builder_Visitor builder (this->orb_.in (), + this->assembly_context_, + this->deployment_config_); + int build_result = this->assembly_spec_->partitioning_.accept (builder); + + ACE_DEBUG ((LM_DEBUG, "------------------------------------\n")); + + // @@ Connect components. this->state_ = ::Components::Deployment::INSERVICE; } @@ -188,6 +209,10 @@ CIAO::Assembly_Impl::tear_down (ACE_ENV_SINGLE_ARG_DECL) ACE_DEBUG ((LM_DEBUG, "CIAO::Assembly_Impl::tear_down %d\n", this->serial_number_)); + if (this->state_ != Components::Deployment::INSERVICE) + return; // Nothing to do here. + + // @@ At least we should remove home and kill the component server. this->state_ = ::Components::Deployment::INACTIVE; } diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h index b26a3a424bc..007482b094d 100644 --- a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.h @@ -15,8 +15,8 @@ //============================================================================= -#ifndef CIAO_SERVERACTIVATOR_IMPL_H -#define CIAO_SERVERACTIVATOR_IMPL_H +#ifndef CIAO_ASSEMBLY_IMPL_H +#define CIAO_ASSEMBLY_IMPL_H #include "ace/pre.h" #include "ace/config-all.h" @@ -27,6 +27,9 @@ #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 { @@ -40,7 +43,7 @@ namespace CIAO * implies, this is actually part of the deployment interface and is * used to manage the lifecycle of containers running on the server. */ - class CIAO_SERVER_Export AssemblyFactory_Impl + class AssemblyFactory_Impl : public virtual POA_Components::Deployment::AssemblyFactory, public virtual PortableServer::RefCountServantBase { @@ -56,8 +59,10 @@ namespace CIAO /// increase the reference count of the POA. virtual PortableServer::POA_ptr _default_POA (void); - /// Initialize the AssemblyFactory. - int init (ACE_ENV_ARG_DECL_WITH_DEFAULTS) + /// 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. @@ -87,6 +92,9 @@ namespace CIAO /// 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_; }; /** @@ -99,14 +107,16 @@ namespace CIAO * implies, this is actually part of the deployment interface and is * used to manage the lifecycle of containers running on the server. */ - class CIAO_SERVER_Export Assembly_Impl + 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); + PortableServer::POA_ptr p, + Assembly_Spec *spec, + Deployment_Configuration &config); /// Destructor virtual ~Assembly_Impl (void); @@ -115,8 +125,12 @@ namespace CIAO /// increase the reference count of the POA. virtual PortableServer::POA_ptr _default_POA (void); - /// Initialize the Assembly. - int init (ACE_ENV_ARG_DECL_WITH_DEFAULTS) + /** + * 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. @@ -147,6 +161,14 @@ namespace CIAO /// <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_; }; } @@ -155,4 +177,4 @@ namespace CIAO #endif /* __ACE_INLINE__ */ #include "ace/post.h" -#endif /* CIAO_SERVERACTIVATOR_IMPL_H */ +#endif /* CIAO_ASSEMBLY_IMPL_H */ diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.inl b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.inl index 94cce8b0d17..b6abaa37513 100644 --- a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.inl +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Impl.inl @@ -5,17 +5,22 @@ ACE_INLINE CIAO::AssemblyFactory_Impl::AssemblyFactory_Impl (CORBA::ORB_ptr o, PortableServer::POA_ptr p) : orb_ (CORBA::ORB::_duplicate (o)), - poa_ (PortableServer::POA::_duplicate (p)) + poa_ (PortableServer::POA::_duplicate (p)), + deployment_config_ (o) { } ACE_INLINE CIAO::Assembly_Impl::Assembly_Impl (CORBA::ORB_ptr o, - PortableServer::POA_ptr p) + PortableServer::POA_ptr p, + Assembly_Spec *spec, + Deployment_Configuration &config) : orb_ (CORBA::ORB::_duplicate (o)), poa_ (PortableServer::POA::_duplicate (p)), state_ (::Components::Deployment::INACTIVE), - serial_number_ (++CIAO::Assembly_Impl::assembly_count_) + serial_number_ (++CIAO::Assembly_Impl::assembly_count_), + deployment_config_ (config), + assembly_spec_ (spec) { ACE_DEBUG ((LM_DEBUG, "CIAO::Assembly_Impl::Assembly_Impl %d\n", diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Manager.cpp b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Manager.cpp new file mode 100644 index 00000000000..7a7db70f26d --- /dev/null +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Manager.cpp @@ -0,0 +1,187 @@ +// $Id$ + +/** + * @file Assembly_Manager.cpp + * + * @brief CIAO's Assembly managing process. + * + */ + +#include "Assembly_Impl.h" +#include "CIAO_ServersC.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 *config_filename_ = 0; +char *output_ior_filename_ = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "c:o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'c': // Get the configuration file for deployment configuration info. + config_filename_ = get_opts.opt_arg (); + break; + + case 'o': // get the file name to write to + output_ior_filename_ = get_opts.opt_arg (); + break; + + case '?': // display help for use of the server. + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + "-c <deployment configuration file>" + "-o <ior_output_file>" + "\n", + argv [0]), + -1); + } + + if (config_filename_ == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Require a deployment configuration flag. Use -c to set it \n" + ), + -1); + } + + return 0; +} + +int +write_IOR(const char* ior) +{ + FILE* ior_output_file_ = + ACE_OS::fopen (output_ior_filename_, "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; + + // 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::AssemblyFactory_Impl *assembly_factory_servant; + + ACE_NEW_RETURN (assembly_factory_servant, + CIAO::AssemblyFactory_Impl (orb.in (), + poa.in ()), + -1); + + PortableServer::ServantBase_var safe_servant (assembly_factory_servant); + + assembly_factory_servant->init (config_filename_ + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Configuring AssemblyFactory. + PortableServer::ObjectId_var cs_oid + = poa->activate_object (assembly_factory_servant + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + obj = poa->id_to_reference (cs_oid + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ::Components::Deployment::AssemblyFactory_var assembly_factory_obj = + ::Components::Deployment::AssemblyFactory::_narrow (obj + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (assembly_factory_obj.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Unable to activate ComponentServer object\n"), -1); + + + CORBA::String_var str = orb->object_to_string (assembly_factory_obj.in () + 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 ("AssemblyFactory", str.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + write_IOR (str.in ()); + ACE_DEBUG ((LM_INFO, "Assembly_Manager IOR: %s\n", str.in ())); + + // End Deployment part + + ACE_DEBUG ((LM_DEBUG, + "Running Assembly_Manager...\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, + "Assembly_Manager::main\t\n"); + return 1; + } + ACE_ENDTRY; + + return 0; +} 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..1f2fdd09378 --- /dev/null +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h @@ -0,0 +1,98 @@ +// -*- 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 + { + ACE_Hash_Map_Manager_Ex<ACE_CString, + Components::CCMHome_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> installed_homes_; + + ACE_Hash_Map_Manager_Ex<ACE_CString, + Components::CCMObject_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> instantiated_components_; + } 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, + Deployment_Configuration &config); + + /// Destructor + virtual ~Assembly_Builder_Visitor (void); + + virtual int visit_Container (Assembly_Placement::Container *c); + + virtual int visit_hostcollocation (Assembly_Placement::hostcollocation *hc); + + virtual int visit_processcollocation (Assembly_Placement::processcollocation *pc); + + virtual int visit_homeplacement (Assembly_Placement::homeplacement *hp); + + virtual int visit_componentinstantiation (Assembly_Placement::componentinstantiation *ci); + + protected: + /// Keep a pointer to the managing ORB serving this servant. + CORBA::ORB_var orb_; + + /// Context to build on. + Assembly_Context &context_; + + /// Deployment Configuration Info. + Deployment_Configuration &deployment_config_; + }; +} + +#if defined (__ACE_INLINE__) +# include "Assembly_Visitor.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* CIAO_ASSEMBLY_VISITOR_H */ diff --git a/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.inl b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.inl new file mode 100644 index 00000000000..971f2e3197d --- /dev/null +++ b/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.inl @@ -0,0 +1,10 @@ +// $Id$ + +CIAO::Assembly_Builder_Visitor::Assembly_Builder_Visitor (CORBA::ORB_ptr o, + Assembly_Context &context, + Deployment_Configuration &config) + : orb_ (CORBA::ORB::_duplicate (o)), + context_ (context), + deployment_config_ (config) +{ +} 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..d546e0756b8 --- /dev/null +++ b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.cpp @@ -0,0 +1,118 @@ +// $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 data file.\n"), -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..5bda09c988b --- /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/Assembly_Deployer/Deployment_Configuration.inl b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/CIAO/tools/Assembly_Deployer/Deployment_Configuration.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/CIAO/tools/Daemon/Daemon.mpc b/TAO/CIAO/tools/Daemon/Daemon.mpc index dfb95f30b8c..a6fe27e7e31 100644 --- a/TAO/CIAO/tools/Daemon/Daemon.mpc +++ b/TAO/CIAO/tools/Daemon/Daemon.mpc @@ -18,5 +18,7 @@ project(DaemonController) : ciao_server, acexml { ../XML_Helpers/XML_Utils.cpp ../XML_Helpers/Softpkg_Handlers.cpp ../XML_Helpers/Cascadable_DocHandler.cpp + ../XML_Helpers/Assembly_Handlers.cpp + ../XML_Helpers/Assembly_Spec.cpp } } diff --git a/TAO/CIAO/tools/Daemon/DaemonController.dsp b/TAO/CIAO/tools/Daemon/DaemonController.dsp index d5fa4252911..8b2996a3f9c 100644 --- a/TAO/CIAO/tools/Daemon/DaemonController.dsp +++ b/TAO/CIAO/tools/Daemon/DaemonController.dsp @@ -44,7 +44,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /machine:IX86
-# ADD LINK32 advapi32.lib user32.lib CIAO_Server.lib TAO_PortableServer.lib TAO_Security.lib CIAO_Container.lib TAO.lib TAO_IFR_Client.lib CIAO_Client.lib ACE.lib ACEXML.lib ACEXML_Parser.lib /nologo /version:1.3 /subsystem:console /machine:I386 /out:"DaemonController.exe" /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer" /libpath:"..\..\..\tao\IFR_Client" /libpath:"..\..\ciao" /libpath:"..\..\..\orbsvcs\orbsvcs" /libpath:"..\..\..\..\ACEXML\Common" /libpath:"..\..\..\..\ACEXML\parser\parser"
+# ADD LINK32 advapi32.lib user32.lib CIAO_Server.lib TAO_PortableServer.lib TAO_Security.lib CIAO_Container.lib TAO.lib TAO_IFR_Client.lib CIAO_Client.lib ACE.lib ACEXML.lib ACEXML_Parser.lib /nologo /version:1.3 /subsystem:console /machine:I386 /out:"DaemonController.exe" /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer" /libpath:"..\..\..\tao\IFR_Client" /libpath:"..\..\ciao" /libpath:"..\..\..\orbsvcs\orbsvcs" /libpath:"..\..\..\..\ACEXML\Common" /libpath:"..\..\..\..\ACEXML\parser\parser"
!ELSEIF "$(CFG)" == "DaemonController EXE - Win32 Debug"
@@ -62,7 +62,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /machine:IX86
-# ADD LINK32 advapi32.lib user32.lib CIAO_Serverd.lib TAO_PortableServerd.lib TAO_Securityd.lib CIAO_Containerd.lib TAOd.lib TAO_IFR_Clientd.lib CIAO_Clientd.lib ACEd.lib ACEXMLd.lib ACEXML_Parserd.lib /nologo /version:1.3 /subsystem:console /incremental:no /debug /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer" /libpath:"..\..\..\tao\IFR_Client" /libpath:"..\..\ciao" /libpath:"..\..\..\orbsvcs\orbsvcs" /libpath:"..\..\..\..\ACEXML\Common" /libpath:"..\..\..\..\ACEXML\parser\parser"
+# ADD LINK32 advapi32.lib user32.lib CIAO_Serverd.lib TAO_PortableServerd.lib TAO_Securityd.lib CIAO_Containerd.lib TAOd.lib TAO_IFR_Clientd.lib CIAO_Clientd.lib ACEd.lib ACEXMLd.lib ACEXML_Parserd.lib /nologo /version:1.3 /subsystem:console /incremental:no /debug /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\tao\PortableServer" /libpath:"..\..\..\tao\IFR_Client" /libpath:"..\..\ciao" /libpath:"..\..\..\orbsvcs\orbsvcs" /libpath:"..\..\..\..\ACEXML\Common" /libpath:"..\..\..\..\ACEXML\parser\parser"
!ENDIF
@@ -75,6 +75,14 @@ LINK32=link.exe # PROP Default_Filter "cpp;cxx;c"
# Begin Source File
+SOURCE=..\XML_Helpers\Assembly_Handlers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\XML_Helpers\Assembly_Spec.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\XML_Helpers\Cascadable_DocHandler.cpp
# End Source File
# Begin Source File
@@ -107,6 +115,14 @@ SOURCE=..\XML_Helpers\XML_Utils.cpp # PROP Default_Filter "h;hpp;hxx;hh"
# Begin Source File
+SOURCE=..\XML_Helpers\Assembly_Handlers.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\XML_Helpers\Assembly_Spec.h
+# End Source File
+# Begin Source File
+
SOURCE=..\XML_Helpers\Cascadable_DocHandler.h
# End Source File
# Begin Source File
@@ -135,6 +151,14 @@ SOURCE=..\XML_Helpers\XML_Utils.h # PROP Default_Filter "i;inl"
# Begin Source File
+SOURCE=..\XML_Helpers\Assembly_Handlers.inl
+# End Source File
+# Begin Source File
+
+SOURCE=..\XML_Helpers\Assembly_Spec.inl
+# End Source File
+# Begin Source File
+
SOURCE=.\controller_i.inl
# End Source File
# Begin Source File
diff --git a/TAO/CIAO/tools/XML_Helpers/Assembly_Handlers.cpp b/TAO/CIAO/tools/XML_Helpers/Assembly_Handlers.cpp index 3b1723dc964..84defecf0ec 100644 --- a/TAO/CIAO/tools/XML_Helpers/Assembly_Handlers.cpp +++ b/TAO/CIAO/tools/XML_Helpers/Assembly_Handlers.cpp @@ -545,6 +545,7 @@ CIAO::Partitioning_Handler::startElement (const ACEXML_Char *namespaceURI, ACEXML_SAXException ("Internal error, no memory.")); ACEXML_CHECK; + this->state_ = COMPONENT_INSTANTIATION; } else if (ACE_OS::strcmp (qName, "registerwithhomefinder") == 0 || @@ -583,7 +584,25 @@ CIAO::Partitioning_Handler::startElement (const ACEXML_Char *namespaceURI, ACEXML_CHECK; this->comp_register_info_.name_ = name; + this->comp_register_info_.method_ = + CIAO::Assembly_Placement::componentinstantiation::NAMINGSERVICE; } + else if (ACE_OS::strcmp (qName, "writeiortofile") == 0) + { + const char *name; + CIAO::XML_Utils::get_single_attribute ("name", + name, + atts + ACEXML_ENV_ARG_PARAMETER); + ACEXML_CHECK; + + this->comp_register_info_.name_ = name; + this->comp_register_info_.method_ = + CIAO::Assembly_Placement::componentinstantiation::IORFILE; + } + + break; + break; diff --git a/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.cpp b/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.cpp index 82a2cc2876b..a05bee015a5 100644 --- a/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.cpp +++ b/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.cpp @@ -25,6 +25,15 @@ CIAO::Assembly_Placement::Node::~Node () // ================================================================ int +CIAO::Assembly_Placement::Container::accept +(CIAO::Assembly_Placement::Visitor &visitor) +{ + return visitor.visit_Container (this); +} + +// ================================================================ + +int CIAO::Assembly_Placement::componentinstantiation::accept (CIAO::Assembly_Placement::Visitor &visitor) { @@ -75,3 +84,7 @@ CIAO::Assembly_Placement::processcollocation::~processcollocation () } // ================================================================ + +CIAO::Assembly_Placement::Visitor::~Visitor (void) +{ +} diff --git a/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.h b/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.h index 5844d9f3e80..4690406eaeb 100644 --- a/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.h +++ b/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.h @@ -94,6 +94,9 @@ namespace CIAO Container (const char *id, unsigned long cardinality); + /// Accepting a visitor. + virtual int accept (Visitor &v); + //@{ /** Accesor/mutator for destination information */ void destination (const char *des); @@ -123,9 +126,16 @@ namespace CIAO CONSUMESID } IF_Register_Type; + typedef enum _register_method + { + NAMINGSERVICE, + IORFILE // CIAO extension + } Register_Method; + typedef struct _register_info { IF_Register_Type type_; + Register_Method method_; ACE_CString port_id_; ACE_CString name_; @@ -239,6 +249,8 @@ namespace CIAO virtual ~Visitor () = 0; + virtual int visit_Container (Container *c) = 0; + virtual int visit_hostcollocation (hostcollocation *hc) = 0; virtual int visit_processcollocation (processcollocation *pc) = 0; diff --git a/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.inl b/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.inl index 7106d7aac02..2d5d8dac3cf 100644 --- a/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.inl +++ b/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.inl @@ -107,6 +107,13 @@ CIAO::Assembly_Placement::processcollocation::processcollocation (const char *id // ================================================================ ACE_INLINE +CIAO::Assembly_Placement::Visitor::Visitor (void) +{ +} + +// ================================================================ + +ACE_INLINE CIAO::Assembly_Connection::IF_Resolver_Info::IF_Resolver_Info (CIAO::Assembly_Connection::IF_Resolution_Method type, const char *info, |