Class JNDIConnectionManager

java.lang.Object
de.hybris.platform.ldap.connection.JNDIConnectionManager

public class JNDIConnectionManager extends Object
This class assists the JNDIConnectionImpl implementation with managing (and failing over) multiple servers. It is instantiated as a static singleton by the JDNIConnectionImpl and should not be used outside this package.
  • Constructor Details

    • JNDIConnectionManager

      public JNDIConnectionManager()
      Create a new connection manager. setConfig must be called before accessing any other method in this class.
    • JNDIConnectionManager

      public JNDIConnectionManager(ConnectionData connectionData)
  • Method Details

    • setConnection

      public void setConnection(ConnectionData connectionData)
      Sets the configuration used by the class. This method must be called once before any other method is used. It is not part of the constructor to help ease the singleton implementation.
      Parameters:
      connectionData -
    • failCurrentServer

      protected void failCurrentServer(Exception reasonForFailure)
      Fails the current server. Note that this method is time locked so if there is more then one thread that calls this method within the configured ldap timeout period, only one failover command is issued and all other threads are paused for a while. This helps prevent extra burden on the directory server and to many failovers.
      Parameters:
      reasonForFailure - the original exception that prompted the failover cycle.
    • getDirContext

      public LdapContext getDirContext(JNDIConnectionImpl conn, String connectDN, char[] connectPassword) throws LDAPUnavailableException, NamingException
      Fetch a working DirContext connection from the pool. If the current pool is broken it will try all available servers until a working one is found.
      Parameters:
      connectDN -
      connectPassword -
      Returns:
      a working DirContext connection from the pool
      Throws:
      LDAPUnavailableException
      NamingException
    • dumpConfiguration

      public final void dumpConfiguration()
      dumps the current JNDI configuration.
      DEBUG mode has to be enabled.
      Value of "java.naming.security.credentials" will be skipped
    • dumpConfiguration

      protected final void dumpConfiguration(Hashtable<String,String> environment)
    • getServerURL

      public String getServerURL()
    • checkForFailBack

      public void checkForFailBack()
      Handles failback to the primary server. If the current server is the primary server, this method does nothing. Otherwise, if it has been greater then the minimum fail back time, the current server is reset to the primary server.
    • isCurrentServerAvailable

      public boolean isCurrentServerAvailable()
      Checks to see if the current server is actually functioning or not. This is used during failover requests to prevent a ton of failover requests from perpetually failing over the list.
      Returns:
      true if the current server is accessable, false if it is unavailable.
    • checkIfExceptionIsFailable

      protected static boolean checkIfExceptionIsFailable(NamingException exception)
      This static method is used to determine if an exception of runtime type NamingException is eligable for a server failover.
      Parameters:
      exception -
      Returns:
      true if the exception should be considered a server failure, false if its not.