summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h')
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h293
1 files changed, 146 insertions, 147 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h b/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h
index 31bc78138d1..42145b8e3c1 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.h
@@ -16,190 +16,189 @@
#ifndef TAO_PERSISTENT_NAMING_CONTEXT_H
#define TAO_PERSISTENT_NAMING_CONTEXT_H
-#include "Hash_Naming_Context.h"
-#include "Persistent_Entries.h"
+#include "Naming_Context.h"
+#include "Persistent_Bindings_Map.h"
-class TAO_ORBSVCS_Export TAO_Persistent_Bindings_Map : public TAO_Bindings_Map
-{
- // = TITLE
- // Provides hash-table-based persistent storage for
- // name to object bindings in a Naming Context.
- //
- // = DESCRIPTION
- // Wrapper on top of ACE_Shared_Hash_Map (which is a wrapper
- // around ACE_Hash_Map_Manager). Uses ACE_Allocator (allocating
- // from persistent storage) to make bindings persistent and
- // supports TAO_Bindings_Map interface. Used by TAO_Persistent_Naming_Context.
-public:
-
- typedef ACE_Shared_Hash_Map<TAO_Persistent_ExtId, TAO_Persistent_IntId> HASH_MAP;
- // Underlying data structure - typedef for ease of use.
-
- // = Initialization and termination methods.
-
- TAO_Persistent_Bindings_Map (CORBA::ORB_ptr orb);
- // Constructor.
-
- int open (size_t hash_map_size,
- ACE_Allocator *alloc);
- // Allocate hash map of size <hash_map_size> from persistent storage
- // using the <alloc>.
-
- void set (HASH_MAP *map,
- ACE_Allocator *alloc);
- // The hash map has already been preallocated for us. We just need
- // to set our data members take ownership of it.
-
- virtual ~TAO_Persistent_Bindings_Map (void);
- // Destructor. Does not deallocate the hash map: if an instance of
- // this class goes out of scope, its hash_map remains in persistent storage.
-
- void destroy (void);
- // This method removes the hash map from persistent storage/frees up
- // the memory. The hash map better be empty, since we are not
- // cleaning up the insides. (We could add <close> to clean entries,
- // but not the data inside the entries.
-
- // = Accessor methods.
-
- HASH_MAP *map (void);
- // Get a pointer to the underlying hash map.
-
- size_t total_size (void);
- // Return the size of the underlying hash table.
-
- virtual size_t current_size (void);
- // Return the size of the underlying hash table.
-
- // = Name bindings manipulation methods.
-
- virtual int bind (const char *id,
- const char *kind,
- CORBA::Object_ptr obj,
- CosNaming::BindingType type);
- // Add a binding with the specified parameters to the table.
- // Return 0 on success and -1 on failure, 1 if there already is a
- // binding with <id> and <kind>.
-
- virtual int rebind (const char *id,
- const char *kind,
- CORBA::Object_ptr obj,
- CosNaming::BindingType type);
- // Overwrite a binding containing <id> and <kind> (or create a new
- // one if one doesn't exist) with the specified parameters. Returns
- // -1 on failure.
-
- virtual int unbind (const char * id,
- const char * kind);
- // Remove a binding containing <id> and <kind> from the table.
- // Return 0 on success and -1 on failure.
-
- virtual int find (const char * id,
- const char * kind,
- CORBA::Object_ptr & obj,
- CosNaming::BindingType &type);
- // Find the binding containing <id> and <kind> in the table, and
- // pass binding's type and object back to the caller by reference.
- // Return 0 on success and -1 on failure. Note: a 'duplicated' object
- // reference is assigned to <obj>, so the caller is responsible for
- // its deallocation.
-
-protected:
-
- int shared_bind (const char *id,
- const char *kind,
- CORBA::Object_ptr obj,
- CosNaming::BindingType type,
- int rebind);
- // Helper: factors common code from <bind> and <rebind>.
-
- ACE_Allocator *allocator_;
- // Pointer to the allocator we use to make bindings persistent.
+class TAO_Index;
- HASH_MAP *map_;
- // Pointer to the underlying hash map.
-
- CORBA::ORB_var orb_;
- // Pointer to the orb. We need it to do string/object conversions.
-};
-
-class TAO_Persistent_Context_Index;
-
-class TAO_ORBSVCS_Export TAO_Persistent_Naming_Context : public TAO_Hash_Naming_Context
+class TAO_ORBSVCS_Export TAO_Persistent_Naming_Context : public TAO_Naming_Context_Impl
{
// = TITLE
// This class plays a role of a 'ConcreteImplementor' in the
- // Bridge pattern architecture of the CosNaming::NamingContext implementation.
+ // Bridge pattern architecture of the Naming Service
+ // implementation. This implementation of the NamingContext
+ // uses ACE_Hash_Map_Manager to store name bindings.
//
// = DESCRIPTION
- // 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.
- //
+ // Extensive idl method descriptions can be found in Naming_Context.h
+
public:
typedef TAO_Persistent_Bindings_Map::HASH_MAP HASH_MAP;
- // Underlying data structure - typedef for ease of use.
// = Initialization and termination methods.
-
- TAO_Persistent_Naming_Context (PortableServer::POA_ptr poa,
+ TAO_Persistent_Naming_Context (TAO_Naming_Context *interface,
+ TAO_Index *context_index,
+ PortableServer::POA_ptr poa,
const char *poa_id,
- TAO_Persistent_Context_Index *context_index);
- // Constructor. MUST be followed up by <init> to allocate the
- // underlying data structure from persistent storage!
+ size_t default_hash_table_size = ACE_DEFAULT_MAP_SIZE);
+ // Default constructor. Sets the implementation pointer of the interface.
- int 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.
-
- TAO_Persistent_Naming_Context (PortableServer::POA_ptr poa,
+ TAO_Persistent_Naming_Context (TAO_Naming_Context *interface,
+ TAO_Index *context_index,
+ 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.
+ // Constructor for recreation.
virtual ~TAO_Persistent_Naming_Context (void);
- // Destructor.
+ // destructor.
+
+ int init (void);
+ // Allocate the map.
+
+ // = CosNaming::NamingContext idl interface methods.
+ virtual void bind (const CosNaming::Name &n,
+ CORBA::Object_ptr obj,
+ CORBA::Environment &ACE_TRY_ENV);
+
+ virtual void rebind (const CosNaming::Name &n,
+ CORBA::Object_ptr obj,
+ CORBA::Environment &ACE_TRY_ENV);
+
+ virtual void bind_context (const CosNaming::Name &n,
+ CosNaming::NamingContext_ptr nc,
+ CORBA::Environment &ACE_TRY_ENV);
- // = Methods not implemented in TAO_Hash_Naming_Context.
+ virtual void rebind_context (const CosNaming::Name &n,
+ CosNaming::NamingContext_ptr nc,
+ CORBA::Environment &ACE_TRY_ENV);
+
+ virtual CORBA::Object_ptr resolve (const CosNaming::Name &n,
+ CORBA::Environment &ACE_TRY_ENV);
+
+ virtual void unbind (const CosNaming::Name &n,
+ CORBA::Environment &ACE_TRY_ENV);
virtual CosNaming::NamingContext_ptr new_context (CORBA::Environment &ACE_TRY_ENV);
- // This operation returns a new naming context implemented by the
- // same naming server in which the operation was invoked. The
- // context is not bound.
+
+ virtual CosNaming::NamingContext_ptr bind_new_context (const CosNaming::Name &n,
+ CORBA::Environment &ACE_TRY_ENV);
+
+ virtual void destroy (CORBA::Environment &ACE_TRY_ENV);
virtual void list (CORBA::ULong how_many,
CosNaming::BindingList_out &bl,
CosNaming::BindingIterator_out &bi,
CORBA::Environment &ACE_TRY_ENV);
- // Returns at most the requested number of bindings <how_many> in
- // <bl>. If the naming context contains additional bindings, they
- // are returned with a BindingIterator. In the naming context does
- // not contain any additional bindings <bi> returned as null.
+ virtual PortableServer::POA_ptr _default_POA (void);
+ // Returns the Default POA of this Servant object
+
+ // = Helper functions.
+ static int populate_binding (TAO_Persistent_Naming_Context::HASH_MAP::ENTRY *hash_entry,
+ CosNaming::Binding &b);
+ // Helper function used by TAO_Persistent_Naming_Context and
+ // TAO_BindingIterator: populate a binding <b> with info contained
+ // in <hash_entry>. Return 1 if everything went smoothly, 0 if an
+ // allocation failed.
ACE_UINT32 *counter_;
- // Counter used for generation of POA ids for children Naming
- // Contexts.
+ // Counter used for generation of POA ids for objects created by
+ // this context.
- TAO_Persistent_Bindings_Map * persistent_context_;
- // 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.
+ TAO_Persistent_Bindings_Map context_;
+ // This implementation of <NamingContext> uses <ACE_Hash_Map> for
+ // storage and manipulation of name-object bindings.
protected:
+ // = These are the helper methods used by other methods.
+
+ CosNaming::NamingContext_ptr get_context (const CosNaming::Name &name,
+ CORBA::Environment &_env);
+ // This is used by methods that need to resolve a compound name to
+ // get the reference to the target context before performing the
+ // actual operation (e.g. bind, unbind, etc.) Takes a full name
+ // (including the last component that doesn't need to be resolved)
+ // Returns a pointer to the target context.
- TAO_Persistent_Context_Index *index_;
+ TAO_Index *index_;
// 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.
+
+ PortableServer::POA_var poa_;
+ // POA we are registered with.
+
+ ACE_CString poa_id_;
+ // ID with which we are registered with <poa_>.
+
+ ACE_Lock *lock_;
+ // Lock to serialize access to the underlying data structure. This
+ // is a lock adapter that hides the type of lock, which may be a
+ // null lock if the ORB decides threading is not necessary.
+
+ size_t hash_table_size_;
+ // Hash table size.
+
+ TAO_Naming_Context *interface_;
+ // Pointer to the 'Abstraction' in the bridge pattern. We need this
+ // pointer so that we can clean up the Abstraction as necessary when <destroy>
+ // method is called. The reason we need to clean up as opposed to
+ // the Abstraction itself is that we, the concrete implementation, have the *knowledge* of how
+ // to do this, e.g., we may have one servant serving many objects
+ // and would not want to delete the servant in the <destroy> operation.
+};
+
+class TAO_ORBSVCS_Export TAO_Persistent_Binding_Iterator :
+ public POA_CosNaming::BindingIterator
+{
+ // = TITLE
+ // This class implements the <BindingIterator> interface that is
+ // part of the <CosNaming> idl module based on the Hash_Map
+ // implementation for CosNaming::NamingContext.
+ //
+ // = DESCRIPTION
+ // <TAO_Persistent_Binding_Iterator> constructor expects a pointer to a
+ // dynamically allocated hash map iterator. Destructor
+ // deallocates hash map iterator.
+public:
+ // = Intialization and termination methods.
+ TAO_Persistent_Binding_Iterator (TAO_Persistent_Naming_Context::HASH_MAP::ITERATOR *hash_iter,
+ PortableServer::POA_ptr poa,
+ ACE_Lock *lock);
+ // Constructor.
+
+ ~TAO_Persistent_Binding_Iterator (void);
+ // Destructor.
+
+ // Returns the Default POA of this Servant object
+ virtual PortableServer::POA_ptr _default_POA (CORBA::Environment &env);
+
+ CORBA::Boolean next_one (CosNaming::Binding_out b,
+ CORBA::Environment &ACE_TRY_ENV);
+ // This operation returns the next binding. If there are no more
+ // bindings false is returned.
+
+ CORBA::Boolean next_n (CORBA::ULong how_many,
+ CosNaming::BindingList_out bl,
+ CORBA::Environment &ACE_TRY_ENV);
+ // This operation returns at most the requested number of bindings.
+
+ void destroy (CORBA::Environment &ACE_TRY_ENV);
+ // This operation destroys the iterator.
+
+private:
+ TAO_Persistent_Naming_Context::HASH_MAP::ITERATOR *hash_iter_;
+ // A pointer to the hash map iterator.
+
+ ACE_Lock *lock_;
+ // Lock passed on from <TAO_NamingContext> to serialize access to the
+ // internal data structure.
+
+ PortableServer::POA_var poa_;
+ // Implement a different _default_POA()
};
#endif /* TAO_PERSISTENT_NAMING_CONTEXT_H */