Components::CCMHome_ptr AssemblyImpl::getHomeInstance (std::string name) throw( Components::CreateFailure ) { Components::CCMHome_var obj; std::map < std::string, Components::CCMHome_var > ::iterator iter; iter = homeMap_.find(name); if (iter != homeMap_.end()) { obj = (*iter).second; return obj._retn(); } DEBUG_OUT2(".......... no home reference for ", name); throw Components::CreateFailure(); }
//@@ Apparently we need to be cautious when handling the exception // thrown here. We should make sure that new DnC interfaces // NodeApplication/NodeApplicationManager etc will cache the new // exceptions--> rethrow of new exceptions is needed. // --Tao Components::CCMHome_ptr Session_Container_i::install_home (const char *primary_artifact, const char *entry_point, const char *servant_artifact, const char *servant_entrypoint, const char *name, CORBA::Long open_mode) { CIAO_TRACE ("Session_Container_i::install_home"); ACE_DLL executor_dll; ACE_DLL servant_dll; Container_i < ::CIAO::Session_Container>::prepare_installation ("Session Home", primary_artifact, entry_point, servant_artifact, servant_entrypoint, name, open_mode, executor_dll, servant_dll); void *void_ptr_executor = executor_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (entry_point)); void *void_ptr_servant = servant_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (servant_entrypoint)); ptrdiff_t tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr_executor); HomeFactory hcreator = reinterpret_cast<HomeFactory> (tmp_ptr); tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr_servant); HomeServantFactory screator = reinterpret_cast<HomeServantFactory> (tmp_ptr); if (hcreator == 0) { std::ostringstream err; err << "Home executor factory function [" << entry_point << "] invalid in DLL [" << primary_artifact; CIAO_ERROR (1, (LM_ERROR, CLINFO "Session_Container_i::install_home " "- Error: %C\n", err.str ().c_str ())); throw CIAO::Installation_Failure (name, err.str ().c_str ()); } if (screator == 0) { std::ostringstream err; err << "Home servant factory function [" << servant_entrypoint << "] invalid in DLL [" << servant_artifact; CIAO_ERROR (1, (LM_ERROR, CLINFO "Session_Container_i::install_home " "- Error: %C\n", err.str ().c_str ())); throw CIAO::Installation_Failure (name, err.str ().c_str ()); } CIAO_DEBUG (9, (LM_TRACE, CLINFO "Session_Container_i::install_home" " - Loading home executor\n")); Components::HomeExecutorBase_var home_executor = hcreator (); if (CORBA::is_nil (home_executor.in ())) { CIAO_ERROR (1, (LM_ERROR, CLINFO "Session_Container_i::install_home - " "Home executor factory failed.\n")); throw CIAO::Installation_Failure (name, "Home executor factory function failed\n"); } CIAO_DEBUG (9, (LM_TRACE, CLINFO "Session_Container_i::install_home" " - Loading home servant\n")); PortableServer::Servant home_servant = screator (home_executor.in (), this, name); if (home_servant == 0) { CIAO_ERROR (1, (LM_ERROR, CLINFO "Session_Container_i::install_home - " "Home servant factory failed.\n")); throw CIAO::Installation_Failure (name, "Home servant factory function failed\n"); } PortableServer::ServantBase_var safe (home_servant); CIAO_DEBUG (9, (LM_TRACE, CLINFO "Session_Container_i::install_home " "- Installing home servant\n")); PortableServer::ObjectId_var oid; CORBA::Object_var objref = this->install_servant (home_servant, Container_Types::HOME_t, oid.out ()); Components::CCMHome_var homeref = Components::CCMHome::_narrow (objref.in ()); CIAO_DEBUG (9, (LM_TRACE, CLINFO "Session_Container_i::install_home - " "Home successfully created with name\n")); return homeref._retn (); }
Components::CCMHome_ptr AssemblyImpl::instantiateHome (Components::Deployment::Container_ptr container, HomeInstanceData data) throw(Components::CreateFailure) { Components::CCMHome_var home; // extension, existing home can be referenced if(data.file.length()) { // // create home // DEBUG_OUT2( "AssemblyImpl: create new home ", data.id ); try { Components::ConfigValues_var config = new Components::ConfigValues(); home = container->install_home(data.impl_id.c_str(), "", config); } catch (Components::Deployment::UnknownImplId&) { NORMAL_ERR2( "AssemblyImpl: unknown impl id during install_home() for ", data.id ); throw Components::CreateFailure(); } catch (Components::Deployment::ImplEntryPointNotFound&) { NORMAL_ERR2( "AssemblyImpl: entry point not found during install_home() for ", data.id ); throw Components::CreateFailure(); } catch (Components::Deployment::InstallationFailure&) { NORMAL_ERR2( "AssemblyImpl: installation failure during install_home() for ", data.id ); throw Components::CreateFailure(); } catch (Components::Deployment::InvalidConfiguration&) { NORMAL_ERR2( "AssemblyImpl: invalid configuration during install_home() for ", data.id ); throw Components::CreateFailure(); } catch (CORBA::SystemException&) { NORMAL_ERR2( "AssemblyImpl: CORBA system exception during install_home() for ", data.id ); throw Components::CreateFailure(); } if (CORBA::is_nil(home)) { NORMAL_ERR2( "AssemblyImpl: Component Home is NIL for ", data.id ); throw Components::CreateFailure(); } // // register created home // homeMap_[data.id] = Components::CCMHome::_duplicate(home); } else { // // extension, use referenced home // DEBUG_OUT2( "AssemblyImpl: resolve home ", data.impl_id ); home = Components::CCMHome::_narrow( resolveName(data.impl_id) ); } // // registerwithhomefinder // // todo // // registerwithnaming // if (data.naming.length()) { DEBUG_OUT2( "AssemblyImpl: register home with naming ", data.naming ); registerName( data.naming, home, true ); } // // registerwithtrader // // todo return home._retn(); }