* (for compatibility with Google App Engine's API white list).
*/
private class LocatorDelegate {
public <T> T lookup(String jndiName, Class<T> requiredType) throws Exception {
JndiLocatorDelegate locator = new JndiLocatorDelegate();
if (jndiEnvironment instanceof JndiTemplate) {
locator.setJndiTemplate((JndiTemplate) jndiEnvironment);
}
else if (jndiEnvironment instanceof Properties) {
locator.setJndiEnvironment((Properties) jndiEnvironment);
}
else if (jndiEnvironment != null) {
throw new IllegalStateException("Illegal 'jndiEnvironment' type: " + jndiEnvironment.getClass());
}
locator.setResourceRef(resourceRef);
return locator.lookup(jndiName, requiredType);
}