Class CNCtx

  • All Implemented Interfaces:
    Context

    public class CNCtx
    extends Object
    implements Context
    Provides a bridge to the CosNaming server provided by JavaIDL. This class provides the InitialContext from CosNaming.
    Author:
    Raj Krishnamurthy, Rosanna Lee
    • Field Detail

      • _nc

        public org.omg.CosNaming.NamingContext _nc
    • Method Detail

      • lookup

        public Object lookup​(String name)
                      throws NamingException
        Converts the "String" name into a CompositeName returns the object resolved by the COS Naming api, resolve. Returns the current context if the name is empty. Returns either an org.omg.CORBA.Object or javax.naming.Context object.
        Specified by:
        lookup in interface Context
        Parameters:
        name - string used to resolve the object.
        Returns:
        the resolved object
        Throws:
        NamingException - See callResolve.
      • lookup

        public Object lookup​(Name name)
                      throws NamingException
        Converts the "Name" name into a NameComponent[] object and returns the object resolved by the COS Naming api, resolve. Returns the current context if the name is empty. Returns either an org.omg.CORBA.Object or javax.naming.Context object.
        Specified by:
        lookup in interface Context
        Parameters:
        name - JNDI Name used to resolve the object.
        Returns:
        the resolved object
        Throws:
        NamingException - See callResolve.
      • bind

        public void bind​(Name name,
                         Object obj)
                  throws NamingException
        Converts the "Name" name into a NameComponent[] object and performs the bind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is empty. We need a name to bind the object even when we work within the current context.
        Specified by:
        bind in interface Context
        Parameters:
        name - JNDI Name object
        obj - Object to be bound.
        Throws:
        NamingException - See callBindOrRebind
      • bind

        public void bind​(String name,
                         Object obj)
                  throws NamingException
        Converts the "String" name into a CompositeName object and performs the bind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is empty.
        Specified by:
        bind in interface Context
        Parameters:
        name - string
        obj - Object to be bound.
        Throws:
        NamingException - See callBindOrRebind
      • rebind

        public void rebind​(Name name,
                           Object obj)
                    throws NamingException
        Converts the "Name" name into a NameComponent[] object and performs the rebind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is empty. We must have a name to rebind the object to even if we are working within the current context.
        Specified by:
        rebind in interface Context
        Parameters:
        name - string
        obj - Object to be bound.
        Throws:
        NamingException - See callBindOrRebind
      • rebind

        public void rebind​(String name,
                           Object obj)
                    throws NamingException
        Converts the "String" name into a CompositeName object and performs the rebind operation. Uses callBindOrRebind. Throws an invalid name exception if the name is an empty string.
        Specified by:
        rebind in interface Context
        Parameters:
        name - string
        obj - Object to be bound.
        Throws:
        NamingException - See callBindOrRebind
      • unbind

        public void unbind​(String name)
                    throws NamingException
        Converts the "String" name into a CompositeName object and performs the unbind operation. Uses callUnbind. If the name is empty, throws an invalid name exception. Do we unbind the current context (JNDI spec says work with the current context if the name is empty) ?
        Specified by:
        unbind in interface Context
        Parameters:
        name - string
        Throws:
        NamingException - See callUnbind
      • unbind

        public void unbind​(Name name)
                    throws NamingException
        Converts the "Name" name into a NameComponent[] object and performs the unbind operation. Uses callUnbind. Throws an invalid name exception if the name is empty.
        Specified by:
        unbind in interface Context
        Parameters:
        name - string
        Throws:
        NamingException - See callUnbind
      • rename

        public void rename​(String oldName,
                           String newName)
                    throws NamingException
        Renames an object. Since COS Naming does not support a rename api, this method unbinds the object with the "oldName" and creates a new binding.
        Specified by:
        rename in interface Context
        Parameters:
        oldName - string, existing name for the binding.
        newName - string, name used to replace.
        Throws:
        NamingException - See bind
      • rename

        public void rename​(Name oldName,
                           Name newName)
                    throws NamingException
        Renames an object. Since COS Naming does not support a rename api, this method unbinds the object with the "oldName" and creates a new binding.
        Specified by:
        rename in interface Context
        Parameters:
        oldName - JNDI Name, existing name for the binding.
        newName - JNDI Name, name used to replace.
        Throws:
        NamingException - See bind
      • list

        public NamingEnumeration list​(String name)
                               throws NamingException
        Returns a NameClassEnumeration object which has a list of name class pairs. Lists the current context if the name is empty.
        Specified by:
        list in interface Context
        Parameters:
        name - string
        Returns:
        a list of name-class objects as a NameClassEnumeration.
        Throws:
        NamingException - All exceptions thrown by lookup with a non-null argument
      • list

        public NamingEnumeration list​(Name name)
                               throws NamingException
        Returns a NameClassEnumeration object which has a list of name class pairs. Lists the current context if the name is empty.
        Specified by:
        list in interface Context
        Parameters:
        name - JNDI Name
        Returns:
        a list of name-class objects as a NameClassEnumeration.
        Throws:
        NamingException - All exceptions thrown by lookup
      • listBindings

        public NamingEnumeration listBindings​(String name)
                                       throws NamingException
        Returns a BindingEnumeration object which has a list of name object pairs. Lists the current context if the name is empty.
        Specified by:
        listBindings in interface Context
        Parameters:
        name - string
        Returns:
        a list of bindings as a BindingEnumeration.
        Throws:
        NamingException - all exceptions returned by lookup
      • listBindings

        public NamingEnumeration listBindings​(Name name)
                                       throws NamingException
        Returns a BindingEnumeration object which has a list of name class pairs. Lists the current context if the name is empty.
        Specified by:
        listBindings in interface Context
        Parameters:
        name - JNDI Name
        Returns:
        a list of bindings as a BindingEnumeration.
        Throws:
        NamingException - all exceptions returned by lookup.
      • createSubcontext

        public Context createSubcontext​(String name)
                                 throws NamingException
        Uses the callBindNewContext convenience function to create a new context. Throws an invalid name exception if the name is empty.
        Specified by:
        createSubcontext in interface Context
        Parameters:
        name - string
        Returns:
        the new context object.
        Throws:
        NamingException - See callBindNewContext
      • createSubcontext

        public Context createSubcontext​(Name name)
                                 throws NamingException
        Uses the callBindNewContext convenience function to create a new context. Throws an invalid name exception if the name is empty.
        Specified by:
        createSubcontext in interface Context
        Parameters:
        name - string
        Returns:
        the new context object.
        Throws:
        NamingException - See callBindNewContext
      • addToEnvironment

        public Object addToEnvironment​(String propName,
                                       Object propValue)
                                throws NamingException
        Adds to the environment for the current context. Record change but do not reinitialize ORB.
        Specified by:
        addToEnvironment in interface Context
        Parameters:
        propName - The property name.
        propValue - The ORB.
        Returns:
        the previous value of this property if any.
        Throws:
        NamingException
      • finalize

        protected void finalize()
        Overrides:
        finalize in class Object