Class NamingContextImpl

java.lang.Object
org.omg.PortableServer.Servant
org.omg.CosNaming.NamingContextExtPOA
com.sun.corba.ee.impl.naming.cosnaming.NamingContextImpl
All Implemented Interfaces:
NamingContextDataStore, InvokeHandler, NamingContextExtOperations, NamingContextOperations
Direct Known Subclasses:
TransientNamingContext

public abstract class NamingContextImpl extends NamingContextExtPOA implements NamingContextDataStore
Class NamingContextImpl implements the org.omg.CosNaming::NamingContext interface, but does not implement the methods associated with maintaining the "table" of current bindings in a NamingContext. Instead, this implementation assumes that the derived implementation implements the NamingContextDataStore interface, which has the necessary methods. This allows multiple NamingContext implementations that differ in storage of the bindings, as well as implementations of interfaces derived from CosNaming::NamingContext that still reuses the implementation.

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.

An implementation a NamingContext must extend this class and implement the NamingContextDataStore interface with the operations: Bind(), Resolve(), Unbind(), List(), NewContext() and Destroy(). Calls to these methods are synchronized; these methods should therefore not be synchronized.

  • Field Details

  • Constructor Details

    • NamingContextImpl

      public NamingContextImpl(ORB orb, POA poa) throws Exception
      Create a naming context servant. Runs the super constructor.
      Parameters:
      orb - an ORB object.
      poa - the POA.
      Throws:
      Exception - a Java exception.
  • Method Details

    • 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 - An object is already bound under the supplied name.
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • 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.
      nc - 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:
    • 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:
    • 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.
      nc - 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:
    • 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.
    • doBind

      public static void doBind(NamingContextDataStore impl, NameComponent[] n, Object obj, boolean rebind, BindingType bt) throws NotFound, CannotProceed, InvalidName, AlreadyBound
      Implements all four flavors of binding. It uses Resolve() to check if a binding already exists (for bind and bind_context), and unbind() to ensure that a binding does not already exist. If the length of the name is 1, then Bind() is called with the name and the object to bind. Otherwise, the first component of the name is resolved in this NamingContext and the appropriate form of bind 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 under which the object will be bound.
      obj - the object reference to be bound.
      rebind - Replace an existing binding or not.
      bt - Type of binding (as object or as context).
      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).
      AlreadyBound - An object is already bound under the supplied name.
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • 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.
      Returns:
      a naming context
      Throws:
      NotFound - The first component could not be resolved.
      SystemException - One of a fixed set of CORBA system exceptions.
      See Also:
    • 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
      Returns:
      the object name as a single string
      Throws:
      InvalidName - Indicates the name does not identify a binding.
    • 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

      Returns:
      an array of name components
      Throws:
      InvalidName - if the name is invalid
    • 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

      Returns:
      a url string
      Throws:
      InvalidAddress - if the provided address is invalid
      InvalidName - if the provided Name is invalid
    • 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
      Returns:
      an object
      Throws:
      NotFound - Indicates there is no object reference for the given name.
      CannotProceed - Indicates that the given compound name is incorrect
      InvalidName - if the provided Name was invalid