コード例 #1
0
ファイル: NamingTreeCtrl.cpp プロジェクト: OspreyHub/ATCD
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"));
  }
}
コード例 #2
0
ファイル: COSBindingNode.cpp プロジェクト: jasonhogan/sti
void COSBindingNode::walkBranches(CosNaming::NamingContext_var& nodeContext)
{
	CosNaming::NamingContext_var newNodeContext;
	CosNaming::Binding_var binding( new CosNaming::Binding );

	CosNaming::BindingIterator_var biIterVar( new CosNaming::_objref_BindingIterator );
	CosNaming::BindingIterator_out biIter( biIterVar );

	CosNaming::BindingList_var biListVar( new CosNaming::BindingList );
	CosNaming::BindingList_out biList( biListVar );
	
	CORBA::Object_var obj;

	unsigned i = 0;
	
	if(CORBA::is_nil(nodeContext))
	{
		_isLeaf = true;
		
		//No need to iterate through the tree; this is a leaf.
		return;
	}
	
	try {
		nodeContext->list(0, biList, biIter);
	}
	catch(CORBA::TRANSIENT&) {
		_isDead = true;
	}
	catch(CORBA::INV_OBJREF&) {
		_isLeaf = true;
	}
	catch(CORBA::Exception&) {
	}
	catch(...)  {
		std::cerr << "Other list exception." << std::endl;
	}

	if( isLeaf() )
	{
		//No need to iterate through the tree; this is a leaf.
		return;
	}

	bool deadServantFound = false;

	while(biIter->next_one(binding))
	{
		i++;
		//get the context for this branch and add a new node
		obj = nodeContext->resolve( binding->binding_name );

		try {
			obj->_non_existent();
		}
		catch(CORBA::TRANSIENT&)
		{
			//This is a dead servant. 
			deadServantFound = true;

			addBranch(std::string(omni::omniURI::nameToString(binding->binding_name)));

			//_branches.push_back( 
			//	new COSBindingNode(
			//	omni::omniURI::nameToString( binding->binding_name ), true) );
		}
		catch(CORBA::COMM_FAILURE)
		{
			//This is a dead servant. 
			deadServantFound = true;

			addBranch(std::string(omni::omniURI::nameToString(binding->binding_name)));
			//_branches.push_back(
			//	new COSBindingNode(
			//	omni::omniURI::nameToString( binding->binding_name ), true) );
		}

		if( !deadServantFound )
		{
			try {
				newNodeContext = CosNaming::NamingContext::
					_narrow( obj );
			}
			catch(...)
			{
				std::cerr << "Branch list exception: _narrow" << std::endl;
			}

			try {
				addBranch(std::string(omni::omniURI::nameToString(binding->binding_name)), newNodeContext);
				
				//_branches.push_back( 
				//	new COSBindingNode(
				//	omni::omniURI::nameToString( binding->binding_name ), newNodeContext)
				//	);
			}
			catch(CORBA::INV_OBJREF&)
			{
				std::cerr << "Branch list exception: push_back" << std::endl;
			}
		}
	}

}
コード例 #3
0
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();
}
コード例 #4
0
::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
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&)
			{ }
		 
	}
}