Class AbstractContext

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ContextAccess contextAccess  
      private java.lang.ThreadLocal<javax.naming.Name> inCall  
      private boolean modifiable  
      private java.lang.String nameInNamespace  
      private javax.naming.Name parsedNameInNamespace  
      private static long serialVersionUID  
      • Fields inherited from interface javax.naming.Context

        APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractContext​(java.lang.String nameInNamespace)  
        AbstractContext​(java.lang.String nameInNamespace, ContextAccess contextAccess)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract boolean addBinding​(java.lang.String name, java.lang.Object value, boolean rebind)  
      protected void addBinding​(javax.naming.Context context, java.lang.String name, java.lang.Object value, boolean rebind)
      Binds the specified value to the specified name within the specified context.
      protected void addDeepBinding​(javax.naming.Name name, java.lang.Object value, boolean rebind, boolean createIntermediateContexts)  
      java.lang.Object addToEnvironment​(java.lang.String propName, java.lang.Object propVal)  
      void bind​(java.lang.String name, java.lang.Object obj)  
      void bind​(javax.naming.Name name, java.lang.Object obj)  
      void close()  
      java.lang.String composeName​(java.lang.String name, java.lang.String prefix)  
      javax.naming.Name composeName​(javax.naming.Name name, javax.naming.Name prefix)  
      javax.naming.Context createSubcontext​(java.lang.String name)  
      javax.naming.Context createSubcontext​(javax.naming.Name name)  
      protected javax.naming.Context createSubcontextTree​(java.lang.String path, javax.naming.Name name, java.lang.Object value)
      Creates a context tree which will be rooted at the specified path and contain a single entry located down a path specified by the name.
      void destroySubcontext​(java.lang.String name)  
      void destroySubcontext​(javax.naming.Name name)  
      protected java.lang.Object faultLookup​(java.lang.String stringName, javax.naming.Name parsedName)
      When a value can not be found within this context, this method is called as a last ditch effort befrore thowing a null pointer exception.
      protected java.lang.Object getBinding​(java.lang.String name)
      Gets the object bound to the name.
      private static java.lang.Object getBinding​(javax.naming.Context context, java.lang.String name)
      Gets the value bound to the specified name within the specified context.
      protected abstract java.util.Map<java.lang.String,​java.lang.Object> getBindings()
      Gets a map of the bindings for the current node (i.e., no names with slashes).
      protected ContextAccess getContextAccess()  
      protected java.lang.Object getDeepBinding​(java.lang.String name)
      Gets the object bound to the name.
      java.util.Hashtable getEnvironment()
      Always returns a new (empty) Hashtable.
      java.lang.String getNameInNamespace()
      Gets the name of this context withing the global namespace.
      protected java.lang.String getNameInNamespace​(java.lang.String path)
      Gets the name of a path withing the global namespace context.
      protected javax.naming.Name getNameInNamespace​(javax.naming.Name path)
      Gets the name of a path withing the global namespace context.
      protected javax.naming.NameParser getNameParser()
      A parser that can turn Strings into javax.naming.Name objects.
      javax.naming.NameParser getNameParser​(java.lang.String name)  
      javax.naming.NameParser getNameParser​(javax.naming.Name name)  
      protected javax.naming.Name getParsedNameInNamespace()
      Gets the name of this context withing the global namespace.
      protected static int getSize​(javax.naming.Context context)  
      protected static boolean isEmpty​(javax.naming.Context context)  
      protected javax.naming.NamingEnumeration<javax.naming.NameClassPair> list()  
      javax.naming.NamingEnumeration<javax.naming.NameClassPair> list​(java.lang.String name)  
      javax.naming.NamingEnumeration<javax.naming.NameClassPair> list​(javax.naming.Name name)  
      protected javax.naming.NamingEnumeration<javax.naming.Binding> listBindings()  
      javax.naming.NamingEnumeration<javax.naming.Binding> listBindings​(java.lang.String name)  
      javax.naming.NamingEnumeration<javax.naming.Binding> listBindings​(javax.naming.Name name)  
      java.lang.Object lookup​(java.lang.String name)  
      protected java.lang.Object lookup​(java.lang.String stringName, javax.naming.Name parsedName)
      Finds the specified entry.
      java.lang.Object lookup​(javax.naming.Name name)  
      protected javax.naming.Context lookupFinalContext​(javax.naming.Name name)  
      java.lang.Object lookupLink​(java.lang.String name)  
      java.lang.Object lookupLink​(javax.naming.Name name)  
      void rebind​(java.lang.String name, java.lang.Object obj)  
      void rebind​(javax.naming.Name name, java.lang.Object obj)  
      protected abstract boolean removeBinding​(java.lang.String name, boolean removeNotEmptyContext)
      Removes the binding from the context.
      protected void removeDeepBinding​(javax.naming.Name name, boolean pruneEmptyContexts)  
      protected void removeDeepBinding​(javax.naming.Name name, boolean pruneEmptyContexts, boolean removeNotEmptyContext)  
      java.lang.Object removeFromEnvironment​(java.lang.String propName)  
      void rename​(java.lang.String oldName, java.lang.String newName)  
      void rename​(javax.naming.Name oldName, javax.naming.Name newName)  
      void unbind​(java.lang.String name)  
      private void unbind​(javax.naming.Context context, java.lang.String name, boolean removeNotEmptyContext)
      Unbinds any value bound to the specified name within the specified context.
      void unbind​(javax.naming.Name name)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nameInNamespace

        private final java.lang.String nameInNamespace
      • parsedNameInNamespace

        private final javax.naming.Name parsedNameInNamespace
      • modifiable

        private final boolean modifiable
      • inCall

        private final java.lang.ThreadLocal<javax.naming.Name> inCall
    • Constructor Detail

      • AbstractContext

        protected AbstractContext​(java.lang.String nameInNamespace)
      • AbstractContext

        public AbstractContext​(java.lang.String nameInNamespace,
                               ContextAccess contextAccess)
    • Method Detail

      • close

        public void close()
                   throws javax.naming.NamingException
        Specified by:
        close in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • getDeepBinding

        protected java.lang.Object getDeepBinding​(java.lang.String name)
        Gets the object bound to the name. The name may contain slashes.
        Parameters:
        name - the name
        Returns:
        the object bound to the name, or null if not found
      • getBinding

        protected java.lang.Object getBinding​(java.lang.String name)
                                       throws javax.naming.NamingException
        Gets the object bound to the name. The name will not contain slashes.
        Parameters:
        name - the name
        Returns:
        the object bound to the name, or null if not found
        Throws:
        javax.naming.NamingException - on error
      • lookup

        protected java.lang.Object lookup​(java.lang.String stringName,
                                          javax.naming.Name parsedName)
                                   throws javax.naming.NamingException
        Finds the specified entry. Normally there is no need to override this method; instead you should simply implement the getDeepBindings(String) and getBindings(String) method. This method will follow links except for the final element which is always just returned without inspection. This means this method can be used to implement lookupLink.
        Parameters:
        stringName - the string version of the name; maybe null
        parsedName - the parsed name; may be null
        Returns:
        the value bound to the name
        Throws:
        javax.naming.NamingException - if no value is bound to that name or if a problem occurs during the lookup
      • faultLookup

        protected java.lang.Object faultLookup​(java.lang.String stringName,
                                               javax.naming.Name parsedName)
        When a value can not be found within this context, this method is called as a last ditch effort befrore thowing a null pointer exception.
        Parameters:
        stringName - the string version of the name; will not be null
        parsedName - the parsed name; will not be null
        Returns:
        the value or null if no fault value could be found
      • lookupFinalContext

        protected javax.naming.Context lookupFinalContext​(javax.naming.Name name)
                                                   throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • getBindings

        protected abstract java.util.Map<java.lang.String,​java.lang.Object> getBindings()
                                                                                       throws javax.naming.NamingException
        Gets a map of the bindings for the current node (i.e., no names with slashes). This method must not return null.
        Returns:
        a Map from binding name to binding value
        Throws:
        javax.naming.NamingException - if a problem occurs while getting the bindigns
      • addDeepBinding

        protected void addDeepBinding​(javax.naming.Name name,
                                      java.lang.Object value,
                                      boolean rebind,
                                      boolean createIntermediateContexts)
                               throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • getBinding

        private static java.lang.Object getBinding​(javax.naming.Context context,
                                                   java.lang.String name)
        Gets the value bound to the specified name within the specified context. If the specified context is an AbstractContext this method will call the faster getBinding method, otherwise it will call lookup.
        Parameters:
        context - the context to get the binding from
        name - the binding name
        Returns:
        the bound value or null if no value was bound
      • addBinding

        protected void addBinding​(javax.naming.Context context,
                                  java.lang.String name,
                                  java.lang.Object value,
                                  boolean rebind)
                           throws javax.naming.NamingException
        Binds the specified value to the specified name within the specified context. If the specified context is an AbstractContext and is a nested subcontext, this method will call the direct addBinding method, otherwise it will call public (re)bind method.
        Parameters:
        context - the context to add the binding to
        name - the binding name
        value - the value to bind
        rebind - if true, this method will replace any exsiting binding, otherwise a NamingException will be thrown
        Throws:
        javax.naming.NamingException - if a problem occurs while (re)binding
      • addBinding

        protected abstract boolean addBinding​(java.lang.String name,
                                              java.lang.Object value,
                                              boolean rebind)
                                       throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • createSubcontextTree

        protected javax.naming.Context createSubcontextTree​(java.lang.String path,
                                                            javax.naming.Name name,
                                                            java.lang.Object value)
                                                     throws javax.naming.NamingException
        Creates a context tree which will be rooted at the specified path and contain a single entry located down a path specified by the name. All necessary intermediate contexts will be created using the createContext method.
        Parameters:
        path - the path to the context that will contains this context
        name - the name under which the value should be bound
        value - the value
        Returns:
        a context with the value bound at the specified name
        Throws:
        javax.naming.NamingException - if a problem occurs while creating the subcontext tree
      • removeBinding

        protected abstract boolean removeBinding​(java.lang.String name,
                                                 boolean removeNotEmptyContext)
                                          throws javax.naming.NamingException
        Removes the binding from the context. The name will not contain a path and the value will not be a nested context although it may be a foreign context.
        Parameters:
        name - name under which the value should be bound
        removeNotEmptyContext - ??? TODO figure this out
        Returns:
        whether removal was successful
        Throws:
        javax.naming.NamingException - if a problem occurs during the bind such as a value already being bound
      • removeDeepBinding

        protected void removeDeepBinding​(javax.naming.Name name,
                                         boolean pruneEmptyContexts)
                                  throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • removeDeepBinding

        protected void removeDeepBinding​(javax.naming.Name name,
                                         boolean pruneEmptyContexts,
                                         boolean removeNotEmptyContext)
                                  throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • isEmpty

        protected static boolean isEmpty​(javax.naming.Context context)
                                  throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • getSize

        protected static int getSize​(javax.naming.Context context)
                              throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • unbind

        private void unbind​(javax.naming.Context context,
                            java.lang.String name,
                            boolean removeNotEmptyContext)
                     throws javax.naming.NamingException
        Unbinds any value bound to the specified name within the specified context. If the specified context is an AbstractContext and is a nested context, this method will call the direct removeBinding method, otherwise it will call public unbind.
        Parameters:
        context - the context to remove the binding from
        name - the binding name
        removeNotEmptyContext - ??? TODO figure this out
        Throws:
        javax.naming.NamingException - if a problem occurs while unbinding
      • getEnvironment

        public java.util.Hashtable getEnvironment()
        Always returns a new (empty) Hashtable.
        Specified by:
        getEnvironment in interface javax.naming.Context
        Returns:
        a new (empty) Hashtable
      • addToEnvironment

        public java.lang.Object addToEnvironment​(java.lang.String propName,
                                                 java.lang.Object propVal)
                                          throws javax.naming.NamingException
        Specified by:
        addToEnvironment in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • removeFromEnvironment

        public java.lang.Object removeFromEnvironment​(java.lang.String propName)
                                               throws javax.naming.NamingException
        Specified by:
        removeFromEnvironment in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • getNameInNamespace

        public java.lang.String getNameInNamespace()
        Gets the name of this context withing the global namespace. This method may return null if the location of the node in the global namespace is not known
        Specified by:
        getNameInNamespace in interface javax.naming.Context
        Returns:
        the name of this context within the global namespace or null if unknown.
      • getParsedNameInNamespace

        protected javax.naming.Name getParsedNameInNamespace()
        Gets the name of this context withing the global namespace. This method may return null if the location of the node in the global namespace is not known
        Returns:
        the name of this context within the global namespace or null if unknown.
      • getNameInNamespace

        protected java.lang.String getNameInNamespace​(java.lang.String path)
        Gets the name of a path withing the global namespace context.
        Parameters:
        path - path to extend
        Returns:
        full path in namespace
      • getNameInNamespace

        protected javax.naming.Name getNameInNamespace​(javax.naming.Name path)
                                                throws javax.naming.NamingException
        Gets the name of a path withing the global namespace context.
        Parameters:
        path - path to extend
        Returns:
        full path in namespace
        Throws:
        javax.naming.NamingException - on error
      • getNameParser

        protected javax.naming.NameParser getNameParser()
        A parser that can turn Strings into javax.naming.Name objects.
        Returns:
        ContextUtil.NAME_PARSER
      • getNameParser

        public javax.naming.NameParser getNameParser​(javax.naming.Name name)
        Specified by:
        getNameParser in interface javax.naming.Context
      • getNameParser

        public javax.naming.NameParser getNameParser​(java.lang.String name)
        Specified by:
        getNameParser in interface javax.naming.Context
      • composeName

        public javax.naming.Name composeName​(javax.naming.Name name,
                                             javax.naming.Name prefix)
                                      throws javax.naming.NamingException
        Specified by:
        composeName in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • composeName

        public java.lang.String composeName​(java.lang.String name,
                                            java.lang.String prefix)
                                     throws javax.naming.NamingException
        Specified by:
        composeName in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • lookup

        public java.lang.Object lookup​(java.lang.String name)
                                throws javax.naming.NamingException
        Specified by:
        lookup in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • lookup

        public java.lang.Object lookup​(javax.naming.Name name)
                                throws javax.naming.NamingException
        Specified by:
        lookup in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • lookupLink

        public java.lang.Object lookupLink​(java.lang.String name)
                                    throws javax.naming.NamingException
        Specified by:
        lookupLink in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • lookupLink

        public java.lang.Object lookupLink​(javax.naming.Name name)
                                    throws javax.naming.NamingException
        Specified by:
        lookupLink in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • bind

        public void bind​(java.lang.String name,
                         java.lang.Object obj)
                  throws javax.naming.NamingException
        Specified by:
        bind in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • bind

        public void bind​(javax.naming.Name name,
                         java.lang.Object obj)
                  throws javax.naming.NamingException
        Specified by:
        bind in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • rebind

        public void rebind​(java.lang.String name,
                           java.lang.Object obj)
                    throws javax.naming.NamingException
        Specified by:
        rebind in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • rebind

        public void rebind​(javax.naming.Name name,
                           java.lang.Object obj)
                    throws javax.naming.NamingException
        Specified by:
        rebind in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • rename

        public void rename​(java.lang.String oldName,
                           java.lang.String newName)
                    throws javax.naming.NamingException
        Specified by:
        rename in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • rename

        public void rename​(javax.naming.Name oldName,
                           javax.naming.Name newName)
                    throws javax.naming.NamingException
        Specified by:
        rename in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • unbind

        public void unbind​(java.lang.String name)
                    throws javax.naming.NamingException
        Specified by:
        unbind in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • unbind

        public void unbind​(javax.naming.Name name)
                    throws javax.naming.NamingException
        Specified by:
        unbind in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • list

        protected javax.naming.NamingEnumeration<javax.naming.NameClassPair> list()
                                                                           throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • listBindings

        protected javax.naming.NamingEnumeration<javax.naming.Binding> listBindings()
                                                                             throws javax.naming.NamingException
        Throws:
        javax.naming.NamingException
      • list

        public javax.naming.NamingEnumeration<javax.naming.NameClassPair> list​(java.lang.String name)
                                                                        throws javax.naming.NamingException
        Specified by:
        list in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • list

        public javax.naming.NamingEnumeration<javax.naming.NameClassPair> list​(javax.naming.Name name)
                                                                        throws javax.naming.NamingException
        Specified by:
        list in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • listBindings

        public javax.naming.NamingEnumeration<javax.naming.Binding> listBindings​(java.lang.String name)
                                                                          throws javax.naming.NamingException
        Specified by:
        listBindings in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • listBindings

        public javax.naming.NamingEnumeration<javax.naming.Binding> listBindings​(javax.naming.Name name)
                                                                          throws javax.naming.NamingException
        Specified by:
        listBindings in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • createSubcontext

        public javax.naming.Context createSubcontext​(java.lang.String name)
                                              throws javax.naming.NamingException
        Specified by:
        createSubcontext in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • createSubcontext

        public javax.naming.Context createSubcontext​(javax.naming.Name name)
                                              throws javax.naming.NamingException
        Specified by:
        createSubcontext in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • destroySubcontext

        public void destroySubcontext​(java.lang.String name)
                               throws javax.naming.NamingException
        Specified by:
        destroySubcontext in interface javax.naming.Context
        Throws:
        javax.naming.NamingException
      • destroySubcontext

        public void destroySubcontext​(javax.naming.Name name)
                               throws javax.naming.NamingException
        Specified by:
        destroySubcontext in interface javax.naming.Context
        Throws:
        javax.naming.NamingException