コード例 #1
0
ファイル: server.cpp プロジェクト: jiaoyk/ATCD
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
{
  register_factories(orb);

  CORBA::Object_var objectman =
    orb->resolve_initial_references ("ORBPolicyManager");

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

  PortableServer::POA_var my_compress_poa = 0;
  CORBA::PolicyList policies(4);
  policies.length(4);

  try
    {
      policies[0] = create_compressor_id_level_list_policy (orb);
      policies[1] = create_low_value_policy (orb);
      policies[2] = create_compression_enabled_policy (orb);
      policies[3] = create_min_ratio_policy (orb);

      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }
  catch(const CORBA::PolicyError&)
    {
      policies.length(0);
      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }

  policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  CORBA::Object_var pcobject =
    orb->resolve_initial_references ("PolicyCurrent");

  CORBA::PolicyCurrent_var policy_current =
    CORBA::PolicyCurrent::_narrow (pcobject.in ());

  policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

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

  Hello *hello_impl = 0;
  ACE_NEW_RETURN (hello_impl,
                  Hello (orb),
                  0);
  PortableServer::ServantBase_var owner_transfer(hello_impl);

  PortableServer::ObjectId_var id =
    my_compress_poa->activate_object (hello_impl);

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

  Test::Hello_var hello = Test::Hello::_narrow (object.in ());

  poa_manager->activate ();

  return hello._retn ();
}
コード例 #2
0
ファイル: server.cpp プロジェクト: asdlei00/ACE
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();
}
コード例 #3
0
ファイル: server.cpp プロジェクト: asdlei00/ACE
PortableServer::POA_ptr
setup_poa (PortableServer::POA_ptr root_poa)
{
  // Policies for the childPOA to be created.
  CORBA::PolicyList policies (2);
  policies.length (2);

  // Tell the POA to use a servant manager.
  policies[0] =
    root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);

  // Allow implicit activation.
  policies[1] =
    root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION);

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

  // Create POA as child of RootPOA with the above policies.  This POA
  // will use a SERVANT_ACTIVATOR because of RETAIN policy.
  PortableServer::POA_var child_poa =
    root_poa->create_POA ("childPOA",
                          poa_manager.in (),
                          policies);

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

  return child_poa._retn ();
}
コード例 #4
0
ファイル: POA_Helper.cpp プロジェクト: asdlei00/ACE
void
TAO_Notify_POA_Helper::create_i (
  PortableServer::POA_ptr parent_poa,
  const char* poa_name,
  CORBA::PolicyList &policy_list)
{
  PortableServer::POAManager_var manager =
    parent_poa->the_POAManager ();

  // Create the child POA.
  this->poa_ = parent_poa->create_POA (poa_name, manager.in (), policy_list);

  if (DEBUG_LEVEL > 0)
    {
      CORBA::String_var the_name = this->poa_->the_name ();
      ORBSVCS_DEBUG ((LM_DEBUG, "Created POA : %C\n", the_name.in ()));
    }

  /*
  // Destroy the policies
  for (CORBA::ULong index = 0; index < policy_list.length (); ++index)
    {
      policy_list[index]->destroy ();
    }
  */
}
コード例 #5
0
//
// 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 ();
}
コード例 #6
0
ファイル: Adapter_Activator.cpp プロジェクト: asdlei00/ACE
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;
}
コード例 #7
0
ファイル: server.cpp プロジェクト: manut/TAO
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;
}
コード例 #8
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;
}
コード例 #9
0
ファイル: Stock_Factory_i.cpp プロジェクト: CCJY/ATCD
void
Quoter_Stock_Factory_i::load_stock_objects (
      PortableServer::POA_ptr poa,
      PortableServer::POAManager_ptr poa_manager,
      RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin)
{
  if (!CORBA::is_nil (this->stock_factory_poa_.in ()))
    return;

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

  policies[0] =
    poa->create_id_assignment_policy (PortableServer::USER_ID);
  policies[1] =
    poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION);

  this->stock_factory_poa_ =
    poa->create_POA ("Stock_Factory_POA",
                     poa_manager,
                     policies);

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

  while (!cin.eof () && cin.peek () != EOF) {
    const int max_symbol_length = 8;
    char symbol[max_symbol_length];
    const int max_full_name_length = 64;
    char full_name[max_full_name_length];
    double price;

    cin.getline (symbol, max_symbol_length, '\n');
    cin.getline (full_name, max_full_name_length, '\n');
    cin >> price;
    cin.ignore (1, '\n');

    Quoter_Stock_i *stock =
      new Quoter_Stock_i (symbol, full_name, price);

    PortableServer::ServantBase_var servant = stock;

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId (symbol);

    this->stock_factory_poa_->activate_object_with_id (oid.in (),
                                                       servant.in ());
    stock->connect (supplier_admin);
  }
}
コード例 #10
0
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;
}
コード例 #11
0
ファイル: AppHelper.cpp プロジェクト: chenbk85/ACE-Middleware
PortableServer::POA_ptr
AppHelper::create_poa(const char*                    name,
                      PortableServer::POA_ptr        root_poa,
                      PortableServer::POAManager_ptr mgr,
                      CORBA::PolicyList&             policies)
{
  PortableServer::POA_var child_poa = root_poa->create_POA(name,
                                                           mgr,
                                                           policies);

  if (CORBA::is_nil(child_poa.in()))
    {
      ACE_ERROR((LM_ERROR,
                 "(%P|%t) Failed to create child POA: %s.\n", name));
      throw TestAppException();
    }

  return child_poa._retn();
}
コード例 #12
0
ファイル: CorbaGC.cpp プロジェクト: RedhawkSDR/framework-core
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();
}
コード例 #13
0
ファイル: server.cpp プロジェクト: asdlei00/ACE
CORBA::Boolean
Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent,
                                    const char *name)
{
  if (ACE_OS::strcmp (name, "firstPOA") == 0)
    {
      PortableServer::POA_var child = parent->create_POA (name,
                                                          this->poa_manager_.in (),
                                                          this->first_poa_policies_);

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

      child->the_activator (this);

      reference_counted_test_i *servant =
        new reference_counted_test_i (this->orb_.in (),
                                      child.in ());

      child->set_servant (servant);

      // This means that the ownership of <servant> now belongs to the
      // POA.
      servant->_remove_ref ();

      // Finally everything is fine
      return 1;
    }
  else if (ACE_OS::strcmp (name, "secondPOA") == 0)
    {
      PortableServer::POA_var child = parent->create_POA (name,
                                                          this->poa_manager_.in (),
                                                          this->second_poa_policies_);

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

      reference_counted_test_i *servant =
        new reference_counted_test_i (this->orb_.in (),
                                      child.in ());

      PortableServer::ObjectId_var oid =
        PortableServer::string_to_ObjectId ("third test");

      child->activate_object_with_id (oid.in (),
                                      servant);

      // This means that the ownership of <servant> now belongs to the
      // POA.
      servant->_remove_ref ();

      // Finally everything is fine
      return 1;
    }
  else
    {
      // Unknown POA.
      return 0;
    }
}
コード例 #14
0
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);
}
コード例 #15
0
int main(int argc,char *argv [])
{
  CORBA::ORB_ptr orb_ptr;
  try
  {
    /************************************************************************/
    /*            INICIALIZAMOS LA PARTE DEL ORB                            */
    /************************************************************************/
    int alt_argc = 0;
    char ** alt_argv;
    const char * orb_id="Test_TIDNotification";
    orb_ptr=CORBA::ORB_init(argc, argv, orb_id);
    if (!orb_ptr)
    {
      cerr<<"El ORB es null"<<endl;
      return -1;
    }

    CORBA::Object_ptr delegado_POA;
    PortableServer::POA_ptr rootPOA;
    try
    {
      delegado_POA = orb_ptr->resolve_initial_references("RootPOA");
    }
    catch ( CORBA::ORB::InvalidName ex )
    {
      ex._name();
      return -1;

    }
    rootPOA = PortableServer::_POAHelper::narrow( delegado_POA,true );
    PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager();
    CORBA::PolicyList_var policies = NULL;
    policies = new CORBA::PolicyList(2);
    policies->length(2);
      // Valores cambiados
    (*policies)[0] = rootPOA->create_lifespan_policy
      ( PortableServer::PERSISTENT );
    (*policies)[1] = rootPOA->create_id_assignment_policy
      ( PortableServer::USER_ID );

    PortableServer::POA_var consumerPOA = rootPOA->create_POA("consumerPOA", poa_manager, *policies );
    
    /***********************************************************************/
    /*   OBTENEMOS LA FACTORIA DEL CANAL DE EVENTOS Y CREAMOS EL CANAL     */
    /**********************************************************************/

    CORBA::Object_ptr delegado_event_channel_factory;
    delegado_event_channel_factory=orb_ptr->string_to_object(argv[1]);
    CosNotifyChannelAdmin::EventChannelFactory_var factory;
    factory = CosNotifyChannelAdmin::EventChannelFactory::_narrow(delegado_event_channel_factory);
    if (CORBA::is_nil(factory)) { 
      cerr << "[server] ERROR: factoria nula " << endl;
      return -1; 
    } 
  
     CosNotifyChannelAdmin::EventChannel_var channel;
    //CosNotifyChannelAdmin::EventChannel_var channelv[10];


    CosNotification::QoSProperties initial_qos;
    CosNotification::AdminProperties initial_admin;
    CosNotifyChannelAdmin::ChannelID id;
    //CosNotifyChannelAdmin::ChannelID idv[10];



//     // Politicas Soportadas:

//     initial_qos.length(9);
//     initial_qos[0].name = CORBA::string_dup("OrderPolicy");
//     initial_qos[0].value <<= CosNotification::FifoOrder; // Any Fifo Priority Deadline

//     initial_qos[1].name = CORBA::string_dup("EventReliability");
//     initial_qos[1].value <<= CosNotification::BestEffort; // Persistent

//     initial_qos[2].name = CORBA::string_dup("ConnectionReliability");
//     initial_qos[2].value <<= CosNotification::BestEffort; // Persistent
    
//     initial_qos[3].name = CORBA::string_dup("Priority");
//     initial_qos[3].value <<= CosNotification::HighestPriority; // Highest, Default

//     initial_qos[4].name = CORBA::string_dup("StartTime");
//     initial_qos[4].value <<= *(new TimeBase::UtcT(
//                                   TIDorb::core::util::Time::currentTimeMillis(),
//                                   0,0,0));

//     initial_qos[5].name = CORBA::string_dup("StopTime");
//     initial_qos[5].value <<= *(new TimeBase::UtcT(
//                                   TIDorb::core::util::Time::currentTimeMillis(),
//                                   0,0,0));

//     initial_qos[6].name = CORBA::string_dup("Timeout");
//     initial_qos[6].value <<= (TimeBase::TimeT)TIDorb::core::util::Time::currentTimeMillis();

//     initial_qos[7].name = CORBA::string_dup("StartTimeSupported");
//     initial_qos[7].value <<= (CORBA::Boolean) 0;

//     initial_qos[8].name = CORBA::string_dup("StopTimeSupported");
//     initial_qos[8].value <<= (CORBA::Boolean) 1;

    //
    // Politicas de QoS no soportadas
    //

    // initial_qos[0].name = CORBA::string_dup("DiscardPolicy");
    // initial_qos[0].value <<= CosNotification::AnyOrder; // Any Fifo Priority Deadline

    // initial_qos[7].name = CORBA::string_dup("MaximumBatchSize");
    // initial_qos[7].value <<= (CORBA::Long) 20;

    // initial_qos[0].name = CORBA::string_dup("PacingInterval");
    // initial_qos[0].value <<= (TimeBase::TimeT)TIDorb::core::util::Time::currentTimeMillis();

    // initial_qos[9].name = CORBA::string_dup("MaxEventsPerConsumer");
    // initial_qos[9].value <<= (CORBA::Long) 20;


    try { 
      // Crear el canal
      channel = factory->get_event_channel(0);

//       for(int i=0; i < 10; i++){
//         channelv[i] = factory->create_channel(initial_qos, initial_admin, idv[i]);
//       }
    } catch (CosNotifyChannelAdmin::ChannelNotFound &ex) { 
      cerr << "[server_consumer] CosNotifyChannelAdmin::ChannelNotFound: " << ex._name(); 
      return -1; 
    }
    /**************************************************************************/
    /*              OBTENEMOS EL CONSUMERADMIN POR DEFECTO                    */
    /**************************************************************************/
    CosNotifyChannelAdmin::ConsumerAdmin_ptr consumerAdmin;
    consumerAdmin = channel->default_consumer_admin();
   
    //Metemos los filtros en el consumer admin
    CosNotifyFilter::Filter* filter_II = create_filter(channel,"GSyC","test","$domain_name != 'GSyC'");
    //consumerAdmin->add_filter(filter_II);
    //CosNotifyFilter::Filter* filter_III = create_filter(channel,"GSyC","test","$.remainder_of_boy.campo_uno != 1");
    //consumerAdmin->add_filter(filter_III);
   /**************************************************************************/
   /*         OBTENEMOS EL PROXYSUPPLIER APARTIR DEL CONSUMERADMIN           */
   /**************************************************************************/
    //TODO_MORFEO: add new filters
    CosNotifyChannelAdmin::ProxySupplier_ptr proxySupplier;
    CosNotifyChannelAdmin::ProxyID proxySupplierID = 1;
    proxySupplier = 
      consumerAdmin->obtain_notification_push_supplier(CosNotifyChannelAdmin::ANY_EVENT,
                                                      proxySupplierID);

                                                      

   /**************************************************************************/
   /*       OBTENEMOS EL PROXYPUSHSUPPLIER APARTIR DEL CONSUMERADMIN         */
   /**************************************************************************/
    CosNotifyChannelAdmin::StructuredProxyPushSupplier_ptr proxyPushSupplier;
    
    proxyPushSupplier = CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(proxySupplier);



    /**************************************************************************/
    /*            INSTANCIAMOS LOS PROXYS Y LOS ACTIVAMOS EN EL POA           */
    /**************************************************************************/
    my_push_consumer * my_consumer = new my_push_consumer(orb_ptr,proxyPushSupplier);
    PortableServer::ObjectId_ptr consumer_objectID = PortableServer::string_to_ObjectId("My_Consumer:1.0");
    consumerPOA->activate_object_with_id(*consumer_objectID,my_consumer);
    poa_manager->activate();
    CORBA::Object_ptr obj_consumer = consumerPOA->id_to_reference(*consumer_objectID);
    CosNotifyComm::StructuredPushConsumer_ptr my_pushConsumer = CosNotifyComm::StructuredPushConsumer::_narrow(obj_consumer);


    /***********************************************************************/
    /*                CONECTAMOS EL PUSHSUPPLIER Y EL PUSHCONSUMER         */
    /***********************************************************************/
    proxyPushSupplier->connect_structured_push_consumer(my_pushConsumer);


    orb_ptr->run();
 
    
  }
  catch (CORBA::Exception & e)
  {
    cerr<<"[Test_Filter] unknown error"<< typeid(e).name() << e._name();
   return -1;
   
  }

}
コード例 #16
0
ファイル: Identity.cpp プロジェクト: chenbk85/ACE-Middleware
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 ();
    }
}
コード例 #17
0
ファイル: POA_Holder.cpp プロジェクト: asdlei00/ACE
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);
}
コード例 #18
0
ファイル: ns_server.C プロジェクト: AlvaroVega/TIDNaming
int main(int argc, char* argv[]) {

//   // Signals staff
//   signal(SIGINT,  handler);
//   signal(SIGTERM, handler);
//   signal(SIGKILL, handler);
  
  // Print the welcome message
  printWelcome();
  
  //
  // Check TIDNaming arguments
  //
  /*
   * Note: this TIDNaming special arguments may be passed to ORB
   * initialization with no problems. Any unknown argument will be ignored
   * by ORB, so no change is needed for argv.
   */
  const char * persistence_dir = "";
  int max_binding_iterators = 40;
  const char * ior_file = "";

  for (int i = 1; i < argc; i++)
  {
    if (strcmp(argv[i], "--help") == 0)
    {
      printUsage(argv[0]);
      _exit(0);
    }

    if (strcmp(argv[i], "--version") == 0)
    {
      cerr << "TIDNaming C++ version " << TIDNaming::st_version << endl;
      _exit(0);
    }
    
    if (strcmp(argv[i], "--persistence-dir") == 0)
     {
       if (i == argc - 1)
       {
         cerr << "Error: --persistence-dir specified but no path given" << endl;
         printUsage(argv[0]);
         _exit(-1);
       }
       persistence_dir = argv[i+1];
     }

    if (strcmp(argv[i], "--max_binding_iterators") == 0) {
      char* ptr;
      long  laux;
      laux = strtol(argv[i+1], &ptr, 10);
      max_binding_iterators = laux;
    }

    if (strcmp(argv[i], "--ior") == 0) {
       if (i == argc - 1)
       {
         cerr << "Error: --ior specified but no file name given" << endl;
         printUsage(argv[0]);
         _exit(-1);
       }
       ior_file = argv[i+1];
    }

  }

  DMSG("Executing in debug mode, a lot of messages will be "\
       "printed to stderr");
  DMSG_P("Using '", persistence_dir, "' as persistence directory"); 
  DMSG_P("Using '", ior_file, "' as ior output file"); 

  char * port = strdup("2809");
  char * ssl_port = strdup("");
  bool port_given = false;
  bool ssl_port_given = false;
  bool ssl_config = false;

  try {
     
     //
     // Start TIDThread library
     //
     TIDThr::init();

     //
     // Check for -ORB_iiop_orb_port to set NameService default
     //
     int new_argc = argc + 2;
     char * new_argv[new_argc];
     for (int i = 1; i < argc; i++)
     {
       new_argv[i] = argv[i]; // No strdup is needed

       if (strcmp(argv[i], "-ORB_iiop_orb_port") == 0)
       {
         port_given = true;
         free(port);
         port = strdup(argv[i+1]);
       }

       if (strcmp(argv[i], "-ORB_ssl_port") == 0)
       {
         ssl_port_given = true; // util??
         free(ssl_port);
         ssl_port = strdup(argv[i+1]);
       }
       if (strcmp(argv[i], "-ORB_ssl_private_key") == 0)
       {
         for (int j = 1; j < argc; j++) {
           if (strcmp(argv[j], "-ORB_ssl_certificate") == 0) {
             ssl_config = true;
             break;
           }
         }
       }
     }
     new_argv[new_argc - 2] = "-ORB_iiop_orb_port";
     new_argv[new_argc - 1] = port;

     int orb_argc     = port_given ? argc : new_argc;
     char ** orb_argv = port_given ? argv : new_argv;

     //
     // ORB initialization
     //
     my_global_orb = CORBA::ORB_init(orb_argc, orb_argv);

     // Get internal ORB 
     TIDorb::core::TIDORB* m_orb = 
       dynamic_cast<TIDorb::core::TIDORB*> (CORBA::ORB::_duplicate(my_global_orb));

     //
     // Getting RootPOA & Manager references
     //
     CORBA::Object_var poa_obj = my_global_orb->resolve_initial_references("RootPOA");
     PortableServer::POA_ptr rootPOA = PortableServer::POA::_narrow(poa_obj);

     PortableServer::POAManager_var manager = rootPOA->the_POAManager();


     //
     // NamingContexts POA creation
     //
     CORBA::PolicyList policies;
     policies.length(4);

     policies[0] = rootPOA->create_servant_retention_policy(PortableServer::RETAIN);
     policies[1] = rootPOA->create_request_processing_policy(
                                                   PortableServer::USE_SERVANT_MANAGER);
     policies[2] = rootPOA->create_id_assignment_policy(PortableServer::USER_ID);
     policies[3] = rootPOA->create_lifespan_policy(PortableServer::PERSISTENT);

     PortableServer::POA_var namingContextsPOA = 
       rootPOA->create_POA("namingContextsPOA", manager, policies);

     PortableServer::POAManager_var namingContextsManager = 
       namingContextsPOA->the_POAManager();


     //
     // BindingIterators POA creation
     //
     CORBA::PolicyList bindingIterators_policies;
     bindingIterators_policies.length(2);

     bindingIterators_policies[0] = 
       rootPOA->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL); 
     bindingIterators_policies[1] = 
       rootPOA->create_id_assignment_policy(PortableServer::USER_ID);

     PortableServer::POA_var bindingIteratorsPOA = 
       namingContextsPOA->create_POA("bindingIteratorsPOA", namingContextsManager, 
                                     bindingIterators_policies);


     // 
     // Creates and sets a new ServantManager
     // 

     TIDNaming::ServantManagerNSImpl* servant_manager = 
       new TIDNaming::ServantManagerNSImpl(my_global_orb, bindingIteratorsPOA,
                                           max_binding_iterators);

     namingContextsPOA->set_servant_manager(servant_manager);


     // Creates the reference to the "root.ctx". Dont create it
     // This fragment of code is not needed anymore. It creates the
     // initial reference to root naming context, now created from
     // PersistenceManager class.
     /*
     PortableServer::ObjectId_var oid =
       PortableServer::string_to_ObjectId("root.ctx"); // Change to "NameService"

     CORBA::Object_var obj = 
       namingContextsPOA->create_reference_with_id(oid,"IDL:omg.org/CosNaming/NamingContextExt:1.0");  
     */

     // Manager activation (ORB/POA staff)
     manager->activate();
     namingContextsManager->activate();


     //
     // Check if has persistence 
     //
     if (strcmp(persistence_dir, "") != 0) {

       if (m_orb->trace != NULL){
         TIDorb::util::StringBuffer msg;
         msg << "Using '" << persistence_dir << "' as persistence directory";
         m_orb->print_trace(TIDorb::util::TR_USER, msg.str().data());
       }

       //
       // Recover the persistent data 
       //
       try {
         TIDNaming::NamingContextFileIOFactory::init(persistence_dir);
       }
       catch (TIDNaming::NamingContextFileIOFactory::InvalidPathException & e) {
         if (m_orb->trace != NULL) {
           TIDorb::util::StringBuffer msg;
           msg << "Error: cannot initialize persistence directory '";
           msg << e.path << "'";
           m_orb->print_trace(TIDorb::util::TR_ERROR, msg.str().data());
         }
         printUsage(argv[0]);
         _exit(-1);
       }

       loadPersistence(namingContextsPOA.inout(), 
                       bindingIteratorsPOA.inout(),
                       ior_file);


     } else {

       //
       // Start without persistent data 
       //     
       try {
         TIDNaming::NamingContextNullIOFactory::init();
       }
       catch (...) {
         printUsage(argv[0]);
         _exit(-1);
       }
       
       if (m_orb->trace != NULL)
         m_orb->print_trace(TIDorb::util::TR_USER, 
                            "No root context found. Initializing a new one... ");

       CosNaming::NamingContext_var root_nc = 
         createNamingContextReference(namingContextsPOA, 
                                      NamingInternals::RootNamingContextOID);

       // Get ssl system assigned port
       if (ssl_config && (!ssl_port_given)) {
         TIDorb::portable::Stub* stub_obj = 
           dynamic_cast<TIDorb::portable::Stub*> ((CORBA::Object*)root_nc);
         TIDorb::core::ObjectDelegateImpl* obj_delegate = 
           dynamic_cast<TIDorb::core::ObjectDelegateImpl*> (stub_obj->_get_delegate());
         TIDorb::core::iop::IOR* ior = obj_delegate->getReference();
         SSLIOP::SSL* _ssl = ior->get_SSL();
         free(ssl_port);
         ssl_port = (char*)malloc(6);
         sprintf(ssl_port, "%d", _ssl->port);         
       }
       registerNameService(my_global_orb, root_nc, ior_file);

       if (m_orb->trace != NULL)
         m_orb->print_trace(TIDorb::util::TR_DEBUG, "Done");
       
       
     }

     //
     // Run the ORB loop forever
     //
     TIDorb::util::StringBuffer msg;
     msg << "Serving at port " << port << "... " << endl;
     if (ssl_config) {
       msg.seekp(0, ios::beg);
       msg << "Serving at SSL port " << ssl_port << "... " << endl;
     }
     if (m_orb->trace != NULL)
       m_orb->print_trace(TIDorb::util::TR_USER,  msg.str().data());
     cerr << msg.str().data();

     my_global_orb->run();

     my_global_orb->destroy();

  }
  catch (const CORBA::INITIALIZE & ex) {
    cerr << "ERROR: cannot initialize Naming Service at port ";
    if (ssl_config) 
      cerr << ssl_port;
    else
      cerr << port;
    cerr << " due to: " << ex << endl;
  }
  catch (const CORBA::Exception& ex) {
    cerr << "ERROR: Naming Server Exception: " << ex << endl << flush;
    exit (1);
  }
  catch (...) {
    cerr << "ERROR: unexpected exception raised" << endl << flush;
    exit (1);
  }

  free(port);
  free(ssl_port);

}
コード例 #19
0
ファイル: registration.cpp プロジェクト: CCJY/ATCD
void
child_poa_testing (PortableServer::POA_ptr root_poa)
{
  // Policies for the child POA.
  CORBA::PolicyList policies (1);
  policies.length (1);

  // Id Assignment Policy
  policies[0] =
    root_poa->create_id_assignment_policy (PortableServer::USER_ID);

  // Create the child POA under the RootPOA.
  PortableServer::POA_var child_poa =
    root_poa->create_POA ("child POA",
                          PortableServer::POAManager::_nil (),
                          policies);

  // Create an array of servants
  test_i *servants =
    new test_i[iterations];

      // Create an array of objects
  CORBA::Object_var *objects =
    new CORBA::Object_var[iterations];

      // Create an array of object ids
  PortableServer::ObjectId_var *object_ids =
    new PortableServer::ObjectId_var[iterations];

  // Buffer for the id string.
  char id_buffer[128];

  // Index counter
  u_long i = 0;

  {
    // Record and quantify stats.
    stats s (QUANTIFY_CREATE_REFERENCE_WITH_ID,
             "create_reference_with_id");
    ACE_UNUSED_ARG (s);

    for (i = 0; i < iterations; i++)
      {
        ACE_OS::sprintf (id_buffer,
                         "%ld",
                         i);

        object_ids[i] =
          PortableServer::string_to_ObjectId (id_buffer);

        objects[i] =
          child_poa->create_reference_with_id (object_ids[i].in (),
                                               "IDL:test:1.0");
      }
  }

  {
    // Record and quantify stats.
    stats s (QUANTIFY_ACTIVATE_OBJECT_WITH_ID,
             "activate_object_with_id");
    ACE_UNUSED_ARG (s);

    for (i = 0; i < iterations; i++)
      {
        child_poa->activate_object_with_id (object_ids[i].in (),
                                            &servants[i]);
      }
  }

  {
    // Record and quantify stats.
    stats s (QUANTIFY_DEACTIVATE_OBJECT,
             "deactivate_object");
    ACE_UNUSED_ARG (s);

    for (i = 0; i < iterations; i++)
      {
        child_poa->deactivate_object (object_ids[i].in ());
      }
  }

  // Cleanup
  delete[] object_ids;
  delete[] objects;
  delete[] servants;
}