Exemple #1
0
void NamingContextHelper::appendBindingList(CosNaming::BindingList_var& bList, ObjectInfoList& objects)
{
    for (CORBA::ULong i = 0; i < bList->length(); ++i) {
        ObjectInfo info;
        info.id_ = bList[i].binding_name[0].id;
        info.kind_ = bList[i].binding_name[0].kind;
        info.isContext_ = false;
        info.hostAddress_ = host_;
        info.portNo_ = port_;

        CORBA::Object_ptr obj = findObject(info.id_, info.kind_);
        info.isAlive_ = isObjectAlive(obj);
        
        if(info.isAlive_){
            CosNaming::NamingContext_var check = CosNaming::NamingContext::_narrow(obj);
            if(check != CosNaming::NamingContext::_nil()){
                info.isContext_ = true;
            }
        }

        info.ior_ = orb->object_to_string(obj);
        ObjectPath path(info.id_, info.kind_);
        info.fullPath_.push_back(path);
        CORBA::release(obj);
        objects.push_back(info);
    }
}
  /*!
   * @if jp
   * @brief NamingContext を再帰的に下って非アクティブ化する
   * @else
   * @brief Destroy the naming context recursively
   * @endif
   */
  void CorbaNaming::destroyRecursive(CosNaming::NamingContext_ptr context)
    throw (SystemException, NotEmpty, NotFound, CannotProceed, InvalidName)
  {
    CosNaming::BindingList_var     bl;
    CosNaming::BindingIterator_var bi;
    CORBA::Boolean cont(true);
    
#ifndef ORB_IS_RTORB
    context->list(m_blLength, bl.out(), bi.out());
#else // ORB_IS_RTORB
    //    context->list(m_blLength, bl, bi);
    context->list(m_blLength, (CosNaming::BindingList_out)bl,
                  (CosNaming::BindingIterator_ptr)bi);
#endif // ORB_IS_RTORB
    
    while (cont)
      {
	CORBA::ULong len(bl->length());
	
	for (CORBA::ULong i = 0; i < len; ++i)
	  {
	    if (bl[i].binding_type == CosNaming::ncontext)
	      {	// If Object is context, destroy recursive.
		CosNaming::NamingContext_var next_context;
		next_context = CosNaming::NamingContext::
		  _narrow(context->resolve(bl[i].binding_name));
		
		// Recursive function call
		destroyRecursive(next_context); // +++ Recursive call +++
		context->unbind(bl[i].binding_name);
		next_context->destroy();
	      }
	    else if (bl[i].binding_type == CosNaming::nobject)
	      {	// If Object is object, unbind it.
		context->unbind(bl[i].binding_name);
	      }
	    else assert(0); // never comes here
	  }
	
	// no more binding -> do-while loop will be finished
	if (CORBA::is_nil(bi)) cont = false;
	else bi->next_n(m_blLength, bl);
      }
    
    if (!CORBA::is_nil(bi)) bi->destroy();
    return;
  }
void NSBrowserTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
									 CosNaming::NamingContext_ptr context)
{
	try {
		// list context
		CosNaming::BindingList_var bl ;
		CosNaming::BindingIterator_var bi;

		context -> list (10, bl, bi);
		wxString str;

		for (CORBA::ULong i = 0; i < bl->length(); i++)
		{
			// if context
	//		if ((*bl)[i].binding_type == CosNaming::ncontext)
	//		{
				CosNaming::NamingContext_var child_context;
				CORBA::Object_var tmp_obj;
				tmp_obj = context -> resolve((*bl)[i].binding_name);
				try {
					child_context = CosNaming::NamingContext::_narrow(tmp_obj);
				} catch (CORBA::SystemException e) {}
				if (!CORBA::is_nil(child_context))
				{
					str.Printf(wxT("%s"), wxT((*bl)[i].binding_name[0].id.in()));
					wxTreeItemId id = AppendItem(idParent, str, TreeCtrlIcon_Folder, TreeCtrlIcon_Folder, new NSBrowserTreeItemData(str));

					AddItemsRecursively(id, child_context.in());
				} else {
					str.Printf(wxT("%s"), wxT((*bl)[i].binding_name[0].id.in()));
					wxTreeItemId id = AppendItem(idParent, str, TreeCtrlIcon_File, TreeCtrlIcon_File, new NSBrowserTreeItemData(str));
				}
	//		}


			// add to tree
			//wxTreeItemId id = AppendItem(idParent, str, 1, 1, new MyTreeItemData(str));

		}
	} catch (CORBA::SystemException&)
	{ }
}
Exemple #4
0
void NamingContextHelper::appendBindingList(CosNaming::BindingList_var& bList, ObjectInfoList& objects)
{
    for(CORBA::ULong i=0; i < bList->length(); ++i){
        ObjectInfo info;
        info.id = bList[i].binding_name[0].id;
        info.kind = bList[i].binding_name[0].kind;
        CORBA::Object_ptr obj = findObject(info.id);
        info.isAlive = isObjectAlive(obj);
        CORBA::release(obj);
        objects.push_back(info);
    }
}
Exemple #5
0
void CNamingTreeCtrl::ListContext(HTREEITEM hItem)
{
  CWaitCursor Waiter;
  try
  {
    // Get the items object and make sure we have a context
    CNamingObject* pObject = GetTreeObject(hItem);
    CosNaming::NamingContext_var Context = pObject->NamingContext();
    if(CORBA::is_nil(Context))
    {
      return;
    }

    // List the contexts entries
    CosNaming::BindingList_var bl;
    CosNaming::BindingIterator_var bi;
    Context->list(LISTQUANTUM, bl, bi);
    ListBindingList(hItem, Context, bl);

    if(!CORBA::is_nil(bi))
    {
      while(bl->length())
      {
        CString Text;
        Text.Format(ACE_TEXT ("This context contains more than %d entries, list the next %d?"), LISTQUANTUM, LISTQUANTUM);
        if(MessageBox(Text, ACE_TEXT ("Question"), MB_YESNO) == IDNO)
        {
          return;
        }
        bi->next_n(LISTQUANTUM, bl);
        ListBindingList(hItem, Context, bl);
      }
      bi->destroy();
    }
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
  /*!
   * @if jp
   * @brief 与えられた NamingContext の Binding を取得する
   * @else
   * @brief Get Binding on the given NamingContext
   * @endif
   */
  void CorbaNaming::list(CosNaming::NamingContext_ptr name_cxt,
			 CORBA::ULong how_many,
			 CosNaming::BindingList_var& bl,
			 CosNaming::BindingIterator_var& bi)
  {
#ifndef ORB_IS_RTORB
    name_cxt->list(how_many, bl.out(), bi.out());
#else // ORB_IS_RTORB
    name_cxt->list(how_many, (CosNaming::BindingList_out)bl,
                   (CosNaming::BindingIterator_ptr)bi);
#endif // ORB_IS_RTORB

  }
Exemple #7
0
void CNamingTreeCtrl::ListBindingList(HTREEITEM hItem, CosNaming::NamingContext_ptr pContext, CosNaming::BindingList_var& bl)
{
  try
  {
    for(unsigned int i=0; i < bl->length(); i++)
    {
      // Add each entry into the tree control
      CORBA::Object_var Object = pContext->resolve(bl[i].binding_name);
      bool Context = (bl[i].binding_type == CosNaming::ncontext);
      CNamingObject* pNewObject = new CNamingObject(bl[i].binding_name, Object, Context);
      CString Name;
      const char* pKind = (bl[i].binding_name[0]).kind;
      if(*pKind)
      {
        Name.Format(ACE_TEXT ("%s | %s"), (bl[i].binding_name[0]).id, pKind);
      }
      else
      {
        Name.Format(ACE_TEXT ("%s"), (bl[i].binding_name[0]).id);
      }
      HTREEITEM hContext = InsertItem(Name, hItem);
      SetItemData(hContext, (DWORD)pNewObject);
      switch(bl[i].binding_type)
      {
      case CosNaming::ncontext:
        {
          // Set the children flag so the + button is displayed
          TV_ITEM Item;
          Item.mask = TVIF_CHILDREN | TVIF_HANDLE;
          Item.cChildren = 1;
          Item.hItem = hContext;
          SetItem(&Item);
        }
        break;
      case CosNaming::nobject:
        break;
      }
    }
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
Exemple #8
0
void NamingContextHelper::appendBindingList(CosNaming::BindingList_var& bList, std::vector<ObjectPath> pathList, ObjectInfoList& objects)
{
    for (CORBA::ULong i = 0; i < bList->length(); ++i) {
        ObjectInfo info;
        info.id_ = bList[i].binding_name[0].id;
        info.kind_ = bList[i].binding_name[0].kind;
        info.hostAddress_ = host_;
        info.portNo_ = port_;

        ObjectPath path(info.id_, info.kind_);
        pathList.push_back(path);

        CORBA::Object_ptr obj = findObjectSub(pathList);
        info.isAlive_ = isObjectAlive(obj);
        info.ior_ = orb->object_to_string(obj);
        copy(pathList.begin(), pathList.end(), std::back_inserter(info.fullPath_));
        pathList.pop_back();
        CORBA::release(obj);
        objects.push_back(info);
    }
}
void
ComponentDeployment::init()
throw (DeploymentFailure)
{
	int dummy = 0;
	CORBA::ORB_var orb = CORBA::ORB_init (dummy, 0);

    //
	// get NameService
	//
    if (! initNameService(orb))
    {
        throw DeploymentFailure();
    }

	//
	// try to get a local AssemblyFactory
	//
	char hostname[256];
	gethostname(hostname, 256);
	CORBA::Object_var obj = resolveName(std::string("Qedo/AssemblyFactory/") + hostname);
	assemblyFactory_ = Components::Deployment::AssemblyFactory::_narrow( obj.in() );
    if( !CORBA::is_nil( assemblyFactory_.in() ) && 
		!assemblyFactory_->_non_existent() )
	{
		std::cerr << "..... take assembly factory on " << hostname << std::endl;
		return;
	}

	//
	// try to get another one
	//
	std::cerr << "..... no local assembly factory, try to get another one" << std::endl;

	obj = resolveName(std::string("Qedo/AssemblyFactory"));
	CosNaming::NamingContext_var ctx = CosNaming::NamingContext::_narrow( obj.in() );
	if( !CORBA::is_nil( ctx.in() ) )
	{
		CosNaming::BindingList_var list;
		CosNaming::BindingIterator_var iter;
		try
		{
			ctx->list(10, list.out(), iter.out());
		}
		catch (...)
		{
		}

		for(CORBA::ULong i = 0; i < list->length(); i++)
		{
			try
			{
				obj = ctx->resolve(list[i].binding_name);
			}
			catch (...)
			{
				continue;
			}
			assemblyFactory_ = Components::Deployment::AssemblyFactory::_narrow( obj.in() );
			if( !CORBA::is_nil( assemblyFactory_.in() ) &&
				!assemblyFactory_->_non_existent() )
			{
				std::cerr << "..... take assembly factory on " << list[i].binding_name[0].id << std::endl;
				return;
			}
		}
	}

	//
	// use our own assembly
	//
	// todo


	std::cerr << "!!!!! no assembly factory found" << std::endl;
	throw DeploymentFailure();
}
::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() ;


}
void DescriptorFrame::addServerActivators() 
{
	//
	// init ORB
	//
	
	int dummy=0;
	e_orb = CORBA::ORB_init (dummy, 0);

	// get name services reference

	std::string ns;
	ns = Qedo::ConfigurationReader::instance()->lookup_config_value( "/General/NameService" );

	CORBA::Object_var obj;
	obj = e_orb -> string_to_object( ns.c_str() );
	

	try {
		nameService = CosNaming::NamingContext::_narrow(obj.in());
	} catch (CORBA::SystemException) {};
		if (!CORBA::is_nil(nameService))
		{
			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 = nameService->resolve(cname);
			ncQA = CosNaming::NamingContext::_narrow (obj);
		
			try {
		
			CosNaming::BindingList *test;
			CosNaming::BindingIterator *test2;
			ncQA->list(100,test,test2);

			CosNaming::BindingList_var bl = test;
			CosNaming::BindingIterator_var bi = test2;
			
			DescriptorFrame::serverinfo si ;
			for (CORBA::ULong as=0;as<bl->length();as++) {

			
				CosNaming::Binding b=bl->operator [](as);
							
				wxTreeItemId id = server_ctrl_->AppendItem(rootId, _T(CORBA::string_dup( b.binding_name[0].id) ),-1,-1,NULL);
				server_ctrl_->SetItemBold(id,TRUE);
				si.servername=CORBA::string_dup( b.binding_name[0].id);
				si.itemid=id;
				serverinfolist.push_back(si);


			}
			} catch (CORBA::SystemException&)
			{ }
		 
	}
}
Exemple #12
0
/*引数にTreeObjectを追加*/
void ListRecursive(CosNaming::NamingContext_ptr context,vector<OtherPort> &rtclist,vector<string> &name, TreeObject *to){
    CosNaming::BindingList_var     bl;
    CosNaming::BindingIterator_var bi;
    CORBA::Boolean cont(true);
    int m_blLength=100;
    context->list(m_blLength, bl, bi);
 
    while (cont){
        CORBA::ULong len(bl->length());
        for (CORBA::ULong i = 0; i < len; ++i){
 
            if (bl[i].binding_type == CosNaming::ncontext){
                CosNaming::NamingContext_var next_context;
                next_context = CosNaming::NamingContext::_narrow(context->resolve(bl[i].binding_name));
                vector<string> namebuff=name;
                name.push_back(string(bl[i].binding_name[0].id));
                //name.push_back("/");
				TreeObject *to2 = new TreeObject(string(bl[i].binding_name[0].id));
				to->to.push_back(to2);
                ListRecursive(next_context,rtclist,name,to2); 
                name=namebuff;
            }
            else if (bl[i].binding_type == CosNaming::nobject){
                if(rtclist.size()>m_blLength)
                    break;
                vector<string> namebuff=name;
                name.push_back(string(bl[i].binding_name[0].id));
/*
データポートの情報を取得するためのコードを追加
*/
				if(string(bl[i].binding_name[0].kind) == "rtc")
				{
					
					RTC::CorbaConsumer<RTC::RTObject> rto;
					rto.setObject(context->resolve(bl[i].binding_name));
					try
					{
						RTC::PortServiceList_var tp = rto._ptr()->get_ports();
					
						TreeObject *to2 = new TreeObject(string(bl[i].binding_name[0].id));
						to->to.push_back(to2);

						for(int k=0;k < tp->length();k++)
						{
							vector<string> namebuff2=name;
							string tname = tp[(CORBA::ULong)k]->get_port_profile()->name;
							PortService_var p = tp[(CORBA::ULong)k];
							vector<string> pn = coil::split(tname, ".");
							namebuff2.push_back(pn[1]);

							TreeObject *to3 = new TreeObject(string(pn[1]));
							to2->to.push_back(to3);

							rtclist.push_back(OtherPort(p, namebuff2));
						}
					}
					catch(...)
					{

					}

					
					

					//name=namebuff2;
				}
/*ここまで*/
				name=namebuff;
				
                //rtclist.push_back(name_buff);
            }
            else {
            }
        }
        if (CORBA::is_nil(bi)) {
            cont = 0;
        }
        else {
            bi->next_n(m_blLength, bl);
        }
    }
    return;
}