TAO_Table_Adapter Class Reference

#include <Table_Adapter.h>

Inheritance diagram for TAO_Table_Adapter:

Inheritance graph
[legend]
Collaboration diagram for TAO_Table_Adapter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Table_Adapter (TAO_ORB_Core &orb_core)
 Constructor.

virtual ~TAO_Table_Adapter (void)
 Destructor.

virtual void open (void)
virtual void close (int wait_for_completion)
virtual void check_close (int wait_for_completion)
virtual int priority (void) const
virtual int dispatch (TAO::ObjectKey &key, TAO_ServerRequest &request, CORBA::Object_out foward_to)
virtual const char * name (void) const
virtual CORBA::Object_ptr root (void)
virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *, const TAO_MProfile &)
virtual CORBA::Long initialize_collocated_object (TAO_Stub *stub)

Private Member Functions

CORBA::Long find_object (TAO::ObjectKey &key, CORBA::Object_out forward_to)

Static Private Member Functions

ACE_Lockcreate_lock (bool enable_locking, TAO_SYNCH_MUTEX &l)

Private Attributes

TAO_ORB_Coreorb_core_
 The ORB Core we belong to.

TAO_IOR_Table_Impl_var root_
 The table implementation.

bool closed_
bool enable_locking_
TAO_SYNCH_MUTEX thread_lock_
ACE_Locklock_

Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Table_Adapter::TAO_Table_Adapter TAO_ORB_Core orb_core  ) 
 

Constructor.

Definition at line 25 of file Table_Adapter.cpp.

00026   :  orb_core_ (orb_core),
00027      root_ (),
00028      closed_ (true),
00029      enable_locking_ (orb_core_.server_factory ()->enable_poa_locking ()),
00030      thread_lock_ (),
00031      lock_ (TAO_Table_Adapter::create_lock (enable_locking_,
00032                                             thread_lock_))
00033 {
00034 }

TAO_Table_Adapter::~TAO_Table_Adapter void   )  [virtual]
 

Destructor.

Definition at line 36 of file Table_Adapter.cpp.

00037 {
00038   delete this->lock_;
00039 }


Member Function Documentation

void TAO_Table_Adapter::check_close int  wait_for_completion  )  [virtual]
 

Implements TAO_Adapter.

Definition at line 90 of file Table_Adapter.cpp.

00091 {
00092 }

void TAO_Table_Adapter::close int  wait_for_completion  )  [virtual]
 

Implements TAO_Adapter.

Definition at line 81 of file Table_Adapter.cpp.

References ACE_GUARD, and closed_.

00082 {
00083   ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00084   this->closed_ = true;
00085   // no need to release the impl now, that will happen in the
00086   // destructor.
00087 }

CORBA::Object_ptr TAO_Table_Adapter::create_collocated_object TAO_Stub ,
const TAO_MProfile
[virtual]
 

Implements TAO_Adapter.

Definition at line 133 of file Table_Adapter.cpp.

References CORBA::Object::_nil(), ACE_NEW_RETURN, and initialize_collocated_object().

00135 {
00136   CORBA::Object_ptr result = CORBA::Object::_nil ();
00137 
00138   if (! this->initialize_collocated_object (stub)) // 0 == success
00139     {
00140       // A reference was found in the table. The stub has been forwarded
00141       // to this. The collocation indicators are now correct on the stub
00142       // (although they may well now indicate that the stub is not in fact
00143       // collocated at all).
00144       ACE_NEW_RETURN (result,
00145                       CORBA::Object (stub,
00146                                      stub->is_collocated (),
00147                                      stub->collocated_servant ()),
00148                       CORBA::Object::_nil ());
00149 
00150     }
00151 
00152   return result;
00153 }

ACE_Lock * TAO_Table_Adapter::create_lock bool  enable_locking,
TAO_SYNCH_MUTEX l
[static, private]
 

Definition at line 43 of file Table_Adapter.cpp.

References ACE_NEW_RETURN.

00045 {
00046 #if defined (ACE_HAS_THREADS)
00047   if (enable_locking)
00048     {
00049       ACE_Lock *the_lock = 0;
00050       ACE_NEW_RETURN (the_lock,
00051                       ACE_Lock_Adapter<TAO_SYNCH_MUTEX> (thread_lock),
00052                       0);
00053       return the_lock;
00054     }
00055 #else
00056   ACE_UNUSED_ARG (enable_locking);
00057   ACE_UNUSED_ARG (thread_lock);
00058 #endif /* ACE_HAS_THREADS */
00059 
00060   ACE_Lock *the_lock = 0;
00061   ACE_NEW_RETURN (the_lock,
00062                   ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX> (),
00063                   0);
00064   return the_lock;
00065 }

int TAO_Table_Adapter::dispatch TAO::ObjectKey key,
TAO_ServerRequest request,
CORBA::Object_out  foward_to
[virtual]
 

Implements TAO_Adapter.

Definition at line 101 of file Table_Adapter.cpp.

References ACE_GUARD_RETURN, closed_, find_object(), and TAO_IOR_Table_Impl_var.

00104 {
00105   TAO_IOR_Table_Impl_var rootref;
00106   {
00107     ACE_GUARD_RETURN (ACE_Lock,
00108                       ace_mon,
00109                       *this->lock_,
00110                       TAO_Adapter::DS_MISMATCHED_KEY);
00111     if (this->closed_)
00112       return TAO_Adapter::DS_MISMATCHED_KEY;
00113     rootref = this->root_;
00114   }
00115 
00116   return this->find_object (key, forward_to) ? TAO_Adapter::DS_FORWARD
00117                                              : TAO_Adapter::DS_MISMATCHED_KEY;
00118 }

CORBA::Long TAO_Table_Adapter::find_object TAO::ObjectKey key,
CORBA::Object_out  forward_to
[private]
 

Helper method to find an object bound in the table.

Returns:
1 if found, 0 otherwise.

Definition at line 190 of file Table_Adapter.cpp.

References TAO::ObjectKey::encode_sequence_to_string(), and TAO_ORB_Core::orb().

Referenced by dispatch(), and initialize_collocated_object().

00192 {
00193   CORBA::String_var object_key;
00194   TAO::ObjectKey::encode_sequence_to_string (object_key.out (), key);
00195   try
00196     {
00197       CORBA::String_var ior = root_->find (object_key.in ());
00198       forward_to = this->orb_core_.orb ()->string_to_object (ior.in ());
00199     }
00200   catch (const ::IORTable::NotFound&)
00201     {
00202       return 0;
00203     }
00204   return 1;
00205 }

CORBA::Long TAO_Table_Adapter::initialize_collocated_object TAO_Stub stub  )  [virtual]
 

Implements TAO_Adapter.

Definition at line 156 of file Table_Adapter.cpp.

References TAO_Profile::_key(), CORBA::Object::_nil(), TAO_Stub::add_forward_profiles(), TAO_Stub::base_profiles(), find_object(), TAO_Stub::forward_profiles(), TAO_MProfile::get_profile(), TAO_Stub::next_profile(), and TAO_PHandle.

Referenced by create_collocated_object().

00157 {
00158   // Get the effective profile set.
00159   const TAO_MProfile &mp = stub->forward_profiles () ? *(stub->forward_profiles ())
00160                                                      : stub->base_profiles ();
00161   TAO_PHandle j = 0;
00162   // We only look at the key from the 0th profile but we only really care about
00163   // corbaloc's here where all profiles share a single object key
00164   TAO::ObjectKey_var key = mp.get_profile (j)->_key ();
00165 
00166   CORBA::Object_var forward_to = CORBA::Object::_nil ();
00167   CORBA::Boolean found = false;
00168 
00169   try
00170     {
00171       found = this->find_object (key, forward_to.out ());
00172     }
00173   catch (const ::CORBA::Exception&)
00174     {
00175     }
00176 
00177   if (found)
00178     {
00179       // This call will set the appropriate collocation values
00180       // to correspond to the reference we found in the table.
00181       stub->add_forward_profiles (forward_to->_stubobj ()->base_profiles ());
00182       stub->next_profile ();
00183     }
00184 
00185   // 0 for success
00186   return ! found;
00187 }

const char * TAO_Table_Adapter::name void   )  const [virtual]
 

Implements TAO_Adapter.

Definition at line 121 of file Table_Adapter.cpp.

00122 {
00123   return "IORTable";
00124 }

void TAO_Table_Adapter::open void   )  [virtual]
 

Implements TAO_Adapter.

Definition at line 68 of file Table_Adapter.cpp.

References ACE_GUARD, ACE_NEW_THROW_EX, and closed_.

00069 {
00070   ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00071   TAO_IOR_Table_Impl *impl = 0;
00072   ACE_NEW_THROW_EX (impl,
00073                     TAO_IOR_Table_Impl (),
00074                     CORBA::NO_MEMORY ());
00075 
00076   this->root_ = impl;
00077   this->closed_ = false;
00078 }

int TAO_Table_Adapter::priority void   )  const [virtual]
 

Implements TAO_Adapter.

Definition at line 95 of file Table_Adapter.cpp.

References TAO_DEFAULT_ADAPTER_REGISTRY_SIZE.

00096 {
00097   return static_cast<int> (TAO_DEFAULT_ADAPTER_REGISTRY_SIZE);
00098 }

CORBA::Object_ptr TAO_Table_Adapter::root void   )  [virtual]
 

Implements TAO_Adapter.

Definition at line 127 of file Table_Adapter.cpp.

References CORBA::Object::_duplicate().

00128 {
00129   return CORBA::Object::_duplicate (this->root_.in());
00130 }


Member Data Documentation

bool TAO_Table_Adapter::closed_ [private]
 

Definition at line 74 of file Table_Adapter.h.

Referenced by close(), dispatch(), and open().

bool TAO_Table_Adapter::enable_locking_ [private]
 

Definition at line 75 of file Table_Adapter.h.

ACE_Lock* TAO_Table_Adapter::lock_ [private]
 

Definition at line 77 of file Table_Adapter.h.

TAO_ORB_Core& TAO_Table_Adapter::orb_core_ [private]
 

The ORB Core we belong to.

Definition at line 69 of file Table_Adapter.h.

TAO_IOR_Table_Impl_var TAO_Table_Adapter::root_ [private]
 

The table implementation.

Definition at line 72 of file Table_Adapter.h.

TAO_SYNCH_MUTEX TAO_Table_Adapter::thread_lock_ [private]
 

Definition at line 76 of file Table_Adapter.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:38:26 2008 for TAO_IORTable by doxygen 1.3.6