Loading projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/ConnectionPools.java +11 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; /** * The object that is bound in JNDI to hold the LDAP pools. */ Loading @@ -82,6 +84,7 @@ public class ConnectionPools private LdapConfig config; private Map<String,LdapConnectionPool> pools; private static final Logger logger = Logger.getLogger(ConnectionPools.class); private long lastPoolCheck = System.currentTimeMillis(); private boolean isClosed; Loading Loading @@ -120,8 +123,15 @@ public class ConnectionPools while (i.hasNext()) { LdapConnectionPool next = i.next(); try { next.shutdown(); } catch (Throwable t) { logger.warn("Could not shutdown pool " + next.getName(), t); } } isClosed = true; } Loading projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnectionPool.java +5 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,11 @@ public class LdapConnectionPool profiler.checkpoint("Pool closed."); } public String getName() { return poolName; } private LDAPConnectionPool createPool(LdapConfig config, LdapPool poolConfig, String poolName, String bindID, String bindPW) { Loading projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapPersistence.java +34 −15 Original line number Diff line number Diff line Loading @@ -155,7 +155,14 @@ public abstract class LdapPersistence pools.close(); } } } } catch (NamingException e) { throw new IllegalStateException("JNDI error", e); } finally { // unbind the pool try { Loading @@ -168,13 +175,6 @@ public abstract class LdapPersistence } } } catch (NamingException e) { throw new IllegalStateException("JNDI error", e); } } private void initPools() { Loading @@ -186,14 +186,33 @@ public abstract class LdapPersistence if (pools == null) { synchronized (jndiMonitor) { try { pools = lookupPools(); logger.debug("Pool from second JNDI lookup: " + pools); } catch (Throwable t) { logger.warn("Failure looking up pool from JNDI, re-initializing", t); pools = null; } if (pools == null) { LdapConfig config = LdapConfig.getLdapConfig(); pools = createPools(config); InitialContext ic = new InitialContext(); try { // unbind just to be safe ic.unbind(LDAP_POOL_JNDI_NAME); logger.warn("Unbound previously bound pool"); } catch (NamingException e) { // happens when nothing to unbind, expected logger.debug("No pool to unbind"); } ic.bind(LDAP_POOL_JNDI_NAME, pools); profiler.checkpoint("Bound LDAP pools to JNDI"); logger.debug("Bound LDAP pools to JNDI"); Loading Loading
projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/ConnectionPools.java +11 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; /** * The object that is bound in JNDI to hold the LDAP pools. */ Loading @@ -82,6 +84,7 @@ public class ConnectionPools private LdapConfig config; private Map<String,LdapConnectionPool> pools; private static final Logger logger = Logger.getLogger(ConnectionPools.class); private long lastPoolCheck = System.currentTimeMillis(); private boolean isClosed; Loading Loading @@ -120,8 +123,15 @@ public class ConnectionPools while (i.hasNext()) { LdapConnectionPool next = i.next(); try { next.shutdown(); } catch (Throwable t) { logger.warn("Could not shutdown pool " + next.getName(), t); } } isClosed = true; } Loading
projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnectionPool.java +5 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,11 @@ public class LdapConnectionPool profiler.checkpoint("Pool closed."); } public String getName() { return poolName; } private LDAPConnectionPool createPool(LdapConfig config, LdapPool poolConfig, String poolName, String bindID, String bindPW) { Loading
projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapPersistence.java +34 −15 Original line number Diff line number Diff line Loading @@ -155,7 +155,14 @@ public abstract class LdapPersistence pools.close(); } } } } catch (NamingException e) { throw new IllegalStateException("JNDI error", e); } finally { // unbind the pool try { Loading @@ -168,13 +175,6 @@ public abstract class LdapPersistence } } } catch (NamingException e) { throw new IllegalStateException("JNDI error", e); } } private void initPools() { Loading @@ -186,14 +186,33 @@ public abstract class LdapPersistence if (pools == null) { synchronized (jndiMonitor) { try { pools = lookupPools(); logger.debug("Pool from second JNDI lookup: " + pools); } catch (Throwable t) { logger.warn("Failure looking up pool from JNDI, re-initializing", t); pools = null; } if (pools == null) { LdapConfig config = LdapConfig.getLdapConfig(); pools = createPools(config); InitialContext ic = new InitialContext(); try { // unbind just to be safe ic.unbind(LDAP_POOL_JNDI_NAME); logger.warn("Unbound previously bound pool"); } catch (NamingException e) { // happens when nothing to unbind, expected logger.debug("No pool to unbind"); } ic.bind(LDAP_POOL_JNDI_NAME, pools); profiler.checkpoint("Bound LDAP pools to JNDI"); logger.debug("Bound LDAP pools to JNDI"); Loading