Ejemplo n.º 1
0
  /*!
   * @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;
  }
Ejemplo n.º 2
0
Components::Deployment::ServerActivator_ptr
get_server_activator (CORBA::ORB_ptr orb, CosNaming::NamingContext_ptr ns, const char* hostname)
{
	cout << "Getting Component Server Activator from Qedo/Activators/" << hostname << endl;

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

	Components::Deployment::ServerActivator_var server_activator;
	CORBA::Object_var server_activator_obj;

	try
	{
		server_activator_obj = ns->resolve (server_activator_name);
	}
	catch (CosNaming::NamingContext::NotFound&)
	{
		cerr << "Component Server Activator not found in Name Service" << endl;
		orb->destroy();
		exit (1);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "CORBA system exception during resolve()" << endl;
		orb->destroy();
		exit (1);
	}

	try
	{
		server_activator = Components::Deployment::ServerActivator::_narrow (server_activator_obj);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "Cannot narrow Component Server Activator" << endl;
		orb->destroy();
		exit (1);
	}

	return server_activator._retn();
}
Ejemplo n.º 3
0
void
FT_EventService::setup_scheduler(CosNaming::NamingContext_ptr naming_context)
{
    RtecScheduler::Scheduler_var scheduler;
    if (CORBA::is_nil(naming_context)) {
        ACE_NEW_THROW_EX (this->sched_impl_,
            ACE_Config_Scheduler,
            CORBA::NO_MEMORY());

        scheduler = this->sched_impl_->_this ();

        if (ACE_Scheduler_Factory::server(scheduler.in()) == -1)
            ORBSVCS_ERROR((LM_ERROR,"Unable to install scheduler\n"));
    }
    else {
        // This is the name we (potentially) register the Scheduling
        // Service in the Naming Service.
        CosNaming::Name schedule_name (1);
        schedule_name.length (1);
        schedule_name[0].id = CORBA::string_dup ("ScheduleService");


        if (1)
        {
            // We must find the scheduler object reference...

            if (this->global_scheduler_ == 0)
            {
                ACE_NEW_THROW_EX (this->sched_impl_,
                    ACE_Config_Scheduler,
                    CORBA::NO_MEMORY());

                scheduler = this->sched_impl_->_this ();

                // Register the servant with the Naming Context....
                naming_context->rebind (schedule_name, scheduler.in ());
            }
            else
            {
                CORBA::Object_var tmp =
                    naming_context->resolve (schedule_name);

                scheduler = RtecScheduler::Scheduler::_narrow (tmp.in ());
            }
        }
    }
}
CosEventChannelAdmin::EventChannel_ptr connectToEventChannel (CosNaming::NamingContext_ptr context, const std::string& name)
{
    TRACE_ENTER(EventChannelSupport);
    CosNaming::Name_var boundName = ossie::corba::stringToName(name);
    try {
        CORBA::Object_var obj = context->resolve(boundName);
        LOG_TRACE(EventChannelSupport, "Existing event channel " << name << " found");
        return CosEventChannelAdmin::EventChannel::_narrow(obj);
    } catch (const CosNaming::NamingContext::NotFound&) {
        // The channel does not exist and can be safely created.
    } catch (const CORBA::Exception& e) {
        LOG_WARN(EventChannelSupport, "CORBA (" << e._name() << ") exception connecting to event channel " << name <<". Continue without connecting to the channel (the event service might not be running)");
    }

    TRACE_EXIT(EventChannelSupport);
    return CosEventChannelAdmin::EventChannel::_nil();
}
Ejemplo n.º 5
0
  /*!
   * @if jp
   * @brief オブジェクトの名前をバインドまたは解決する
   * @else
   * @brief Bind or resolve the given name component
   * @endif
   */
  CORBA::Object_ptr
  CorbaNaming::bindOrResolve(CosNaming::NamingContext_ptr context,
			     const CosNaming::Name& name,
			     CORBA::Object_ptr obj)
  {
    try
      {
	context->bind(name, obj);
	return obj;
      }
    catch (AlreadyBound& e)
      {
	(void)(e);
	return context->resolve(name);
      }
    return CORBA::Object::_nil();
  }
Ejemplo n.º 6
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"));
  }
}
Ejemplo n.º 7
0
typename T::_ptr_type
resolve_name(
    CosNaming::NamingContext_ptr    nc,
    const CosNaming::Name &         name)
{
    CORBA::Object_var obj;
    try {
        obj = nc->resolve(name);
    }
    catch (const CosNaming::NamingContext::NotFound &) {
        throw;
    }
    catch (const CORBA::Exception & e) {
        std::cerr << "Cannot resolve binding: "
                  << e
                  << std::endl;
        throw 0;
    }
    if (CORBA::is_nil(obj.in())) {
        std::cerr << "Nil binding in Naming Service" << std::endl;
        throw 0;
    }

    typename T::_var_type ref;
    try {
        ref = T::_narrow(obj.in());
    }
    catch (const CORBA::Exception & e) {
        std::cerr << "Cannot narrow reference: "
                  << e
                  << std::endl;
        throw 0;
    }
    if (CORBA::is_nil(ref.in())) {
        std::cerr << "Reference has incorrect type" << std::endl;
        throw 0;
    }
    return ref._retn();
}
Ejemplo n.º 8
0
void
deploy_test_components (CORBA::ORB_ptr orb, CosNaming::NamingContext_ptr ns, const char* hostname)
{
	cout << "Getting Component Installation from Qedo/ComponentInstallation/" << hostname << endl;

	CosNaming::Name installer_name;
	installer_name.length (3);
	installer_name[0].id = CORBA::string_dup ("Qedo");
	installer_name[0].kind = CORBA::string_dup ("");
	installer_name[1].id = CORBA::string_dup ("ComponentInstallation");
	installer_name[1].kind = CORBA::string_dup ("");
	installer_name[2].id = CORBA::string_dup (hostname);
	installer_name[2].kind = CORBA::string_dup ("");

	Components::Deployment::ComponentInstallation_var component_installer;
	CORBA::Object_var component_installer_obj;

	try
	{
		component_installer_obj = ns->resolve (installer_name);
	}
	catch (CosNaming::NamingContext::NotFound&)
	{
		cerr << "Component Installer not found in Name Service" << endl;
		orb->destroy();
		exit (1);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "CORBA system exception during resolve()" << endl;
		orb->destroy();
		exit (1);
	}

	try
	{
		component_installer = Components::Deployment::ComponentInstallation::_narrow (component_installer_obj);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "Cannot narrow Component Installer" << endl;
		orb->destroy();
		exit (1);
	}

#ifdef _WIN32
	std::string servant_loc = getCurrentDirectory() + "\\dinner_SERVANT.dll";
	std::string phil_loc = getCurrentDirectory() + "\\dinner_PhilosopherImpl.dll";
	std::string cutl_loc = getCurrentDirectory() + "\\dinner_CutleryImpl.dll";
	std::string obse_loc = getCurrentDirectory() + "\\dinner_ObserverImpl.dll";
#else
	std::string servant_loc = getCurrentDirectory() + "/libdinner_SERVANT.so";
	std::string phil_loc = getCurrentDirectory() + "/libdinner_PhilosopherImpl.so";
	std::string cutl_loc = getCurrentDirectory() + "/libdinner_CutleryImpl.so";
	std::string obse_loc = getCurrentDirectory() + "/libdinner_ObserverImpl.so";
#endif
	std::string loc_p = servant_loc + ";create_PhilosopherHomeS;" + phil_loc + ";create_PhilosopherHomeE";
	std::string loc_c = servant_loc + ";create_CutleryHomeS;" + cutl_loc + ";create_CutleryHomeE";
	std::string loc_o = servant_loc + ";create_ObserverHomeS;" + obse_loc + ";create_ObserverHomeE";

	try
	{
		component_installer->install ("PHILOSOPHER", loc_p.c_str());
		component_installer->install ("CUTLERY", loc_c.c_str());
		component_installer->install ("OBSERVER", loc_o.c_str());
	}
	catch (Components::Deployment::InvalidLocation&)
	{
		cerr << "Component Installer raised Components::Deployment::InvalidLocation" << endl;
	}
	catch (Components::Deployment::InstallationFailure&)
	{
		cerr << "Component Installer raised Components::Deployment::InstallationFailure" << endl;
	}
}
Ejemplo n.º 9
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;
}