Exemple #1
0
int
create_POA_and_register_servant (CORBA::Policy_ptr threadpool_policy,
                                 const char *poa_name,
                                 PortableServer::POAManager_ptr poa_manager,
                                 PortableServer::POA_ptr root_poa,
                                 CORBA::ORB_ptr orb,
                                 RTCORBA::RTORB_ptr rt_orb)
{
  // Policies for the firstPOA to be created.
  CORBA::PolicyList policies (3); policies.length (3);

  // Implicit_activation policy.
  policies[0] =
    root_poa->create_implicit_activation_policy
    (PortableServer::IMPLICIT_ACTIVATION);

  // Thread pool policy.
  policies[1] =
    CORBA::Policy::_duplicate (threadpool_policy);

  // Priority Model policy.
  policies[2] =
    rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0);

  // Create the POA under the RootPOA.
  PortableServer::POA_var poa =
    root_poa->create_POA (poa_name,
                          poa_manager,
                          policies);

  // Creation of POAs is over. Destroy the Policy objects.
  for (CORBA::ULong i = 0;
       i < policies.length ();
       ++i)
    {
      policies[i]->destroy ();
    }

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

  PortableServer::ServantBase_var safe_servant (servant);
  ACE_UNUSED_ARG (safe_servant);

  PortableServer::ObjectId_var id =
    poa->activate_object (servant);

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

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

  int const result = write_ior_to_file (orb, test.in ());

  return result;
}
Exemple #2
0
void
POA_Holder::activate (RTCORBA::RTORB_ptr rt_orb, PortableServer::POA_ptr parent_poa)
{
  CORBA::Policy_var priority_model_policy;
  CORBA::Policy_var lanes_policy;
  CORBA::Policy_var bands_policy;
  CORBA::Policy_var thread_pool_policy;

  // Create a priority model policy.
  priority_model_policy =
    rt_orb->create_priority_model_policy (priority_model_,
                                          server_priority_);

  if (lanes_.length () != 0)
    {
      // Create a thread-pool.
      CORBA::ULong stacksize = 0;
      CORBA::Boolean allow_request_buffering = 0;
      CORBA::ULong max_buffered_requests = 0;
      CORBA::ULong max_request_buffer_size = 0;
      CORBA::Boolean allow_borrowing = 0;

      // Create the thread-pool.
      RTCORBA::ThreadpoolId threadpool_id =
        rt_orb->create_threadpool_with_lanes (stacksize,
                                              lanes_,
                                              allow_borrowing,
                                              allow_request_buffering,
                                              max_buffered_requests,
                                              max_request_buffer_size);

      // Create a thread-pool policy.
      lanes_policy =
        rt_orb->create_threadpool_policy (threadpool_id);

      ACE_DEBUG ((LM_DEBUG,
      "Activated Lanes\n"));

    }

  if (thread_pool_)
    {
      CORBA::ULong stacksize = 0;
      CORBA::Boolean allow_request_buffering = 0;
      CORBA::ULong max_buffered_requests = 0;
      CORBA::ULong max_request_buffer_size = 0;

      RTCORBA::ThreadpoolId threadpool_id_1 =
        rt_orb->create_threadpool (stacksize,
                                   tp_static_threads_,
                                   tp_dynamic_threads_,
                                   tp_priority_,
                                   allow_request_buffering,
                                   max_buffered_requests,
                                   max_request_buffer_size);


      thread_pool_policy = rt_orb->create_threadpool_policy (threadpool_id_1);

      ACE_DEBUG ((LM_DEBUG,
      "Activated thread pool\n"));


    }

  if (bands_.length () != 0)
    {
      // Create a bands policy.
      bands_policy =
        rt_orb->create_priority_banded_connection_policy (this->bands_);
      ACE_DEBUG ((LM_DEBUG,
      "Activated Bands\n"));

    }

  CORBA::PolicyList poa_policy_list;

  if (lanes_.length () == 0 && bands_.length () == 0)
    {
      if (thread_pool_)
  {
    poa_policy_list.length (2);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = thread_pool_policy;
  }
      else
  {
    poa_policy_list.length (1);
    poa_policy_list[0] = priority_model_policy;
  }
    }
  else if (lanes_.length () != 0 && bands_.length () == 0)
    {
      if (thread_pool_)
  {
    poa_policy_list.length (3);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = lanes_policy;
    poa_policy_list[2] = thread_pool_policy;
  }
      else
  {
    poa_policy_list.length (2);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = lanes_policy;
  }
    }
  else if (lanes_.length () == 0 && bands_.length () != 0)
    {
      if (thread_pool_)
  {
    poa_policy_list.length (3);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = bands_policy;
    poa_policy_list[2] = thread_pool_policy;
  }
      else
  {
    poa_policy_list.length (2);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = bands_policy;
  }
    }
  else
    {
      if (thread_pool_)
  {
    poa_policy_list.length (4);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = lanes_policy;
    poa_policy_list[2] = bands_policy;
    poa_policy_list[3] = thread_pool_policy;
  }
      else
  {
    poa_policy_list.length (3);
    poa_policy_list[0] = priority_model_policy;
    poa_policy_list[1] = lanes_policy;
    poa_policy_list[2] = bands_policy;
  }
    }

  ACE_DEBUG ((LM_DEBUG,
        "Initialized POA Policy\n"));

  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "creating POA %C\n", POA_name_.c_str ()));

  // Get the POA Manager.
  PortableServer::POAManager_var poa_manager =
    parent_poa->the_POAManager ();

  PortableServer::POA_var poa =
    parent_poa->create_POA (POA_name_.c_str (),
                            poa_manager.in (),
                            poa_policy_list);
}