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

static 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_

Detailed Description

Definition at line 34 of file Table_Adapter.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Table_Adapter::TAO_Table_Adapter ( TAO_ORB_Core orb_core  ) 

Constructor.

Definition at line 26 of file Table_Adapter.cpp.

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

TAO_Table_Adapter::~TAO_Table_Adapter ( void   )  [virtual]

Destructor.

Definition at line 37 of file Table_Adapter.cpp.

References lock_.

00038 {
00039   delete this->lock_;
00040 }


Member Function Documentation

void TAO_Table_Adapter::check_close ( int  wait_for_completion  )  [virtual]

Implements TAO_Adapter.

Definition at line 91 of file Table_Adapter.cpp.

00092 {
00093 }

void TAO_Table_Adapter::close ( int  wait_for_completion  )  [virtual]

Implements TAO_Adapter.

Definition at line 82 of file Table_Adapter.cpp.

References ACE_GUARD, and closed_.

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

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

Implements TAO_Adapter.

Definition at line 139 of file Table_Adapter.cpp.

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

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

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

Definition at line 44 of file Table_Adapter.cpp.

References ACE_NEW_RETURN.

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

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

Implements TAO_Adapter.

Definition at line 102 of file Table_Adapter.cpp.

References ACE_GUARD_RETURN, TAO_Adapter::DS_FORWARD, TAO_Adapter::DS_MISMATCHED_KEY, TAO_ServerRequest::forward_location(), and root_.

00105 {
00106   TAO_IOR_Table_Impl_var rootref;
00107   {
00108     ACE_GUARD_RETURN (ACE_Lock,
00109                       ace_mon,
00110                       *this->lock_,
00111                       TAO_Adapter::DS_MISMATCHED_KEY);
00112     if (this->closed_)
00113       return TAO_Adapter::DS_MISMATCHED_KEY;
00114     rootref = this->root_;
00115   }
00116 
00117   if (this->find_object (key, forward_to))
00118     {
00119       request.forward_location (forward_to);
00120       return TAO_Adapter::DS_FORWARD;
00121     }
00122   else
00123     return TAO_Adapter::DS_MISMATCHED_KEY;
00124 }

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 196 of file Table_Adapter.cpp.

References TAO_ORB_Core::orb(), orb_core_, root_, and CORBA::ORB::string_to_object().

Referenced by initialize_collocated_object().

00198 {
00199   CORBA::String_var object_key;
00200   TAO::ObjectKey::encode_sequence_to_string (object_key.out (), key);
00201   try
00202     {
00203       CORBA::String_var ior = root_->find (object_key.in ());
00204       forward_to = this->orb_core_.orb ()->string_to_object (ior.in ());
00205     }
00206   catch (const ::IORTable::NotFound&)
00207     {
00208       return 0;
00209     }
00210   return 1;
00211 }

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

Implements TAO_Adapter.

Definition at line 162 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_Pseudo_Var_T< T >::out().

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

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

Implements TAO_Adapter.

Definition at line 127 of file Table_Adapter.cpp.

00128 {
00129   return "IORTable";
00130 }

void TAO_Table_Adapter::open ( void   )  [virtual]

Implements TAO_Adapter.

Definition at line 69 of file Table_Adapter.cpp.

References ACE_GUARD, ACE_NEW_THROW_EX, closed_, and root_.

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

int TAO_Table_Adapter::priority ( void   )  const [virtual]

Implements TAO_Adapter.

Definition at line 96 of file Table_Adapter.cpp.

References TAO_DEFAULT_ADAPTER_REGISTRY_SIZE.

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

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

Implements TAO_Adapter.

Definition at line 133 of file Table_Adapter.cpp.

References CORBA::Object::_duplicate().

00134 {
00135   return CORBA::Object::_duplicate (this->root_.in());
00136 }


Member Data Documentation

bool TAO_Table_Adapter::closed_ [private]

Definition at line 74 of file Table_Adapter.h.

Referenced by close(), 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.

Referenced by ~TAO_Table_Adapter().

TAO_ORB_Core& TAO_Table_Adapter::orb_core_ [private]

The ORB Core we belong to.

Definition at line 69 of file Table_Adapter.h.

Referenced by find_object().

TAO_IOR_Table_Impl_var TAO_Table_Adapter::root_ [private]

The table implementation.

Definition at line 72 of file Table_Adapter.h.

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

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 Tue Feb 2 17:43:42 2010 for TAO_IORTable by  doxygen 1.4.7