#include <Table_Adapter.h>
Public Member Functions | |
TAO_Table_Adapter (TAO_ORB_Core &orb_core) | |
Constructor. | |
virtual | ~TAO_Table_Adapter (void) |
Destructor. | |
virtual void | open (void) |
Initialize the Adapter. | |
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) |
Return the status.... | |
virtual const char * | name (void) const |
virtual CORBA::Object_ptr | root (void) |
virtual CORBA::Object_ptr | create_collocated_object (TAO_Stub *, const TAO_MProfile &) |
Create a collocated object using the given profile and stub. | |
virtual CORBA::Long | initialize_collocated_object (TAO_Stub *stub) |
Private Member Functions | |
bool | find_object (TAO::ObjectKey &key, CORBA::Object_out forward_to) |
Helper method to find an object bound in the table. | |
Static Private Member Functions | |
static ACE_Lock * | create_lock (bool enable_locking, TAO_SYNCH_MUTEX &l) |
Private Attributes | |
TAO_ORB_Core & | orb_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_Lock * | lock_ |
Definition at line 34 of file Table_Adapter.h.
TAO_Table_Adapter::TAO_Table_Adapter | ( | TAO_ORB_Core & | orb_core | ) |
Constructor.
Definition at line 26 of file Table_Adapter.cpp.
: orb_core_ (orb_core), root_ (), closed_ (true), enable_locking_ (orb_core_.server_factory ()->enable_poa_locking ()), thread_lock_ (), lock_ (TAO_Table_Adapter::create_lock (enable_locking_, thread_lock_)) { }
TAO_Table_Adapter::~TAO_Table_Adapter | ( | void | ) | [virtual] |
void TAO_Table_Adapter::check_close | ( | int | wait_for_completion | ) | [virtual] |
Check if the adapter can be closed in the current context, raise an exception if not.
Implements TAO_Adapter.
Definition at line 91 of file Table_Adapter.cpp.
{ }
void TAO_Table_Adapter::close | ( | int | wait_for_completion | ) | [virtual] |
The ORB is shutting down, destroy any resources attached to this adapter.
Implements TAO_Adapter.
Definition at line 82 of file Table_Adapter.cpp.
CORBA::Object_ptr TAO_Table_Adapter::create_collocated_object | ( | TAO_Stub * | , | |
const TAO_MProfile & | ||||
) | [virtual] |
Create a collocated object using the given profile and stub.
Implements TAO_Adapter.
Definition at line 139 of file Table_Adapter.cpp.
{ CORBA::Object_ptr result = CORBA::Object::_nil (); if (! this->initialize_collocated_object (stub)) // 0 == success { // A reference was found in the table. The stub has been forwarded // to this. The collocation indicators are now correct on the stub // (although they may well now indicate that the stub is not in fact // collocated at all). ACE_NEW_RETURN (result, CORBA::Object (stub, stub->is_collocated (), stub->collocated_servant ()), CORBA::Object::_nil ()); } return result; }
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.
{ #if defined (ACE_HAS_THREADS) if (enable_locking) { ACE_Lock *the_lock = 0; ACE_NEW_RETURN (the_lock, ACE_Lock_Adapter<TAO_SYNCH_MUTEX> (thread_lock), 0); return the_lock; } #else ACE_UNUSED_ARG (enable_locking); ACE_UNUSED_ARG (thread_lock); #endif /* ACE_HAS_THREADS */ ACE_Lock *the_lock = 0; ACE_NEW_RETURN (the_lock, ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX> (), 0); return the_lock; }
int TAO_Table_Adapter::dispatch | ( | TAO::ObjectKey & | key, | |
TAO_ServerRequest & | request, | |||
CORBA::Object_out | forward_to | |||
) | [virtual] |
Return the status....
Implements TAO_Adapter.
Definition at line 102 of file Table_Adapter.cpp.
{ TAO_IOR_Table_Impl_var rootref; { ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, TAO_Adapter::DS_MISMATCHED_KEY); if (this->closed_) return TAO_Adapter::DS_MISMATCHED_KEY; rootref = this->root_; } if (this->find_object (key, forward_to)) { request.forward_location (forward_to); return TAO_Adapter::DS_FORWARD; } else return TAO_Adapter::DS_MISMATCHED_KEY; }
bool TAO_Table_Adapter::find_object | ( | TAO::ObjectKey & | key, | |
CORBA::Object_out | forward_to | |||
) | [private] |
Helper method to find an object bound in the table.
Definition at line 196 of file Table_Adapter.cpp.
{ CORBA::String_var object_key; TAO::ObjectKey::encode_sequence_to_string (object_key.out (), key); try { CORBA::String_var ior = root_->find (object_key.in ()); forward_to = this->orb_core_.orb ()->string_to_object (ior.in ()); } catch (const ::IORTable::NotFound&) { return false; } return true; }
CORBA::Long TAO_Table_Adapter::initialize_collocated_object | ( | TAO_Stub * | ) | [virtual] |
Initialize a collocated object using the given stub pointer for lazily evaluated object references.
Implements TAO_Adapter.
Definition at line 162 of file Table_Adapter.cpp.
{ // Get the effective profile set. const TAO_MProfile &mp = stub->forward_profiles () ? *(stub->forward_profiles ()) : stub->base_profiles (); TAO_PHandle j = 0; // We only look at the key from the 0th profile but we only really care about // corbaloc's here where all profiles share a single object key TAO::ObjectKey_var key = mp.get_profile (j)->_key (); CORBA::Object_var forward_to = CORBA::Object::_nil (); CORBA::Boolean found = false; try { found = this->find_object (key, forward_to.out ()); } catch (const ::CORBA::Exception&) { } if (found) { // This call will set the appropriate collocation values // to correspond to the reference we found in the table. stub->add_forward_profiles (forward_to->_stubobj ()->base_profiles ()); stub->next_profile (); } // 0 for success return ! found; }
const char * TAO_Table_Adapter::name | ( | void | ) | const [virtual] |
Return the name, i.e. the object id used to resolve it in the ORB.
Implements TAO_Adapter.
Definition at line 127 of file Table_Adapter.cpp.
{ return "IORTable"; }
void TAO_Table_Adapter::open | ( | void | ) | [virtual] |
Initialize the Adapter.
Implements TAO_Adapter.
Definition at line 69 of file Table_Adapter.cpp.
{ ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); TAO_IOR_Table_Impl *impl = 0; ACE_NEW_THROW_EX (impl, TAO_IOR_Table_Impl (), CORBA::NO_MEMORY ()); this->root_ = impl; this->closed_ = false; }
int TAO_Table_Adapter::priority | ( | void | ) | const [virtual] |
Return the priority assigned to this adapter. Adapters at higher priority are used first, the first adapter that matches a key is used to dispatch a request.
Implements TAO_Adapter.
Definition at line 96 of file Table_Adapter.cpp.
{ return static_cast<int> (TAO_DEFAULT_ADAPTER_REGISTRY_SIZE); }
CORBA::Object_ptr TAO_Table_Adapter::root | ( | void | ) | [virtual] |
Return the root of the Object Adapter. Each adapter defines its own IDL interface accessed through the method above.
Implements TAO_Adapter.
Definition at line 133 of file Table_Adapter.cpp.
{ return CORBA::Object::_duplicate (this->root_.in()); }
bool TAO_Table_Adapter::closed_ [private] |
Definition at line 73 of file Table_Adapter.h.
bool TAO_Table_Adapter::enable_locking_ [private] |
Definition at line 74 of file Table_Adapter.h.
ACE_Lock* TAO_Table_Adapter::lock_ [private] |
Definition at line 76 of file Table_Adapter.h.
TAO_ORB_Core& TAO_Table_Adapter::orb_core_ [private] |
The ORB Core we belong to.
Definition at line 68 of file Table_Adapter.h.
The table implementation.
Definition at line 71 of file Table_Adapter.h.
TAO_SYNCH_MUTEX TAO_Table_Adapter::thread_lock_ [private] |
Definition at line 75 of file Table_Adapter.h.