From e2656e675a396eec76dffd4f35d3e7a8d8d6ca56 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 4 Dec 2015 10:17:00 -0600 Subject: [PATCH] LDAP-316: Polish --- .../ldap/pool2/DelegatingContext.java | 4 ++-- .../ldap/pool2/DelegatingDirContext.java | 16 +++++++-------- .../ldap/pool2/DelegatingLdapContext.java | 2 +- .../DirContextPoolableObjectFactory.java | 20 ++++++++++--------- .../pool2/factory/PooledContextSource.java | 12 +++++------ 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/pool2/DelegatingContext.java b/core/src/main/java/org/springframework/ldap/pool2/DelegatingContext.java index 06d0b5e0..2ca3b90f 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/DelegatingContext.java +++ b/core/src/main/java/org/springframework/ldap/pool2/DelegatingContext.java @@ -32,7 +32,7 @@ import java.util.Hashtable; * @author Eric Dalquist */ public class DelegatingContext implements Context { - private KeyedObjectPool keyedObjectPool; + private KeyedObjectPool keyedObjectPool; private Context delegateContext; private final DirContextType dirContextType; @@ -45,7 +45,7 @@ public class DelegatingContext implements Context { * @param dirContextType The type of context, used as a key for the pool. * @throws IllegalArgumentException if any of the arguments are null */ - public DelegatingContext(KeyedObjectPool keyedObjectPool, Context delegateContext, DirContextType dirContextType) { + public DelegatingContext(KeyedObjectPool keyedObjectPool, Context delegateContext, DirContextType dirContextType) { Assert.notNull(keyedObjectPool, "keyedObjectPool may not be null"); Assert.notNull(delegateContext, "delegateContext may not be null"); Assert.notNull(dirContextType, "dirContextType may not be null"); diff --git a/core/src/main/java/org/springframework/ldap/pool2/DelegatingDirContext.java b/core/src/main/java/org/springframework/ldap/pool2/DelegatingDirContext.java index 24da594e..93444da1 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/DelegatingDirContext.java +++ b/core/src/main/java/org/springframework/ldap/pool2/DelegatingDirContext.java @@ -42,37 +42,37 @@ public class DelegatingDirContext extends DelegatingContext implements DirContex /** * Create a new delegating dir context for the specified pool, context and context type. - * + * * @param keyedObjectPool The pool the delegate context was checked out from. * @param delegateDirContext The dir context to delegate operations to. * @param dirContextType The type of context, used as a key for the pool. * @throws IllegalArgumentException if any of the arguments are null */ - public DelegatingDirContext(KeyedObjectPool keyedObjectPool, + public DelegatingDirContext(KeyedObjectPool keyedObjectPool, DirContext delegateDirContext, DirContextType dirContextType) { super(keyedObjectPool, delegateDirContext, dirContextType); Assert.notNull(delegateDirContext, "delegateDirContext may not be null"); this.delegateDirContext = delegateDirContext; } - - + + //***** Helper Methods *****// - + /** * @return The direct delegate for this dir context proxy */ public DirContext getDelegateDirContext() { return this.delegateDirContext; } - + public Context getDelegateContext() { return this.getDelegateDirContext(); } /** * Recursivley inspect delegates until a non-delegating dir context is found. - * + * * @return The innermost (real) DirContext that is being delegated to. */ public DirContext getInnermostDelegateDirContext() { @@ -93,7 +93,7 @@ public class DelegatingDirContext extends DelegatingContext implements DirContex super.assertOpen(); } - + //***** Object methods *****// /** diff --git a/core/src/main/java/org/springframework/ldap/pool2/DelegatingLdapContext.java b/core/src/main/java/org/springframework/ldap/pool2/DelegatingLdapContext.java index 1755a5db..3a922e1f 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/DelegatingLdapContext.java +++ b/core/src/main/java/org/springframework/ldap/pool2/DelegatingLdapContext.java @@ -47,7 +47,7 @@ public class DelegatingLdapContext extends DelegatingDirContext implements LdapC * @param dirContextType The type of context, used as a key for the pool. * @throws IllegalArgumentException if any of the arguments are null */ - public DelegatingLdapContext(KeyedObjectPool keyedObjectPool, + public DelegatingLdapContext(KeyedObjectPool keyedObjectPool, LdapContext delegateLdapContext, DirContextType dirContextType) { super(keyedObjectPool, delegateLdapContext, dirContextType); Assert.notNull(delegateLdapContext, "delegateLdapContext may not be null"); diff --git a/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java b/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java index d59566b2..463aed2b 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPoolableObjectFactory.java @@ -43,7 +43,7 @@ import java.util.Set; * configured {@link ContextSource}. The {@link DirContext}s are keyed based * on if they are read only or read/write. The expected key type is the * {@link org.springframework.ldap.pool2.DirContextType} enum. - * + * *
*
* Configuration: @@ -76,16 +76,18 @@ import java.util.Set; * @author Mattias Hellborg Arthursson * @author Anindya Chatterjee */ -class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory { +class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory { /** * Logger for this class and subclasses */ protected final Logger logger = LoggerFactory.getLogger(this.getClass()); private static final Set> DEFAULT_NONTRANSIENT_EXCEPTIONS - = new HashSet>(){{ - add(CommunicationException.class); - }}; + = new HashSet>(); + + static { + DEFAULT_NONTRANSIENT_EXCEPTIONS.add(CommunicationException.class); + }; private ContextSource contextSource; @@ -151,7 +153,7 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory { * * */ @Override - public boolean validateObject(Object key, PooledObject pooledObject) { + public boolean validateObject(Object key, PooledObject pooledObject) { Assert.notNull(this.dirContextValidator, "DirContextValidator may not be null"); Assert.isTrue(key instanceof DirContextType, @@ -179,7 +181,7 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory { * * */ @Override - public void destroyObject(Object key, PooledObject pooledObject) throws Exception { + public void destroyObject(Object key, PooledObject pooledObject) throws Exception { Assert.notNull(pooledObject, "The Object to destroy must not be null"); Assert.isTrue(pooledObject.getObject() instanceof DirContext, @@ -250,8 +252,8 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory { * * */ @Override - public PooledObject wrap(Object value) { - return new DefaultPooledObject(value); + public PooledObject wrap(Object value) { + return new DefaultPooledObject(value); } /** diff --git a/core/src/main/java/org/springframework/ldap/pool2/factory/PooledContextSource.java b/core/src/main/java/org/springframework/ldap/pool2/factory/PooledContextSource.java index 444ae6bf..6ad532dc 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/factory/PooledContextSource.java +++ b/core/src/main/java/org/springframework/ldap/pool2/factory/PooledContextSource.java @@ -37,7 +37,7 @@ import java.util.Collection; * A {@link ContextSource} implementation that wraps an object pool and another * {@link ContextSource}. {@link DirContext}s are retrieved from the pool which * maintains them. - * + * * NOTE: This implementation is based on apache commons-pool2. *
*
@@ -83,7 +83,7 @@ public class PooledContextSource */ protected final Logger logger = LoggerFactory.getLogger(this.getClass()); - protected final GenericKeyedObjectPool keyedObjectPool; + protected final GenericKeyedObjectPool keyedObjectPool; private final DirContextPooledObjectFactory dirContextPooledObjectFactory; @@ -99,10 +99,10 @@ public class PooledContextSource this.poolConfig = poolConfig; GenericKeyedObjectPoolConfig objectPoolConfig = getConfig(poolConfig); this.keyedObjectPool = - new GenericKeyedObjectPool(this.dirContextPooledObjectFactory, objectPoolConfig); + new GenericKeyedObjectPool(this.dirContextPooledObjectFactory, objectPoolConfig); } else { this.keyedObjectPool = - new GenericKeyedObjectPool(this.dirContextPooledObjectFactory); + new GenericKeyedObjectPool(this.dirContextPooledObjectFactory); } } @@ -217,7 +217,7 @@ public class PooledContextSource /* * (non-Javadoc) - * + * * @see org.springframework.beans.factory.DisposableBean#destroy() */ public void destroy() throws Exception { @@ -248,7 +248,7 @@ public class PooledContextSource /** * Gets a DirContext of the specified type from the keyed object pool. - * + * * @param dirContextType The type of context to return. * @return A wrapped DirContext of the specified type. * @throws DataAccessResourceFailureException If retrieving the object from