Class JNDIConnectionManager
java.lang.Object
de.hybris.platform.ldap.connection.JNDIConnectionManager
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 Summary
ConstructorsConstructorDescriptionCreate a new connection manager.JNDIConnectionManager(ConnectionData connectionData) -
Method Summary
Modifier and TypeMethodDescriptionvoidHandles failback to the primary server.protected static booleancheckIfExceptionIsFailable(NamingException exception) This static method is used to determine if an exception of runtime type NamingException is eligable for a server failover.final voiddumps the current JNDI configuration.DEBUG mode has to be enabled.Value of "java.naming.security.credentials" will be skippedprotected final voiddumpConfiguration(Hashtable<String, String> environment) protected voidfailCurrentServer(Exception reasonForFailure) Fails the current server.getDirContext(JNDIConnectionImpl conn, String connectDN, char[] connectPassword) Fetch a working DirContext connection from the pool.booleanChecks to see if the current server is actually functioning or not.voidsetConnection(ConnectionData connectionData) Sets the configuration used by the class.
-
Constructor Details
-
JNDIConnectionManager
public JNDIConnectionManager()Create a new connection manager. setConfig must be called before accessing any other method in this class. -
JNDIConnectionManager
-
-
Method Details
-
setConnection
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
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:
LDAPUnavailableExceptionNamingException
-
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
-
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
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.
-