Public Member Functions | Private Attributes

TAO_EndpointPolicy_Factory Class Reference

Policy factory for the endpoint policies. More...

#include <EndpointPolicy_Factory.h>

Inheritance diagram for TAO_EndpointPolicy_Factory:
Inheritance graph
[legend]
Collaboration diagram for TAO_EndpointPolicy_Factory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_EndpointPolicy_Factory (TAO_ORB_Core *orb_core)
virtual CORBA::Policy_ptr create_policy (CORBA::PolicyType type, const CORBA::Any &value)

Private Attributes

TAO_ORB_Coreorb_core_
 Cached pointer of our ORB_Core.

Detailed Description

Policy factory for the endpoint policies.

Definition at line 41 of file EndpointPolicy_Factory.h.


Constructor & Destructor Documentation

TAO_EndpointPolicy_Factory::TAO_EndpointPolicy_Factory ( TAO_ORB_Core orb_core  ) 

Definition at line 24 of file EndpointPolicy_Factory.cpp.

  : orb_core_ (orb_core)
{
}


Member Function Documentation

CORBA::Policy_ptr TAO_EndpointPolicy_Factory::create_policy ( CORBA::PolicyType  type,
const CORBA::Any value 
) [virtual]

Definition at line 31 of file EndpointPolicy_Factory.cpp.

{
  if (type == EndpointPolicy::ENDPOINT_POLICY_TYPE)
    {
      const EndpointPolicy::EndpointList* endpoint_list = 0;
      if (!(value >>= endpoint_list))
        throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE);

      TAO_Acceptor_Registry & registry =
        this->orb_core_->lane_resources ().acceptor_registry ();

      TAO_Acceptor ** const acceptors_begin = registry.begin ();
      TAO_Acceptor ** const acceptors_end = registry.end ();
      CORBA::ULong const num_eps = endpoint_list->length ();

      // need to count the protocol types offered by the acceptors
      // partially defaulted endpoint values are only acceptable if
      // there are more than one protocol available to the ORB.

      CORBA::ULong last_known_prot = 0xFFFFFFFF; // tag = 0 is IIOP
      int prot_count = 0;
      for (TAO_Acceptor** acceptor = acceptors_begin;
           acceptor != acceptors_end;
           ++acceptor)
        {
          if ((*acceptor)->tag () != last_known_prot)
            {
              last_known_prot = (*acceptor)->tag ();
              ++prot_count;
            }
        }


      // The endpoint list in the value is validated to ensure that
      // at least one endpoint in the list matches an endpoint the
      // ORB is listening on.

      bool found_one = false;
      for (CORBA::ULong idx = 0; !found_one && idx < num_eps; ++idx)
        {
          CORBA::ULong prot_tag = (*endpoint_list)[idx]->protocol_tag();

          TAO_Endpoint_Value_Impl const * const evi =
            dynamic_cast <TAO_Endpoint_Value_Impl const *> (
              (*endpoint_list)[idx].in ());

          if (!evi)
            continue;

          for (TAO_Acceptor** acceptor = acceptors_begin;
               !found_one && acceptor != acceptors_end;
               ++acceptor)
            {
              if ((*acceptor)->tag () == prot_tag)
                found_one = evi->validate_acceptor (*acceptor, prot_count > 1);
            }
        }

      // There is no endpoint policy value matches an endpoint the ORB
      // is listening on. A CORBA::PolicyError exception with a
      // PolicyErrorCode of UNSUPPORTED_POLICY_VALUE is raised.
      if (!found_one)
        throw ::CORBA::PolicyError (CORBA::UNSUPPORTED_POLICY_VALUE);

      TAO_EndpointPolicy_i *tmp = 0;
      ACE_NEW_THROW_EX (tmp,
                        TAO_EndpointPolicy_i (*endpoint_list),
                        CORBA::NO_MEMORY (TAO::VMCID,
                                          CORBA::COMPLETED_NO));

      return tmp;
    }
  else
    throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);
}


Member Data Documentation

Cached pointer of our ORB_Core.

Be aware that this pointer can be zero or not. In fact there are two ways to get this pointer filled:

  • If CORBA::Object is constructed through one of the constructors with a stub and null ORB_Core, we use the orb_core from the stub to fill this pointer
  • If the other constructor, which uses IOP::IOR is used, a stub needs to be created first (i.e., the IOR needs to be evaluated first), in which case the ORB_Core would be null. The orb_core pointer then needs to be accessed from the stub and passed back as part of _get_orb().

Reimplemented from CORBA::Object.

Definition at line 53 of file EndpointPolicy_Factory.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines