Class NamingContextImpl

java.lang.Object
org.omg.PortableServer.Servant
org.omg.CosNaming.NamingContextExtPOA
com.sun.corba.se.impl.naming.pcosnaming.NamingContextImpl
All Implemented Interfaces:
NamingContextDataStore, Serializable, InvokeHandler, NamingContextExtOperations, NamingContextOperations

public class NamingContextImpl extends NamingContextExtPOA implements NamingContextDataStore, Serializable
Class NamingContextImpl implements the org.omg.CosNaming::NamingContext and NamingContextExt interface.

The operations bind(), rebind(), bind_context() and rebind_context() are all really implemented by doBind(). resolve() is really implemented by doResolve(), unbind() by doUnbind(). list(), new_context() and destroy() uses the NamingContextDataStore interface directly. All the doX() methods are public static. They synchronize on the NamingContextDataStore object.

None of the methods here are Synchronized because These methods will be invoked from Super class's doBind( ), doResolve( ) which are already Synchronized.

See Also:
  • Constructor Details

    • NamingContextImpl

      public NamingContextImpl(ORB orb, String objKey, NameService theNameService, ServantManagerImpl theServantManagerImpl) throws Exception
      Create a naming context servant. Runs the super constructor.
      Parameters:
      orb - an ORB object.
      objKey - as String
      TheNameService - as NameService
      TheServantManagerImpl - as ServantManagerImpl
      Throws:
      Exception - a Java exception.
  • Method Details

    • setRootNameService

      public void setRootNameService(NameService theNameService)
    • setORB

      public void setORB(ORB theOrb)
    • setServantManagerImpl

      public void setServantManagerImpl(ServantManagerImpl theServantManagerImpl)
    • getNSPOA

      public POA getNSPOA()
      Specified by:
      getNSPOA in interface NamingContextDataStore
    • bind

      public void bind(NameComponent[] n, Object obj) throws NotFound, CannotProceed, InvalidName, AlreadyBound
      Bind an object under a name in this NamingContext. If the name contains multiple (n) components, n-1 will be resolved in this NamingContext and the object bound in resulting NamingContext. An exception is thrown if a binding with the supplied name already exists. If the object to be bound is a NamingContext it will not participate in a recursive resolve.
      Specified by:
      bind in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name under which the object will be bound.
      obj - the object reference to be bound.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      AlreadyBound - The supplied name is already bound.
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
      • doBind(com.sun.corba.se.impl.naming.cosnaming.NamingContextDataStore,org.omg.CosNaming.NameComponent[],org.omg.CORBA.Object,boolean,org.omg.CosNaming.BindingType)
    • bind_context

      public void bind_context(NameComponent[] n, NamingContext nc) throws NotFound, CannotProceed, InvalidName, AlreadyBound
      Bind a NamingContext under a name in this NamingContext. If the name contains multiple (n) components, n-1 will be resolved in this NamingContext and the object bound in resulting NamingContext. An exception is thrown if a binding with the supplied name already exists. The NamingContext will participate in recursive resolving.
      Specified by:
      bind_context in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name under which the object will be bound.
      obj - the NamingContect object reference to be bound.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      AlreadyBound - An object is already bound under the supplied name.
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
      • doBind(com.sun.corba.se.impl.naming.cosnaming.NamingContextDataStore,org.omg.CosNaming.NameComponent[],org.omg.CORBA.Object,boolean,org.omg.CosNaming.BindingType)
    • rebind

      public void rebind(NameComponent[] n, Object obj) throws NotFound, CannotProceed, InvalidName
      Bind an object under a name in this NamingContext. If the name contains multiple (n) components, n-1 will be resolved in this NamingContext and the object bound in resulting NamingContext. If a binding under the supplied name already exists it will be unbound first. If the object to be bound is a NamingContext it will not participate in a recursive resolve.
      Specified by:
      rebind in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name under which the object will be bound.
      obj - the object reference to be bound.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
      • doBind(com.sun.corba.se.impl.naming.cosnaming.NamingContextDataStore,org.omg.CosNaming.NameComponent[],org.omg.CORBA.Object,boolean,org.omg.CosNaming.BindingType)
    • rebind_context

      public void rebind_context(NameComponent[] n, NamingContext nc) throws NotFound, CannotProceed, InvalidName
      Bind a NamingContext under a name in this NamingContext. If the name contains multiple (n) components, the first n-1 components will be resolved in this NamingContext and the object bound in resulting NamingContext. If a binding under the supplied name already exists it will be unbound first. The NamingContext will participate in recursive resolving.
      Specified by:
      rebind_context in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name under which the object will be bound.
      obj - the object reference to be bound.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
      • doBind(com.sun.corba.se.impl.naming.cosnaming.NamingContextDataStore,org.omg.CosNaming.NameComponent[],org.omg.CORBA.Object,boolean,org.omg.CosNaming.BindingType)
    • resolve

      public Object resolve(NameComponent[] n) throws NotFound, CannotProceed, InvalidName
      Resolve a name in this NamingContext and return the object reference bound to the name. If the name contains multiple (n) components, the first component will be resolved in this NamingContext and the remaining components resolved in the resulting NamingContext, provided that the NamingContext bound to the first component of the name was bound with bind_context().
      Specified by:
      resolve in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name to be resolved.
      Returns:
      the object reference bound under the supplied name.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • unbind

      public void unbind(NameComponent[] n) throws NotFound, CannotProceed, InvalidName
      Remove a binding from this NamingContext. If the name contains multiple (n) components, the first n-1 components will be resolved from this NamingContext and the final component unbound in the resulting NamingContext.
      Specified by:
      unbind in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name to be unbound.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • list

      public void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi)
      List the contents of this NamingContest. A sequence of bindings is returned (a BindingList) containing up to the number of requested bindings, and a BindingIterator object reference is returned for iterating over the remaining bindings.
      Specified by:
      list in interface NamingContextOperations
      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.
      See Also:
    • new_context

      public NamingContext new_context()
      Create a NamingContext object and return its object reference.
      Specified by:
      new_context in interface NamingContextOperations
      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.
    • bind_new_context

      public NamingContext bind_new_context(NameComponent[] n) throws NotFound, AlreadyBound, CannotProceed, InvalidName
      Create a new NamingContext, bind it in this Naming Context and return its object reference. This is equivalent to using new_context() followed by bind_context() with the supplied name and the object reference for the newly created NamingContext.
      Specified by:
      bind_new_context in interface NamingContextOperations
      Parameters:
      n - a sequence of NameComponents which is the name to be unbound.
      Returns:
      an object reference for a new NamingContext object implemented by this Name Server, bound to the supplied name.
      Throws:
      AlreadyBound - An object is already bound under the supplied name.
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • destroy

      public void destroy() throws NotEmpty
      Destroy this NamingContext object. If this NamingContext contains no bindings, the NamingContext is deleted.
      Specified by:
      destroy in interface NamingContextOperations
      Throws:
      NotEmpty - This NamingContext is not empty (i.e., contains bindings).
      SystemException - One of a fixed set of CORBA system exceptions.
    • doResolve

      public static Object doResolve(NamingContextDataStore impl, NameComponent[] n) throws NotFound, CannotProceed, InvalidName
      Implements resolving names in this NamingContext. The first component of the supplied name is resolved in this NamingContext by calling Resolve(). If there are no more components in the name, the resulting object reference is returned. Otherwise, the resulting object reference must have been bound as a context and be narrowable to a NamingContext. If this is the case, the remaining components of the name is resolved in the resulting NamingContext. This method is static for maximal reuse - even for extended naming context implementations where the recursive semantics still apply.
      Parameters:
      impl - an implementation of NamingContextDataStore
      n - a sequence of NameComponents which is the name to be resolved.
      Returns:
      the object reference bound under the supplied name.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the first component of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • doUnbind

      public static void doUnbind(NamingContextDataStore impl, NameComponent[] n) throws NotFound, CannotProceed, InvalidName
      Implements unbinding bound names in this NamingContext. If the name contains only one component, the name is unbound in this NamingContext using Unbind(). Otherwise, the first component of the name is resolved in this NamingContext and unbind passed to the resulting NamingContext. This method is static for maximal reuse - even for extended naming context implementations where the recursive semantics still apply.
      Parameters:
      impl - an implementation of NamingContextDataStore
      n - a sequence of NameComponents which is the name to be unbound.
      Throws:
      NotFound - A name with multiple components was supplied, but the first component could not be resolved.
      CannotProceed - Could not proceed in resolving the n-1 components of the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • resolveFirstAsContext

      protected static NamingContext resolveFirstAsContext(NamingContextDataStore impl, NameComponent[] n) throws NotFound
      Implements resolving a NameComponent in this context and narrowing it to CosNaming::NamingContext. It will throw appropriate exceptions if not found or not narrowable.
      Parameters:
      impl - an implementation of NamingContextDataStore
      n - a NameComponents which is the name to be found.
      Throws:
      NotFound - The first component could not be resolved.
      CannotProceed - Could not proceed in resolving the first component of the supplied name.
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • nameToString

      public static String nameToString(NameComponent[] name)
    • Bind

      public void Bind(NameComponent n, Object obj, BindingType bt)
      Implements all flavors of binding( bind and bindcontext) This method will be called from the superclass's doBind( ) method which takes care of all the conditions before calling this method. i.e., It checks whether the Name is already Bounded, Then in the case of rebind it calls Unbind first. This method does one level binding only, To have n-level binding with compound names, doBind( ) calls this method recursively.
      Specified by:
      Bind in interface NamingContextDataStore
      Parameters:
      n - a sequence of NameComponents which is the name under which the object will be bound.
      obj - the object reference to be bound.
      bt - Type of binding (as object or as context).
      Throws:
      NotFound - raised if the NameComoponent list is invalid
      CannotProceed - Could not proceed in resolving the Name from the given NameComponent
      AlreadyBound - An object is already bound under the supplied name.
      SystemException - One of a fixed set of CORBA system exceptions
      See Also:
    • Resolve

      public Object Resolve(NameComponent n, BindingTypeHolder bth) throws SystemException
      This method resolves the NamingContext or Object Reference for one level The doResolve( ) method calls Resolve( ) recursively to resolve n level Names.
      Specified by:
      Resolve in interface NamingContextDataStore
      Parameters:
      n - a sequence of NameComponents which is the name to be resolved.
      bt - Type of binding (as object or as context).
      Returns:
      the object reference bound under the supplied name.
      Throws:
      NotFound - Neither a NamingContext or a Corba Object reference not found under this Name
      CannotProceed - Could not proceed in resolving the the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • Unbind

      public Object Unbind(NameComponent n) throws SystemException
      This method Unbinds the NamingContext or Object Reference for one level The doUnbind( ) method from superclass calls Unbind() to recursively Unbind using compound Names.
      Specified by:
      Unbind in interface NamingContextDataStore
      Parameters:
      n - a sequence of NameComponents which is the name to be resolved.
      Returns:
      the object reference bound under the supplied name.
      Throws:
      NotFound - Neither a NamingContext or a Corba Object reference not found under this Name
      CannotProceed - Could not proceed in resolving the the supplied name.
      InvalidName - The supplied name is invalid (i.e., has length less than 1).
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • List

      public void List(int how_many, BindingListHolder bl, BindingIteratorHolder bi) throws SystemException
      List the contents of this NamingContext. It creates a new PersistentBindingIterator 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 NamingContext NewContext() throws SystemException
      Create a NamingContext object and return its object reference.
      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 void Destroy() throws SystemException
      Destroys the NamingContext.
      Specified by:
      Destroy in interface NamingContextDataStore
      Throws:
      SystemException - One of a fixed set of CORBA system exceptions.
    • to_string

      public String to_string(NameComponent[] n) throws InvalidName
      This operation creates a stringified name from the array of Name components.
      Specified by:
      to_string in interface NamingContextExtOperations
      Parameters:
      n - Name of the object

      Throws:
      org.omg.CosNaming.NamingContextExtPackage.InvalidName - Indicates the name does not identify a binding.

      InvalidName
    • to_name

      public NameComponent[] to_name(String sn) throws InvalidName
      This operation converts a Stringified Name into an equivalent array of Name Components.
      Specified by:
      to_name in interface NamingContextExtOperations
      Parameters:
      sn - Stringified Name of the object

      Throws:
      org.omg.CosNaming.NamingContextExtPackage.InvalidName - Indicates the name does not identify a binding.

      InvalidName
    • to_url

      public String to_url(String addr, String sn) throws InvalidAddress, InvalidName
      This operation creates a URL based "iiopname://" format name from the Stringified Name of the object.
      Specified by:
      to_url in interface NamingContextExtOperations
      Parameters:
      addr - internet based address of the host machine where Name Service is running

      sn - Stringified Name of the object

      Throws:
      org.omg.CosNaming.NamingContextExtPackage.InvalidName - Indicates the name does not identify a binding.

      org.omg.CosNaming.NamingContextPackage.InvalidAddress - Indicates the internet based address of the host machine is incorrect

      InvalidAddress
      InvalidName
    • resolve_str

      public Object resolve_str(String sn) throws NotFound, CannotProceed, InvalidName
      This operation resolves the Stringified name into the object reference.
      Specified by:
      resolve_str in interface NamingContextExtOperations
      Parameters:
      sn - Stringified Name of the object

      Throws:
      NotFound - Indicates there is no object reference for the given name.

      CannotProceed - Indicates that the given compound name is incorrect

      org.omg.CosNaming.NamingContextExtPackage.InvalidName - Indicates the name does not identify a binding.

      InvalidName
    • IsEmpty

      public boolean IsEmpty()
      This is a Debugging Method
      Specified by:
      IsEmpty in interface NamingContextDataStore
      Returns:
      true if this NamingContext contains no bindings.
    • printSize

      public void printSize()
      This is a Debugging Method