Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions

TAO_Stub Class Reference

TAO_Stub. More...

#include <Stub.h>

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

List of all members.

Public Member Functions

virtual CORBA::Policy_ptr get_policy (CORBA::PolicyType type)
virtual CORBA::Policy_ptr get_cached_policy (TAO_Cached_Policy_Type type)
virtual TAO_Stubset_policy_overrides (const CORBA::PolicyList &policies, CORBA::SetOverrideType set_add)
virtual CORBA::PolicyList * get_policy_overrides (const CORBA::PolicyTypeSeq &types)
TAO::Transport_Queueing_Strategy * transport_queueing_strategy (void)
CORBA::ULong hash (CORBA::ULong maximum)
CORBA::Boolean is_equivalent (CORBA::Object_ptr other_obj)
 Implement the is_equivalent() method for the CORBA::Object.
 TAO_Stub (const char *repository_id, const TAO_MProfile &profiles, TAO_ORB_Core *orb_core)
 Construct from a repository ID and a list of profiles.
void _incr_refcnt (void)
void _decr_refcnt (void)
ACE_Lockprofile_lock (void) const
TAO_Profileprofile_in_use (void)
const TAO::ObjectKey & object_key (void) const
 Return the ObjectKey.
TAO_MProfilemake_profiles (void)
const TAO_MProfilebase_profiles (void) const
 Obtain a reference to the basic profile set.
TAO_MProfilebase_profiles (void)
 Obtain a reference to the basic profile set.
const TAO_MProfileforward_profiles (void) const
 Obtain a pointer to the forwarded profile set.
TAO_Profilenext_profile (void)
 True if permanent location forward occured, in this case the lock must be set and the.
void reset_profiles (void)
CORBA::Boolean valid_forward_profile (void)
void set_valid_profile (void)
 NON-THREAD-SAFE. Will set profile_success_ to true.
CORBA::Boolean valid_profile (void) const
TAO_Profilebase_profiles (const TAO_MProfile &mprofiles)
void add_forward_profiles (const TAO_MProfile &mprofiles, const CORBA::Boolean permanent_forward=false)
CORBA::Boolean next_profile_retry (void)
TAO_ORB_Coreorb_core (void) const
 Accessor.
CORBA::Boolean is_collocated (void) const
 Is this stub collocated with the servant?
void is_collocated (CORBA::Boolean)
 Mutator to mark this stub as being collocated with the servant.
CORBA::ORB_ptr servant_orb_ptr (void)
 This returns a duplicated ORB pointer.
CORBA::ORB_varservant_orb_var (void)
 This returns the ORB var itself (generally for temporary use).
void servant_orb (CORBA::ORB_ptr orb)
void collocated_servant (TAO_Abstract_ServantBase *servant)
 Mutator for setting the servant in collocated cases.
TAO_Abstract_ServantBasecollocated_servant (void) const
 Accessor for the servant reference in collocated cases.
void object_proxy_broker (TAO::Object_Proxy_Broker *proxy_broker)
TAO::Object_Proxy_Broker * object_proxy_broker (void) const
int create_ior_info (IOP::IOR *&ior_info, CORBA::ULong &index)
void destroy (void)
 Deallocate the TAO_Stub object.
CORBA::Boolean optimize_collocation_objects (void) const
 Return the cached value from the ORB_Core.
CORBA::Boolean marshal (TAO_OutputCDR &)
 Needed to avoid copying forward_profiles for thread safety.
void forwarded_on_exception (bool forwarded)
bool forwarded_on_exception () const

Public Attributes

CORBA::String_var type_id
 All objref representations carry around a type ID.

Protected Member Functions

virtual ~TAO_Stub (void)
void reset_profiles_i (void)
 NON-THREAD SAFE version of reset_profiles (void);.
TAO_Profilenext_profile_i (void)
 NON-THREAD SAFE version of next_profile (void).

Protected Attributes

TAO_ORB_Core_Auto_Ptr orb_core_
 Automatically manage the ORB_Core reference count.
CORBA::ORB_var orb_
CORBA::Boolean is_collocated_
CORBA::ORB_var servant_orb_
TAO_Abstract_ServantBasecollocated_servant_
 Servant pointer. It is 0 except for collocated objects.
TAO::Object_Proxy_Broker * object_proxy_broker_
 Pointer to the Proxy Broker.
TAO_MProfile base_profiles_
 Ordered list of profiles for this object.
TAO_MProfileforward_profiles_
TAO_MProfileforward_profiles_perm_
TAO_Profileprofile_in_use_
 This is the profile that we are currently sending/receiving with.
ACE_Lockprofile_lock_ptr_
 Mutex to protect access to the forwarding profile.
CORBA::Boolean profile_success_
 Have we successfully talked to the forward profile yet?
ACE_Atomic_Op< TAO_SYNCH_MUTEX,
unsigned long > 
refcount_
 Reference counter.
TAO_Policy_Setpolicies_
IOP::IOR * ior_info_
IOP::IOR * forwarded_ior_info_
 Forwarded IOR info.
CORBA::Boolean const collocation_opt_
ACE_Atomic_Op< TAO_SYNCH_MUTEX,
bool > 
forwarded_on_exception_

Private Member Functions

TAO_Profileset_profile_in_use_i (TAO_Profile *pfile)
void reset_base ()
void forward_back_one (void)
void reset_forward ()
TAO_Profilenext_forward_profile (void)
 NON-THREAD-SAFE. utility method for next_profile.
int get_profile_ior_info (TAO_MProfile &profile, IOP::IOR *&ior_info)
 THREAD-SAFE Create the IOR info.
 TAO_Stub (const TAO_Stub &)
TAO_Stuboperator= (const TAO_Stub &)

Detailed Description

TAO_Stub.

Per-objref data includes the (protocol-specific) Profile, which is handled by placing it into a subclass of this type along with data that may be used in protocol-specific caching schemes. The type ID (the data specified by CORBA 2.0 that gets exposed "on the wire", and in stringified objrefs) is held by this module. The stub APIs are member functions of this type.

Definition at line 69 of file Stub.h.


Constructor & Destructor Documentation

TAO_Stub::TAO_Stub ( const char *  repository_id,
const TAO_MProfile profiles,
TAO_ORB_Core orb_core 
)

Construct from a repository ID and a list of profiles.

Definition at line 36 of file Stub.cpp.

  : type_id (repository_id)
  , orb_core_ (orb_core)
  , orb_ ()
  , is_collocated_ (false)
  , servant_orb_ ()
  , collocated_servant_ (0)
  , object_proxy_broker_ (the_tao_remote_object_proxy_broker ())
  , base_profiles_ ((CORBA::ULong) 0)
  , forward_profiles_ (0)
  , forward_profiles_perm_ (0)
  , profile_in_use_ (0)
  , profile_lock_ptr_ (0)
  , profile_success_ (false)
  , refcount_ (1)
#if (TAO_HAS_CORBA_MESSAGING == 1)
  , policies_ (0)
#endif
  , ior_info_ (0)
  , forwarded_ior_info_ (0)
  , collocation_opt_ (orb_core->optimize_collocation_objects ())
  , forwarded_on_exception_ (false)
{
  if (this->orb_core_.get() == 0)
    {
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO: (%P|%t) TAO_Stub created with default ")
                      ACE_TEXT ("ORB core\n")));
        }

      this->orb_core_.reset (TAO_ORB_Core_instance ());
    }

  // Duplicate the ORB_Core, otherwise the allocators and other
  // resources that this class references (directly or indirectly)
  // could be destroyed before it is time.
  (void) this->orb_core_->_incr_refcnt ();

  // Cache the ORB pointer to respond faster to certain queries.
  this->orb_ = CORBA::ORB::_duplicate (this->orb_core_->orb ());

  this->profile_lock_ptr_ =
    this->orb_core_->client_factory ()->create_profile_lock ();

  this->base_profiles (profiles);
}

TAO_Stub::~TAO_Stub ( void   )  [protected, virtual]

Destructor is to be called only through _decr_refcnt() to enforce proper reference counting.

Definition at line 87 of file Stub.cpp.

{
  ACE_ASSERT (this->refcount_ == 0);

  if (this->forward_profiles_)
    reset_profiles ();

  // reset_profiles doesn't delete forward_profiles_perm_.
  delete this->forward_profiles_perm_;

  if (this->profile_in_use_ != 0)
    {
      // decrease reference count on profile
      this->profile_in_use_->_decr_refcnt ();
      this->profile_in_use_ = 0;
    }

  delete this->profile_lock_ptr_;

#if (TAO_HAS_CORBA_MESSAGING == 1)
  delete this->policies_;
#endif

  delete this->ior_info_;

  delete this->forwarded_ior_info_;
}

TAO_Stub::TAO_Stub ( const TAO_Stub  )  [private]

Member Function Documentation

void TAO_Stub::_decr_refcnt ( void   ) 

Definition at line 562 of file Stub.cpp.

{
  if (--this->refcount_ == 0)
    delete this;
}

void TAO_Stub::_incr_refcnt ( void   ) 

Definition at line 556 of file Stub.cpp.

{
  ++this->refcount_;
}

void TAO_Stub::add_forward_profiles ( const TAO_MProfile mprofiles,
const CORBA::Boolean  permanent_forward = false 
)

THREAD SAFE. Set the forward_profiles. This object will assume ownership of this TAO_MProfile object!! if permanent_forward is true, currently used profiles will be replaced permanently, otherwise stub may fallback to current profiles later. The flag permanent_forward=true is only valid if currently used profile set represents a GroupObject (IOGR), otherwise this flag will be ignored.

Definition at line 116 of file Stub.cpp.

{
  // we assume that the profile_in_use_ is being
  // forwarded!  Grab the lock so things don't change.
  ACE_MT (ACE_GUARD (ACE_Lock,
                     guard,
                     *this->profile_lock_ptr_));

  if (permanent_forward)
    {
      // paranoid, reset the bookmark, then clear the forward-stack
      this->forward_profiles_perm_ = 0;

      this->reset_forward ();
    }

  TAO_MProfile *now_pfiles = this->forward_profiles_;
  if (now_pfiles == 0)
    now_pfiles = &this->base_profiles_;

  ACE_NEW (this->forward_profiles_,
           TAO_MProfile (mprofiles));

  if (permanent_forward)
    // bookmark the new element at bottom of stack
    this->forward_profiles_perm_ = this->forward_profiles_;

  // forwarded profile points to the new IOR (profiles)
  this->profile_in_use_->forward_to (this->forward_profiles_);

  // new profile list points back to the list which was forwarded.
  this->forward_profiles_->forward_from (now_pfiles);

  // make sure we start at the beginning of mprofiles
  this->forward_profiles_->rewind ();

  // Since we have been forwarded, we must set profile_success_ to false
  // since we are starting a new with a new set of profiles!
  this->profile_success_ = false;
}

TAO_Profile * TAO_Stub::base_profiles ( const TAO_MProfile mprofiles  ) 

Initialize the base_profiles_ and set profile_in_use_ to reference the first profile.

Definition at line 185 of file Stub.inl.

{
  ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
                            guard,
                            *this->profile_lock_ptr_,
                            0));

  // first reset things so we start from scratch!

  // @note This reset forward could effect the collocation status
  // but as this method is only used from the Stub ctr, when the status
  // is already correctly set, we don't reinitialise here. sm.
  this->reset_forward ();
  this->base_profiles_.set (mprofiles);
  this->reset_base ();
  return this->profile_in_use_;

}

const TAO_MProfile & TAO_Stub::base_profiles ( void   )  const

Obtain a reference to the basic profile set.

Definition at line 234 of file Stub.inl.

{
  return this->base_profiles_;
}

TAO_MProfile & TAO_Stub::base_profiles ( void   ) 

Obtain a reference to the basic profile set.

Definition at line 240 of file Stub.inl.

{
  return this->base_profiles_;
}

TAO_Abstract_ServantBase * TAO_Stub::collocated_servant ( void   )  const

Accessor for the servant reference in collocated cases.

Definition at line 284 of file Stub.inl.

{
  return collocated_servant_;
}

void TAO_Stub::collocated_servant ( TAO_Abstract_ServantBase servant  ) 

Mutator for setting the servant in collocated cases.

Definition at line 290 of file Stub.inl.

{
  this->collocated_servant_ = servant;
}

int TAO_Stub::create_ior_info ( IOP::IOR *&  ior_info,
CORBA::ULong index 
)

Create the IOP::IOR info. We will create the info at most once. Get the index of the profile we are using to make the invocation.

Definition at line 159 of file Stub.cpp.

{
  // We are creating the IOR info. Let us not be disturbed. So grab a
  // lock.
  ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
                            guard,
                            *this->profile_lock_ptr_,
                            -1));

  IOP::IOR *tmp_info = 0;

  if (this->forward_profiles_ != 0)
    {
      if (this->forwarded_ior_info_ == 0)
        {
          this->get_profile_ior_info (*this->forward_profiles_, tmp_info);

          this->forwarded_ior_info_ = tmp_info;
        }

      // First we look at the forward profiles to see whether the
      // profile_in_use is any of it.
      for (CORBA::ULong i = 0;
           i < this->forward_profiles_->profile_count ();
           ++i)
        {
          if (this->forward_profiles_->get_profile (i)
              == this->profile_in_use_)
            {
              ior_info = this->forwarded_ior_info_;
              index = i;
              return 0;
            }
        }
    }

  // Else we look at the base profiles
  if (this->ior_info_ == 0)
    {
      this->get_profile_ior_info (this->base_profiles_, tmp_info);

      this->ior_info_ = tmp_info;
    }


  for (CORBA::ULong ind = 0;
       ind < this->base_profiles_.profile_count ();
       ++ind)
    {
      if (this->base_profiles_.get_profile (ind) == this->profile_in_use_)
        {
          index = ind;
          ior_info = this->ior_info_;
          return 0;
        }
    }

  // Error, there was no match
  return -1;
}

void TAO_Stub::destroy ( void   ) 

Deallocate the TAO_Stub object.

This method is intended to be used only by the CORBA::Object class.

Definition at line 308 of file Stub.inl.

{
  // The reference count better be zero at this point!
  delete this;
}

void TAO_Stub::forward_back_one ( void   )  [private]

NON-THREAD-SAFE. Utility method which unrolls (removes or pops) the top most forwarding profile list.

Definition at line 349 of file Stub.cpp.

{
  TAO_MProfile *from = forward_profiles_->forward_from ();

  // Only delete the forward location if it is not permanent
  if (this->forward_profiles_ != this->forward_profiles_perm_)
    delete this->forward_profiles_;

  // the current profile in this profile list is no
  // longer being forwarded, so set the reference to zero.
  if (from == &this->base_profiles_)
    {
      this->base_profiles_.get_current_profile ()->forward_to (0);
      this->forward_profiles_ = 0;
    }
  else
    {
      from->get_current_profile ()->forward_to (0);
      this->forward_profiles_ = from;
    }
}

const TAO_MProfile * TAO_Stub::forward_profiles ( void   )  const

Obtain a pointer to the forwarded profile set.

Definition at line 246 of file Stub.inl.

{
  return this->forward_profiles_;
}

void TAO_Stub::forwarded_on_exception ( bool  forwarded  ) 

Definition at line 339 of file Stub.inl.

{
  forwarded_on_exception_ = forwarded;
}

bool TAO_Stub::forwarded_on_exception (  )  const

Definition at line 345 of file Stub.inl.

CORBA::Policy_ptr TAO_Stub::get_cached_policy ( TAO_Cached_Policy_Type  type  )  [virtual]

Reimplemented in TAO_RT_Stub, and TAO_ZIOP_Stub.

Definition at line 422 of file Stub.cpp.

{
  // No need to lock, the stub only changes its policies at
  // construction time...

  CORBA::Policy_var result;
  if (this->policies_ != 0)
    {
      result = this->policies_->get_cached_policy (type);
    }

  if (CORBA::is_nil (result.in ()))
    {
      result = this->orb_core_->get_cached_policy_including_current (type);
    }

  return result._retn ();
}

CORBA::Policy_ptr TAO_Stub::get_policy ( CORBA::PolicyType  type  )  [virtual]

Returns the effective policy if type is a known client-exposed policy type. Returns the effective override for all other policy types.

Reimplemented in TAO_RT_Stub, and TAO_ZIOP_Stub.

Definition at line 402 of file Stub.cpp.

{
  // No need to lock, the stub only changes its policies at
  // construction time...

  CORBA::Policy_var result;
  if (this->policies_ != 0)
    {
      result = this->policies_->get_policy (type);
    }

  if (CORBA::is_nil (result.in ()))
    {
      result = this->orb_core_->get_policy_including_current (type);
    }

  return result._retn ();
}

CORBA::PolicyList * TAO_Stub::get_policy_overrides ( const CORBA::PolicyTypeSeq &  types  )  [virtual]

Definition at line 476 of file Stub.cpp.

{
  if (this->policies_ == 0)
    {
      CORBA::PolicyList *policy_list_ptr = 0;
      ACE_NEW_THROW_EX (policy_list_ptr,
                        CORBA::PolicyList (),
                        CORBA::NO_MEMORY ());

      return policy_list_ptr;
    }
  else
    {
      return this->policies_->get_policy_overrides (types);
    }
}

int TAO_Stub::get_profile_ior_info ( TAO_MProfile profile,
IOP::IOR *&  ior_info 
) [private]

THREAD-SAFE Create the IOR info.

Definition at line 241 of file Stub.cpp.

{
  ACE_NEW_THROW_EX (ior_info,
                    IOP::IOR (),
                    CORBA::NO_MEMORY ());

  // Get the number of elements
  CORBA::ULong const count = profiles.profile_count ();

  // Set the number of elements in the sequence of tagged_profile
  ior_info->profiles.length (count);

  // Call the create_tagged_profile one every member of the
  // profile and make the sequence
  for (CORBA::ULong index = 0; index < count; ++index)
    {
      TAO_Profile *prof = profiles.get_profile (index);

      IOP::TaggedProfile *tp = prof->create_tagged_profile ();

      if (tp == 0)
        throw ::CORBA::NO_MEMORY ();
      ior_info->profiles[index] = *tp;
    }

  return 0;
}

CORBA::ULong TAO_Stub::hash ( CORBA::ULong  maximum  ) 

All objref representations know how to hash themselves and compare themselves for equivalence to others. It's easily possible to have two objrefs that are distinct copies of data that refers/points to the same remote object (i.e. are equivalent).

Definition at line 294 of file Stub.cpp.

{
  // we rely on the profile objects that its address info
  return this->base_profiles_.hash (max);
}

CORBA::Boolean TAO_Stub::is_collocated ( void   )  const

Is this stub collocated with the servant?

Definition at line 252 of file Stub.inl.

{
  return this->is_collocated_;
}

void TAO_Stub::is_collocated ( CORBA::Boolean  collocated  ) 

Mutator to mark this stub as being collocated with the servant.

Definition at line 270 of file Stub.cpp.

CORBA::Boolean TAO_Stub::is_equivalent ( CORBA::Object_ptr  other_obj  ) 

Implement the is_equivalent() method for the CORBA::Object.

Definition at line 309 of file Stub.cpp.

{
  if (CORBA::is_nil (other_obj))
    return false;

  TAO_Profile * const other_profile = other_obj->_stubobj ()->profile_in_use_;
  TAO_Profile * const this_profile = this->profile_in_use_;

  if (other_profile == 0 || this_profile == 0)
    return false;

  // Compare the profiles
  return this_profile->is_equivalent (other_profile);
}

TAO_MProfile * TAO_Stub::make_profiles ( void   ) 

Copy of the profile list, user must free memory when done. although the user can call make_profiles() then reorder the list and give it back to TAO_Stub.

Definition at line 69 of file Stub.inl.

{
  TAO_MProfile *mp = 0;

  ACE_NEW_RETURN (mp,
                  TAO_MProfile (base_profiles_),
                  0);

  return mp;
}

CORBA::Boolean TAO_Stub::marshal ( TAO_OutputCDR cdr  ) 

Needed to avoid copying forward_profiles for thread safety.

Definition at line 495 of file Stub.cpp.

{
  // do as many outside of locked else-branch as posssible

  // STRING, a type ID hint
  if ((cdr << this->type_id.in()) == 0)
    return 0;

  if ( ! this->forward_profiles_perm_)
    {
      const TAO_MProfile& mprofile = this->base_profiles_;

      CORBA::ULong const profile_count = mprofile.profile_count ();
      if ((cdr << profile_count) == 0)
        return 0;

    // @@ The MProfile should be locked during this iteration, is there
    // anyway to achieve that?
    for (CORBA::ULong i = 0; i < profile_count; ++i)
      {
        const TAO_Profile* p = mprofile.get_profile (i);
        if (p->encode (cdr) == 0)
          return 0;
      }
    }
  else
    {
      ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
                                guard,
                                *this->profile_lock_ptr_,
                                0));

      ACE_ASSERT(this->forward_profiles_ !=0);

      // paranoid - in case of FT the basic_profiles_ would do, too,
      // but might be dated
      const TAO_MProfile& mprofile =
          this->forward_profiles_perm_
        ? *(this->forward_profiles_perm_)
        : this->base_profiles_;

      CORBA::ULong const profile_count = mprofile.profile_count ();
      if ((cdr << profile_count) == 0)
           return 0;

      // @@ The MProfile should be locked during this iteration, is there
      // anyway to achieve that?
      for (CORBA::ULong i = 0; i < profile_count; ++i)
        {
          const TAO_Profile* p = mprofile.get_profile (i);
          if (p->encode (cdr) == 0)
            return 0;
        }

      // release ACE_Lock
    }

  return (CORBA::Boolean) cdr.good_bit ();
}

TAO_Profile * TAO_Stub::next_forward_profile ( void   )  [private]

NON-THREAD-SAFE. utility method for next_profile.

Definition at line 81 of file Stub.inl.

{
  TAO_Profile *pfile_next = 0;

  while (this->forward_profiles_
         && (pfile_next = this->forward_profiles_->get_next ()) == 0
         && this->forward_profiles_ != this->forward_profiles_perm_)  // do not remove permanent forward from bottom of stack
    // that was the last profile.  Now we clean up our forward profiles.
    // since we own the forward MProfiles, we must delete them when done.
    this->forward_back_one ();

  return pfile_next;
}

TAO_Profile * TAO_Stub::next_profile ( void   ) 

True if permanent location forward occured, in this case the lock must be set and the.

THREAD SAFE. If forward_profiles is null then this will get the next profile in the base_profiles list. If forward is not null then this will get the next profile for the list of forwarding profiles. If all profiles have been tried then 0 is returned and profile_in_use_ is set to the first profile in the base_profiles list.

Definition at line 157 of file Stub.inl.

{
  ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
                            guard,
                            *this->profile_lock_ptr_,
                            0));
  return this->next_profile_i ();
}

TAO_Profile * TAO_Stub::next_profile_i ( void   )  [protected]

NON-THREAD SAFE version of next_profile (void).

Definition at line 96 of file Stub.inl.

{
  TAO_Profile *pfile_next = 0;

  // First handle the case that a permanent forward occured
  if (this->forward_profiles_perm_) // the permanent forward defined
                                    // at bottom of stack
                                    // forward_profiles_
    {
      // In case of permanent forward the base_profiles are ingored.

      pfile_next = this->next_forward_profile ();

      if (pfile_next == 0)
        {
          // COND: this->forward_profiles_ == this->forward_profiles_perm_

          // reached end of list of permanent forward profiles
          // now, reset forward_profiles_perm_

          this->forward_profiles_->rewind ();
          this->profile_success_ = false;
          this->set_profile_in_use_i (this->forward_profiles_->get_next());
        }
      else
        this->set_profile_in_use_i (pfile_next);

      // We may have been forwarded to / from a collocated situation
      // Check for this and apply / remove optimisation if required.
      this->orb_core_->reinitialize_object (this);

      return pfile_next;
    }
  else
    {
      if (this->forward_profiles_) // Now do the common operation
        {
          pfile_next = this->next_forward_profile ();
          if (pfile_next == 0)
            {
              // Fall back to base profiles
              pfile_next = this->base_profiles_.get_next ();
            }

          // We may have been forwarded to / from a collocated situation
          // Check for this and apply / remove optimisation if required.
          this->orb_core_->reinitialize_object (this);
        }
      else
        pfile_next = this->base_profiles_.get_next ();

      if (pfile_next == 0)
        this->reset_base ();
      else
        this->set_profile_in_use_i (pfile_next);

      return pfile_next;
   }
}

CORBA::Boolean TAO_Stub::next_profile_retry ( void   ) 

THREAD SAFE Used to get the next profile after the one being used has failed during the initial connect or send of the message!

Definition at line 205 of file Stub.inl.

{
  ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
                            guard,
                            *this->profile_lock_ptr_,
                            0));

  if (this->profile_success_ && this->forward_profiles_)
    {
      // We have a forwarded reference that we have managed to *send* a message to
      // previously in the remote path only (but not counting object proxy broker ops).
      // @todo I can see little sense to this. It is at best highly inconsistent. sm.

      // In this case we are falling back from the forwarded IOR stright to the base IOR
      this->reset_profiles_i ();

      // We used to return unconditional true at this point but this results in
      // infinite retries of any permanent location forward. This is undesirable.
      return !this->forward_profiles_perm_;
    }
  else if (this->next_profile_i ())
    {
      return true;
    }

  return false;
}

const TAO::ObjectKey & TAO_Stub::object_key ( void   )  const

Return the ObjectKey.

Definition at line 221 of file Stub.cpp.

{
  // Return the profile in use's object key if you see one.
  if (this->profile_in_use_)
    return this->profile_in_use_->object_key ();

  if (this->forward_profiles_)
    {
      // Double-checked
      ACE_Guard<ACE_Lock> obj (*this->profile_lock_ptr_);

      if (obj.locked () != 0 &&  this->forward_profiles_ != 0)
        return this->forward_profiles_->get_profile (0)->object_key ();
    }

  // If no forwarded profiles, just use the base profile
  return this->base_profiles_.get_profile (0)->object_key ();
}

void TAO_Stub::object_proxy_broker ( TAO::Object_Proxy_Broker *  proxy_broker  ) 

Mutator for setting the object proxy broker pointer. CORBA::Objects using this stub will use this for standard calls like is_a; get_interface; etc...

Definition at line 302 of file Stub.inl.

{
  this->object_proxy_broker_ = object_proxy_broker;
}

TAO::Object_Proxy_Broker * TAO_Stub::object_proxy_broker ( void   )  const

Accessor for getting the object proxy broker pointer. CORBA::Objects using this stub use this for standard calls like is_a; get_interface; etc...

Definition at line 296 of file Stub.inl.

{
  return this->object_proxy_broker_;
}

TAO_Stub& TAO_Stub::operator= ( const TAO_Stub  )  [private]
CORBA::Boolean TAO_Stub::optimize_collocation_objects ( void   )  const

Return the cached value from the ORB_Core.

This flag indicates whether the stub code should make use of the collocation opportunities that are available to the ORB.

Definition at line 315 of file Stub.inl.

{
  return this->collocation_opt_;
}

TAO_ORB_Core * TAO_Stub::orb_core ( void   )  const

Accessor.

Definition at line 258 of file Stub.inl.

{
  return this->orb_core_.get ();
}

TAO_Profile * TAO_Stub::profile_in_use ( void   ) 

Manage the base (non-forwarded) profiles. Returns a pointer to the profile_in_use object. This object retains ownership of this profile.

Definition at line 63 of file Stub.inl.

{
  return this->profile_in_use_;
}

ACE_Lock * TAO_Stub::profile_lock ( void   )  const

Return the Profile lock. This lock can be used at places where profiles need to be edited.

Definition at line 20 of file Stub.inl.

{
  return this->profile_lock_ptr_;
}

void TAO_Stub::reset_base ( void   )  [private]

NON-THREAD-SAFE. Utility method which resets or initializes the base_profile list and forward flags.

Definition at line 10 of file Stub.inl.

void TAO_Stub::reset_forward ( void   )  [private]

NOT THREAD-SAFE. Utility method which pops all forward profile lists and resets the forward_profiles_ pointer.

Definition at line 26 of file Stub.inl.

{
  while (this->forward_profiles_ != 0
         && this->forward_profiles_ != this->forward_profiles_perm_) // Disturbingly the permanent
                                                                     // forwarded profile lives at the  bottom
                                                                     // of this stack if it exists. Avoid deleting it.
    this->forward_back_one ();
}

void TAO_Stub::reset_profiles ( void   ) 

THREAD SAFE This method will reset the base profile list to reference the first profile and if there are anmy existing forward profiles they are reset.

Definition at line 54 of file Stub.inl.

{
  ACE_MT (ACE_GUARD (ACE_Lock,
                     guard,
                     *this->profile_lock_ptr_));
  this->reset_profiles_i ();
}

void TAO_Stub::reset_profiles_i ( void   )  [protected]

NON-THREAD SAFE version of reset_profiles (void);.

Definition at line 36 of file Stub.inl.

{
  this->reset_forward ();
  this->reset_base ();

  if (this->forward_profiles_perm_)
    {
      // The *permanent* forward is being kept in the transient
      // forward queue (??!). We have just nuked it. Put it back the way it was.
      // reset_base should have reset the profile success.
      // @todo We have knives in the spoon draw - TAO_Stub needs total rewrite.
      this->forward_profiles_ = this->forward_profiles_perm_;
      this->forward_profiles_->rewind ();
      this->set_profile_in_use_i (this->forward_profiles_->get_next ());
    }
}

void TAO_Stub::servant_orb ( CORBA::ORB_ptr  orb  ) 

Accesor and mutator for the servant ORB. Notice that the mutator assumes the ownership of the passed in ORB and the accesor does not return a copy of the orb since the accessing of the ORB is considered temporary.

Definition at line 278 of file Stub.inl.

CORBA::ORB_ptr TAO_Stub::servant_orb_ptr ( void   ) 

This returns a duplicated ORB pointer.

Definition at line 271 of file Stub.inl.

{
  // Simply pass back the ORB pointer for temporary use.
  return CORBA::ORB::_duplicate (this->servant_orb_.in ());
}

CORBA::ORB_var & TAO_Stub::servant_orb_var ( void   ) 

This returns the ORB var itself (generally for temporary use).

Definition at line 264 of file Stub.inl.

{
  // Simply pass back the ORB pointer for temporary use.
  return this->servant_orb_;
}

TAO_Stub * TAO_Stub::set_policy_overrides ( const CORBA::PolicyList &  policies,
CORBA::SetOverrideType  set_add 
) [virtual]

Reimplemented in TAO_RT_Stub.

Definition at line 442 of file Stub.cpp.

{
  // Notice the use of an explicit constructor....
  auto_ptr<TAO_Policy_Set> policy_manager (
    new TAO_Policy_Set (TAO_POLICY_OBJECT_SCOPE));

  if (set_add == CORBA::SET_OVERRIDE)
    {
      policy_manager->set_policy_overrides (policies, set_add);
    }
  else if (this->policies_ == 0)
    {
      policy_manager->set_policy_overrides (policies, CORBA::SET_OVERRIDE);
    }
  else
    {
      policy_manager->copy_from (this->policies_);

      policy_manager->set_policy_overrides (policies, set_add);
    }

  TAO_Stub* stub = this->orb_core_->create_stub (this->type_id.in (),
                                                 this->base_profiles_);

  stub->policies_ = policy_manager.release ();

  // Copy the servant ORB if it is present.
  stub->servant_orb (this->servant_orb_var ().in ());

  return stub;
}

TAO_Profile * TAO_Stub::set_profile_in_use_i ( TAO_Profile pfile  )  [private]

Makes a copy of the profile and frees the existing profile_in_use. NOT THREAD SAFE

Definition at line 327 of file Stub.cpp.

{
  TAO_Profile *const old = this->profile_in_use_;

  // Since we are actively using this profile we dont want
  // it to disappear, so increase the reference count by one!!
  if (pfile && (pfile->_incr_refcnt () == 0))
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                        ACE_TEXT ("(%P|%t) unable to increment profile ref!\n")),
                        0);
    }

  this->profile_in_use_ = pfile;

  if (old)
    old->_decr_refcnt ();

  return this->profile_in_use_;
}

void TAO_Stub::set_valid_profile ( void   ) 

NON-THREAD-SAFE. Will set profile_success_ to true.

Definition at line 173 of file Stub.inl.

{
  this->profile_success_ = true;
}

TAO::Transport_Queueing_Strategy * TAO_Stub::transport_queueing_strategy ( void   ) 

Return the queueing strategy to be used in by the transport. Selection will be based on the SyncScope policies.

Definition at line 321 of file Stub.inl.

{
#if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)

  bool has_synchronization;
  Messaging::SyncScope scope;

  this->orb_core_->call_sync_scope_hook (this, has_synchronization, scope);

  if (has_synchronization == true)
    return this->orb_core_->get_transport_queueing_strategy  (this, scope);
#endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */

  // No queueing strategy, let the transport use its default
  return 0;
}

CORBA::Boolean TAO_Stub::valid_forward_profile ( void   ) 

Returns true if a forward profile has successfully been used. profile_success_ && forward_profiles_

Definition at line 167 of file Stub.inl.

{
  return (this->profile_success_ && this->forward_profiles_);
}

CORBA::Boolean TAO_Stub::valid_profile ( void   )  const

Returns true if a connection was successful with at least one profile.

Definition at line 179 of file Stub.inl.

{
  return this->profile_success_;
}


Member Data Documentation

Ordered list of profiles for this object.

Definition at line 358 of file Stub.h.

Servant pointer. It is 0 except for collocated objects.

Definition at line 347 of file Stub.h.

TRUE if we want to take advantage of collocation optimization in this ORB. This should be the same value as cached in the ORB_Core. The reason for caching this helps our generated code, notably the stubs to be decoubled from ORB_Core. Please do not move it away.

Definition at line 404 of file Stub.h.

The list of forwarding profiles. This is actually implemented as a linked list of TAO_MProfile objects.

Definition at line 362 of file Stub.h.

Definition at line 366 of file Stub.h.

IOP::IOR* TAO_Stub::forwarded_ior_info_ [protected]

Forwarded IOR info.

Definition at line 395 of file Stub.h.

ACE_Atomic_Op<TAO_SYNCH_MUTEX, bool> TAO_Stub::forwarded_on_exception_ [protected]

Definition at line 409 of file Stub.h.

IOP::IOR* TAO_Stub::ior_info_ [protected]

The ior info. This is needed for GIOP 1.2, as the clients could receive an exception from the server asking for this info. The exception that the client receives is LOC_NEEDS_ADDRESSING_MODE. The data is set up here to be passed on to Invocation classes when they receive an exception. This info is for the base profiles that this class stores

Definition at line 392 of file Stub.h.

Flag that indicates that this stub is collocated (and that it belongs to an ORB for which collocation optimisation is active).

Definition at line 335 of file Stub.h.

TAO::Object_Proxy_Broker* TAO_Stub::object_proxy_broker_ [protected]

Pointer to the Proxy Broker.

This cached pointer instance takes care of routing the call for standard calls in CORBA::Object like _is_a (), _get_component () etc.

Definition at line 355 of file Stub.h.

ORB required for reference counting. This will help us keep the ORB around until the CORBA::Object we represent dies.

Todo:
Why do we need both a reference to the ORB_Core and its ORB? It think the memory management rules for the ORB_Core changed, in the good old days it was the CORBA::ORB class who owned the ORB_Core, now it is the other way around....

Definition at line 331 of file Stub.h.

Automatically manage the ORB_Core reference count.

The ORB_Core cannot go away until the object references it creates are destroyed. There are multiple reasons for this, but in particular, the allocators used for some of the TAO_Profile objects contained on each TAO_Stub are owned by the TAO_ORB_Core.

This must be the first field of the class, otherwise the TAO_ORB_Core is destroyed too early!

Definition at line 321 of file Stub.h.

The policy overrides in this object, if nil then use the default policies.

Definition at line 382 of file Stub.h.

This is the profile that we are currently sending/receiving with.

Definition at line 369 of file Stub.h.

Mutex to protect access to the forwarding profile.

Definition at line 372 of file Stub.h.

Have we successfully talked to the forward profile yet?

Definition at line 375 of file Stub.h.

ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> TAO_Stub::refcount_ [protected]

Reference counter.

Definition at line 378 of file Stub.h.

If this stub refers to a collocated object then we need to hold on to the servant's ORB (which may be different from the client ORB) so that, 1. we know that the ORB will stay alive long enough, and, 2. we can search for the servant/POA's status starting from the ORB's RootPOA.

Definition at line 344 of file Stub.h.

All objref representations carry around a type ID.

Definition at line 94 of file Stub.h.


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