/** * Returns the supplied connection count if {@link #useConnectionCount} is true. Otherwise returns {@link * #invocationCount}. * * @param connectionCount as reported by the connection * * @return count used to reorder the URL list */ protected int getCount(final int connectionCount) { if (useConnectionCount) { return connectionCount; } return returnAndIncrementInvocationCount(); }
/** * 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()]); }