| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.admin.ads.util; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Collections; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.ldap.InitialLdapContext; |
| | |
| | | return type; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | return (type+ldapUrl.toLowerCase()).hashCode(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(Object o) |
| | | { |
| | | if (this == o) |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Commodity method that returns a PreferredConnection object with the |
| | | * information on a given InitialLdapContext. |
| | | * @param ctx the connection we retrieve the information from. |
| | | * @return a preferred connection object. |
| | | */ |
| | | public static PreferredConnection getPreferredConnection( |
| | | InitialLdapContext ctx) |
| | | public static PreferredConnection getPreferredConnection(InitialLdapContext ctx) |
| | | { |
| | | String ldapUrl = ConnectionUtils.getLdapUrl(ctx); |
| | | PreferredConnection.Type type; |
| | |
| | | return new PreferredConnection(ldapUrl, type); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Commodity method that generates a list of preferred connection (of just |
| | | * one) with the information on a given InitialLdapContext. |
| | | * @param ctx the connection we retrieve the information from. |
| | | * @return a list containing the preferred connection object. |
| | | */ |
| | | public static Set<PreferredConnection> getPreferredConnections( |
| | | InitialLdapContext ctx) |
| | | public static Set<PreferredConnection> getPreferredConnections(InitialLdapContext ctx) |
| | | { |
| | | PreferredConnection cnx = PreferredConnection.getPreferredConnection(ctx); |
| | | Set<PreferredConnection> returnValue = new LinkedHashSet<>(); |
| | | returnValue.add(cnx); |
| | | return returnValue; |
| | | return Collections.singleton(getPreferredConnection(ctx)); |
| | | } |
| | | } |