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

  • 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.
      nsPOA - the POA
      Throws:
      Exception - a Java exception thrown of the base class cannot initialize.
  • Method Details

    • bindImpl

      public final void bindImpl(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:
      bindImpl 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.
    • resolveImpl

      public final Object resolveImpl(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:
      resolveImpl 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.
    • unbindImpl

      public final Object unbindImpl(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:
      unbindImpl 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.
    • listImpl

      public final void listImpl(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:
      listImpl 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.
    • newContextImpl

      public final NamingContext newContextImpl() throws SystemException
      Create a new NamingContext. It creates a new TransientNamingContext object, passing it the orb object.
      Specified by:
      newContextImpl 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.
    • destroyImpl

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

      private String getName(NameComponent n)
      A Utility Method For Logging..
    • isEmptyImpl

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