Interface JndiCallback<T>

  • Type Parameters:
    T - the resulting object type
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    public interface JndiCallback<T>
    Callback interface to be implemented by classes that need to perform an operation (such as a lookup) in a JNDI context. This callback approach is valuable in simplifying error handling, which is performed by the JndiTemplate class. This is a similar to JdbcTemplate's approach.

    Note that there is hardly any need to implement this callback interface, as JndiTemplate provides all usual JNDI operations via convenience methods.

    Rod Johnson
    See Also:
    JndiTemplate, JdbcTemplate
    • Method Detail

      • doInContext

        T doInContext(javax.naming.Context ctx)
                         throws javax.naming.NamingException
        Do something with the given JNDI context.

        Implementations don't need to worry about error handling or cleanup, as the JndiTemplate class will handle this.

        ctx - the current JNDI context
        a result object, or null
        javax.naming.NamingException - if thrown by JNDI methods