本文整理匯總了Java中org.apache.commons.pool2.PooledObject.getObject方法的典型用法代碼示例。如果您正苦於以下問題:Java PooledObject.getObject方法的具體用法?Java PooledObject.getObject怎麽用?Java PooledObject.getObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.pool2.PooledObject
的用法示例。
在下文中一共展示了PooledObject.getObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public boolean validateObject(PooledObject<Jedis> pooledJedis) {
final BinaryJedis jedis = pooledJedis.getObject();
try {
HostAndPort hostAndPort = this.hostAndPort.get();
String connectionHost = jedis.getClient().getHost();
int connectionPort = jedis.getClient().getPort();
return hostAndPort.getHost().equals(connectionHost)
&& hostAndPort.getPort() == connectionPort && jedis.isConnected()
&& jedis.ping().equals("PONG");
} catch (final Exception e) {
return false;
}
}
示例2: passivateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void passivateObject(Event.Type key, PooledObject<Event> pooledObject) throws Exception {
final Event event = pooledObject.getObject();
switch (event.type) {
case BEFORE:
unsafe.putObject(event, targetFieldInBeforeEventOffset, null);
unsafe.putObject(event, argumentArrayFieldInBeforeEventOffset, null);
break;
case IMMEDIATELY_THROWS:
case THROWS:
unsafe.putObject(event, throwableFieldInThrowsEventOffset, null);
break;
case IMMEDIATELY_RETURN:
case RETURN:
unsafe.putObject(event, objectFieldInReturnEventOffset, null);
}
}
示例3: validateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public boolean validateObject(PooledObject<Jedis> pooledJedis) {
final BinaryJedis jedis = pooledJedis.getObject();
try {
HostAndPort hostAndPort = this.hostAndPort.get();
String connectionHost = jedis.getClient().getHost();
int connectionPort = jedis.getClient().getPort();
return hostAndPort.getHost().equals(connectionHost)
&& hostAndPort.getPort() == connectionPort && jedis.isConnected()
&& jedis.ping().equals("PONG");
} catch (final Exception e) {
return false;
}
}
示例4: activateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
final BinaryJedis jedis = pooledJedis.getObject();
if (jedis.getDB() != database) {
jedis.select(database);
}
}
示例5: activateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
final BinaryJedis jedis = pooledJedis.getObject();
if (jedis.getDB() != database) {
jedis.select(database);
}
}
示例6: validateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public boolean validateObject(PooledObject<Jedis> pooledJedis) {
final BinaryJedis jedis = pooledJedis.getObject();
try {
HostAndPort hostAndPort = this.hostAndPort.get();
String connectionHost = jedis.getClient().getHost();
int connectionPort = jedis.getClient().getPort();
return hostAndPort.getHost().equals(connectionHost) && hostAndPort.getPort() == connectionPort
&& jedis.isConnected() && jedis.ping().equals("PONG");
} catch (final Exception e) {
return false;
}
}
示例7: validateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public boolean validateObject(PooledObject<ShardedJedis> pooledShardedJedis) {
try {
ShardedJedis jedis = pooledShardedJedis.getObject();
for (Jedis shard : jedis.getAllShards()) {
if (!shard.ping().equals("PONG")) {
return false;
}
}
return true;
} catch (Exception ex) {
return false;
}
}
示例8: destroyObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void destroyObject(ConnectionDetails connectionDetails, PooledObject<Session> sessionObject) {
log.debug("Destroying session for "+connectionDetails);
if (sessionObject != null) {
Session session = sessionObject.getObject();
if (session != null) {
session.disconnect();
}
}
}
示例9: activateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void activateObject(final PooledObject<Session> p) throws BackgroundException {
final Session session = p.getObject();
if(log.isDebugEnabled()) {
log.debug(String.format("Activate session %s", session));
}
// Load vault to increment open count for pooled vault
connect.check(session, cache, new DisabledCancelCallback());
}
示例10: passivateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void passivateObject(final PooledObject<Session> p) throws Exception {
final Session session = p.getObject();
if(log.isDebugEnabled()) {
log.debug(String.format("Pause session %s", session));
}
}
示例11: destroyObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void destroyObject(final PooledObject<Session> p) throws BackgroundException {
final Session session = p.getObject();
if(log.isDebugEnabled()) {
log.debug(String.format("Destroy session %s", session));
}
session.close();
}
示例12: passivateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void passivateObject(PooledObject<PooledFastResource> p) throws Exception {
PooledFastResource resource = p.getObject();
synchronized (resource) {
resource.getStorageServer().close();
resource.getTrackerServer().close();
}
}
示例13: activateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
final BinaryJedis jedis = pooledJedis.getObject();
if (jedis.getDB() != database) {
jedis.select(database);
}
}
示例14: validateObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public boolean validateObject(PooledObject<ShardedJedis> pooledShardedJedis) {
try {
ShardedJedis jedis = pooledShardedJedis.getObject();
for (Jedis shard : jedis.getAllShards()) {
if (!shard.ping().equals("PONG")) {
return false;
}
}
return true;
} catch (Exception ex) {
return false;
}
}
示例15: destroyObject
import org.apache.commons.pool2.PooledObject; //導入方法依賴的package包/類
@Override
public void destroyObject(PooledObject<KuduClient> pooledKuduClient)
throws Exception
{
final KuduClient kuduClient = pooledKuduClient.getObject();
kuduClient.close();
}