Example usage for org.springframework.jndi JndiCallback doInContext

List of usage examples for org.springframework.jndi JndiCallback doInContext

Introduction

In this page you can find the example usage for org.springframework.jndi JndiCallback doInContext.

Prototype

@Nullable
T doInContext(Context ctx) throws NamingException;

Source Link

Document

Do something with the given JNDI context.

Usage

From source file:org.springframework.jndi.JndiTemplate.java

/**
 * Execute the given JNDI context callback implementation.
 * @param contextCallback JndiCallback implementation
 * @return a result object returned by the callback, or {@code null}
 * @throws NamingException thrown by the callback implementation
 * @see #createInitialContext/*from   w  w  w .  j av  a  2  s.c  o  m*/
 */
@Nullable
public <T> T execute(JndiCallback<T> contextCallback) throws NamingException {
    Context ctx = getContext();
    try {
        return contextCallback.doInContext(ctx);
    } finally {
        releaseContext(ctx);
    }
}