Exemplo n.º 1
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

      RTCORBA::RTORB_var rtorb =
        RTCORBA::RTORB::_narrow (object.in ());

      object =
        orb->resolve_initial_references ("ORBPolicyManager");

      CORBA::PolicyManager_var policy_manager =
        CORBA::PolicyManager::_narrow (object.in ());

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

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

      object =
        orb->string_to_object (ior);

      test_var receiver =
        test::_narrow (object.in ());

      test_i *servant =
        new test_i (orb.in (),
                    root_poa.in (),
                    rtorb.in (),
                    policy_manager.in (),
                    receiver.in ());
      PortableServer::ServantBase_var safe_servant (servant);
      ACE_UNUSED_ARG (safe_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;
}
Exemplo n.º 2
0
void
CIDL_SenderImpl::SenderExec_i::start (
    ::CORBA::ULong iterations,
    ::CORBA::ULong invocation_rate,
    ::CORBA::Boolean count_missed_end_deadlines,
    ::CORBA::Boolean do_dump_history,
    ::CORBA::Boolean print_missed_invocations,
    ::CORBA::ULong message_size,
    ::CORBA::ULong test_protocol_tag,
    ::CORBA::Boolean print_statistics,
    ::CORBA::ULong number_of_connection_attempts,
    ::CORBA::Boolean enable_diffserv_code_points,
    ::CORBA::Short priority,
    ::Protocols::Sender_Controller::Test_Type test_type
  )
{
  ACE_DEBUG ((LM_DEBUG, "CIDL_SenderImpl::SenderExec_i::start\n"));

  gsf = ACE_High_Res_Timer::global_scale_factor ();

  int argc = 0;
  char **argv = 0;

  this->orb_ =
    CORBA::ORB_init (argc, argv);

  CORBA::Object_var object =
    this->orb_->resolve_initial_references ("RTORB");

  RTCORBA::RTORB_var rtorb =
    RTCORBA::RTORB::_narrow (object.in ());

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

  CORBA::PolicyManager_var policy_manager =
    CORBA::PolicyManager::_narrow (object.in ());

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

  RTCORBA::NetworkPriorityMappingManager_var mapping_manager =
    RTCORBA::NetworkPriorityMappingManager::_narrow (object.in ());

  Custom_Network_Priority_Mapping *custom_network_priority_mapping =
    new Custom_Network_Priority_Mapping;

  // Set the desired corba priority on the network mapping manager
  custom_network_priority_mapping->corba_priority (priority);

  mapping_manager->mapping (custom_network_priority_mapping);

  Protocols::test_var test =
    this->context_->get_connection_reader ();

  Worker worker (this->orb_.in (),
                 rtorb.in (),
                 policy_manager.in (),
                 test.in (),
                 iterations,
                 invocation_rate,
                 count_missed_end_deadlines,
                 do_dump_history,
                 print_missed_invocations,
                 message_size,
                 test_protocol_tag,
                 number_of_connection_attempts,
                 enable_diffserv_code_points,
                 test_type);

  worker.setup ();

  worker.run ();

  if (print_statistics)
    worker.print_stats ();
}