Exemplo n.º 1
0
void
TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator,
                                       TAO_ORB_Core &orb_core)
{
  // Just give a last chance for all the unloaded validators in other
  // libraries to be registered
  orb_core.load_policy_validators (validator);

  // Validate that all of the specified policies make sense.
  validator.validate (this->impl_ );

  // Verify that all policies are legal for the currently loaded
  // POA extensions.
  for (CORBA::ULong i = 0;
       i < this->impl_.num_policies ();
       i++)
    {
      CORBA::Policy_var policy = this->impl_.get_policy_by_index (i);

      CORBA::PolicyType type = policy->policy_type ();

      if (!(validator.legal_policy (type)))
        {
#if !defined (CORBA_E_MICRO)
          // An invalid policy was specified.  Let the user know about
          // it.
          throw PortableServer::POA::InvalidPolicy ();
#else
          TAOLIB_ERROR ((LM_ERROR, "Invalid policy\n"));
#endif
        }
    }
}
void
TAO_DiffServ_Network_Priority_Hook::update_network_priority (
  TAO_Root_POA &poa, TAO_POA_Policy_Set &policy_set)
{
  for (CORBA::ULong i = 0; i < policy_set.num_policies (); i++)
    {
      CORBA::Policy_var policy = policy_set.get_policy_by_index (i);

      if (policy->policy_type () == TAO::NETWORK_PRIORITY_TYPE)
        {
          ::TAO::NetworkPriorityPolicy_var npp =
            ::TAO::NetworkPriorityPolicy::_narrow (policy.in ());

          if (!CORBA::is_nil (npp.in ()))
            {
              TAO::NetworkPriorityModel network_priority_model =
                npp->network_priority_model ();

              poa.cached_policies ().network_priority_model (
                TAO::Portable_Server::Cached_Policies::NetworkPriorityModel (
                  network_priority_model));

              TAO::DiffservCodepoint request_diffserv_codepoint  =
                npp->request_diffserv_codepoint ();

              TAO::DiffservCodepoint reply_diffserv_codepoint  =
                npp->reply_diffserv_codepoint ();

              poa.cached_policies ().request_diffserv_codepoint (
                request_diffserv_codepoint);
              poa.cached_policies ().reply_diffserv_codepoint (
                reply_diffserv_codepoint);
            }
        }
    }
}
Exemplo n.º 3
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      PortableInterceptor::ORBInitializer_ptr temp_initializer =
        PortableInterceptor::ORBInitializer::_nil ();

      ACE_NEW_RETURN (temp_initializer,
                      Server_ORBInitializer,
                      -1);  // No CORBA exceptions yet!
      PortableInterceptor::ORBInitializer_var orb_initializer =
        temp_initializer;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());

      CORBA::ORB_var orb = CORBA::ORB_init (argc,
                                            argv,
                                            "test_orb");

      // Create the test policy.

      const CORBA::ULong val = 40442;
      CORBA::Any any;
      any <<= val;

      CORBA::Policy_var p (orb->create_policy (Test::POLICY_TYPE,
                                               any));

      const CORBA::PolicyType ptype =
        p->policy_type ();

      // Sanity check.
      if (ptype != Test::POLICY_TYPE)
        throw CORBA::INTERNAL ();

      Test::Policy_var policy (Test::Policy::_narrow (p.in ()));

      const CORBA::ULong pval = policy->value ();

      // Sanity check.
      if (val != pval)
        throw CORBA::INTERNAL ();

      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (obj.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Unable to obtain RootPOA reference.\n"),
                          -1);

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

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

      policies[0] = policy->copy ();

      PortableServer::POA_var poa =
        root_poa->create_POA ("Test POA",
                              poa_manager.in (),
                              policies);

      policy->destroy ();

      poa_manager->activate ();

      root_poa->destroy (1, 1);

      orb->destroy ();

      ACE_DEBUG ((LM_INFO,
                  "\n"
                  "PolicyFactory test succeeded.\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("PolicyFactory test:");

      return -1;
    }

  return 0;
}