Exemplo n.º 1
0
PortableServer::POA_ptr
ServerApp::create_poa(CORBA::ORB_ptr orb,
                      const char* poa_name)
{
  // Get the Root POA.
  PortableServer::POA_var root_poa
    = RefHelper<PortableServer::POA>::resolve_initial_ref(orb,
                                                          "RootPOA");

  // Get the POAManager from the Root POA.
  PortableServer::POAManager_var poa_manager
    = root_poa->the_POAManager();

  // Create the child POA Policies.
  CORBA::PolicyList policies(0);
  policies.length(0);

  // Create the child POA
  PortableServer::POA_var poa = AppHelper::create_poa(poa_name,
                                                      root_poa.in(),
                                                      poa_manager.in(),
                                                      policies);

  // Give away the child POA_ptr from the POA_var variable.
  return poa._retn();
}
Exemplo n.º 2
0
PortableServer::POA_ptr
createPOA (PortableServer::POA_ptr root_poa,
           bool share_mgr,
           const char* poa_name)
{
  PortableServer::LifespanPolicy_var life =
    root_poa->create_lifespan_policy(PortableServer::PERSISTENT);

  PortableServer::IdAssignmentPolicy_var assign =
    root_poa->create_id_assignment_policy(PortableServer::USER_ID);

  CORBA::PolicyList pols;
  pols.length(2);
  pols[0] = PortableServer::LifespanPolicy::_duplicate(life.in());
  pols[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign.in());

  PortableServer::POAManager_var mgr = PortableServer::POAManager::_nil();
  if (share_mgr)
    {
      mgr = root_poa->the_POAManager();
    }
  PortableServer::POA_var poa =
    root_poa->create_POA(poa_name, mgr.in(), pols);

  life->destroy();
  assign->destroy();

  return poa._retn();
}
Exemplo n.º 3
0
PortableServer::POA_ptr 
VOmniORBHelper::poaGetOrCreatePoa(const char* program, const char* object,
				  int telescopenumber)
  throw(CORBA::SystemException)
{
  ZThread::Guard<ZThread::RecursiveMutex> guard(m_mutex);

  // Munge the path name into a unique POA name
  char* poa_name = poaPathToPoaName(program, object, telescopenumber);

  // Check to see if we created this one already, if so then return it now
  std::map<std::string,PortableServer::POA_var>::iterator poaFound = 
    m_poaMap.find(poa_name);
  
  if(poaFound != m_poaMap.end())
    return PortableServer::POA::_duplicate(poaFound->second);

  // Grab the root POA
  PortableServer::POA_var root_poa = poaRootPoa();

  // Must create the POA, use the PERSISTENT and USER_ID policies
  PortableServer::LifespanPolicy_var lifespan = 
    root_poa -> create_lifespan_policy(PortableServer::PERSISTENT);
  PortableServer::IdAssignmentPolicy_var assign =
    root_poa -> create_id_assignment_policy(PortableServer::USER_ID);

  CORBA::PolicyList policy_list;
  policy_list.length(2);
  policy_list[0] = PortableServer::LifespanPolicy::_duplicate(lifespan);
  policy_list[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign);

  // Root POA manager
  PortableServer::POAManager_var root_poa_manager = 
    PortableServer::POAManager::_duplicate(m_rootPoaManager);

  // Create the POA
  PortableServer::POA_var poa = 
    root_poa -> create_POA(poa_name, root_poa_manager, policy_list);

  // Make a copy of the POA object and remember it in case we are asked
  // for it again some time
  m_poaMap[poa_name] = PortableServer::POA::_duplicate(poa);

  CORBA::string_free(poa_name);

  lifespan->destroy();
  assign->destroy();

  return poa._retn();
}
Exemplo n.º 4
0
PortableServer::POA_ptr ossie::corba::createGCPOA(PortableServer::POA_ptr parent, const std::string& name)
{
    CORBA::PolicyList policy_list;
    policy_list.length(2);
    policy_list[0] = parent->create_servant_retention_policy(PortableServer::NON_RETAIN);
    policy_list[1] = parent->create_request_processing_policy(PortableServer::USE_SERVANT_MANAGER);

    PortableServer::POAManager_var poa_mgr = parent->the_POAManager();
    PortableServer::POA_var poa = parent->create_POA(name.c_str(), poa_mgr, policy_list);

    for (size_t ii = 0; ii < policy_list.length(); ++ii) {
        policy_list[ii]->destroy();
    }

    GCServantLocator* manager = new GCServantLocator();
    PortableServer::ServantManager_var manager_ref = manager->_this();
    poa->set_servant_manager(manager_ref);
    manager->_remove_ref();

    return poa._retn();
}