/** * Returns an array containing a single entry URL obtained from {@link ConnectionFactoryMetadata#getLdapUrl()}. * * @param metadata which can be used to produce the URL list * * @return list of URLs to attempt connections to */ @Override public String[] getLdapUrls(final ConnectionFactoryMetadata metadata) { if (metadata == null || metadata.getLdapUrl() == null) { return null; } return new String[] {metadata.getLdapUrl()}; } }
/** * Return the URLs in the order they are provided, so that the first URL is always tried first, then the second, and * so forth. * * @param metadata which can be used to produce the URL list * * @return list of URLs to attempt connections to */ @Override public String[] getLdapUrls(final ConnectionFactoryMetadata metadata) { if (metadata == null || metadata.getLdapUrl() == null) { return null; } final String[] urls = metadata.getLdapUrl().split(" "); return urls; } }
/** * Return a list of URLs in random order. * * @param metadata which can be used to produce the URL list * * @return list of URLs to attempt connections to */ @Override public String[] getLdapUrls(final ConnectionFactoryMetadata metadata) { if (metadata == null || metadata.getLdapUrl() == null) { return null; } final List<String> l = Arrays.asList(metadata.getLdapUrl().split(" ")); Collections.shuffle(l); return l.toArray(new String[l.size()]); } }
/** * Return a list of URLs that cycles the list order. The first entry is moved to the end of the list for each * invocation. * * @param metadata which can be used to produce the URL list * * @return list of URLs to attempt connections to */ @Override public String[] getLdapUrls(final ConnectionFactoryMetadata metadata) { if (metadata == null || metadata.getLdapUrl() == null) { return null; } final List<String> l = new ArrayList<>(Arrays.asList(metadata.getLdapUrl().split(" "))); final int count = getCount(metadata.getConnectionCount()); for (int i = 0; i < count % l.size(); i++) { l.add(l.remove(0)); } return l.toArray(new String[l.size()]); }
public String[] getLdapUrls(final ConnectionFactoryMetadata metadata) if (metadata == null || metadata.getLdapUrl() == null) { return null; System.currentTimeMillis() >= srvRecords.get(0).getExpirationTime()) { try { srvRecords = sortSrvRecords(retrieveDNSRecords(metadata.getLdapUrl(), jndiEnv, srvTtl)); } catch (NamingException e) { throw new IllegalArgumentException("Could not retrieve DNS SRV record for " + metadata.getLdapUrl(), e); throw new IllegalArgumentException("No DNS SRV records found for " + metadata.getLdapUrl());