Class TransientNamingContext

All Implemented Interfaces:
NamingContextDataStore, InvokeHandler, NamingContextExtOperations, NamingContextOperations

public class TransientNamingContext extends NamingContextImpl implements NamingContextDataStore
Class TransientNamingContext implements the methods defined by NamingContextDataStore, and extends the NamingContextImpl class to provide a servant implementation of CosNaming::NamingContext. The TransientNamingContext uses a hash table to store the mappings between bindings and object references and the hash table is not persistent; thereby the name "transient". This class should not be used directly; instead, the class TransientNameService should be instantiated.

The keys in the hash table are InternalBindingKey objects, containing a single NameComponent and implementing the proper functions, i.e., equals() and hashCode() in an efficient manner. The values in the hash table are InternalBindingValues and store a org.omg.CosNaming::Binding and the object reference associated with the binding. For iteration, TransientBindingIterator objects are created, which are passed a cloned copy of the hashtable. Since elements are inserted and deleted and never modified, this provides stable iterators at the cost of cloning the hash table.

To create and destroy object references, the TransientNamingContext uses the orb.connect() and orb.disconnect() methods.

See Also:
  • Field Details

    • localRoot

      public Object localRoot
      The local root naming context.
  • Constructor Details

    • TransientNamingContext

      public TransientNamingContext(ORB orb, Object initial, POA nsPOA) throws Exception
      Constructs a new TransientNamingContext object.
      Parameters:
      orb - an orb object.
      initial - the initial naming context.
      Throws:
      Exception - a Java exception thrown of the base class cannot initialize.
  • Method Details

    • Bind

      public final void Bind(NameComponent n, Object obj, BindingType bt) throws SystemException
      Binds the object to the name component as the specified binding type. It creates a InternalBindingKey object and a InternalBindingValue object and inserts them in the hash table.
      Specified by:
      Bind in interface NamingContextDataStore
      Parameters:
      n - A single org.omg.CosNaming::NameComponent under which the object will be bound.
      obj - An object reference to be bound under the supplied name.
      bt - The type of the binding (i.e., as object or as context).
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • Resolve

      public final Object Resolve(NameComponent n, BindingTypeHolder bth) throws SystemException
      Resolves the supplied name to an object reference and returns the type of the resolved binding. It creates a InternalBindingKey and uses the key for looking up in the hash table. If nothing is found an exception is thrown, otherwise the object reference is returned and the binding type set.
      Specified by:
      Resolve in interface NamingContextDataStore
      Parameters:
      n - a NameComponent which is the name to be resolved.
      bth - the BindingType as an out parameter.
      Returns:
      the object reference bound under the supplied name, null if not found.
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • Unbind

      public final Object Unbind(NameComponent n) throws SystemException
      Deletes the binding with the supplied name. It creates a InternalBindingKey and uses it to remove the value associated with the key. If nothing is found an exception is thrown, otherwise the element is removed from the hash table.
      Specified by:
      Unbind in interface NamingContextDataStore
      Parameters:
      n - a NameComponent which is the name to unbind
      Returns:
      the object reference bound to the name, or null if not found.
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • List

      public final void List(int how_many, BindingListHolder bl, BindingIteratorHolder bi) throws SystemException
      List the contents of this NamingContext. It creates a new TransientBindingIterator object and passes it a clone of the hash table and an orb object. It then uses the newly created object to return the required number of bindings.
      Specified by:
      List in interface NamingContextDataStore
      Parameters:
      how_many - The number of requested bindings in the BindingList.
      bl - The BindingList as an out parameter.
      bi - The BindingIterator as an out parameter.
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • NewContext

      public final NamingContext NewContext() throws SystemException
      Create a new NamingContext. It creates a new TransientNamingContext object, passing it the orb object.
      Specified by:
      NewContext in interface NamingContextDataStore
      Returns:
      an object reference for a new NamingContext object implemented by this Name Server.
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • Destroy

      public final void Destroy() throws SystemException
      Destroys this NamingContext by disconnecting from the ORB.
      Specified by:
      Destroy in interface NamingContextDataStore
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • IsEmpty

      public final boolean IsEmpty()
      Return whether this NamingContext contains any bindings. It forwards this request to the hash table.
      Specified by:
      IsEmpty in interface NamingContextDataStore
      Returns:
      true if this NamingContext contains no bindings.