//
// initialize_poa
//
void Tao_Data_Channel_Service::initialize_poa (::PortableServer::POA_ptr poa)
{
  // Construct the policy list for the LoggingServerPOA.
  ::CORBA::PolicyList policies (6);
  policies.length (6);

  policies[0] = poa->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
  policies[1] = poa->create_servant_retention_policy (PortableServer::RETAIN);
  policies[2] = poa->create_id_assignment_policy (PortableServer::SYSTEM_ID);
  policies[3] = poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID);
  policies[4] = poa->create_lifespan_policy (PortableServer::TRANSIENT);
  policies[5] = poa->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY);

  // Create the child POA for the test logger factory servants.
  this->poa_ =
    poa->create_POA ("DataChannelPOA",
                     ::PortableServer::POAManager::_nil (),
                     policies);

  for (size_t i = 0; i < 6; ++ i)
    policies[i]->destroy ();

  // Activate this POA's manager.
  PortableServer::POAManager_var the_mgr = this->poa_->the_POAManager ();
  the_mgr->activate ();
}
Esempio n. 2
0
CORBA::Boolean
ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent,
                              const char *name)
{
  ACE_ASSERT (! CORBA::is_nil(parent));
  ACE_ASSERT (name != 0);
  CORBA::PolicyList policies (3);

  const char *exception_message = "Null Message";
  policies.length (3);
  try
    {
      // Servant Retention Policy
      exception_message = "While PortableServer::POA::create_servant_retention_policy";
      policies[0] =
        parent->create_servant_retention_policy (PortableServer::NON_RETAIN);

      // Request Processing Policy
      exception_message = "While PortableServer::POA::create_request_processing_policy";

      policies[1] =
        parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);
      policies[2] =
        parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

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

      exception_message = "While create_POA";
      PortableServer::POA_var child =
        parent->create_POA (name,
                            poa_manager.in (),
                            policies);

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

      exception_message = "While child->the_activator";
      child->the_activator (this);

      exception_message = "While set_servant";
      child->set_servant (this->default_servant_);
    }
  catch (const CORBA::Exception& ex)
    {
      ORBSVCS_ERROR ((LM_ERROR,
                  "IMR_Adapter_Activator::unknown_adapter - %s\n",
                  exception_message));
      ex._tao_print_exception ("System Exception");
      return 0;
    }

  // Finally, now everything is fine
  return 1;
}
Esempio n. 3
0
// Implementation skeleton constructor
CDBPropertySet::CDBPropertySet (CORBA::ORB_ptr orb,
				PortableServer::POAManager_ptr poa_manager,
				PortableServer::POA_ptr root_poa) :
  poa_m(PortableServer::POA::_nil()),
  poaCurrent_m(PortableServer::Current::_nil())
{
  ACS_TRACE("baci::CDBPropertySet::CDBPropertySet");

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

  // ID Assignment Policy
  policies[0] =
    root_poa->create_id_assignment_policy (PortableServer::USER_ID);
  
  // Lifespan Policy
  policies[1] =
    root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
  
  // Request Processing Policy
  policies[2] =
    root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);

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

  // Id Uniqueness Policy
  policies[4] =
    root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

  ACE_CString name = "DefaultServantPOA";
  poa_m = root_poa->create_POA (name.c_str (),
				poa_manager,
				policies);
  
  for (CORBA::ULong i = 0UL; i < policies.length (); ++i)
    {
      CORBA::Policy_ptr policy_p = policies[i];
      policy_p->destroy();
    }

  // Get the POA Current object reference
  CORBA::Object_var obj =
			orb->resolve_initial_references ("POACurrent");
  
  // Narrow the object reference to a POA Current reference
  this->poaCurrent_m =
      PortableServer::Current::_narrow (obj.in());
  
  // Set default servant
  poa_m->set_servant (this);
  
  instance_mp = this;
}
Esempio n. 4
0
void
TAO_Notify_POA_Helper::set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list)
{
  policy_list.length (2);

  policy_list[0] =
    parent_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID);

  policy_list[1] =
    parent_poa->create_id_assignment_policy (PortableServer::USER_ID);
}
int
TAO_CosEventChannelFactory_i::init (PortableServer::POA_ptr poa,
                                    const char* child_poa_name,
                                    CosNaming::NamingContext_ptr naming)
{
  // Check if we have a parent poa.
  if (CORBA::is_nil (poa))
    return -1;

  this->naming_ = CosNaming::NamingContext::_duplicate (naming);
  // Save the naming context.

  // Create a UNIQUE_ID and USER_ID policy because we want the POA
  // to detect duplicates for us.
  PortableServer::IdUniquenessPolicy_var idpolicy =
    poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID);

  PortableServer::IdAssignmentPolicy_var assignpolicy =
    poa->create_id_assignment_policy (PortableServer::USER_ID);

  // Create a PolicyList
  CORBA::PolicyList policy_list;
  policy_list.length (2);
  policy_list [0] =
    PortableServer::IdUniquenessPolicy::_duplicate (idpolicy.in ());
  policy_list [1] =
    PortableServer::IdAssignmentPolicy::_duplicate (assignpolicy.in ());

  PortableServer::POAManager_ptr manager =
    poa->the_POAManager ();
  // @@ Pradeep : TODO - find a way to destroy the policy_list if we return here.

  // Create the child POA.
  this->poa_ = poa->create_POA (child_poa_name,
                                manager,
                                policy_list);


  idpolicy->destroy ();

  assignpolicy->destroy ();

  //this->poa_ =  PortableServer::POA::_duplicate (poa);
  // uncomment this if we want to use the parent poa for some reason.
   return 0;
}
Esempio n. 6
0
void
create_poas (PortableServer::POA_ptr root_poa,
             PortableServer::LifespanPolicyValue lifespan_policy,
             PortableServer::POA_out first_poa,
             PortableServer::POA_out second_poa,
             PortableServer::POA_out third_poa,
             PortableServer::POA_out forth_poa)
{
  // Policies for the new POAs
  CORBA::PolicyList policies (3);
  policies.length (3);

  policies[0] = root_poa->create_lifespan_policy (lifespan_policy);

  policies[1] = root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

  policies[2] = root_poa->create_id_assignment_policy (PortableServer::SYSTEM_ID);

  // Creation of the firstPOA
  ACE_CString name = "firstPOA";
  first_poa = root_poa->create_POA (name.c_str (),
                                    PortableServer::POAManager::_nil (),
                                    policies);

  policies[1]->destroy ();

  policies[1] = root_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID);

  // Creation of the secondPOA
  name = "secondPOA";
  second_poa = root_poa->create_POA (name.c_str (),
                                     PortableServer::POAManager::_nil (),
                                     policies);

  policies[2]->destroy ();

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

  // Creation of the thirdPOA
  name = "thirdPOA";
  third_poa = root_poa->create_POA (name.c_str (),
                                    PortableServer::POAManager::_nil (),
                                    policies);

  policies[1]->destroy ();

  policies[1] = root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

  // Creation of the forthPOA
  name = "forthPOA";
  forth_poa = root_poa->create_POA (name.c_str (),
                                    PortableServer::POAManager::_nil (),
                                    policies);

  // Creation of the new POAs over, so destroy the policies
  for (CORBA::ULong i = 0;
       i < policies.length ();
       ++i)
    {
      policies[i]->destroy ();
    }
}
void 
HomeServantBase::initialize
( PortableServer::POA_ptr root_poa
, Components::HomeExecutorBase_ptr home_executor
, ContainerInterfaceImpl* container
, std::string install_dir )
throw (Components::Deployment::InstallationFailure)
{
	home_executor_ = Components::HomeExecutorBase::_duplicate (home_executor);
	container_ = container;
	container_->_add_ref();
	install_dir_ = install_dir;

	// Create a new POA for the components
	CORBA::PolicyList policies;
	policies.length (7);
	policies[0] = root_poa->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
	policies[1] = root_poa->create_lifespan_policy (PortableServer::TRANSIENT);
	policies[2] = root_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID);
	policies[3] = root_poa->create_id_assignment_policy (PortableServer::USER_ID);
	policies[4] = root_poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION);
	policies[5] = root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN);
	policies[6] = root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);

	static CORBA::ULong poa_name = 0;
	char buffer[17];

	sprintf (buffer, "Qedo_POA_%ld", ++poa_name);
	
	try
	{
		home_poa_ = root_poa->create_POA (buffer, NULL, policies);
	}
	catch (PortableServer::POA::AdapterAlreadyExists&)
	{
		NORMAL_ERR ("HomeServantBase: Fatal internal error - POA already exists???");
		throw Components::Deployment::InstallationFailure();
	}
	catch (PortableServer::POA::InvalidPolicy&)
	{
		NORMAL_ERR ("HomeServantBase: Fatal internal error - Invalid policy during POA creation: ORB not CORBA 2.3 compliant???");
		throw Components::Deployment::InstallationFailure();
	}

	// Set servant locator
	try
	{
	    home_poa_->set_servant_manager (servant_locator_);
	}
	catch (PortableServer::POA::WrongPolicy&)
	{
		// Cannot be, since our POA has the right policies
		NORMAL_ERR ("HomeServantBase: Fatal internal error - Setting servant manager complains about a wrong policy???");
		throw Components::Deployment::InstallationFailure();
	}

	my_home_servant_ = dynamic_cast <PortableServer::Servant> (this);

	if (! my_home_servant_)
	{
		NORMAL_ERR ("HomeServantBase: initialize(): Cannot dynamic_cast this pointer to PortableServer::Servant");
		throw Components::Deployment::InstallationFailure();
	}

	// Activate the POA using the POA manager
	home_poa_manager_ = home_poa_->the_POAManager();

	home_poa_manager_->activate();

	// Create a first object reference, which belongs to this home
	CORBA::Object_var home_obj = this->create_primary_object_reference (repository_id_);
	my_object_id_ = this->reference_to_oid (home_obj);

	// Narrow the object reference for the home (this can involve remote _is_a() calls to the
	// servant, so it must be active at this time)
	my_home_ref_ = Components::CCMHome::_narrow (home_obj);
}