类 JndiTemplate

    • 字段详细资料

    • 构造器详细资料

      • JndiTemplate

        public JndiTemplate()
        Create a new JndiTemplate instance.
      • JndiTemplate

        public JndiTemplate​(Properties environment)
        Create a new JndiTemplate instance, using the given environment.
    • 方法详细资料

      • createInitialContext

        protected Context createInitialContext()
                                        throws NamingException
        Create a new JNDI initial context. Invoked by getContext().

        The default implementation use this template's environment settings. Can be subclassed for custom contexts, e.g. for testing.

        返回:
        the initial Context instance
        抛出:
        NamingException - in case of initialization errors
      • lookup

        public Object lookup​(String name)
                      throws NamingException
        Look up the object with the given name in the current JNDI context.
        参数:
        name - the JNDI name of the object
        返回:
        object found (cannot be null; if a not so well-behaved JNDI implementations returns null, a NamingException gets thrown)
        抛出:
        NamingException - if there is no object with the given name bound to JNDI
      • lookup

        public <T> T lookup​(String name,
                            Class<T> requiredType)
                     throws NamingException
        Look up the object with the given name in the current JNDI context.
        参数:
        name - the JNDI name of the object
        requiredType - type the JNDI object must match. Can be an interface or superclass of the actual class, or null for any match. For example, if the value is Object.class, this method will succeed whatever the class of the returned instance.
        返回:
        object found (cannot be null; if a not so well-behaved JNDI implementations returns null, a NamingException gets thrown)
        抛出:
        NamingException - if there is no object with the given name bound to JNDI
      • bind

        public void bind​(String name,
                         Object object)
                  throws NamingException
        Bind the given object to the current JNDI context, using the given name.
        参数:
        name - the JNDI name of the object
        object - the object to bind
        抛出:
        NamingException - thrown by JNDI, mostly name already bound
      • rebind

        public void rebind​(String name,
                           Object object)
                    throws NamingException
        Rebind the given object to the current JNDI context, using the given name. Overwrites any existing binding.
        参数:
        name - the JNDI name of the object
        object - the object to rebind
        抛出:
        NamingException - thrown by JNDI