public class JedisFactory extends java.lang.Object implements PooledObjectFactory<Jedis>
限定符和类型 | 方法和说明 |
---|---|
void |
activateObject(PooledObject<Jedis> pooledJedis)
Reinitializes an instance to be returned by the pool.
|
void |
destroyObject(PooledObject<Jedis> pooledJedis)
Destroys an instance no longer needed by the pool, using the default (NORMAL)
DestroyMode.
|
PooledObject<Jedis> |
makeObject()
Creates an instance that can be served by the pool and wrap it in a
PooledObject to be managed by the pool. |
void |
passivateObject(PooledObject<Jedis> pooledJedis)
Uninitializes an instance to be returned to the idle object pool.
|
void |
setHostAndPort(HostAndPort hostAndPort) |
void |
setPassword(java.lang.String password) |
boolean |
validateObject(PooledObject<Jedis> pooledJedis)
Ensures that the instance is safe to be returned by the pool.
|
destroyObject
public void setHostAndPort(HostAndPort hostAndPort)
public void setPassword(java.lang.String password)
public void activateObject(PooledObject<Jedis> pooledJedis) throws java.lang.Exception
PooledObjectFactory
activateObject
在接口中 PooledObjectFactory<Jedis>
pooledJedis
- a PooledObject
wrapping the instance to be activatedjava.lang.Exception
- if there is a problem activating obj
,
this exception may be swallowed by the pool.PooledObjectFactory.destroyObject(org.apache.commons.pool2.PooledObject<T>)
public void destroyObject(PooledObject<Jedis> pooledJedis) throws java.lang.Exception
PooledObjectFactory
It is important for implementations of this method to be aware that there
is no guarantee about what state obj
will be in and the
implementation should be prepared to handle unexpected errors.
Also, an implementation must take in to consideration that instances lost to the garbage collector may never be destroyed.
destroyObject
在接口中 PooledObjectFactory<Jedis>
pooledJedis
- a PooledObject
wrapping the instance to be destroyedjava.lang.Exception
- should be avoided as it may be swallowed by
the pool implementation.PooledObjectFactory.validateObject(org.apache.commons.pool2.PooledObject<T>)
,
ObjectPool.invalidateObject(T)
public PooledObject<Jedis> makeObject() throws java.lang.Exception
PooledObjectFactory
PooledObject
to be managed by the pool.makeObject
在接口中 PooledObjectFactory<Jedis>
PooledObject
wrapping an instance that can be served by the pooljava.lang.Exception
- if there is a problem creating a new instance,
this will be propagated to the code requesting an object.public void passivateObject(PooledObject<Jedis> pooledJedis) throws java.lang.Exception
PooledObjectFactory
passivateObject
在接口中 PooledObjectFactory<Jedis>
pooledJedis
- a PooledObject
wrapping the instance to be passivatedjava.lang.Exception
- if there is a problem passivating obj
,
this exception may be swallowed by the pool.PooledObjectFactory.destroyObject(org.apache.commons.pool2.PooledObject<T>)
public boolean validateObject(PooledObject<Jedis> pooledJedis)
PooledObjectFactory
validateObject
在接口中 PooledObjectFactory<Jedis>
pooledJedis
- a PooledObject
wrapping the instance to be validatedfalse
if obj
is not valid and should
be dropped from the pool, true
otherwise.