class JcrRepositoriesContainer implements RepositoriesContainer {

    @Override
    public Set<String> getRepositoryNames( Map<?, ?> parameters ) throws RepositoryException {
        Set<String> repositoryNames = engine().getRepositoryNames();

        String repositoryURL = repositoryURLFromParams(parameters);
        if (repositoryURL == null) {
            LOG.debug("No repository URL parameter found");
            return repositoryNames;
        }

        if (repositoryURL.toLowerCase().startsWith(JNDI_PROTOCOL)) {
            Set<String> jndiRepositories = new JNDIRepositoryLookup().repositoryNames(parameters, repositoryURL);
            repositoryNames.addAll(jndiRepositories);
        } else {
            // based on the parameters try to lookup a repository (note that this may actually start it)
            JcrRepository repository = new UrlRepositoryLookup().repository(parameters, repositoryURL);
            if (repository != null) {
                repositoryNames.add(repository.getName());
            }
        }
        return repositoryNames;
    }

}