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


C++ POA_var::create_request_processing_policy方法代码示例

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


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

示例1: policies

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 object =
      orb->resolve_initial_references ("RootPOA");
    PortableServer::POA_var rootPOA =
      PortableServer::POA::_narrow (object.in ());
    PortableServer::POAManager_var poa_manager =
      rootPOA->the_POAManager ();

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

    // Lifespan policy
    policies[0] =
      rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);

    // Servant Retention Policy
    policies[1] =
      rootPOA->create_servant_retention_policy (PortableServer::RETAIN );

    // ID Assignment Policy
    policies[2] =
      rootPOA->create_id_assignment_policy (PortableServer::USER_ID );

    // Request Processing Policy
    policies[3] =
      rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );

    // Threading policy
    policies[4] =
      rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);

    PortableServer::POA_var poa_a = rootPOA->create_POA ("poaA",
        poa_manager.in (),
        policies
        );
    PortableServer::POA_var poa_c = rootPOA->create_POA ("poaC",
        poa_manager.in (),
        policies
        );

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

    Test_Time_i* time = new Test_Time_i();

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId ("Server_A");
    poa_a->activate_object_with_id (oid.in (), time);
    CORBA::Object_var time_obj = poa_a->id_to_reference(oid.in());
    CORBA::String_var ior =
      orb->object_to_string (time_obj.in ());

    poa_manager->activate ();

    FILE *output_file = ACE_OS::fopen (pid_file, ACE_TEXT ("w"));
    if (output_file == 0)
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("Cannot open output file for writing IOR: %s\n"),
                         pid_file),
                        1);
    int pid = static_cast<int> (ACE_OS::getpid ());
    ACE_OS::fprintf (output_file, "%d\n", pid);
    ACE_OS::fclose (output_file);

    orb->run ();

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

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

示例2: worker

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 object =
      orb->resolve_initial_references ("RootPOA");

    ORB_Task worker (orb.in ());
    worker.activate (THR_NEW_LWP | THR_JOINABLE,
                      1);

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

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

    // Lifespan policy
    policies[0] =
      rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);

    // Servant Retention Policy
    policies[1] =
      rootPOA->create_servant_retention_policy (PortableServer::RETAIN );

    // ID Assignment Policy
    policies[2] =
      rootPOA->create_id_assignment_policy (PortableServer::USER_ID );

    // Request Processing Policy
    policies[3] =
      rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );

    // Threading policy
    policies[4] =
      rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);

    if (server_notify_delay > 0)
    {
      ACE_OS::sleep (server_notify_delay);
      ACE_DEBUG ((LM_DEBUG, "(%P|%t)ServerB Now register with IMR \n"));
    }

    PortableServer::POA_var poa_a = rootPOA->create_POA ("poaB",
        poa_manager.in (),
        policies
        );

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

    Test_Dummy_i* dummy = new Test_Dummy_i();

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId ("Server_B");
    poa_a->activate_object_with_id (oid.in (), dummy);
    CORBA::Object_var dummy_obj = poa_a->id_to_reference(oid.in());
    CORBA::String_var ior =
      orb->object_to_string (dummy_obj.in ());

    poa_manager->activate ();

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

    worker.wait ();

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

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

示例3: policies

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");
    PortableServer::POA_var rootPOA =  PortableServer::POA::_narrow (poa_object.in ());
    PortableServer::POAManager_var poa_manager =  rootPOA->the_POAManager ();

    // Policies for the firstPOA to be created.
    CORBA::PolicyList policies (5);
    policies.length (5);
    // Lifespan policy
    policies[0] =
      rootPOA->create_lifespan_policy (PortableServer::PERSISTENT );

    // Servant Retention Policy
    policies[1] =
      rootPOA->create_servant_retention_policy (PortableServer::RETAIN );


    // ID Assignment Policy
    policies[2] =
      rootPOA->create_id_assignment_policy (PortableServer::USER_ID );

    // Request Processing Policy
    policies[3] =
      rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );

    // Threading policy
    policies[4] =
      rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL  );

    PortableServer::POA_var demoPOA
      = rootPOA->create_POA ("HelloWorldServer",
                              poa_manager.in (),
                              policies
                              );

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

    // Create object for shutdown commanded by client.
    {
        // create the object
        Demo_HelloWorld_i * hello = new Demo_HelloWorld_i(orb.in());

        // Get the Object ID.
        PortableServer::ObjectId_var oid =  PortableServer::string_to_ObjectId ("shutdown");
        demoPOA->activate_object_with_id (oid.in (),  hello);


        // Create an object reference.
        CORBA::Object_var myhello = demoPOA->id_to_reference(oid.in());

        // Put the object reference as an IOR string
        ofstream out(ACE_TEXT_ALWAYS_CHAR (shutdown_ior_output_file));
        CORBA::String_var ior = orb->object_to_string (myhello.in ());
        out  << ior.in();
        // save the reference into a file
        out.close();
    }

    // Create object to handle client sayHello requests.
    {
        // create the object
        Demo_HelloWorld_i * hello = new Demo_HelloWorld_i(orb.in());

        // Get the Object ID.
        PortableServer::ObjectId_var oid =  PortableServer::string_to_ObjectId ("hello");
        demoPOA->activate_object_with_id (oid.in (),  hello);


        // Create an object reference.
        CORBA::Object_var myhello = demoPOA->id_to_reference(oid.in());

        // Put the object reference as an IOR string
        ofstream out(ACE_TEXT_ALWAYS_CHAR (ior_output_file));
        CORBA::String_var ior = orb->object_to_string (myhello.in ());
        out  << ior.in();
        // save the reference into a file
        out.close();
    }



    //////////////////////////////////////////////////////////////////////////////////////////////////
    poa_manager->activate ();

    std::cout << ior_output_file << " is ready " << std::endl;
//.........这里部分代码省略.........
开发者ID:manut,项目名称:TAO,代码行数:101,代码来源:server.cpp

示例4: ctrl_servant

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

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

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

        // Get POA manager
        PortableServer::POAManager_var poa_mgr = poa->the_POAManager ();

        // Create a policy list. We use persistent objects with
        // user-assigned IDs, and explicit activation.
        CORBA::PolicyList policy_list;
        policy_list.length (6);
        policy_list[0] = poa->create_lifespan_policy (
                             PortableServer::TRANSIENT   // REVISIT
                         );
        policy_list[1] = poa->create_id_assignment_policy (
                             PortableServer::USER_ID
                         );
        policy_list[2] = poa->create_implicit_activation_policy (
                             PortableServer::NO_IMPLICIT_ACTIVATION
                         );
        policy_list[3] = poa->create_request_processing_policy (
                             PortableServer::USE_SERVANT_MANAGER
                         );
        policy_list[4] = poa->create_servant_retention_policy (
                             PortableServer::NON_RETAIN
                         );
        policy_list[5] = poa->create_thread_policy (
                             PortableServer::SINGLE_THREAD_MODEL
                         );

        // Create a POA for all CCS elements.
        PortableServer::POA_var ccs_poa
            = poa->create_POA ("CCS_POA", poa_mgr.in (), policy_list);

        // Create a controller and set static m_ctrl member
        // for thermostats and thermometers.
        Controller_impl ctrl_servant (ccs_poa.in (), "/tmp/CCS_assets");
        Thermometer_impl::m_ctrl = &ctrl_servant;

        // Create a reference for the controller and
        // create the corresponding CORBA object.
        PortableServer::ObjectId_var oid
            = PortableServer::string_to_ObjectId (Controller_oid);
        CORBA::Object_var ctrl
            = ccs_poa->create_reference_with_id (
                  oid.in (), "IDL:acme.com/CCS/Controller:1.0"
              );

        // Get reference to initial naming context.
        CosNaming::NamingContext_var inc
            = resolve_init<CosNaming::NamingContext> (
                  orb.in (), "NameService"
              );

        // Attempt to create CCS context.
        CosNaming::Name n;
        n.length (1);
        n[0].id = CORBA::string_dup ("CCS");
        try {
            CosNaming::NamingContext_var nc
                = inc->bind_new_context (n);
        } catch (const CosNaming::NamingContext::AlreadyBound &) {
            // Fine, CCS context already exists.
        }

        // Force binding of controller reference to make
        // sure it is always up-to-date.
        n.length (2);
        n[1].id = CORBA::string_dup ("Controller");
        inc->rebind (n, ctrl.in ());

        // Instantiate the servant locator for devices.
        PortableServer::ServantManager_var locator =
            new DeviceLocator_impl (&ctrl_servant);

        // Set servant locator.
        ccs_poa->set_servant_manager (locator.in ());

        // Activate the POA manager.
        poa_mgr->activate ();

        // Accept requests
        orb->run ();
    }
    catch (const CORBA::Exception & e) {
        std::cerr << "Uncaught CORBA exception: "
                  << e
                  << std::endl;
        return 1;
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:server.cpp


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