示例#1
0
typename COMP_SVNT::_stub_ptr_type
Home_Servant_Impl<BASE_SKEL,
                  EXEC,
                  COMP_SVNT,
                  CONTAINER>::_ciao_activate_component (
                      typename COMP_SVNT::_exec_type::_ptr_type exe)
{
    CIAO_TRACE ("Home_Servant_Impl<>::_ciao_activate_component");

    typename CONTAINER::_var_type cnt_safe =
        CONTAINER::_duplicate (this->container_.in());

    CORBA::Object_var hobj = cnt_safe->get_objref (this);

    Components::CCMHome_var home =
        Components::CCMHome::_narrow (hobj.in ());

    char buffer[256];
    unsigned long const serial = this->serial_number_++;
    if (ACE_OS::sprintf (buffer, "%ld", serial) < 0)
    {
        throw CORBA::INTERNAL ();
    }

    typedef typename COMP_SVNT::_stub_type stub_type;
    COMP_SVNT *svt = 0;
    ACE_NEW_THROW_EX (svt,
                      COMP_SVNT (exe,
                                 home.in (),
                                 (this->ins_name_ + buffer).c_str (),
                                 this,
                                 cnt_safe),
                      CORBA::NO_MEMORY ());

    PortableServer::ServantBase_var safe (svt);
    PortableServer::ObjectId_var oid;

    CORBA::Object_var objref =
        cnt_safe->install_servant (svt,
                                   Container_Types::COMPONENT_t,
                                   oid.out ());
    typedef typename COMP_SVNT::_stub_type stub_type;
    typename COMP_SVNT::_stub_var_type ho = stub_type::_narrow (objref.in ());

    Components::CCMObject_var ccmobjref =
        Components::CCMObject::_narrow (objref.in ());

    this->objref_map_.bind (
        oid.in (),
        Components::CCMObject::_duplicate (ccmobjref.in ()));
    return ho._retn ();
}
示例#2
0
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();
}
示例#3
0
	Components::CCMObject_var
	create_sender(CIAO::Session_Container_i &a_container, Components::CCMHome_var a_home)
	{
		a_container.init("container");
		a_home = a_container.install_home("RateGen_exec",
												 "create_HUDisplay_RateGenHome_Impl",
												 "RateGen_svnt",
												 "create_HUDisplay_RateGenHome_Servant",
												 "HUDisplay-RateGen-idd",
												 ACE_DEFAULT_SHLIB_MODE);
		assert(a_home.operator->());

		Components::KeylessCCMHome_var keyless_home;
		keyless_home = Components::KeylessCCMHome::_narrow(a_home.in());
		Components::CCMObject_var component = keyless_home->create_component();
		return component;
	}
::ComponentServerActivatorInfoList* Explore_impl::explore_qedo()
{	
	
	
	//CORBA::ORB_var e_orb=CORBA::ORB_init(e_argc,e_argv);

	// get name services reference
	CORBA::Object_var nsobj = e_orb->resolve_initial_references("NameService");
	CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow(nsobj);
	CORBA::Object_var saobj = e_orb ->resolve_initial_references("NameService");
		
	/*
	if (CORBA::is_nil(nc)) {

		cerr << "Kann den Naming Service nicht finden!" << endl;
		cin >> t;
		exit(1);

	}
	
	if (CORBA::is_nil(saobj)) {
		cout << "ServerActivator kann nicht gefunden werden" << endl;
		cin >>  t;
		exit(1);
	} */



	// get server activator reference
	char hostname[256];
	//int gethostname;
	 gethostname (hostname, 256);
	if (gethostname (hostname, 256))
	{
		std::cout<< "Kann Hostname nicht finden"<<endl;
		e_orb->destroy();
		exit(1);
	}
	
	
	CosNaming::Name cname;
	cname.length(2);
	cname[0].id=CORBA::string_dup("Qedo");
	cname[0].kind=CORBA::string_dup("");
	cname[1].id=CORBA::string_dup("Activators");
	cname[1].kind=CORBA::string_dup("");
	
		
	CosNaming::NamingContext_var ncQA = CosNaming::NamingContext::_nil();
	CORBA::Object_var obj = nc->resolve(cname);
	ncQA = CosNaming::NamingContext::_narrow (obj);

	
	CORBA::Object_var server_activator_obj;
		server_activator_obj=nc->resolve(cname);
		CosNaming::BindingList *test;
		CosNaming::BindingIterator *test2;
		ncQA->list(100,test,test2);



		CosNaming::BindingList_var bl = test;
		CosNaming::BindingIterator_var bi = test2;
		std::cout<< bl->length() << " ServerActivator gefunden" << endl;
		

	ComponentServerActivatorInfoList_var Activatorlist=new ComponentServerActivatorInfoList;
	for (int as=0;as<bl->length();as++) {

			
			CosNaming::Binding b=bl->operator [](as);
			

			CosNaming::Name name;
			name.length(3);
			name[0].id=CORBA::string_dup("Qedo");
			name[0].kind=CORBA::string_dup("");
			name[1].id=CORBA::string_dup("Activators");
			name[1].kind=CORBA::string_dup("");
			name[2].id=CORBA::string_dup(b.binding_name[0].id);
			name[2].kind=CORBA::string_dup("");

	

	try {
		std::cout<< "ServerActivator: " << b.binding_name[0].id << endl;
		server_activator_obj=nc->resolve(name);

	}
	catch (CosNaming::NamingContext::NotFound_catch &exec) {
		std::cerr << "Notfound" << endl;
	}
	catch (CosNaming::NamingContext::CannotProceed_catch &exec) {
		std::cerr << "CannotProceed" <<endl;
	}
	catch (CosNaming::NamingContext::InvalidName_catch &exec) {
		std::cout << "InvalidName exception"<<endl;
	}

	
	Components::Deployment::ServerActivator_var server_activator ;
	try {
		server_activator= Components::Deployment::ServerActivator::_narrow(server_activator_obj);
	} 
	catch (CORBA::SystemException&) 
	{
		std::cout<<"Cannon narrow"<<endl;
		e_orb->destroy();
		exit(1);
	}
	

	
	// get Component Servers
	
	Components::Deployment::ComponentServers *component_servers = 
	server_activator -> get_component_servers();
	

	std::cout << "ServerActivator liefert " << component_servers->length() << " Component Server"<< endl;

	
	ComponentServerActivatorInfo ComponentServerActivator;
	const char* host="schlepptop";
	ComponentServerActivator.host_name=(const char*)hostname;
	ComponentServerActivator.component_server_activator_ref=server_activator;
	
	ComponentServerInfoList ComponentServerList;
	ComponentServerList.length(component_servers->length());
	

	for (int i=1; i<=component_servers->length(); i++) {
		
	std::cout<<"ComponentServer " << i-1 << endl;	


		Components::Deployment::ComponentServer_var comp_server = 
			Components::Deployment::ComponentServer::_duplicate((*component_servers)[i-1]);

		ComponentServerInfo ComponentServer;

		// Der Hostname muss noch gefunden werden

		const char* host="schlepptop";
		ComponentServer.host_name=(const char*)hostname;
		ComponentServer.component_server_ref=comp_server;

		Components::Deployment::Containers *comp_containers = 
			comp_server->get_containers();
		ContainerInstanceInfoList ContainerList;
		ContainerList.length(comp_containers->length());

		std::cout<< " ->" << comp_containers->length() << " Container"<<endl;



		for (int y=1; y<=comp_containers->length(); y++) {
			std::cout<<"    " << y-1 << " Container" << endl;
			
			
			Components::Deployment::Container_var container = 
				Components::Deployment::Container::_duplicate((*comp_containers)[y-1]);
			
			ContainerInstanceInfo ContainerInfo;
			const char* egal="SESSION";
			
			ContainerInfo.short_name=egal;
			ContainerInfo.container_ref=container;
		   // Components::Deployment::ComponentServer_var test = container->get_component_server();
            Components::CCMHomes *homes = container->get_homes();
			
			HomeInstanceInfoList HomeList;
			HomeList.length(homes->length());
			std::cout<< "  ->" << homes->length() << " Homes" << endl;

			for (int z=1; z<=homes->length(); z++) {

				std::cout<<"     " << z-1 << " Home" << endl;

				Components::CCMHome_var home = 
					Components::CCMHome::_duplicate((*homes)[z-1]);

				HomeInstanceInfo HomeInfo;
				HomeInfo.full_scoped_name=home->get_home_rep_id();
				//std::cout << z << " " << home->get_home_rep_id() << endl;
				std::cout << "    " <<  z-1 << get_short_name(HomeInfo.full_scoped_name)<<endl;
				
				HomeInfo.short_name=get_short_name(HomeInfo.full_scoped_name).c_str();
				//std::cout << "HomeInfo" << HomeInfo.short_name << " " <<  endl;
				HomeInfo.home_ref=home;
				Components::CCMObjects *homeinstances = home->get_instances();
				
				ComponentInstanceInfoList ComponentList;
				ComponentList.length(homeinstances->length());


				for (int a=1; a<=homeinstances->length(); a++) {
				
					Components::CCMObject_var inst=
						Components::CCMObject::_duplicate((*homeinstances)[a-1]);

					ComponentInstanceInfo ComponentInfo;
					//std::cout<<a-1<<endl;
					ComponentInfo.full_scoped_name=home->get_component_rep_id();
					//std::cout<< a-1 << ":" << home->get_component_rep_id()<<endl;
					std::cout<< "        " << a-1 << get_short_name(home->get_component_rep_id()).c_str() << endl;;
					ComponentInfo.short_name=get_short_name(home->get_component_rep_id()).c_str();	
					ComponentInfo.compont_ref=inst;
					ComponentList[a-1]=ComponentInfo;

                } // Ende Components
				
				HomeInfo.my_components=ComponentList;
				HomeList[z-1]=HomeInfo;

			} // Ende Homes
			ContainerInfo.my_homes=HomeList;
			ContainerList[y-1]=ContainerInfo;
		
		} // Ende Container

		ComponentServer.my_containers=ContainerList;
		ComponentServerList[i-1]=ComponentServer;

	} // Ende ComponentServers
	ComponentServerActivator.my_component_servers=ComponentServerList;
	
	
	Activatorlist->length(bl->length());
		
	Activatorlist.inout()[as]=ComponentServerActivator;
	
}
	
//	ComponentServerActivatorInfoList* wert = Activatorlist;
	 
   return Activatorlist._retn() ;


}
示例#5
0
  //@@ 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 ();
  }
示例#6
0
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();
}