Object target = context.lookup(jndiName);
repositoryName = connInfo.getRepositoryName();
if (target instanceof Repositories) {
logger.trace("JNDI Lookup found Repositories ");
Repositories repositories = (Repositories)target;
if (repositoryName == null) {
repositoryNames = repositories.getRepositoryNames();
if (repositoryNames == null || repositoryNames.isEmpty()) {
throw new SQLException(JdbcLocalI18n.noRepositoryNamesFound.text());
}
if (repositoryNames.size() == 1) {
repositoryName = repositoryNames.iterator().next();
connInfo.setRepositoryName(repositoryName);
logger.trace("Setting Repository {0} as default", repositoryName);
} else {
throw new SQLException(JdbcLocalI18n.objectInJndiIsRepositories.text(jndiName));
}
}
try {
repository = repositories.getRepository(repositoryName);
} catch (RepositoryException e) {
throw new SQLException(JdbcLocalI18n.unableToFindNamedRepository.text(jndiName, repositoryName));
}
} else if (target instanceof Repository) {
logger.trace("JNDI Lookup found a Repository");