Class JNDIUtil


  • public class JNDIUtil
    extends Object
    This class helps work with the JNDI tree.
    • Field Detail

      • logger

        private static final org.slf4j.Logger logger
      • PATHS

        private static final String[] PATHS
    • Constructor Detail

      • JNDIUtil

        public JNDIUtil()
    • Method Detail

      • getJNDIProperties

        public static Properties getJNDIProperties​(String prefix)
                                            throws IOException
        This method will return a jndi.properties object that is based on the properties found in ejava-jndi.properties that start with the provided prefix. This method is useful when examples are using different JNDI mechanisms and want to keep them separate by forming the jndi.properties in memory.
        Parameters:
        prefix -
        Returns:
        Properties object that can be used during a new InitialContext(env)
        Throws:
        IOException
      • lookup

        public static <T> T lookup​(Context ctx,
                                   Class<T> type,
                                   String name,
                                   int waitSecs)
                            throws NamingException
        Performs a JNDI lookup and will wait supplied number of seconds before giving up.
        Parameters:
        ctx -
        type -
        name -
        waitSecs -
        Returns:
        Object resolved from the lookup
        Throws:
        NamingException
      • dump

        public String dump()
                    throws NamingException
        Produces a debug string listing the JNDI contents of the current, default Context.
        Returns:
        String describing contents of context
        Throws:
        NamingException
      • dump

        public String dump​(Context context,
                           String name)
        Produces a debug string listing the JNDI contents of the specified Context.
        Parameters:
        context -
        name -
        Returns:
        String describing contents of context
      • isContext

        protected boolean isContext​(String className)
      • getPad

        protected String getPad​(int level)