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

C++ Test_var类代码示例

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

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



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

示例1: ACE_TMAIN

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Initialize and obtain reference to the Test object.
      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_var server = Test::_narrow (object.in ());

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

      // Make an invocation on the obtained Test object.
      server->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught exception:");
      return -1;
    }

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


示例2: ACE_TMAIN

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;

    CORBA::Object_var obj = orb->resolve_initial_references("Test");
    ACE_ASSERT (!CORBA::is_nil(obj.in()));
    Test_var test = Test::_narrow( obj.in() );
    ACE_ASSERT (!CORBA::is_nil(test.in()));

    CORBA::Short n = test->get_server_num ();
    ACE_DEBUG ((LM_DEBUG,
                "Client received reply from server %d\n",
                n));
    if (expect_transient)
      return -1;
    return 0;

  }
  catch(const CORBA::TRANSIENT& ex) {
    if (expect_transient)
      return 0;

    ex._tao_print_exception ("client:");
  }
  catch(const CORBA::Exception& ex) {
    ex._tao_print_exception ("client:");
  }
  return -1;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:35,代码来源:client.cpp


示例3: ACE_TMAIN

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      PortableInterceptor::ORBInitializer_ptr temp_initializer =
        PortableInterceptor::ORBInitializer::_nil ();

      ACE_NEW_RETURN (temp_initializer,
                      Client_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,
                                            "Client ORB");

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

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

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

      ::client_test (server.in ());

      ::server_test (server.in ());

      server->shutdown ();

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

  ACE_DEBUG ((LM_INFO,
              "Request interceptor flow test passed.\n"));

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


示例4: ACE_TMAIN

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;

      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("(%P|%t|%T) Client %d sending request to %C\n"),
                  client_num, server_ior));
      try
        {
          CORBA::Object_var obj =
            orb->string_to_object (server_ior);
          ACE_ASSERT (!CORBA::is_nil (obj.in ()));
          Test_var test = Test::_narrow (obj.in());
          ACE_ASSERT (!CORBA::is_nil (test.in()));
          CORBA::Short n = test->get_server_num ();
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t|%T) Client %d received reply from server %d\n"),
                      client_num, n));
        }
      catch (CORBA::TRANSIENT &)
        {
          if (expect_transient)
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t|%T) Client %d got expected transient exception\n"),
                          client_num));
            }
          else
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t|%T) Client %d caught unexpected transent\n"),
                          client_num));
              return -1;
            }
        }
      return 0;

    }
  catch(const CORBA::Exception& ex)
    {
      ex._tao_print_exception (ACE_TEXT ("client:"));
    }

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


示例5: do_restart_test

void
do_restart_test (void)
{
  CORBA::Object_var obj = orb->string_to_object (ior);
  ACE_ASSERT (!CORBA::is_nil(obj.in ()));
  obj = set_timeout_policy (obj.in (), ACE_Time_Value (5,0));
  Test_var test = Test::_narrow( obj.in () );
  ACE_ASSERT (!CORBA::is_nil(test.in ()));
  int attempt = 2;
  while (attempt > 0)
    {
      try
        {
          test->arm ();
          attempt = 0;
        }
      catch (const CORBA::Exception& ex)
        {
          attempt--;
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("client caught %C during arm, retrying\n"),
                      ex._name ()));
        }
    }

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("client sleeping %d seconds\n"),
              request_delay_secs));
  ACE_OS::sleep (request_delay_secs);

  try
    {
      test->trigger ();
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("client trigger completed\n")));
      return;
    }
  catch (const CORBA::Exception& ex)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("client caught %C during first trigger\n"),
                  ex._name ()));
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("client second trigger\n")));
  test->trigger ();
}
开发者ID:CCJY,项目名称:ATCD,代码行数:46,代码来源:client.cpp


示例6: ACE_TMAIN

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;

    CORBA::Object_var obj = orb->resolve_initial_references("Test");
    if (CORBA::is_nil(obj.in()))
      {
        ACE_DEBUG ((LM_DEBUG, "Client could not RIR Test\n"));
        return 1;
      }
    Test_var test = Test::_narrow( obj.in() );
    if (CORBA::is_nil(test.in()))
      {
        ACE_DEBUG ((LM_DEBUG, "Client could not narrow Test\n"));
        return 1;
      }

    test->_stubobj()->reset_profiles();

    test->foo ();

    CORBA::Any a;
    a <<= Messaging::SYNC_WITH_SERVER;

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

    obj = test->_set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE);
    test = Test::_narrow ( obj.in());

    test->_stubobj()->reset_profiles();

    test->foo ();

    CORBA::Short n = test->get_call_count();
    ACE_DEBUG ((LM_DEBUG,
                "Got call count of %d\n",
                n));

    return n != 1;

  }
  catch(const CORBA::Exception& ex) {
    ex._tao_print_exception ("client:");
  }

  return -1;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:56,代码来源:client.cpp


示例7: ACE_TMAIN

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

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

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

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

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Nil Test::Server reference <%s>\n",
                             ior),
                            1);
        }

      server->test_method();
      result =0;

      if (shutdown_server)
        {
          server->shutdown ();
        }

      orb->destroy ();
    }
  catch (const CORBA::Exception&)
    {
      result = 1;
    }

  return result;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:43,代码来源:client.cpp


示例8: do_test

void
do_test (void)
{
  CORBA::Object_var obj = orb->string_to_object (ior);
  Test_var test = Test::_narrow( obj.in () );
  ACE_ASSERT (!CORBA::is_nil(test.in ()));

  try
    {
      test->contact ();
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("client contact completed\n")));
      return;
    }
  catch (const CORBA::Exception& ex)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("client caught %C during contact\n"),
                  ex._name ()));
    }
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:21,代码来源:client.cpp


示例9: create_and_activate_server

char *
test_i::
create_and_activate_server()
{
  PortableServer::Servant_var<test_i> impl(
      new test_i (this->orb_.in ()));

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

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

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

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

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

  return this->orb_->object_to_string(ref.in());
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:22,代码来源:test_i.cpp


示例10: run_test

int
run_test (CORBA::ORB_ptr orb_ptr,
          int target)
{
  CORBA::ORB_var orb = CORBA::ORB::_duplicate (orb_ptr);
  CORBA::Object_var object;
  try
    {
      if (target == 1)
        {
          object =
            orb->string_to_object (ior1);
        }
      else
        {
          object =
            orb->string_to_object (ior2);
        }

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

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

      server->method (0);

      server->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Client-side exception:");
    }
return 0;
}
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:37,代码来源:client.cpp


示例11: test_impl

void test_impl(
    CORBA::ORB_ptr orb,
    ACE_TCHAR const * ior,
    bool shutdown)
{
  CORBA::Object_var object = orb->string_to_object(ior);
  Test_var test = Test::_narrow(object.in());

  if(CORBA::is_nil(test.in()))
  {
    throw "Nil reference after narrow";
  }

  for(int i = 0; i != niterations; ++i)
  {
    test->sendc_the_operation(AMI_TestHandler::_nil());
  }

  ACE_Time_Value wait_for_responses_interval(1, 0);
  orb->run(wait_for_responses_interval);

  if (shutdown)
    test->shutdown ();
}
开发者ID:asdlei00,项目名称:ACE,代码行数:24,代码来源:client.cpp


示例12: ACE_TMAIN

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

    const ACE_TCHAR *iorfile = ACE_TEXT ("");

    ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("o:?"));
    int c;

    while ((c = get_opts ()) != -1)
      switch (c)
        {
        case 'o':
          iorfile = get_opts.opt_arg ();
          break;
        case '?':
          ACE_DEBUG ((LM_DEBUG,
                      "usage: %s "
                      "-d <seconds to delay before initializing POA> "
                      "-n Number of the server\n",
                      argv[0]));
          return 1;
          break;
        }

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

    ACE_CString base = ACE_CString ("TestObject");
    createPOAs (base);

    PortableServer::Servant_var<Test_i> test_servant = new Test_i ();

    PortableServer::ObjectId_var object_id =
      PortableServer::string_to_ObjectId (base.c_str());

    poa_a->activate_object_with_id (object_id.in(), test_servant.in ());
    obj = poa_a->id_to_reference (object_id.in());

    Test_var tva = Test::_narrow (obj.in());

    if (ACE_OS::strlen (iorfile) > 0)
      {
        CORBA::String_var ior = orb->object_to_string (obj.in());
        FILE *output_file= ACE_OS::fopen (iorfile, "w");
        if (output_file == 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Cannot open output file for writing IOR: %s\n",
                             iorfile),
                            1);
        ACE_OS::fprintf (output_file, "%s", ior.in ());
        ACE_OS::fclose (output_file);
      }

    poa_b->activate_object_with_id (object_id.in(), test_servant.in ());
    obj = poa_b->id_to_reference (object_id.in());

    Test_var tvb = Test::_narrow (obj.in());

    //    object_id = root_poa->activate_object (test_servant.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.
    //
    activatePOAs ();

    //
    // Create binding between "TestService" and
    // the test 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*> (poa_a.in ());
    ACE_ASSERT (tpoa != 0);

    obj = tpoa->id_to_reference_i (object_id.in (), false);
    CORBA::String_var test_ior = orb->object_to_string (obj.in ());
    obj = orb->resolve_initial_references("IORTable");
    IORTable::Table_var table = IORTable::Table::_narrow (obj.in ());
    table->bind(base.c_str (), test_ior.in ());

    {
      ACE_CString status_file = base + ACE_CString(".status");
      ofstream out(status_file.c_str ());
      out << "started" << endl;
    }

    test_ior = orb->object_to_string (tva.in());
    base += "_a";
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:ATCD,代码行数:101,代码来源:server.cpp


示例13: make_iogr

/// Thread entry point
int Client_Task::svc (void)
{
  try
    {
      // Get a ref to the IORManipulation object
      CORBA::Object_var IORM =
        corb_->resolve_initial_references (TAO_OBJID_IORMANIPULATION,
        0);

      // Narrow
      this->iorm_ =
        TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in());

      CORBA::Object_var iogr = make_iogr ("Domain_1", 1, 1);

      CORBA::String_var iorgr_string =
        corb_->object_to_string (iogr.in ());

      CORBA::Object_var object =
        corb_->string_to_object (iorgr_string.in ());

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

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

      CORBA::Object_var remote_server(
        corb_->string_to_object (ACE_TString(file_prefix + this->server_ior_file_).c_str()));

      Test_var remote_server_as_test =
        Test::_narrow (remote_server.in ());

      CORBA::Object_var collocated_server(
        corb_->string_to_object (ACE_TString(file_prefix + this->collocated_ior_file_).c_str()));

      Test_var collocated_server_as_test =
        Test::_narrow (collocated_server.in ());

      if (!collocated_server->_is_collocated())
        { // Collocation is disabled, just skip the test - it has no sense.
          ACE_DEBUG ((LM_ERROR, "Test has no sense, because collocation is disabled.\n") );
        }
      else
        {
          try
          {
            // Following call will fail if the problem is not fixed.

            // Because we are using TRANSIENT objects with the SYSTEM_ID policy
            // the object keys won't match so the POA won't be able to dispatch locally.
            // This wouldn't work with 'direct' collocation strategy but the default is 'through poa'.
            server->myMethod ();
          }
          catch (const CORBA::Exception& ex)
          {
            ex._tao_print_exception ("Exception caught in client task:");
          }
        }

      remote_server_as_test->shutdown();

      collocated_server_as_test->shutdown();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught in client task:");
      return 1;
    }

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:76,代码来源:Client_Task.cpp


示例14: ACE_TMAIN

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

      // All factories are kindly provided by
      // compiler so we just to put everything in a right order.

      // Create and register factory for BaseNode.
      BaseNode_init *bn_factory = 0;
      ACE_NEW_RETURN (bn_factory,
                      BaseNode_init,
                      1);

      orb->register_value_factory (bn_factory->tao_repository_id (),
                                   bn_factory);
      bn_factory->_remove_ref (); // release ownership

      // Create and register factory for TreeController.
      TreeController_init *tc_factory = 0;
      ACE_NEW_RETURN (tc_factory,
                      TreeController_init,
                      1);

      orb->register_value_factory (tc_factory->tao_repository_id (),
                                   tc_factory);
      tc_factory->_remove_ref (); // release ownership

      // Create and register factory for StringNode.
      StringNode_init *sn_factory = 0;
      ACE_NEW_RETURN (sn_factory,
                      StringNode_init,
                      1);

      orb->register_value_factory (sn_factory->tao_repository_id (),
                                   sn_factory);
      sn_factory->_remove_ref (); // release ownership

      //Well, done with factories.

      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;

      Test_impl *test_impl;
      ACE_NEW_RETURN (test_impl,
                      Test_impl (orb.in ()),
                      1);

      PortableServer::ServantBase_var owner_transfer(test_impl);

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

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

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

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

      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:");
//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:server.cpp


示例15: ACE_TMAIN

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 obj = orb->string_to_object (ior);

        // force a scope to see the destruction of the server object
        {
            Test_Smart_Factory *test_factory = 0;
            ACE_NEW_RETURN (test_factory,
                            Test_Smart_Factory,
                            -1);

            ACE_UNUSED_ARG (test_factory);

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

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

            server->hello(3);

#if (TAO_HAS_MINIMUM_CORBA == 0)
            // Testing the _non_existent function
            ACE_DEBUG ((LM_DEBUG, "Testing _non_existent()\n"));
            CORBA::Boolean ne =
                server->_non_existent();
            if (ne)
                ACE_ERROR_RETURN ((LM_ERROR,
                                   "Not a Messenger object reference\n"),
                                  1);
            else
                ACE_DEBUG ((LM_DEBUG,"Successfully called _non_existent()\n"));
#endif /* TAO_HAS_MINIMUM_CORBA */

            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);
        }
        // here we should get the smart proxy destructor printout
        if (!dtor_called) {
            ACE_ERROR_RETURN((LM_ERROR,
                              "The Smart proxy is not deleted\n"),1);
        }

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

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


示例16: ACE_TMAIN

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


示例17: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
#if defined (ACE_WIN32)
  ACE_UNUSED_ARG (argc);
  ACE_UNUSED_ARG (argv);
  cout << "HandleExhaustion test not available on Windows" << endl;
#else
  try
    {
#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
    // We must make sure that our file descriptor limit does not exceed
    // the size allowed (in the fd set) by the reactor.  If it does, this
    // test will fail (in a different way than expected) which is a
    // completely different bug than this test is designed to address
    // (see Bug #3326).
    //
    // We must also make sure that this happens before creating the first
    // ORB.  Otherwise, the reactor will be created with a maximum size of
    // the current rlimit for file desriptors (which will later on be
    // increased).
    rlimit rlim;
    if (ACE_OS::getrlimit(RLIMIT_NOFILE, &rlim) == 0)
      {
        cout << "server evaluating rlimit, cur = "
             << rlim.rlim_cur << " max = " << rlim.rlim_max
             << " reactor max = "
             << ACE_DEFAULT_SELECT_REACTOR_SIZE << endl;
        if (rlim.rlim_cur < static_cast<rlim_t> (ACE_DEFAULT_SELECT_REACTOR_SIZE) &&
            rlim.rlim_max > static_cast<rlim_t> (ACE_DEFAULT_SELECT_REACTOR_SIZE))
          {
            rlim.rlim_cur = ACE_DEFAULT_SELECT_REACTOR_SIZE;
            rlim.rlim_max = ACE_DEFAULT_SELECT_REACTOR_SIZE;
            ACE_OS::setrlimit(RLIMIT_NOFILE, &rlim);
            cout << "server set rlimit_nofile" << endl;
          }
      }
#else
    cout << "server does not support setting rlimit, reactor max = "
         << ACE_DEFAULT_SELECT_REACTOR_SIZE << endl;
#endif /* !ACE_LACKS_RLIMIT && RLIMIT_NOFILE */

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

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

      Test_i* test_i;
      ACE_NEW_RETURN (test_i,
                      Test_i (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(test_i);

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

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

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

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

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

      Descriptors descriptors;
      descriptors.leak (
#ifdef _WRS_KERNEL
                        "server.out");
#else
                        argv[0]);
#endif

      ACE_Time_Value tv (10);
      orb->run (tv);

      cout << "Server: closing some fds" << endl;
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:server.cpp


示例18: thread_barrier

int
Task::svc (void)
{
  try
    {
      // Priority Mapping Manager.
      CORBA::Object_var object =
        this->orb_->resolve_initial_references ("PriorityMappingManager");
      RTCORBA::PriorityMappingManager_var mapping_manager =
        RTCORBA::PriorityMappingManager::_narrow (object.in ());
      if (check_for_nil (mapping_manager.in (), "Mapping Manager") == -1)
        return -1;

      RTCORBA::PriorityMapping *pm =
        mapping_manager->mapping ();

      // RTCurrent.
      object =
        this->orb_->resolve_initial_references ("RTCurrent");
      RTCORBA::Current_var current =
        RTCORBA::Current::_narrow (object.in ());
      if (check_for_nil (current.in (), "RTCurrent") == -1)
        return -1;

      // Obtain Test object reference.
      object =
        this->orb_->string_to_object (ior);
      Test_var server = Test::_narrow (object.in ());
      if (check_for_nil (server.in (), "Test object") == -1)
        return -1;

      // Check that test object is configured with CLIENT_PROPAGATED
      // PriorityModelPolicy.
      CORBA::Policy_var policy =
        server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE);

      RTCORBA::PriorityModelPolicy_var priority_policy =
        RTCORBA::PriorityModelPolicy::_narrow (policy.in ());

      if (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1)
        return -1;

      RTCORBA::PriorityModel priority_model =
        priority_policy->priority_model ();
      if (priority_model != RTCORBA::CLIENT_PROPAGATED)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "ERROR: priority_model != "
                           "RTCORBA::CLIENT_PROPAGATED!\n"),
                          -1);

      // Spawn two worker threads.
      ACE_Barrier thread_barrier (2);
      int flags  =
        THR_NEW_LWP |
        THR_JOINABLE |
        this->orb_->orb_core ()->orb_params ()->thread_creation_flags ();

      // Worker 1.
      Worker_Thread worker1 (this->orb_.in (),
                             server.in (),
                             protocol1,
                             &thread_barrier);

      CORBA::Short native_priority1 = 0;
      if (pm->to_native (priority1, native_priority1) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot convert corba priority %d to native priority\n",
                           priority1),
                          -1);

      if (worker1.activate (flags,
                            1, 0,
                            native_priority1) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot activate first client worker threads\n"),
                          -1);

      // Worker 2.
      Worker_Thread worker2 (this->orb_.in (),
                             server.in (),
                             protocol2,
                             &thread_barrier);

      CORBA::Short native_priority2 = 0;
      if (pm->to_native (priority2, native_priority2) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot convert corba priority %d to native priority\n",
                           priority2),
                          -1);

      if (worker2.activate (flags,
                            1, 0,
                            native_priority2) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot activate second client worker threads\n"),
                          -1);

      // Wait for worker threads to finish.
      ACE_Thread_Manager::instance ()->wait ();

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


示例19: catch

int
Task::svc (void)
{

  int result = 0;
  try
    {
      CORBA::Object_var object =
        this->orb_->string_to_object (ior);

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

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

      // Check that the object is configured with CLIENT_PROPAGATED
      // PriorityModelPolicy.
      CORBA::Policy_var policy =
        server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE);

      RTCORBA::PriorityModelPolicy_var priority_policy =
        RTCORBA::PriorityModelPolicy::_narrow (policy.in ());

      if (CORBA::is_nil (priority_policy.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "ERROR: Priority Model Policy not exposed!\n"),
                          -1);

      RTCORBA::PriorityModel priority_model =
        priority_policy->priority_model ();

      if (priority_model != RTCORBA::CLIENT_PROPAGATED)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "ERROR: priority_model != "
                           "RTCORBA::CLIENT_PROPAGATED!\n"),
                          -1);

      // Make several invocations, changing the priority of this thread
      // for each.
      object =
        this->orb_->resolve_initial_references ("RTCurrent");

      RTCORBA::Current_var current =
        RTCORBA::Current::_narrow (object.in ());

      object = this->orb_->resolve_initial_references ("PriorityMappingManager");

      RTCORBA::PriorityMappingManager_var mapping_manager =
        RTCORBA::PriorityMappingManager::_narrow (object.in ());

      RTCORBA::PriorityMapping *pm =
        mapping_manager->mapping ();

      int sched_policy =
        this->orb_->orb_core ()->orb_params ()->ace_sched_policy ();

      int max_priority =
        ACE_Sched_Params::priority_max (sched_policy);
      int min_priority =
        ACE_Sched_Params::priority_min (sched_policy);

      CORBA::Short native_priority =
        (max_priority - min_priority) / 2;

      CORBA::Short desired_priority = 0;

      for (int i = 0; i < 3; ++i)
        {
          if (pm->to_CORBA (native_priority, desired_priority) == 0)
            {
              ACE_ERROR ((LM_ERROR,
                           "ERROR: Cannot convert native priority %d to corba priority\n",
                           native_priority));
              result = -1;
              break;
            }

          current->the_priority (desired_priority);

          CORBA::Short priority =
            current->the_priority ();

          if (desired_priority != priority)
            {
              ACE_ERROR ((LM_ERROR,
                               "ERROR: No exception setting the priority but mismatch between requested and returned value from Current. "
                               "Set to %d but Current::the_priority returns %d\n", desired_priority, priority));
              result = -1;
            }


          server->test_method (priority);

          native_priority++;
//.........这里部分代码省略.........
开发者ID:manut,项目名称:TAO,代码行数:101,代码来源:client.cpp


示例20: ACE_TMAIN

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;

    CORBA::Object_var obj = orb->resolve_initial_references("Test");
    Test_var test;

    try
      {
        test = Test::_narrow( obj.in() );
        if (killit)
          {
            test->terminate ();
          }
        else
          {
            CORBA::Short n = test->get_server_num ();
            ACE_DEBUG ((LM_DEBUG,
                        "Client received reply from server %d on first attempt\n",
                        n));
          }
      }
    catch (const CORBA::Exception &ex)
      {
        ex._tao_print_exception ("Client caught: ");
#if 0
        try
          {
            if (CORBA::is_nil (test.in()))
              {
                test = Test::_narrow( obj.in() );
              }
            CORBA::Short n = test->get_server_num ();
            ACE_DEBUG ((LM_DEBUG,
                        "Client received reply from server %d on second attempt\n",
                        n));
          }
        catch (const CORBA::Exception &ex)
          {
            ex._tao_print_exception ("Client second attempt: ");
          }
#endif
      }

    orb->destroy ();

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

  return -1;
}
开发者ID:,项目名称:,代码行数:61,代码来源:



注:本文中的Test_var类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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