当前位置: 首页>>代码示例>>C++>>正文


C++ ORB_var::resolve_initial_references方法代码示例

本文整理汇总了C++中corba::ORB_var::resolve_initial_references方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_var::resolve_initial_references方法的具体用法?C++ ORB_var::resolve_initial_references怎么用?C++ ORB_var::resolve_initial_references使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corba::ORB_var的用法示例。


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

示例1: policies

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

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      CORBA::Object_var object =
        orb->resolve_initial_references ("PolicyCurrent");

      CORBA::PolicyCurrent_var policy_current =
        CORBA::PolicyCurrent::_narrow (object.in ());

      if (CORBA::is_nil (policy_current.in ()))
        {
          ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n"));
          return 1;
        }
      CORBA::Any scope_as_any;
      scope_as_any <<= Messaging::SYNC_WITH_SERVER;

      CORBA::PolicyList policies(1); policies.length (1);
      policies[0] =
        orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
                            scope_as_any);

      policy_current->set_policy_overrides (policies,
                                            CORBA::ADD_OVERRIDE);

      policies[0]->destroy ();

      seed = (unsigned int) ACE_OS::gethrtime ();

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

      ACE_DEBUG ((LM_DEBUG, "SEED = %u\n", seed));

      Server_Peer *impl;
      ACE_NEW_RETURN (impl,
                      Server_Peer (seed, orb.in (), payload_size),
                      1);
      PortableServer::ServantBase_var owner_transfer(impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (impl);

      CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());

      Test::Peer_var peer =
        Test::Peer::_narrow (object_act.in ());

      CORBA::String_var ior =
        orb->object_to_string (peer.in ());

      // If the ior_output_file exists, output the ior to it
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                              1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      Sleeper sleeper (orb.in ());

      ACE_Time_Value interval(0, 500000);
      ACE_Reactor * reactor = orb->orb_core()->reactor();
      reactor->schedule_timer(&sleeper, 0, interval, interval);

      // ACE_Time_Value run_time(600, 0);
      // orb->run (run_time);
      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:server.cpp

示例2: catch

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

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

      CORBA::Object_var object =
        orb->string_to_object (ior);

      UDP_var udp_var =
        UDP::_narrow (object.in ());

      if (CORBA::is_nil (udp_var.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Object reference <%s> is nil.\n",
                             ior),
                            1);
        }

      // Activate POA to handle the call back.
      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      poa_manager->activate ();

      // Instantiate reply handler
      UDP_i udp_i;

      // let it remember our ORB
      udp_i.orb (orb.in ());

      UDP_var udpHandler_var =
        udp_i._this ();

      // Instantiate client
      ACE_Task_Base* client = new UDP_PerformanceClient (orb.in (),
                                                         udp_var.in (),
                                                         &udp_i,
                                                         burst_messages);

      // let the client run in a separate thread
      client->activate ();

      // ORB loop, will be shut down by our client thread
      orb->run ();  // Fetch responses

      ACE_DEBUG ((LM_DEBUG, "ORB finished\n"));

      client->wait ();

      root_poa->destroy (1, // ethernalize objects
                         0  // wait for completion
                         );

      orb->destroy ();

      // it is save to delete the client, because the client was actually
      // the one calling orb->shutdown () triggering the end of the ORB
      // event loop.
      delete client;

    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught exception:");
      return 1;
    }

  return 0;
}
开发者ID:INMarkus,项目名称:ATCD,代码行数:87,代码来源:client.cpp

示例3: catch

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

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

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

      CORBA::String_var repo_id =
        "IDL:omg.org/CosNotifyComm/StructuredPushConsumer:1.0";

      CORBA::Object_var object =
        root_poa->create_reference (repo_id.in());

      CORBA::String_var ior = orb->object_to_string (object.in ());

      FILE *output_file= ACE_OS::fopen (output_filename, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("Cannot open output file for writing IOR: %C\n"),
                           output_file),
                           1);
      const char * dummy_consumer_proxy = ior.in();

      ACE_OS::fprintf (output_file, format,
                       dummy_consumer_proxy, dummy_consumer_proxy,
                       dummy_consumer_proxy, dummy_consumer_proxy);
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:63,代码来源:proxy_dummy.cpp

示例4:

int
main (int argc, char** argv)
{
	cout << "Test Client for Stream Container" << endl;

	CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

    orb->register_value_factory ("IDL:omg.org/Components/FacetDescription:1.0", new FacetDescriptionFactory_impl());
	orb->register_value_factory ("IDL:omg.org/Components/ReceptacleDescription:1.0", new ReceptacleDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/SubscriberDescription:1.0", new SubscriberDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/EmitterDescription:1.0", new EmitterDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/ConsumerDescription:1.0", new ConsumerDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/ComponentPortDescription:1.0", new ComponentPortDescriptionFactory_impl());
    orb->register_value_factory ("IDL:omg.org/Components/Cookie:1.0", new CookieFactory_impl());

	CosNaming::NamingContext_var ns;

	try
	{
		CORBA::Object_var ns_obj = orb->resolve_initial_references ("NameService");
		ns = CosNaming::NamingContext::_narrow (ns_obj);
	}
	catch (CORBA::ORB::InvalidName&)
	{
		cerr << "Name Service not found" << endl;
		orb->destroy();
		exit (1);
	}
	catch (CORBA::SystemException&)
	{
		cerr << "Cannot narrow object reference of Name Service" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (ns))
	{
		cerr << "Name Service is nil" << endl;
		orb->destroy();
		exit (1);
	}

	// Now get the Component Server Activator from the Name Service, use the name TETRA/Activators/<hostname>
	char hostname[256];
	if (gethostname (hostname, 256))
	{
		cerr << "Cannot determine my hostname" << endl;
		orb->destroy();
		exit (1);
	}

	// Get the Server Activator
	Components::Deployment::ServerActivator_var server_activator = get_server_activator (orb, ns, hostname);

	// Feed our test deployment into the Component Installer
	deploy_test_components (orb, ns, hostname);

	//
	// Begin tests
	//

	// Create Component Server
	Components::ConfigValues config;
	Components::ConfigValues config1;
	Components::Deployment::ComponentServer_var component_server;
	Components::Deployment::ComponentServer_var component_server1;
	Components::Deployment::ComponentServer_var component_server2;

	try
	{
		component_server = 	server_activator->create_component_server (config1);
	}
	catch (CORBA::Exception&)
	{
		cerr << "Exception during test run" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (component_server))
	{
		cerr << "I got a nil reference for the created Component Server" << endl;
		orb->destroy();
		exit (1);
	}
#if 0
	try
	{
		component_server1 = 	server_activator->create_component_server (config1);
	}
	catch (CORBA::Exception&)
	{
		cerr << "Exception during test run" << endl;
		orb->destroy();
		exit (1);
	}

	if (CORBA::is_nil (component_server1))
	{
		cerr << "I got a nil reference for the created Component Server" << endl;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:qedo,代码行数:101,代码来源:main.cpp

示例5:

CORBA::Object_ptr
TAO_Trading_Loader::create_object (CORBA::ORB_ptr orb_ptr,
                                   int argc,
                                   ACE_TCHAR *argv[])
{
  // Duplicate the ORB
  CORBA::ORB_var orb = CORBA::ORB::_duplicate (orb_ptr);

  // Activating the poa manager
  this->orb_manager_.activate_poa_manager ();

  // Create a Trader Object and set its Service Type Repository.
  auto_ptr<TAO_Trader_Factory::TAO_TRADER> auto_trader (TAO_Trader_Factory::create_trader (argc, argv));

  this->trader_ = auto_trader;

  TAO_Support_Attributes_i &sup_attr =
    this->trader_->support_attributes ();

  TAO_Trading_Components_i &trd_comp =
    this->trader_->trading_components ();

  sup_attr.type_repos (this->type_repos_._this ());

  // The Spec says: return a reference to the Lookup interface from
  // the resolve_initial_references method.
  CosTrading::Lookup_ptr lookup =
    trd_comp.lookup_if ();

  this->ior_ =
    orb->object_to_string (lookup);

  // Parse the args
  if (this->parse_args (argc, argv) == -1)
    return CORBA::Object::_nil ();

  // Dump the ior to a file.
  if (this->ior_output_file_ != 0)
    {
      ACE_OS::fprintf (this->ior_output_file_,
                       "%s",
                       this->ior_.in ());
      ACE_OS::fclose (this->ior_output_file_);
    }

  CORBA::Object_var table_object =
    orb->resolve_initial_references ("IORTable");

  IORTable::Table_var adapter =
    IORTable::Table::_narrow (table_object.in ());

  if (CORBA::is_nil (adapter.in ()))
    {
      ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n"));
    }
  else
    {
      adapter->bind ("TradingService",
                     this->ior_.in ());
    }

  if (this->federate_)
    {
      // Only become a multicast server if we're the only trader
      // on the multicast network.
      // @@ Could do other things. For example, every timeout
      // period try to federate again, but let's not hardcode that
      // policy.
      int rc = this->bootstrap_to_federation ();

      if (rc == -1)
        this->init_multicast_server ();
    }
  else
    this->init_multicast_server ();

  return CORBA::Object::_nil ();
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:78,代码来源:Trading_Loader.cpp

示例6: display_impl

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{


    try
    {
        Server_ORBInitializer *temp_initializer = 0;
        ACE_NEW_RETURN (temp_initializer,
                        Server_ORBInitializer,
                        -1);  // No exceptions yet!
        PortableInterceptor::ORBInitializer_var orb_initializer =
            temp_initializer;

        PortableInterceptor::register_orb_initializer (orb_initializer.in ());

        CORBA::ORB_var orb =
            CORBA::ORB_init (argc, argv);

        // We do the command line parsing first
        if (parse_args (argc, argv) != 0)
            return -1;
        CORBA::Object_var poa_object =
            orb->resolve_initial_references("RootPOA");

        if (CORBA::is_nil (poa_object.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Unable to initialize the POA.\n"),
                              -1);

        PortableServer::POA_var root_poa =
            PortableServer::POA::_narrow (poa_object.in ());

        PortableServer::POAManager_var poa_manager =
            root_poa->the_POAManager ();

        CORBA::PolicyList policies;
        policies.length (3);
        policies[0] = root_poa->create_id_assignment_policy (
                          PortableServer::USER_ID);
        policies[1] = root_poa->create_implicit_activation_policy (
                          PortableServer::NO_IMPLICIT_ACTIVATION);
        policies[2] = root_poa->create_lifespan_policy (
                          PortableServer::PERSISTENT);

        PortableServer::POA_var poa = root_poa->create_POA (
                                          "PERS_POA", poa_manager.in (), policies);

        for (CORBA::ULong i = 0; i < policies.length (); ++i)
        {
            policies[i]->destroy ();
        }

        // Instantiate the LCD_Display implementation class
        Simple_Server_i display_impl (orb.in (), ACE_TEXT_ALWAYS_CHAR(key));
        PortableServer::ObjectId_var id =
            PortableServer::string_to_ObjectId ("IOGR_OID");

        poa->activate_object_with_id (id.in(), &display_impl);

        CORBA::Object_var server =
            poa->id_to_reference (id.in ());

        CORBA::String_var ior =
            orb->object_to_string (server.in ());

        ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));

        // If the ior_output_file exists, output the ior to it
        if (ior_output_file != 0)
        {
            FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
            if (output_file == 0)
                ACE_ERROR_RETURN ((LM_ERROR,
                                   "Cannot open output file for writing IOR: %s",
                                   ior_output_file),
                                  -1);
            ACE_OS::fprintf (output_file, "%s", ior.in ());
            ACE_OS::fclose (output_file);
        }

        // Set the forward references in the server request interceptor.
        PortableInterceptor::ServerRequestInterceptor_var
        server_interceptor = temp_initializer->server_interceptor ();

        Simple_ServerRequestInterceptor_var interceptor =
            Simple_ServerRequestInterceptor::_narrow (
                server_interceptor.in ());

        if (CORBA::is_nil (interceptor.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               "(%P|%t) Could not obtain reference to "
                               "server request interceptor.\n"),
                              -1);

        interceptor->forward_reference (ACE_TEXT_ALWAYS_CHAR(merged_iorstr));

        poa_manager->activate ();

        orb->run ();
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:server.cpp

示例7: svc

int TestTask::svc()
{

  try {
    // 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_->string_to_object ("corbaloc:iiop:[email protected]:9932/NameService");
    CosNaming::NamingContext_var root =
      CosNaming::NamingContext::_narrow(obj.in());

    if (CORBA::is_nil(root.in())) {
      ACE_ERROR ((LM_ERROR, "Error, Nil Naming Context reference\n"));
      return 1;
    }
    // Bind the example Naming Context, if necessary
    CosNaming::NamingContext_var example_nc;
    CosNaming::Name name;
    name.length(1);
    name[0].id = CORBA::string_dup("example");
    try
    {
      obj = root->resolve(name);
      example_nc =
        CosNaming::NamingContext::_narrow(obj.in());
    }
    catch (const CosNaming::NamingContext::NotFound&)
    {
      example_nc = root->bind_new_context(name);
    }

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

    // Create an object
    Hello servant(orb_.in ());
    PortableServer::ObjectId_var oid = poa->activate_object(&servant);
    obj = poa->id_to_reference(oid.in());
    root->rebind(name, obj.in());

    ACE_DEBUG ((LM_INFO, "Hello object bound in Naming Service B\n"));

    name.length(1);
    obj = orb_->string_to_object ("corbaloc:iiop:[email protected]:9931/NameService");
    root = CosNaming::NamingContext::_narrow(obj.in());
    root->bind_context (name, example_nc.in ());

    ACE_DEBUG ((LM_INFO, "'example' context of NS B bound in Naming Service A\n"));

    CORBA::String_var ior =
      orb_->object_to_string (obj.in ());

    // Output the IOR to the <ior_output_file>
    FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
    if (output_file == 0)
      ACE_ERROR_RETURN ((LM_ERROR,
                          "Cannot open output file %s for writing IOR: %C\n",
                          ior_output_file,
                          ior.in ()),
                          1);
    ACE_OS::fprintf (output_file, "%s", ior.in ());
    ACE_OS::fclose (output_file);

    ACE_DEBUG ((LM_INFO, "Wrote IOR file\n"));

    // Normally we run the orb and the orb is shutdown by
    // calling TestTask::end().
    // Accept requests
    orb_->run();
    orb_->destroy();

    return 0;
  }
  catch (CORBA::Exception& ex)
  {
    ex._tao_print_exception ("CORBA exception: ");
  }

  return -1;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:87,代码来源:server.cpp

示例8: safe_monitor_servant

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      ORBInitializer *initializer = 0;
      ACE_NEW_RETURN (initializer,
                      ORBInitializer,
                      -1);  // No exceptions yet!
      PortableInterceptor::ORBInitializer_var orb_initializer =
        initializer;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());

      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);


      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

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

      poa_manager->activate ();

      CORBA::Object_var lm_object =
        orb->resolve_initial_references ("LoadManager");

      CosLoadBalancing::LoadManager_var load_manager =
        CosLoadBalancing::LoadManager::_narrow (lm_object.in ());

      RPS_Monitor * monitor_servant;
      ACE_NEW_THROW_EX (monitor_servant,
                        RPS_Monitor (initializer->interceptor ()),
                        CORBA::NO_MEMORY ());

      PortableServer::ServantBase_var safe_monitor_servant (monitor_servant);

      CosLoadBalancing::LoadMonitor_var load_monitor =
        monitor_servant->_this ();

      PortableGroup::Location_var location =
        load_monitor->the_location ();

      CORBA::Object_var stockfactory =
        ::join_object_group (orb.in (),
                             load_manager.in (),
                             location.in ());

      TAO_LB_LoadAlert & alert_servant = initializer->load_alert ();

      CosLoadBalancing::LoadAlert_var load_alert =
        alert_servant._this ();


      CORBA::String_var ior =
        orb->object_to_string (stockfactory.in ());

      // If the ior_output_file exists, output the ior to it
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      load_manager->register_load_monitor (location.in (),
                                           load_monitor.in ());

      load_manager->register_load_alert (location.in (),
                                         load_alert.in ());

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("lb_server exception");
      return 1;
    }

//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:server.cpp

示例9: publisher

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

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

      CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

      PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ());
      PortableServer::POAManager_var poa_manager =
      root_poa->the_POAManager();

      Publisher_impl publisher(orb.in ());
      PortableServer::ObjectId_var id = root_poa->activate_object (&publisher);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Publisher_var publisher_var = Publisher::_narrow (object.in ());

      CORBA::String_var ior = orb->object_to_string(publisher_var.in());
      ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in()));

      // output the ior
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate();

      const CORBA::Object_var pmobj (orb->resolve_initial_references("ORBPolicyManager" ) );
      CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow(pmobj.in() );

      CORBA::Any orb_level;
      orb_level <<= Messaging::SYNC_NONE;
      CORBA::PolicyList policy_list;
      policy_list.length(1);
      policy_list[0] = orb->create_policy(Messaging::SYNC_SCOPE_POLICY_TYPE,
                                          orb_level);
      policy_manager->set_policy_overrides(policy_list,
                                           CORBA::SET_OVERRIDE);

      ThreadPool pool (orb.in ());
      if (pool.activate(THR_NEW_LWP | THR_JOINABLE, 5) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot activate client threads\n"),
                          1);

      pool.thr_mgr ()->wait ();

      ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:73,代码来源:server.cpp

示例10: ACE_TMAIN

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

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

    if (CORBA::is_nil(naming_obj.in())) {
      std::cerr << "Unable to find naming service" << std::endl;
      return 1;
    }

    CosNaming::NamingContext_var naming_context =
      CosNaming::NamingContext::_narrow(naming_obj.in());

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

    CORBA::Object_var obj = naming_context->resolve(name);

    CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
      CosNotifyChannelAdmin::EventChannelFactory::_narrow(obj.in());

    if (CORBA::is_nil(notify_factory.in())) {
      std::cerr << "Unable to find notify factory" << std::endl;
      return 1;
    }

    name.length (1);
    name[0].id = CORBA::string_dup("MyEventChannel");
    CORBA::Object_var ecObj = naming_context->resolve(name);

    CosNotifyChannelAdmin::EventChannel_var ec =
      CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());

    if (CORBA::is_nil (ec.in())) {
      std::cerr << "Unable to find event channel" << std::endl;
      return 1;
    }

    CosNotifyChannelAdmin::AdminID adminid;
    CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
      CosNotifyChannelAdmin::AND_OP;

    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
      ec->new_for_consumers(ifgop,
                            adminid);

    if (CORBA::is_nil (consumer_admin.in())) {
      std::cerr << "Unable to find consumer admin" << std::endl;
      return 1;
    }

    CosNotifyFilter::FilterFactory_var ffact =
      ec->default_filter_factory ();

    // setup a filter at the consumer admin
    CosNotifyFilter::Filter_var ca_filter =
      ffact->create_filter (TCL_GRAMMAR);

    if (CORBA::is_nil (ca_filter.in())) {
      std::cerr << "Unable to create filetr object" << std::endl;
      return 1;
    }

    CosNotifyFilter::ConstraintExpSeq constraint_list (1);
    constraint_list.length (1);
    constraint_list[0].event_types.length (0);
    constraint_list[0].constraint_expr = CORBA::string_dup (CA_FILTER);

    ca_filter->add_constraints (constraint_list);

    consumer_admin ->add_filter (ca_filter.in());

    CosNotification::EventTypeSeq added(1);
    CosNotification::EventTypeSeq removed (0);
    added.length (1);
    removed.length (0);

    added[0].domain_name =  CORBA::string_dup ("*");
    added[0].type_name = CORBA::string_dup ("*");

    consumer_admin->subscription_change (added, removed);

    CORBA::Object_var poa_object =
      orb->resolve_initial_references("RootPOA");

    if (CORBA::is_nil (poa_object.in())) {
      std::cerr << "Unable to initialize the POA." << std::endl;
      return 1;
    }

    PortableServer::POA_var poa =
      PortableServer::POA::_narrow(poa_object.in());

    PortableServer::Servant_var<StructuredEventConsumer_i> servant =
      new StructuredEventConsumer_i(orb.in());
//.........这里部分代码省略.........
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:101,代码来源:MessengerConsumer.cpp

示例11: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      PortableInterceptor::ORBInitializer_ptr tmp;

      ACE_NEW_RETURN (tmp,
                      ServerORBInitializer,
                      -1); // No CORBA exceptions yet!

      PortableInterceptor::ORBInitializer_var orb_initializer = tmp;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());

      // Initialize the ORB.
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "ORT Test ORB");

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

      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

      // Narrow
      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (obj.in ());

      // Check for nil references
      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Unable to obtain RootPOA reference.\n"),
                          -1);

      // Get poa_manager reference
      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      // Activate it.
      poa_manager->activate ();

      CORBA::PolicyList policies (0);
      policies.length (0);

      // Lets create some POA's
      PortableServer::POA_var first_poa =
        root_poa->create_POA ("FIRST_POA",
                              poa_manager.in (),
                              policies);

      PortableServer::POA_var second_poa =
        first_poa->create_POA ("SECOND_POA",
                               poa_manager.in (),
                               policies);

      PortableServer::POA_var third_poa =
        second_poa->create_POA ("THIRD_POA",
                                poa_manager.in (),
                                policies);

      PortableServer::POA_var fourth_poa =
        third_poa->create_POA ("FOURTH_POA",
                               poa_manager.in (),
                               policies);

      ORT_test_i ort_test_impl (orb.in ());

      PortableServer::ObjectId_var oid =
        fourth_poa->activate_object (&ort_test_impl);

      obj = fourth_poa->servant_to_reference (&ort_test_impl);

      // Convert the object reference to a string format.
      CORBA::String_var ior =
        orb->object_to_string (obj.in ());

      // Dump it to a file.
      if (ior_output_file != 0)
        {
          FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
          if (output_file == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Cannot open output file %s for writing "
                               "IOR: %C",
                               ior_output_file,
                               ior.in ()),
                              1);
          ACE_OS::fprintf (output_file, "%s", ior.in ());
          ACE_OS::fclose (output_file);
        }

      orb->run ();

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("ORT test server:");
      return -1;
    }

//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:server.cpp

示例12: acscomponentTestServer

int acscomponentTestServer (char *szCmdLn)
{
  int  argc;
  char *argv[100];

  argc = argUnpack(szCmdLn, argv);
  argv[0] = "acscomponentTestServer";
#else
int main(int argc, char* argv[]) 
{
#endif // defined( MAKE_VXWORKS )

 
  // creating ORB
  ACS_TEST_INIT_CORBA;


  try
    {
    ACE_OS::signal(SIGINT,  TerminationSignalHandler);  // Ctrl+C
    ACE_OS::signal(SIGTERM, TerminationSignalHandler);  // termination request

      //Get a reference to the RootPOA
      CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
      
      PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
      
   
      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
      

      // The component will throw an exception if receives a NULL ContainerServices
      // in the constructor.
      // We pass a value only to avoid that i throws the exception. On the other 
      // hand the test doe not use the ContainerServices (remember: ContainerServices
      // does not yet exist at this point!!!!)
      ACE_CString compName("TEST");
      ACSComponentTestClassImpl mytestImpl(compName.c_str(), new TestContainerServices(compName,NULL));
      ACSCOMPONENT_TEST::ACSComponentTestClass_var mytest = mytestImpl._this ();;
      


      poa_manager->activate ();
      
      ACS_DEBUG ("acscomponentTestServer","POA Manager -> activate");

      ACS_DEBUG ("acscomponentTestServer", "Writing ior to the file: ACSCOMPONENTTEST1");
      char* ior =  orb->object_to_string (mytest.in());
      
      
      char fileName[64];
      sprintf(fileName, "%s.ior", "ACSCOMPONENTTEST1");
      FILE *output_file = ACE_OS::fopen (fileName, "w");
      if (output_file == 0) {
	ACS_SHORT_LOG((LM_ERROR, "Cannot open output files for writing IOR: ior.ior"));
	return -1;
      }

      int result = ACE_OS::fprintf (output_file, "%s", ior);
      if (result < 0) {
	ACE_ERROR_RETURN ((LM_ERROR, "ACE_OS::fprintf failed while writing %s to ior.ior", ior), -1);
      }

      ACE_OS::fclose (output_file);
      
      ACS_DEBUG ("acscomponentTestServer", "Waiting for requests ...");
      orb->run ();
      
    }

  catch( CORBA::Exception &_ex )
    {
      _ex._tao_print_exception("EXCEPTION CAUGHT");
      return -1;
    }

  //    orb->shutdown(true); //wait until all requests have completed

  return 0;


}
开发者ID:ACS-Community,项目名称:ACS,代码行数:82,代码来源:acscomponentTestServer.cpp

示例13: main

int main(int argc, char* argv[])
{
    int i;
    string url = "file://";
    double ddp = 0.001;
    double timeK = 10.0;

    // -urlでモデルのURLを指定  
    for(i=0; i < argc - 1; i++)
    {
        if( strcmp(argv[i], "-url") == 0)
        {
            url += argv[++i];
        } else if( strcmp(argv[i], "-ddp") == 0)
        {
            ddp = strtod( argv[++i], NULL);
        } else if( strcmp(argv[i], "-timeK") == 0)
        {
            timeK = strtod( argv[++i], NULL);
        }
    }

    string robot_url = url+"sample.wrl";
    string floor_url = url+"floor.wrl";

    const char *ROBOT_URL = robot_url.c_str();
    const char *FLOOR_URL = floor_url.c_str();

    //////////////////////////////////////////////////////////////////////

    // CORBA初期化
    CORBA::ORB_var orb;
    orb = CORBA::ORB_init(argc, argv);

    // ROOT POA
    CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
    PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj);

    // POAマネージャへの参照を取得
    PortableServer::POAManager_var manager = rootPOA -> the_POAManager();
    
    // NamingServiceの参照取得
    CosNaming::NamingContext_var cxT;
    {
      CORBA::Object_var    nS = orb->resolve_initial_references("NameService");
      cxT = CosNaming::NamingContext::_narrow(nS);
    }

    /////////////////////////////////////////////////////////////////////////

    // DynamicsSimulatorの取得
    DynamicsSimulatorFactory_var dynamicsSimulatorFactory;
    dynamicsSimulatorFactory = 
        checkCorbaServer <DynamicsSimulatorFactory,
        DynamicsSimulatorFactory_var> ("DynamicsSimulatorFactory", cxT);

    if (CORBA::is_nil(dynamicsSimulatorFactory)) 
    {
        std::cerr << "DynamicsSimulatorFactory not found" << std::endl;
    }

    DynamicsSimulator_var dynamicsSimulator 
        = dynamicsSimulatorFactory->create();

    // モデルの読み込み・登録
    BodyInfo_var robotInfo = loadBodyInfo(ROBOT_URL, argc, argv);
    dynamicsSimulator->registerCharacter("robot", robotInfo);

    // 床の読み込み・登録
    BodyInfo_var floorInfo = loadBodyInfo(FLOOR_URL, argc, argv);
    dynamicsSimulator->registerCharacter("floor", floorInfo);


    /////////////////////////////////////////////////////////////////////////

    // DynamicsSimulatorの初期化
    dynamicsSimulator->init(0.002, 
        DynamicsSimulator::RUNGE_KUTTA, 
        DynamicsSimulator::ENABLE_SENSOR);

    // 重力ベクトルの設定
    DblSequence3 gVector;
    gVector.length(3);
    gVector[0] = gVector[1] = 0;
    gVector[2] = 9.8;
    dynamicsSimulator->setGVector(gVector);
    
    // 関節駆動モードの設定
    dynamicsSimulator->setCharacterAllJointModes(
        "robot", DynamicsSimulator::TORQUE_MODE);

    // 初期姿勢
    double init_pos[] = {0.00E+00, -3.60E-02, 0,  7.85E-02, -4.25E-02,  0.00E+00,
                         1.75E-01, -3.49E-03, 0, -1.57E+00,  0.00E+00,  0.00E+00,
                         0.00E+00,  0.00E+00, -3.60E-02, 0,  7.85E-02, -4.25E-02,
                         0.00E+00,  1.75E-01,  3.49E-03, 0, -1.57E+00,  0.00E+00,
                         0.00E+00,  0.00E+00, 0, 0, 0};

    // 初期姿勢を関節角にセット
    DblSequence q;
//.........这里部分代码省略.........
开发者ID:YoheiKakiuchi,项目名称:openhrp3-1,代码行数:101,代码来源:clap.cpp

示例14: catch

int
main
( int argc, char **argv )
{
    std::cout << "CIDL Repository Version " << GENERATOR_VERSION << std::endl;
    std::cout << "Qedo Team" << std::endl;


    //
    // get ORB
    //
    CORBA::ORB_var orb;
    try
    {
        orb = CORBA::ORB_init ( argc, argv );
    }
    catch ( ... )
    {
        std::cerr << "Error during ORB_init()" << std::endl;
        exit ( 1 );
    }


    //
    // get POA
    //
    PortableServer::POA_var root_poa;
    try
    {
        CORBA::Object_var root_poa_obj = orb->resolve_initial_references ( "RootPOA" );
        root_poa = PortableServer::POA::_narrow ( root_poa_obj );
    }
    catch ( ... )
    {
        std::cerr << "Error during getting root POA" << std::endl;
        orb -> destroy();
        exit ( 1 );
    }


    //
    // get POA manager and activate it
    //
    PortableServer::POAManager_var root_poa_manager;
    try
    {
        root_poa_manager = root_poa -> the_POAManager();
    }
    catch ( ... )
    {
        std::cerr << "Error getting root POA manager" << std::endl;
        orb->destroy();
        exit ( 1 );
    }
    root_poa_manager -> activate();

    QEDO_ComponentRepository::CIDLRepository_impl* repository = new QEDO_ComponentRepository::CIDLRepository_impl ( orb, root_poa );

    CORBA::Object_var anObject = root_poa->servant_to_reference(repository);

    CIDL::CIDLRepository_var rep_ref = CIDL::CIDLRepository::_narrow(anObject);

    std::string rep_ior;
    rep_ior = orb->object_to_string(rep_ref);

    std::ofstream ior_file;
    ior_file.open("rep.ior");

    ior_file << rep_ior.c_str();

    ior_file.close();

    orb->run();

    return 0;

};
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:77,代码来源:main.cpp

示例15: orb_thr

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

      if (parse_args (argc, argv) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("ERROR: wrong arguments\n")),
                          -1);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableGroup::GOA_var root_goa =
        PortableGroup::GOA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_goa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("ERROR: nil RootPOA\n")),
                          -1);

      PortableServer::POAManager_var poa_manager = root_goa->the_POAManager ();

      // Create UIPMC reference.
      CORBA::Object_var obj = orb->string_to_object (uipmc_url);

      // Create id.
      PortableServer::ObjectId_var id =
        root_goa->create_id_for_reference (obj.in ());

      // Activate UIPMC Object.
      UIPMC_Object_Impl* uipmc_impl;
      ACE_NEW_RETURN (uipmc_impl,
                      UIPMC_Object_Impl (payload_length,
                                         client_threads,
                                         payload_calls),
                      -1);
      PortableServer::ServantBase_var owner_transfer1 (uipmc_impl);
      root_goa->activate_object_with_id (id.in (), uipmc_impl);

      Test::UIPMC_Object_var uipmc_obj =
        Test::UIPMC_Object::_unchecked_narrow (obj.in ());

      if (CORBA::is_nil (uipmc_obj.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("ERROR: nil Hello object\n")),
                          -1);
      CORBA::String_var ior = orb->object_to_string (obj.in ());

      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("MIOP object is <%C>\n"), ior.in ()));

      Hello_Impl* hello_impl;
      ACE_NEW_RETURN (hello_impl,
                      Hello_Impl (orb.in (), uipmc_obj.in ()),
                      -1);
      PortableServer::ServantBase_var owner_transfer2 (hello_impl);

      obj = hello_impl->_this ();

      ior = orb->object_to_string (obj.in ());

      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Activated as <%C>\n"), ior.in ()));

      // If the ior_output_file exists, output the ior to it.
      if (ior_output_file != 0)
        {
          FILE *output_file= ACE_OS::fopen (ior_output_file, "w");

          if (output_file == 0)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("Cannot open output file ")
                                 ACE_TEXT ("for writing IOR: %s"),
                                 ior_output_file),
                                -1);
            }

          ACE_OS::fprintf (output_file, "%s", ior.in ());
          ACE_OS::fclose (output_file);
        }

      poa_manager->activate ();

      {
        // start clients
        OrbThread orb_thr (orb.in ());
        orb_thr.activate (THR_NEW_LWP | THR_JOINABLE, orb_threads);
        orb_thr.wait ();
      }

      root_goa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught in server main ():");
      return -1;
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:server.cpp


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