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

C++ corba::ORB_var类代码示例

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

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



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

示例1: catch

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
#if TAO_HAS_INTERCEPTORS == 1

      PortableInterceptor::ORBInitializer_ptr orb_initializer =
        PortableInterceptor::ORBInitializer::_nil ();

      ACE_NEW_RETURN (orb_initializer,
                      Server_IORInterceptor_ORBInitializer,
                      -1); // No CORBA exceptions yet!

      PortableInterceptor::ORBInitializer_var orb_initializer_var =
        orb_initializer;

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

#endif /* TAO_HAS_INTERCEPTORS == 1 */

      // The usual initialization stuff

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

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

      // Resolve reference to RootPOA
      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

      // Narrow it down correctly.
      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 ();

      // initialize the sum_server
      sum_server_i sum_server_impl;

      // Activate
      obj = sum_server_impl._this ();

      // Narrow it down.
      ORT::sum_server_var sum_server =
        ORT::sum_server::_narrow (obj.in ());

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

      // Convert the object reference to a string format.
      CORBA::String_var ior =
        orb->object_to_string (sum_server.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);
        }

      orb->run ();

      ACE_DEBUG ((LM_INFO, "Successful.\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("ORT example server:");
      return -1;
    }

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


示例2: main

int main(int argc, char *argv[])
{

  if (argc<4){
    ACE_OS::printf ("usage: testClient <server_name> <depth> <isError> [iteration]\n");
    return -1;
  }//if

  

// create logging proxy
  LoggingProxy m_logger (0, 0, 31, 0);
  LoggingProxy::init (&m_logger); 

  CORBA::ORB_var orb;
  ACS_TEST_INIT_CORBA;

  // init ACS error system
  ACSError::init (orb.ptr());


  /**************************************/
  acserrOldTest_var test;
  int depth;
  sscanf (argv[2], "%d", &depth);
  bool isErr = *argv[3]-'0';
  int iteration=1, i=1;
  const int size = 20;  // max value 1.84 x 10^19
  char printBuf[size+1];

  if (argc>4)
	sscanf (argv[4], "%d", &iteration); 
  
  ACS_DEBUG("main", "****** Test Block *****");
 
  try
    {
      ACS_DEBUG("acserrOldTestClient", "Getting object reference ... ");
      char fileName[64];
      sprintf(fileName, "file://%s.ior", argv[1]);
      CORBA::Object_var testObj = orb->string_to_object (fileName);

      ACS_DEBUG("acserrOldTestClient", "Narrowing it .... ");
      test = acserrOldTest::_narrow (testObj.in());

      unsigned long long numToPrint; 
      while( iteration >= i ){
	ACS_SHORT_LOG((LM_INFO, "Performing test1 (remote call)... (%d/%d)", i, iteration));
	ACSErr::ErrorTrace *c = test->test (depth, isErr);
	
	ACSError error(c, true);
	ACS_SHORT_LOG((LM_INFO, "Stack depth: %d", error.getDepth()));
	error.log();

	//ACSError *error = new ACSError (c, true) -> new ACS_ERROR (c, true);
	while (c!=NULL){
	  ACS_SHORT_LOG((LM_INFO, "FileName:   \"%s\"",error.getFileName()));
	  ACS_SHORT_LOG((LM_INFO, "LineNumber: \"%d\"",error.getLineNumber()));  
	  ACS_SHORT_LOG((LM_INFO, "Routine:    \"%s\"",error.getRoutine()));
          ACS_SHORT_LOG((LM_INFO, "HostName:   \"%s\"",error.getHostName()));
	  ACS_SHORT_LOG((LM_INFO, "Process:    \"%s\"",error.getProcess()));
          ACS_SHORT_LOG((LM_INFO, "Thread:     \"%s\"",error.getThread()));
          for (int ii = 0; ii < size; ii++) printBuf[ii] = ' ';
          printBuf[size] = '\0';
          numToPrint = error.getTimeStamp(); 
          for (int ii = size - 1; ii >= 0; ii--) {
                 printBuf[ii] = numToPrint % 10 + '0';
                 numToPrint /= 10;
                 if (numToPrint == 0)
                  break;
             }
	  ACS_SHORT_LOG((LM_INFO, "TimeStamp:  \"%s\"",printBuf));
	  ACS_SHORT_LOG((LM_INFO, "ErrorType:  \"%d\"",error.getErrorType()));
	  ACS_SHORT_LOG((LM_INFO, "ErrorCode:  \"%d\"",error.getErrorCode()));
	  ACS_SHORT_LOG((LM_INFO, "Severity:   \"%d\"", error.getSeverity()));
          ACS_SHORT_LOG((LM_INFO, "Description: \"%s\"",error.getDescription()));
	  c = error.getNext();
	  }	
	i++;
      }//while
      
   
    }
  catch( CORBA::Exception &ex)
    {    
      ACE_PRINT_EXCEPTION (ex, "EXCEPTION CAUGHT");
      return -1;
    }
  ACS_SHORT_LOG((LM_INFO, "Test1 performed."));

//test2
  i=1;
  while (i<=iteration){
    try
      {
	ACS_SHORT_LOG((LM_INFO, 
              "Performing test2 (remote call - exceptions) ... (%d/%d)", i, iteration));
	test->testExceptions (depth, isErr);
      }
    catch (ACSErr::ACSException &ex)
//.........这里部分代码省略.........
开发者ID:flyingfrog81,项目名称:ACS,代码行数:101,代码来源:acserrOldTestClient.cpp


示例3: logger

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  MessageLog logger(HELLO_CALL_NUMBER);

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

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

      PortableGroup::GOA_var root_poa =
        PortableGroup::GOA::_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 ();

      // servant
      Hello_Impl* hello_impl;
      ACE_NEW_RETURN (hello_impl,
                      Hello_Impl (orb.in (), &logger),
                      1);
      PortableServer::ServantBase_var owner_transfer (hello_impl);

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

      // create UIPMC reference
      CORBA::String_var multicast_url =
        CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(uipmc_url));
      CORBA::Object_var miop_ref =
        orb->string_to_object (multicast_url.in ());

      // create id
      PortableServer::ObjectId_var id =
        root_poa->create_id_for_reference (miop_ref.in ());

      // activate Hello Object
      root_poa->activate_object_with_id (id.in (),
                                         hello_impl);

      CORBA::String_var ior =
        orb->object_to_string (miop_ref.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);
        }

      poa_manager->activate ();

      orb->run ();

      root_poa->destroy (1, 1);

      orb->destroy ();

      if (logger.report_statistics () == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "\n (%P|%t) ERROR: No single call got through to the server\n"),
                           3);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught in server main ():");
      return 4;
    }

  ACE_DEBUG ((LM_DEBUG,
              "\n (%P|%t) server finished successfully..\n"));
  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:93,代码来源:server.cpp


示例4: tv

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

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

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

      // To use the smart proxy it is necessary to allocate the
      // user-defined smart factory on the heap as the smart proxy
      // generated classes take care of destroying the object. This
      // way it a win situation for the application developer who
      // doesnt have to make sure to destoy it and also for the smart
      // proxy designer who now can manage the lifetime of the object
      // much surely.
      Smart_Test_Factory *test_factory = 0;
      ACE_NEW_RETURN (test_factory,
                      Smart_Test_Factory,
                      -1);

      ACE_UNUSED_ARG (test_factory);

      Test_var server =
        Test::_narrow (object.in ());

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

      try
        {
          CORBA::String_var sm_ior = orb->object_to_string (server.in ());
          if (Smart_Test_Proxy::fake_ior () != sm_ior.in ())
            {
              status = 1;
              ACE_ERROR ((LM_ERROR,
                          "ERROR: The Smart Proxy IOR is:\n%C\n"
                          "but should have been: %C\n",
                          sm_ior.in (),
                          Smart_Test_Proxy::fake_ior ().c_str ()));
            }
        }
      catch (const CORBA::MARSHAL& ex)
        {
          status = 1;
          ex._tao_print_exception ("Unexpected MARSHAL exception:");
        }

      server->method (0);

      server->shutdown ();

      // The following sleep is a hack to make sure the above oneway
      // request gets sent before we exit. Otherwise, at least on
      // Windows XP, the server may not even get the request.
      ACE_Time_Value tv (0, 100000);
      ACE_OS::sleep(tv);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Client-side exception:");
      status = 1;
    }

  return status;
}
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:76,代码来源:client.cpp


示例5: safe

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

      // Get initial reference to the Root POA
      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      // Narrow down to the appropriate type
      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);

      // Get referencee to the POA manager
      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      // Parse the arguments
      if (parse_args (argc, argv) != 0)
        return 1;

      ACE_DEBUG(( LM_DEBUG, "ior file = %s\t#threads = %d\t"
                  "msglen = %d\n",
                  ior_output_file, nthreads, msglen));

      // Create the factory servant
      Object_Factory_i *factory_impl = 0;
      ACE_NEW_THROW_EX (factory_impl,
                        Object_Factory_i (orb.in (), msglen),
                        CORBA::NO_MEMORY ());
      PortableServer::ServantBase_var safe (factory_impl);

      // _this method registers the object withe the POA and returns
      // an object reference
      PortableServer::ObjectId_var id =
        root_poa->activate_object (factory_impl);

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

      Two_Objects_Test::Object_Factory_var factory =
        Two_Objects_Test::Object_Factory::_narrow (object_act.in ());

      // Convert the object reference to a string so that it can
      // be saved in a file and used by clinet programs later
      CORBA::String_var ior =
        orb->object_to_string (factory.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);

      // Activate the POA manager
      poa_manager->activate ();

      // Instantiate the specified # of worker threads
      Worker worker (orb.in ());

      if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
                           nthreads) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot activate server threads\n"),
                          1);

      // Wait for all threads to get done
      worker.thr_mgr ()->wait ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) 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:manut,项目名称:TAO,代码行数:97,代码来源:server.cpp


示例6: task

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

      // Parse arguments.
      if (parse_args (argc, argv) != 0)
        return -1;

      // Make sure we can support multiple priorities that are required
      // for this test.
      if (!check_supported_priorities (orb.in ()))
        return 2;

      // Thread Manager for managing task.
      ACE_Thread_Manager thread_manager;

      // Create task.
      Task task (thread_manager,
                 orb.in ());

      // Task activation flags.
      long flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        orb->orb_core ()->orb_params ()->thread_creation_flags ();

      // Activate task.
      int result =
        task.activate (flags);
      if (result == -1)
        {
          if (errno == EPERM)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Cannot create thread with scheduling policy %s\n"
                                 "because the user does not have the appropriate privileges, terminating program....\n"
                                 "Check svc.conf options and/or run as root\n",
                                 sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
                                2);
            }
          else
            // Unexpected error.
            ACE_ASSERT (0);
        }

      // Wait for task to exit.
      result =
        thread_manager.wait ();
      ACE_ASSERT (result != -1);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught");
      return -1;
    }

  return 0;
}
开发者ID:manut,项目名称:TAO,代码行数:63,代码来源:server.cpp


示例7: get_opts

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int c_breath = 4;
  int c_depth = 4;
  int o_breath = 4;
  ACE_TCHAR *ns1ref = 0;
  ACE_TCHAR *ns2ref = 0;

  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("b:d:o:p:q:"));
  int c;
  int i;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'b':
        i = ACE_OS::atoi(get_opts.opt_arg ());
        if (i<2)
        {
          ACE_ERROR((LM_ERROR,
                     ACE_TEXT ("Invalid breath, must be 2 or more\n")));
          ACE_OS::exit(1);
        }
        c_breath = i;
        break;
      case 'd':
        i = ACE_OS::atoi(get_opts.opt_arg ());
        if (i<2)
        {
          ACE_ERROR((LM_ERROR,
                     ACE_TEXT ("Invalid depth, must be 2 or more\n")));
          ACE_OS::exit(1);
        }
        c_depth = i;
        break;
      case 'o':
        i = ACE_OS::atoi(get_opts.opt_arg ());
        if (i<2)
        {
          ACE_ERROR((LM_ERROR,
                     ACE_TEXT ("Invalid breath, must be 2 or more\n")));
          ACE_OS::exit(1);
        }
        o_breath = i;
        break;
      case 'p':
        ns1ref = get_opts.opt_arg ();
        break;
      case 'q':
        ns2ref = get_opts.opt_arg ();
        break;
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("Argument %c \n usage:  %s")
                           ACE_TEXT (" [-b <breath of context tree>]")
                           ACE_TEXT (" [-d <depth of context tree>]")
                           ACE_TEXT (" [-o <breath of object tree>]")
                           ACE_TEXT (" -p <ior of first name server>")
                           ACE_TEXT (" -q <ior of second name server>")
                           ACE_TEXT ("\n")),
                          -1);
      }

  CosNaming::NamingContext_var root_context_1;
  CosNaming::NamingContext_var root_context_2;

  try
  {
    // Initialize orb
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    // ior's are specified for the name servers through a commandline
    // option or a file.

    // Resolve the first name server

    CORBA::Object_var ns1obj = orb->string_to_object (
                            ACE_TEXT_ALWAYS_CHAR (ns1ref));

    if (CORBA::is_nil (ns1obj.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("invalid ior <%s>\n"),
                               ns1ref),
                              -1);
    root_context_1 = CosNaming::NamingContext::_narrow (ns1obj.in ());

    // Resolve the second name server

    CORBA::Object_var ns2obj = orb->string_to_object (
                            ACE_TEXT_ALWAYS_CHAR (ns2ref));

    if (CORBA::is_nil (ns2obj.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("invalid ior <%s>\n"),
                               ns2ref),
                              -1);
    root_context_2 = CosNaming::NamingContext::_narrow (ns2obj.in ());

  }
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:client.cpp


示例8: history

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int priority =
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.

  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              priority,
                                              ACE_SCOPE_PROCESS)) != 0)
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "client (%P|%t): user is not superuser, "
                      "test runs in time-shared class\n"));
        }
      else
        ACE_ERROR ((LM_ERROR,
                    "client (%P|%t): sched_params failed\n"));
    }

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

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

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

      Test::Roundtrip_var roundtrip =
        Test::Roundtrip::_narrow (object.in ());

      if (CORBA::is_nil (roundtrip.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Nil Test::Roundtrip reference <%s>\n",
                             ior),
                            1);
        }
      for (int j = 0; j < 100; ++j)
        {
          ACE_hrtime_t start = 0;
          (void) roundtrip->test_method (start, number);
        }

      ACE_Sample_History history (niterations);

      // const float usecs = 1.0 / rate * 1e6;

      // ACE_Time_Value tv (0, static_cast<const long> (usecs));

      // const timespec ts = tv;

      ACE_hrtime_t test_start = ACE_OS::gethrtime ();
      for (int i = 0; i < niterations; ++i)
        {
          ACE_hrtime_t start = ACE_OS::gethrtime ();

          /*
          if (rate)
            {
              //(void) ACE_OS::nanosleep (&ts, 0);
              //prime_number = ACE::is_prime (699999, 2, 349999);
            }
          */

          (void) roundtrip->test_method (start, number);

          ACE_hrtime_t now = ACE_OS::gethrtime ();
          history.sample (now - start);

        }

      ACE_hrtime_t test_end = ACE_OS::gethrtime ();

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

      ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
      ACE_High_Res_Timer::global_scale_factor_type gsf =
        ACE_High_Res_Timer::global_scale_factor ();
      ACE_DEBUG ((LM_DEBUG, "done\n"));

      if (do_dump_history)
        {
          history.dump_samples (ACE_TEXT("HISTORY"), gsf);
        }

      ACE_Basic_Stats stats;
      history.collect_basic_stats (stats);
      stats.dump_results (ACE_TEXT("Total"), gsf);

      ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf,
                                             test_end - test_start,
                                             stats.samples_count ());

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


示例9: Messenger_i

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

    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());

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

    const char* poa_name = "MessengerService";

    PortableServer::POA_var messenger_poa = createPOA(root_poa.in(), poa_name);

    Terminator terminator;
    if (terminator.open (0) == -1)
      ACE_ERROR_RETURN((LM_ERROR,
                        ACE_TEXT ("main Error opening terminator\n")),-1);

    PortableServer::Servant_var<Messenger_i> messenger_servant =
      new Messenger_i(orb.in(), terminator);

    PortableServer::ObjectId_var object_id =
      PortableServer::string_to_ObjectId("messenger_object");

    //
    // Activate the servant with the messenger POA,
    // obtain its object reference, and get a
    // stringified IOR.
    //
    messenger_poa->activate_object_with_id(object_id.in(), messenger_servant.in());

    //
    // Create binding between "MessengerService" and
    // the messenger object reference in the IOR Table.
    // Use a TAO extension to get the non imrified poa
    // to avoid forwarding requests back to the ImR.

    TAO_Root_POA* tpoa = dynamic_cast<TAO_Root_POA*>(messenger_poa.in());
    obj = tpoa->id_to_reference_i(object_id.in(), false);
    CORBA::String_var messenger_ior = orb->object_to_string(obj.in());
    obj = orb->resolve_initial_references("IORTable");
    IORTable::Table_var table = IORTable::Table::_narrow(obj.in());
    table->bind(poa_name, messenger_ior.in());

    //
    // This server is now ready to run.
    // This version does not create an IOR
    // file as demonstrated in the
    // Developer's Guide.  It assumes that
    // users create IORs for the client using
    // the tao_imr utility.
    //
    //
    // Stop discarding requests.
    //
    mgr->activate();

    std::cout << "Messenger server ready." << std::endl;

    orb->run();

    std::cout << "Messenger server shutting down." << std::endl;

    root_poa->destroy(1,1);
    orb->destroy();

    ACE_Message_Block *mb;
    ACE_NEW_RETURN(mb, ACE_Message_Block(0, ACE_Message_Block::MB_HANGUP), -1);
    terminator.putq(mb);
    terminator.wait();
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "Server main() Caught CORBA::Exception" << ex << std::endl;
    return 1;
  }

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


示例10: test_i

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    gsf = ACE_High_Res_Timer::global_scale_factor ();

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

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

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

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

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

        test_i *servant =
            new test_i (orb.in (),
                        root_poa.in ());

        PortableServer::ServantBase_var safe_servant (servant);

        test_var test =
            servant->_this ();

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

        FILE *output_file =
            ACE_OS::fopen (ior_file, "w");
        ACE_ASSERT (output_file != 0);

        u_int result =
            ACE_OS::fprintf (output_file,
                             "%s",
                             ior.in ());
        ACE_ASSERT (result == ACE_OS::strlen (ior.in ()));
        ACE_UNUSED_ARG (result);

        ACE_OS::fclose (output_file);

        poa_manager->activate ();

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

    return 0;
}
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:62,代码来源:receiver.cpp


示例11: 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:CCJY,项目名称:ATCD,代码行数:101,代码来源:server.cpp


示例12: catch

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

        TAO_IFR_Client_Adapter *ifr_client =
            ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
                TAO_ORB_Core::ifr_client_adapter_name ());

        if (ifr_client == 0)
        {
            throw ::CORBA::INTF_REPOS ();
        }

        ACE_DEBUG ((LM_DEBUG, "Got IFR_Client ref.\n"));

        CORBA::InterfaceDef_var intDef =
            ifr_client->get_interface (orb.in (), "IDL:IFR_Test/test_if:1.0");

        if (CORBA::is_nil (intDef.in ()))
        {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "get interface returned nil ref\n"),
                              1);
        }

        CORBA::ContainedSeq_var attributes =
            intDef->contents (CORBA::dk_Attribute, 1);
        CORBA::ULong n_ats = attributes->length ();

        CORBA::ULong index = 0UL;
        CORBA::String_var name = attributes[index]->name ();
        ACE_DEBUG ((LM_DEBUG,
                    "found %d attributes, name = %s\n",
                    n_ats,
                    name.in ()));

        CORBA::AttributeDef_var attr =
            CORBA::AttributeDef::_narrow (attributes[index]);

        if (CORBA::is_nil (attr.in ()))
        {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "could not narrow attribute ref\n"),
                              1);
        }

        CORBA::TypeCode_var tc = attr->type ();

        ACE_DEBUG ((LM_DEBUG, "foo attr typecode = %s\n", tc->id ()));
    }
    catch (const ::CORBA::Exception &ex)
    {
        ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :");
        return 1;
    }

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


示例13: initializer

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      {
        PortableInterceptor::ORBInitializer_var initializer(
            new Server_ORBInitializer);
        PortableInterceptor::register_orb_initializer(initializer.in());
      }

      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;

      Echo *echo_impl;
      ACE_NEW_RETURN (echo_impl,
                      Echo (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(echo_impl);

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

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

      Test::Echo_var echo =
        Test::Echo::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (echo.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 for writing IOR: %s",
                           ior_output_file),
                              1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      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:OspreyHub,项目名称:ATCD,代码行数:76,代码来源:server.cpp


示例14: middle

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  ACE_DEBUG ((LM_DEBUG,
              "Middle (%P|%t) started\n"));

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

      if ( ! parse_args (argc, argv))
        {
          return -1;
        }

      ///////////////////////////////
      // Prepare to be a CORBA server
      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA");

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

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

      ///////////////////////////////
      // Prepare to be a CORBA client
      FILE *input_file = ACE_OS::fopen (ior_input_file, "r");
      if (input_file == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Cannot open input IOR file: %s",
                             ior_input_file),
                            -1);
        }
      ACE_OS::fread (input_ior, 1, sizeof(input_ior), input_file);
      ACE_OS::fclose (input_file);

      // Convert the IOR to an object reference.
      CORBA::Object_var object =
        orb->string_to_object (input_ior);

      // narrow the object reference to a ThreeTier reference
      ThreeTier_var target = ThreeTier::_narrow (object.in ());

      if (CORBA::is_nil (target.in ()))
        {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "IOR does not refer to a ThreeTier implementation"),
                              -1);
        }

      // We should have a good connection now
      // temporary: check it out
      //target->tick();
      //target->tock();

      Middle_i middle (orb.in(), target.in ());
      if (middle.parse_args (argc, argv) )
        {
          /////////////////////////////////
          // Activate server side mechanism
          PortableServer::ObjectId_var id =
            root_poa->activate_object (&middle);

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

          ThreeTier_var server =
            ThreeTier::_narrow (object.in ());

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

          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 ();
          orb->run ();
        }
    }
  catch (const CORBA::UserException& userex)
    {
      userex._tao_print_exception ("Middle: User Exception in main");
      return -1;
    }
  catch (const CORBA::SystemException& sysex)
    {
      sysex._tao_print_exception ("Middle: System Exception in main");
      return -1;
    }

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


示例15: policies

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      Server_ORBInitializer2 *temp_initializer = 0;
      ACE_NEW_RETURN (temp_initializer,
                      Server_ORBInitializer2,
                      -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);

      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::PolicyList policies (2);
      policies.length (2);

      policies[0] =
        root_poa->create_id_assignment_policy (PortableServer::USER_ID);

      policies[1] =
        root_poa->create_lifespan_policy (PortableServer::PERSISTENT);

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

      // Creation of the new POA is over, so destroy the Policy_ptr's.
      for (CORBA::ULong i = 0; i < policies.length (); ++i)
        {
          CORBA::Policy_ptr policy = policies[i];
          policy->destroy ();
        }


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

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in (), Test::Hello::_nil (), my_id_number),
                      -1);
      PortableServer::ServantBase_var owner (hello_impl);

      PortableServer::ObjectId_var server_id =
        PortableServer::string_to_ObjectId ("server_id");

      my_poa->activate_object_with_id (server_id.in (),
                                       hello_impl);

      CORBA::Object_var hello =
        my_poa->id_to_reference (server_id.in ());

      CORBA::String_var ior =
        orb->object_to_string (hello.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 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 ();

      orb->run ();

      root_poa->destroy (1, 1);

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

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


示例16: udp_i

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");

      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 ();

      // Install a persistent POA in order to achieve a persistent IOR
      // for our object.
      CORBA::PolicyList policies;
      policies.length (2);
      policies[0] =
        root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
      policies[1] =
        root_poa->create_id_assignment_policy (PortableServer::USER_ID);


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

      policies[0]->destroy ();

      policies[1]->destroy ();

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

      UDP_i udp_i (orb.in ());

      PortableServer::ObjectId_var id =
        PortableServer::string_to_ObjectId ("UDP_Object");

      persistent_poa->activate_object_with_id (id.in (),
                                               &udp_i);

      CORBA::Object_var obj =
        persistent_poa->id_to_reference (id.in ());


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

  

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ corba::Object_ptr类代码示例发布时间:2022-05-31
下一篇:
C++ corba::ORB_ptr类代码示例发布时间: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