LDAP-316: Polish

This commit is contained in:
Rob Winch
2015-12-04 10:17:00 -06:00
parent 4cefc5b147
commit e2656e675a
5 changed files with 28 additions and 26 deletions

View File

@@ -32,7 +32,7 @@ import java.util.Hashtable;
* @author Eric Dalquist
*/
public class DelegatingContext implements Context {
private KeyedObjectPool keyedObjectPool;
private KeyedObjectPool<Object,Object> 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<Object,Object> 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");

View File

@@ -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<Object,Object> 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 *****//
/**

View File

@@ -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<Object,Object> keyedObjectPool,
LdapContext delegateLdapContext, DirContextType dirContextType) {
super(keyedObjectPool, delegateLdapContext, dirContextType);
Assert.notNull(delegateLdapContext, "delegateLdapContext may not be null");

View File

@@ -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.
*
*
* <br>
* <br>
* Configuration: <table border="1">
@@ -76,16 +76,18 @@ import java.util.Set;
* @author Mattias Hellborg Arthursson
* @author Anindya Chatterjee
*/
class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory {
class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory<Object,Object> {
/**
* Logger for this class and subclasses
*/
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
private static final Set<Class<? extends Throwable>> DEFAULT_NONTRANSIENT_EXCEPTIONS
= new HashSet<Class<? extends Throwable>>(){{
add(CommunicationException.class);
}};
= new HashSet<Class<? extends Throwable>>();
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<Object> 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<Object> 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<Object> wrap(Object value) {
return new DefaultPooledObject<Object>(value);
}
/**

View File

@@ -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.
* <br>
* <br>
@@ -83,7 +83,7 @@ public class PooledContextSource
*/
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final GenericKeyedObjectPool keyedObjectPool;
protected final GenericKeyedObjectPool<Object,Object> 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<Object,Object>(this.dirContextPooledObjectFactory, objectPoolConfig);
} else {
this.keyedObjectPool =
new GenericKeyedObjectPool(this.dirContextPooledObjectFactory);
new GenericKeyedObjectPool<Object,Object>(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