• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cosnaming::NamingContext_var类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cosnaming::NamingContext_var的典型用法代码示例。如果您正苦于以下问题:C++ NamingContext_var类的具体用法?C++ NamingContext_var怎么用?C++ NamingContext_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了NamingContext_var类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OBJECT_NOT_EXIST

CosNaming::NamingContext_ptr
TAO_Transient_Naming_Context::new_context (void)
{
  ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
                      ace_mon,
                      this->lock_,
                      CORBA::INTERNAL ());

  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Generate a POA id for the new context.
  char poa_id[BUFSIZ];
  ACE_OS::sprintf (poa_id,
                   "%s_%d",
                   this->poa_id_.c_str (),
                   this->counter_++);

  // Create a new context.
  CosNaming::NamingContext_var result =
    make_new_context (this->poa_.in (),
                      poa_id,
                      this->transient_context_->total_size ());

  return result._retn ();
}
开发者ID:asdlei00,项目名称:ACE,代码行数:28,代码来源:Transient_Naming_Context.cpp


示例2:

Web_Server::Iterator_Factory_ptr
get_iterator (CORBA::ORB_ptr o)
{
  CORBA::ORB_var orb = CORBA::ORB::_duplicate (o);

  // Get a reference to the Name Service.
  CORBA::Object_var obj =
    orb->resolve_initial_references ("NameService");

  // Narrow to a Naming Context
  CosNaming::NamingContext_var nc =
    CosNaming::NamingContext::_narrow (obj.in ());

  if (CORBA::is_nil (obj.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Nil reference to Name Service\n")));
      return Web_Server::Iterator_Factory::_nil ();
    }

  // Create a name.
  CosNaming::Name name;
  name.length (1);
  name[0].id = CORBA::string_dup ("Iterator_Factory");
  name[0].kind = CORBA::string_dup ("");

  obj = nc->resolve (name);

  Web_Server::Iterator_Factory_ptr factory =
    Web_Server::Iterator_Factory::_narrow (obj.in ());

  return factory;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:33,代码来源:client.cpp


示例3: OnContextPopupBindContext

void CNamingTreeCtrl::OnContextPopupBindContext()
{
  // TODO: Add your command handler code here
  CBindDialog Dialog(true, m_pORB);
  if(Dialog.DoModal() != IDOK)
  {
    return;
  }
  try
  {
    CNamingObject* pObject = GetTreeObject();
    CosNaming::NamingContext_var Context = pObject->NamingContext();
    if(CORBA::is_nil(Context.in ()))
    {
      return;
    }
    CosNaming::NamingContext_var NewContext = CosNaming::NamingContext::_narrow(Dialog.GetObject());
    if(CORBA::is_nil(NewContext.in ()))
    {
      AfxMessageBox(ACE_TEXT ("Object is not a CosNaming::NamingContext"));
      return;
    }
    Context->bind_context(Dialog.GetName(), NewContext);
    OnContextPopupRefresh();
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:30,代码来源:NamingTreeCtrl.cpp


示例4: OnObjectpopupUnbind

void CNamingTreeCtrl::OnObjectpopupUnbind()
{
  // TODO: Add your command handler code here
  if(MessageBox(ACE_TEXT ("Are you sure you want to unbind this object?"),
                ACE_TEXT ("Confirm"), MB_YESNO | MB_ICONEXCLAMATION) != IDYES)
  {
    return;
  }
  HTREEITEM hItem = GetSelectedItem();
  HTREEITEM hParent = GetParentItem(hItem);
  if(!hParent)
  {
    return;
  }
  CNamingObject* pObject = GetTreeObject(hItem);
  CNamingObject* pParent= GetTreeObject(hParent);
  CosNaming::NamingContext_var Context = pParent->NamingContext();
  try
  {
    Context->unbind(pObject->Name());
    ClearChildren(hItem);
    delete pObject;
    DeleteItem(hItem);
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:29,代码来源:NamingTreeCtrl.cpp


示例5: OnContextPopupDestroy

void CNamingTreeCtrl::OnContextPopupDestroy()
{
  // TODO: Add your command handler code here
  if(MessageBox(ACE_TEXT ("Are you sure you want to destroy this context?"),
                ACE_TEXT ("Confirm"), MB_YESNO | MB_ICONEXCLAMATION) != IDYES)
  {
    return;
  }
  HTREEITEM hItem = GetSelectedItem();
  HTREEITEM hParent = GetParentItem(hItem);
  if(!hParent)
  {
    return;
  }
  CNamingObject* pObject = GetTreeObject(hItem);
  CNamingObject* pParent= GetTreeObject(hParent);
  CosNaming::NamingContext_var Parent = pParent->NamingContext();
  try
  {
    // First try to destroy, it will raise exception if its not empty
    CosNaming::NamingContext_var Context = pObject->NamingContext();
    Context->destroy();
    // Ok its destroyed, clean up any children we might have laying around
    ClearChildren(hItem);
    DeleteItem(hItem);
    // do the unbind
    Parent->unbind(pObject->Name());
    delete pObject;
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:34,代码来源:NamingTreeCtrl.cpp


示例6: bindRecursive

  /*!
   * @if jp
   * @brief 途中のコンテキストを再帰的に bind しながら Object を bind する
   * @else
   * @brief Bind intermediate context recursively and bind object
   * @endif
   */
  void CorbaNaming::bindRecursive(CosNaming::NamingContext_ptr context,
				  const CosNaming::Name& name,
				  CORBA::Object_ptr obj)
    throw (SystemException, CannotProceed, InvalidName, AlreadyBound)
  {
    CORBA::ULong len(name.length());
    CosNaming::NamingContext_var cxt;
    cxt = CosNaming::NamingContext::_duplicate(context);
    
    for (CORBA::ULong i = 0; i < len; ++i)
      {
	if (i == (len - 1))
	  { // this operation may throw AlreadyBound, 
	    cxt->bind(subName(name, i, i), obj);
	    return;
	  }
	else
	  { // If the context is not a NamingContext, CannotProceed is thrown
	    if (isNamingContext(cxt))
	      cxt = bindOrResolveContext(cxt, subName(name, i, i));
	    else
	      throw CannotProceed(cxt, subName(name, i));
	  }
      }
    return;
  }
开发者ID:pansas,项目名称:OpenRTM-aist-portable,代码行数:33,代码来源:CorbaNaming.cpp


示例7: OBJECT_NOT_EXIST

void
TAO_Hash_Naming_Context::bind_context (const CosNaming::Name &n,
                                       CosNaming::NamingContext_ptr nc)
{
  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Do not allow binding of nil context reference.
  if (CORBA::is_nil (nc))
    throw CORBA::BAD_PARAM ();

  // Get the length of the name.
  CORBA::ULong const name_len = n.length ();

  // Check for invalid name.
  if (name_len == 0)
    throw CosNaming::NamingContext::InvalidName();

  // If we received compound name, resolve it to get the context in
  // which the binding should take place, then perform the binding on
  // target context.
  if (name_len > 1)
    {
      CosNaming::NamingContext_var context = this->get_context (n);

      CosNaming::Name simple_name;
      simple_name.length (1);
      simple_name[0] = n[name_len - 1];
      try
        {
          context->bind_context (simple_name, nc);
        }
      catch (const CORBA::SystemException&)
        {
          throw CosNaming::NamingContext::CannotProceed(
            context.in (), simple_name);
        }
    }
  // If we received a simple name, we need to bind it in this context.
  else
    {
      ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
                                this->lock_,
                                CORBA::INTERNAL ());

      // Try binding the name.
      int result = this->context_->bind (n[0].id,
                                        n[0].kind,
                                        nc,
                                        CosNaming::ncontext);
      if (result == 1)
        throw CosNaming::NamingContext::AlreadyBound();

      // Something went wrong with the internal structure
      else if (result == -1)
        throw CORBA::INTERNAL ();
    }
}
开发者ID:binary42,项目名称:OCI,代码行数:60,代码来源:Hash_Naming_Context.cpp


示例8:

void
handle_sigint
( int signal )
{
	std::cout << "\nGot Crtl-C" << std::endl;
	std::cerr << "..... unbind in NameService" << std::endl;

	//
	// unbind in naming service
	//
    CORBA::Object_var obj;
	CosNaming::NamingContext_var nameService;
	char hostname[256];
	gethostname(hostname, 256);
	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("ComponentInstallation");
    name[1].kind = CORBA::string_dup("");
	name[2].id = CORBA::string_dup(hostname);
    name[2].kind = CORBA::string_dup("");
    try
    {
        obj = orb->resolve_initial_references("NameService");
		nameService = CosNaming::NamingContext::_narrow(obj.in());
		nameService->unbind(name);
    }
	catch (const CORBA::Exception&)
	{
		std::cerr << "..... could not unbind" << std::endl;
	}
	
	exit(1);
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:35,代码来源:ci.cpp


示例9: OnContextpopupBindnewcontext

void CNamingTreeCtrl::OnContextpopupBindnewcontext()
{
  // TODO: Add your command handler code here
  HTREEITEM hItem = GetSelectedItem();
  CNamingObject* pObject = GetTreeObject(hItem);
  CosNaming::NamingContext_var Context = pObject->NamingContext();
  if(CORBA::is_nil(Context.in ()))
  {
    return;
  }
  CBindNewContext Dialog;
  if(Dialog.DoModal() != IDOK)
  {
    return;
  }
  try
  {
    CosNaming::NamingContext_var NewContext = Context->new_context();
    Context->bind_context(Dialog.GetName(), NewContext);
    OnContextPopupRefresh();
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:26,代码来源:NamingTreeCtrl.cpp


示例10: throw

void
VOmniORBHelper::nsRegisterObject(CORBA::Object_ptr obj,
				 const char* program, const char* object,
				 int telescopenumber)
  throw(CORBA::SystemException, 
	CosNaming::NamingContext::NotFound,
	CosNaming::NamingContext::CannotProceed,
	CosNaming::NamingContext::InvalidName,
	CosNaming::NamingContext::AlreadyBound)
{
  ZThread::Guard<ZThread::RecursiveMutex> guard(m_mutex);
  CosNaming::NamingContext_var root = nsRootContext();
  CosNaming::Name_var name = 
    nsPathToObjectName(program, object, telescopenumber);

  for(unsigned int n=0; n<name->length()-1; n++)
    {
      CosNaming::Name_var child_name = name;
      child_name->length(n+1);
      
      try
	{
	  CORBA::Object_var object = root->resolve(child_name);
	}
      catch(CosNaming::NamingContext::NotFound)
	{
	  CosNaming::NamingContext_var 
	    child = root->bind_new_context(child_name);
	}
    }

  root->rebind(name,obj);
}
开发者ID:sfegan,项目名称:astro_db_reslover,代码行数:33,代码来源:VOmniORBHelper.cpp


示例11: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try {
    // Initialize orb
    CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );

    //Get reference to Root POA
    CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
    PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );

    // Activate POA Manager
    PortableServer::POAManager_var mgr = poa->the_POAManager();
    mgr->activate();


    // Find the Naming Service
    obj = orb->resolve_initial_references("NameService");
    CosNaming::NamingContext_var root =
      CosNaming::NamingContext::_narrow(obj.in());
    if (CORBA::is_nil(root.in())) {
      std::cerr << "Nil Naming Context reference" << std::endl;
      return 1;
    }

    // Bind the example Naming Context, if necessary
    CosNaming::Name name;
    name.length( 1 );
    name[0].id = CORBA::string_dup("example");
    try {
      obj = root->resolve(name);
    }
    catch(const CosNaming::NamingContext::NotFound&) {
      CosNaming::NamingContext_var dummy = root->bind_new_context(name);
    }

    // Bind the Messenger object
    name.length(2);
    name[1].id = CORBA::string_dup("Messenger");

    // Create an object
    PortableServer::Servant_var<Messenger_i> servant = new Messenger_i;
    PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
    obj = poa->id_to_reference(oid.in());
    Messenger_var messenger = Messenger::_narrow(obj.in());
    root->rebind(name, messenger.in());

    std::cout << "Messenger object bound in Naming Service" << std::endl;

    // Accept requests
    orb->run();
    orb->destroy();
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "server: Caught a CORBA::Exception: " << ex << std::endl;
    return 1;
  }

  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:59,代码来源:MessengerServer.cpp


示例12: getObjectReference

static CORBA::Object_ptr getObjectReference(CORBA::ORB_ptr orb) {
  CosNaming::NamingContext_var rootContext;
  
  try {
    // Obtain a reference to the root context of the Name service:
    CORBA::Object_var obj;
    obj = orb->resolve_initial_references("NameService");

    // Narrow the reference returned.
    rootContext = CosNaming::NamingContext::_narrow(obj);
    if( CORBA::is_nil(rootContext) ) {
      cerr << "Failed to narrow the root naming context." << endl;
      return CORBA::Object::_nil();
    }
  } catch (CORBA::NO_RESOURCES&) {
    cerr << "Caught NO_RESOURCES exception. You must configure omniORB "
	 << "with the location" << endl
	 << "of the naming service." << endl;
    return 0;
  } catch(CORBA::ORB::InvalidName& ex) {
    // This should not happen!
    cerr << "Service required is invalid [does not exist]." << endl;
    return CORBA::Object::_nil();
  }

  // Create a name object, containing the name test/context:
  CosNaming::Name name;
  name.length(2);

  name[0].id   = (const char*) "test";       // string copied
  name[0].kind = (const char*) "my_context"; // string copied
  name[1].id   = (const char*) "IdServer";
  name[1].kind = (const char*) "Object";
  // Note on kind: The kind field is used to indicate the type
  // of the object. This is to avoid conventions such as that used
  // by files (name.type -- e.g. test.ps = postscript etc.)

  try {
    // Resolve the name to an object reference.
    return rootContext->resolve(name);
  } catch(CosNaming::NamingContext::NotFound& ex) {
    // This exception is thrown if any of the components of the
    // path [contexts or the object] aren't found:
    cerr << "Context not found." << endl;
  } catch(CORBA::TRANSIENT& ex) {
    cerr << "Caught system exception TRANSIENT -- unable to contact the "
         << "naming service." << endl
	 << "Make sure the naming server is running and that omniORB is "
	 << "configured correctly." << endl;

  } catch(CORBA::SystemException& ex) {
    cerr << "Caught a CORBA::" << ex._name()
	 << " while using the naming service." << endl;
    return 0;
  }

  return CORBA::Object::_nil();
}
开发者ID:vibonadia,项目名称:CORBAIDServer,代码行数:58,代码来源:idserver_clt.cpp


示例13: main

int main(int argc, char *argv[])
{
    CORBA::ORB_var orb = CORBA::ORB::_nil();
  
    try {

	orb = CORBA::ORB_init(argc, argv);
	
	CORBA::Object_var obj;
	
	obj = orb->resolve_initial_references("RootPOA");
	PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
	if(CORBA::is_nil(poa)){
	    throw std::string("error: failed to narrow root POA.");
	}
	
	PortableServer::POAManager_var poaManager = poa->the_POAManager();
	if(CORBA::is_nil(poaManager)){
	    throw std::string("error: failed to narrow root POA manager.");
	}
	
	OnlineViewer_impl* OnlineViewerImpl = new OnlineViewer_impl(orb, poa);
	poa->activate_object(OnlineViewerImpl);
	OnlineViewer_var OnlineViewer = OnlineViewerImpl->_this();
	OnlineViewerImpl->_remove_ref();

	obj = orb->resolve_initial_references("NameService");
	CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(obj);
	if(CORBA::is_nil(namingContext)){
	    throw std::string("error: failed to narrow naming context.");
	}
	
	CosNaming::Name name;
	name.length(1);
	name[0].id = CORBA::string_dup("OnlineViewer");
	name[0].kind = CORBA::string_dup("");
	namingContext->rebind(name, OnlineViewer);

	poaManager->activate();
	
        glmain(argc, argv);
    }
    catch (CORBA::SystemException& ex) {
        std::cerr << ex._rep_id() << std::endl;
    }
    catch (const std::string& error){
        std::cerr << error << std::endl;
    }

    try {
	orb->destroy();
    }
    catch(...){

    }
    
    return 0;
}
开发者ID:fkanehiro,项目名称:glutolv,代码行数:58,代码来源:glutolv.cpp


示例14: Messenger_i

int
ACE_TMAIN (int argc, ACE_TCHAR *argv [])
{
  try
  {
    // Initialize orb
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    if (parse_args (argc, argv) != 0)
      return 1;

    // Find the Naming Service.
    CORBA::Object_var rootObj =  orb->resolve_initial_references("NameService");
    CosNaming::NamingContext_var rootNC =
      CosNaming::NamingContext::_narrow(rootObj.in());

    // Get the  Root POA.
    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());

    // Activate POA manager
    PortableServer::POAManager_var mgr = poa->the_POAManager();
    mgr->activate();

    // Create our Messenger servant.
    PortableServer::Servant_var<Messenger_i> messenger_servant =
      new Messenger_i(orb.in());

    // Register it with the RootPOA.
    PortableServer::ObjectId_var oid =
      poa->activate_object( messenger_servant.in() );
    CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );

    // Bind it in the Naming Service.
    CosNaming::Name name;
    name.length (1);
    name[0].id = CORBA::string_dup("MessengerService");
    rootNC->rebind(name, messenger_obj.in());

    CORBA::String_var str = orb->object_to_string (messenger_obj.in());
    std::ofstream iorFile (ACE_TEXT_ALWAYS_CHAR(ior_output_file));
    iorFile << str.in () << std::endl;
    iorFile.close ();
    std::cout << "IOR written to file " << ior_output_file << std::endl;

    // Accept requests
    orb->run();
    orb->destroy();

  }
  catch(const CORBA::Exception& ex) {
    std::cerr << ex << std::endl;
    return 1;
  }
  return 0;

}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:57,代码来源:MessengerServer.cpp


示例15: main

int main( int argc, char *argv[] )
{
  try 
  {
    // Initialize the CORBA Object Request Broker
    CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );

	// Find the CORBA Services Naming Service
	CORBA::Object_var naming_obj = orb->resolve_initial_references("NameService");
	CosNaming::NamingContext_var root = CosNaming::NamingContext::_narrow(naming_obj.in());
	if(CORBA::is_nil(root.in()))
	{
		cerr << "Could not narrow NameService to NamingContext!" << endl;
		throw 0;
	}

    // Resolve the desired object (ExampleInterfaces.IAdder).
	// The module and interface bindings need to be the same here in the client as they
	// are in the server.
    CosNaming::Name name;
    name.length(2);
    name[0].id = CORBA::string_dup( "ExampleInterfaces" );	// IDL-defined Module (namespace)
    name[1].id = CORBA::string_dup( "IAdder" );				// IDL-defined Interface (interface class)
    CORBA::Object_var obj = root->resolve(name);

    // Narrow to confirm that we have the interface we want.
	ExampleInterfaces::IAdder_var iAdder = ExampleInterfaces::IAdder::_narrow(obj.in());
    if (CORBA::is_nil(iAdder.in())) 
	{
      cerr << "Could not narrow to an iAdder reference" << endl;
      return 1;
    }

	// Now use the remote object...
	cout << "Using a remote object that implements the IAdder interface..." << endl;
	cout << endl;
	double number1 = 0;
	double number2 = 0;
	double sum = 0;
	while (true)
	{
		cout << "Enter the first number: ";
		cin >> number1;
		cout << "Enter the second number: ";
		cin >> number2;
		sum = iAdder->add(number1, number2);
		cout << "The sum is: " << sum << endl;
		cout << "------------------" << endl;
	}
  }
  catch ( CORBA::Exception& ex ) {
    cerr << "Caught a CORBA::Exception: " << ex << endl;
    return 1;
  }
  
  return 0;
}
开发者ID:lwFace,项目名称:CSharp,代码行数:57,代码来源:TAOAdderClient.cpp


示例16: ACE_TMAIN

int ACE_TMAIN(int argc, ACE_TCHAR * argv[])
{
    try
    {
        // Initialize orb
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

        CORBA::Object_var rootObj =
            orb->resolve_initial_references("NameService");

        CosNaming::NamingContext_var rootContext =
            CosNaming::NamingContext::_narrow(rootObj.in());

        CosNaming::Name name;
        name.length (1);
        name[0].id = CORBA::string_dup ("MessengerService");

        CORBA::Object_var messengerObj = rootContext->resolve(name);

        if (CORBA::is_nil(messengerObj.in())) {
            std::cerr << "Nil Messenger reference" << std::endl;
            return 1;
        }

        // Narrow
        Messenger_var messenger = Messenger::_narrow(messengerObj.in());
        if (CORBA::is_nil(messenger.in ())) {
            std::cerr << "Argument is not a Messenger reference" << std::endl;
            return 1;
        }

        CORBA::String_var message = CORBA::string_dup(
                                        "We are experiencing network problems.");
        messenger->send_message ("[email protected]",
                                 "urgent",
                                 message.inout());

        message = CORBA::string_dup("Where can I get TAO?");
        messenger->send_message ("[email protected]",
                                 "OCI's Distribution of TAO",
                                 message.inout());

        message = CORBA::string_dup(
                      "Please contact [email protected] regarding your request.");
        messenger->send_message ("[email protected]",
                                 "OCI's Distribution of TAO",
                                 message.inout());

    }
    catch(const CORBA::Exception& ex) {
        std::cerr << "Caught a CORBA exception: " << ex << std::endl;
        return 1;
    }

    std::cout << "MessengerClient: success" << std::endl;
    return 0;
}
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:57,代码来源:MessengerClient.cpp


示例17: checkLogging

static void checkLogging(ACSDaemonContext * context, short instance)
{
	if (!loggingSystemInitialized)
	{
		// we need msg_callback to get LoggingProxy
		if (ACE_LOG_MSG->msg_callback () != 0 &&
				context->hasConfigurationReference(instance, acsServices[NAMING_SERVICE].xmltag))
		{
			try
			{
				// we get via NS and not a manager (to support logging when manager is not running)
				std::string nsReference = context->getConfigurationReference(instance, acsServices[NAMING_SERVICE].xmltag);
				CORBA::Object_var nc_obj = context->getORB()->string_to_object(nsReference.c_str());
				if (nc_obj.ptr() != CORBA::Object::_nil())
				{
					CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow(nc_obj.in());
					if (nc.ptr() != CosNaming::NamingContext::_nil())
					{
						CosNaming::Name name;
						name.length(1);
						name[0].id = CORBA::string_dup("Log");

						CORBA::Object_var obj = nc->resolve(name);
						if (!CORBA::is_nil(obj.in()))
                    	{
							Logging::AcsLogService_var logger = Logging::AcsLogService::_narrow(obj.in());

							LoggingProxy* lp = static_cast<LoggingProxy*>(ACE_LOG_MSG->msg_callback());
							lp->setCentralizedLogger(logger.in());
							lp->setNamingContext(nc.in());
                            loggingSystemInitialized = true;
                            ACS_SHORT_LOG((LM_DEBUG, "Remote logging system initialized."));
                        }
						else
						{
							ACS_SHORT_LOG((LM_DEBUG, "Unable to resolve Log from the naming service."));
						}
					}
					else
					{
						ACS_SHORT_LOG((LM_DEBUG, "Unable to narrow NamingContext."));
					}
				}
				else
				{
					ACS_SHORT_LOG((LM_ERROR, "Unable to resolve naming service, invalid corbaloc reference: '%s'.", nsReference.c_str()));
				}
			}
			catch (...)
			{
				ACS_SHORT_LOG((LM_DEBUG, "Unable to initialize logging sytem, unexpected exception caught."));
			}
		}
	}
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:55,代码来源:acsServiceController.cpp


示例18: My_Test_Object

int
MT_Test::execute (TAO_Naming_Client &root_context)
{
  if (CORBA::is_nil (this->orb_.in ()))
    return -1;

  // Create data which will be used by all threads.

  // Dummy object instantiation.
  My_Test_Object *test_obj_impl =
    new My_Test_Object (CosNaming_Client::OBJ1_ID);

  try
    {
      test_ref_ =
        test_obj_impl->_this ();

      test_obj_impl->_remove_ref ();

      // Get the IOR for the Naming Service.  Each thread can use it
      // in <string_to_object> to create its own stub for the Naming
      // Service.  This 'trick' is necessary, because multiple threads
      // cannot be using the same stub - bad things happen...  This is
      // just a way to give each thread its own stub.

      CosNaming::NamingContext_var context =
        root_context.get_context ();

      name_service_ior_ =
        orb_->object_to_string (context.in ());

    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "Unexpected exception while instantiating dummy");
      return -1;
    }

  // Create a name for dummy.
  test_name_.length (1);
  test_name_[0].id = CORBA::string_dup ("Foo");

  // Spawn threads, each of which will be executing svc ().
  int status = this->activate (THR_NEW_LWP | THR_JOINABLE,
                               size_);

  if (status == -1)
    return -1;

  status = this->wait ();
  return status;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:53,代码来源:client.cpp


示例19: sigemptyset

void
handle_sigint
( int sig )
{
#ifdef HAVE_SIGACTION
	 struct sigaction act;

    /* Assign sig_chld as our SIGINT handler */
    act.sa_handler = SIG_IGN;

    /* We don't want to block any other signals in this example */
    sigemptyset(&act.sa_mask);

	 sigaction(SIGINT,&act,0);
#else
	signal(sig, SIG_IGN);
#endif
	std::cout << "\nGot Crtl-C" << std::endl;
	std::cerr << "..... unbind in NameService" << std::endl;

	//
	// unbind in naming service
	//
    CORBA::Object_var obj;
	CosNaming::NamingContext_var nameService;
	char hostname[256];
	gethostname(hostname, 256);
	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("ComponentInstallation");
    name[1].kind = CORBA::string_dup("");
	name[2].id = CORBA::string_dup(hostname);
    name[2].kind = CORBA::string_dup("");
    try
    {
        obj = orb->resolve_initial_references("NameService");
		nameService = CosNaming::NamingContext::_narrow(obj.in());
		nameService->unbind(name);
    }
	catch (const CORBA::Exception&)
	{
		std::cerr << "..... could not unbind" << std::endl;
	}
	catch(...)
	{
		std::cerr << "..... error in signal handler" << std::endl;
	}
	
	exit(1);
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:52,代码来源:qci.cpp


示例20: getObjectReference

CORBA::Object_ptr getObjectReference(CORBA::ORB_ptr orb, const char serviceName[])
{  
   CosNaming::NamingContext_var rootContext;

   try
   {  
      // Obtain a reference to the root context of the name service:
      CORBA::Object_var initServ;
      initServ = orb->resolve_initial_references("NameService");

      // Narrow the object returned by resolve_initial_references() to a CosNaming::NamingContext 
      // object
      rootContext = CosNaming::NamingContext::_narrow(initServ);
      if (CORBA::is_nil(rootContext))
      {  
         cerr << "Failed to narrow naming context." << endl;
         return CORBA::Object::_nil();
      }
   }
   catch (CORBA::ORB::InvalidName&)
   {  
      cerr << "Name service does not exist." << endl;
      return CORBA::Object::_nil();
   }

   // Create a name object, containing the name corejava/SysProp:
   CosNaming::Name name;
   name.length(1);

   name[0].id   = serviceName;
   name[0].kind = "Object";

   CORBA::Object_ptr obj;
   try
   {  
      // Resolve the name to an object reference, and assign the returned reference to a 
      // CORBA::Object:
      obj = rootContext->resolve(name);
   }
   catch (CosNaming::NamingContext::NotFound&)
   {  
      // This exception is thrown if any of the components of the path [contexts or the object] 
      // aren't found:
      cerr << "Context not found." << endl;
      return CORBA::Object::_nil();
   }
   return obj;
}
开发者ID:wanghcster,项目名称:corejava7,代码行数:48,代码来源:SysPropClient.cpp



注:本文中的cosnaming::NamingContext_var类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cosnotification::EventTypeSeq类代码示例发布时间:2022-05-31
下一篇:
C++ cosnaming::Name类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap