TAO_Persistent_Naming_Context Class Reference

This class plays a role of a 'ConcreteImplementor' in the Bridge pattern architecture of the CosNaming::NamingContext implementation. More...

#include <Persistent_Naming_Context.h>

Inheritance diagram for TAO_Persistent_Naming_Context:

Inheritance graph
[legend]
Collaboration diagram for TAO_Persistent_Naming_Context:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_Persistent_Bindings_Map::HASH_MAP HASH_MAP
 Underlying data structure - typedef for ease of use.


Public Member Functions

 TAO_Persistent_Naming_Context (PortableServer::POA_ptr poa, const char *poa_id, TAO_Persistent_Context_Index *context_index)
int init (size_t hash_table_size=ACE_DEFAULT_MAP_SIZE)
 TAO_Persistent_Naming_Context (PortableServer::POA_ptr poa, const char *poa_id, TAO_Persistent_Context_Index *context_index, HASH_MAP *map, ACE_UINT32 *counter)
virtual ~TAO_Persistent_Naming_Context (void)
 Destructor.

virtual CosNaming::NamingContext_ptr new_context (ACE_ENV_SINGLE_ARG_DECL)
virtual void list (CORBA::ULong how_many, CosNaming::BindingList_out &bl, CosNaming::BindingIterator_out &bi ACE_ENV_ARG_DECL)

Static Public Member Functions

CosNaming::NamingContext_ptr make_new_context (PortableServer::POA_ptr poa, const char *poa_id, size_t context_size, TAO_Persistent_Context_Index *ind ACE_ENV_ARG_DECL)

Protected Member Functions

void set_cleanup_level (int level)

Protected Attributes

ACE_UINT32 * counter_
TAO_Persistent_Bindings_Mappersistent_context_
TAO_Persistent_Context_Indexindex_

Detailed Description

This class plays a role of a 'ConcreteImplementor' in the Bridge pattern architecture of the CosNaming::NamingContext implementation.

This class provides a persistent implementation of the NamingContext functionality, i.e., the state is preserved across process boundaries. Derives from TAO_Hash_Naming_Context and uses TAO_Persistent_Bindings_Map to store name to object bindings.

Definition at line 164 of file Persistent_Naming_Context.h.


Member Typedef Documentation

typedef TAO_Persistent_Bindings_Map::HASH_MAP TAO_Persistent_Naming_Context::HASH_MAP
 

Underlying data structure - typedef for ease of use.

Definition at line 168 of file Persistent_Naming_Context.h.


Constructor & Destructor Documentation

TAO_Persistent_Naming_Context::TAO_Persistent_Naming_Context PortableServer::POA_ptr  poa,
const char *  poa_id,
TAO_Persistent_Context_Index context_index
 

Constructor. MUST be followed up by to allocate the underlying data structure from persistent storage!

Definition at line 257 of file Persistent_Naming_Context.cpp.

References ACE_NEW, TAO_Persistent_Context_Index::orb(), and persistent_context_.

00261   : TAO_Hash_Naming_Context (poa,
00262                              poa_id),
00263     counter_ (0),
00264     persistent_context_ (0),
00265     index_ (context_index)
00266 {
00267   ACE_NEW (this->persistent_context_,
00268            TAO_Persistent_Bindings_Map (context_index->orb ()));
00269 
00270   // Set the superclass pointer.
00271   context_ = persistent_context_;
00272 }

TAO_Persistent_Naming_Context::TAO_Persistent_Naming_Context PortableServer::POA_ptr  poa,
const char *  poa_id,
TAO_Persistent_Context_Index context_index,
HASH_MAP map,
ACE_UINT32 *  counter
 

Constructor that takes in preallocated data structure and takes ownership of it. This constructor is for 'recreating' servants from persistent state.

Definition at line 274 of file Persistent_Naming_Context.cpp.

References ACE_NEW, TAO_Persistent_Context_Index::allocator(), TAO_Persistent_Context_Index::orb(), persistent_context_, and TAO_Persistent_Bindings_Map::set().

00279   : TAO_Hash_Naming_Context (poa,
00280                              poa_id),
00281     counter_ (counter),
00282     persistent_context_ (0),
00283     index_ (context_index)
00284 {
00285   ACE_NEW (this->persistent_context_,
00286            TAO_Persistent_Bindings_Map (context_index->orb ()));
00287 
00288   // Set the superclass pointer.
00289   context_ = persistent_context_;
00290 
00291   persistent_context_->set (map, index_->allocator ());
00292 }

TAO_Persistent_Naming_Context::~TAO_Persistent_Naming_Context void   )  [virtual]
 

Destructor.

Definition at line 300 of file Persistent_Naming_Context.cpp.

References TAO_Persistent_Bindings_Map::destroy(), persistent_context_, and TAO_Persistent_Context_Index::unbind().

00301 {
00302   // Perform appropriate cleanup based on the destruction level specified.
00303 
00304   if (this->destroyed_ > 1)
00305     {
00306       // Remove ourselves from context index.
00307       index_->unbind (poa_id_.c_str ());
00308       // Remove the underlying data structure from persistent storage.
00309       persistent_context_->destroy ();
00310     }
00311   else if (this->destroyed_ == 1)
00312     // Remove the underlying data structure from persistent storage.
00313     persistent_context_->destroy ();
00314 }


Member Function Documentation

int TAO_Persistent_Naming_Context::init size_t  hash_table_size = ACE_DEFAULT_MAP_SIZE  ) 
 

Allocate the underlying data structure from persistent storage. Returns 0 on success and -1 on failure.

Definition at line 295 of file Persistent_Naming_Context.cpp.

References TAO_Persistent_Context_Index::allocator(), TAO_Persistent_Bindings_Map::open(), and persistent_context_.

00296 {
00297   return persistent_context_->open (hash_table_size, index_->allocator ());
00298 }

virtual void TAO_Persistent_Naming_Context::list CORBA::ULong  how_many,
CosNaming::BindingList_out &  bl,
CosNaming::BindingIterator_out &bi  ACE_ENV_ARG_DECL
[virtual]
 

Returns at most the requested number of bindings in . If the naming context contains additional bindings, they are returned with a BindingIterator. In the naming context does not contain any additional bindings returned as null.

Implements TAO_Naming_Context_Impl.

CosNaming::NamingContext_ptr TAO_Persistent_Naming_Context::make_new_context PortableServer::POA_ptr  poa,
const char *  poa_id,
size_t  context_size,
TAO_Persistent_Context_Index *ind  ACE_ENV_ARG_DECL
[static]
 

This utility method factors out the code needed to create a new Persistent Naming Context servant and activate it under the specified POA with the specified id. This function is static so that the code can be used, both from inside the class (e.g., ), and from outside (e.g., Naming_Utils.cpp).

Referenced by TAO_Persistent_Context_Index::init().

virtual CosNaming::NamingContext_ptr TAO_Persistent_Naming_Context::new_context ACE_ENV_SINGLE_ARG_DECL   )  [virtual]
 

This operation returns a new naming context implemented by the same naming server in which the operation was invoked. The context is not bound.

Implements TAO_Naming_Context_Impl.

void TAO_Persistent_Naming_Context::set_cleanup_level int  level  )  [protected]
 

Set flag (inherited from TAO_Hash_Naming_Context) to . Legal values for are 0, 1, and 2. The values specify the extent of cleanup that should take place in the context's destructor: '0' - no cleanup (e.g., if the context goes out of scope, but it's state is to remain in persistent storage); '1' - free up the underlying data structure in persistent storage (e.g., if the initialization of this context was only partially completed due to some failures, and we need to roll back); '2' - free up the underlying data structure, and deregister this naming context from its (e.g., if the context had method invoked and needs to be completely removed from existence).

Definition at line 317 of file Persistent_Naming_Context.cpp.

00318 {
00319   this->destroyed_ = level;
00320 }


Member Data Documentation

ACE_UINT32* TAO_Persistent_Naming_Context::counter_ [protected]
 

Counter used for generation of POA ids for children Naming Contexts.

Definition at line 250 of file Persistent_Naming_Context.h.

TAO_Persistent_Context_Index* TAO_Persistent_Naming_Context::index_ [protected]
 

A pointer to the index object of this naming service: it keeps track of all the naming contexts created. Every time we make a new context or destroy one, we need to make an entry there. Also, we get the allocator needed to initialize us from this guy.

Definition at line 267 of file Persistent_Naming_Context.h.

TAO_Persistent_Bindings_Map* TAO_Persistent_Naming_Context::persistent_context_ [protected]
 

A pointer to the underlying data structure used to store name bindings. While our superclass (TAO_Hash_Naming_Context) also maintains a pointer to the data structure, keeping this pointer around saves us from the need to downcast when invoking non-virtual methods.

Definition at line 259 of file Persistent_Naming_Context.h.

Referenced by init(), TAO_Persistent_Naming_Context(), and ~TAO_Persistent_Naming_Context().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:57:46 2006 for TAO_CosNaming by doxygen 1.3.6