@SuppressWarnings("unchecked")
    public T getInstance() {
        try {
            if (requiredType != null) {
                return requiredType.cast(this.lookup(resourceName, requiredType));
            } else {
                return (T) this.lookup(resourceName);
            }
        } catch (NamingException e) {
            final String typeName = requiredType != null ? requiredType.getName() : "object";
            throw new IllegalStateException("Unable to look up " + typeName + " with jndi name '" + resourceName + "'.", e);
        }
    }
A factory implementation intended to be used to look up objects in jndi.

@param <T>
@since 1.2
core/src/main/java/org/apache/shiro/jndi/JndiObjectFactory.java