List of usage examples for org.apache.commons.pool2 PooledObject getObject
T getObject();
From source file:org.eclipse.kapua.transport.mqtt.pooling.PooledMqttClientFactory.java
/** * Validates status of the given {@link MqttClient} pooled object. * //from w w w.j av a 2 s.co m * <p> * Check performed for the client to be marked as valid are: * </p> * <ul> * <li>{@link MqttClient} {@code != null}</li> * <li>{@link MqttClient#isConnected()} {@code == true}</li> * </ul> * * @param pooledMqttClient * The object to validate. * * @since 1.0.0 */ @Override public boolean validateObject(PooledObject<MqttClient> pooledMqttClient) { MqttClient mqttClient = pooledMqttClient.getObject(); return (mqttClient != null && mqttClient.isConnected()); }
From source file:org.eclipse.kapua.transport.mqtt.pooling.PooledMqttClientFactory.java
/** * Destroys the given {@link MqttClient} pooled object. * <p>/* w w w . ja v a2 s .c om*/ * Before calling super implementation {@link BasePooledObjectFactory#destroyObject(PooledObject)} it tries to clean up the {@link MqttClient}. * </p> * * @param pooledMqttClient * The pooled object to destroy. * * @since 1.0.0. */ @Override public void destroyObject(PooledObject<MqttClient> pooledMqttClient) throws Exception { MqttClient mqttClient = pooledMqttClient.getObject(); if (mqttClient != null) { if (mqttClient.isConnected()) { mqttClient.disconnectClient(); } mqttClient.terminateClient(); } super.destroyObject(pooledMqttClient); }
From source file:org.geosdi.geoplatform.connector.api.pool.GPPoolConnectorFactory.java
/** * @param key// ww w . j ava 2 s .c om * @param p * @throws Exception */ @Override public void destroyObject(K key, PooledObject<C> p) throws Exception { p.getObject().dispose(); }
From source file:org.geosdi.geoplatform.gml.api.jaxb.context.pool.GMLUnmarshallerFactory.java
/** * @param p//from w ww.j a v a2 s .c o m * @throws Exception */ @Override public void destroyObject(PooledObject<GMLUnmarshaller> p) throws Exception { p.getObject().dispose(); }
From source file:org.geosdi.geoplatform.jaxb.pool.factory.GPUnmarshallerFactory.java
@Override public void passivateObject(PooledObject<Unmarshaller> p) throws Exception { logger.debug("####################PASSIVATE OBJECT : {}\n\n", p.getObject()); }
From source file:org.geosdi.geoplatform.jaxb.pool.factory.GPUnmarshallerFactory.java
@Override public void activateObject(PooledObject<Unmarshaller> p) throws Exception { logger.debug("####################ACTIVATE OBJECT : {}\n\n", p.getObject()); }
From source file:org.helios.rindle.store.redis.ExtendedJedisFactory.java
/** * {@inheritDoc}/* w w w . j a v a 2s . com*/ * @see org.apache.commons.pool2.PooledObjectFactory#activateObject(org.apache.commons.pool2.PooledObject) */ @SuppressWarnings("resource") @Override public void activateObject(PooledObject<ExtendedJedis> pooledJedis) throws Exception { final BinaryJedis jedis = pooledJedis.getObject(); if (jedis.getDB() != database) { jedis.select(database); } }
From source file:org.helios.rindle.store.redis.ExtendedJedisFactory.java
/** * {@inheritDoc}/*from w w w. j av a2 s . c om*/ * @see org.apache.commons.pool2.PooledObjectFactory#destroyObject(org.apache.commons.pool2.PooledObject) */ @SuppressWarnings("resource") @Override public void destroyObject(PooledObject<ExtendedJedis> pooledJedis) throws Exception { final ExtendedJedis jedis = pooledJedis.getObject(); if (jedis != null) { jedis.realClose(); } listener.onClose(jedis); }
From source file:org.helios.rindle.store.redis.ExtendedJedisFactory.java
/** * {@inheritDoc}//w ww. ja va 2 s . c o m * @see org.apache.commons.pool2.PooledObjectFactory#validateObject(org.apache.commons.pool2.PooledObject) */ @SuppressWarnings("resource") @Override public boolean validateObject(PooledObject<ExtendedJedis> pooledJedis) { final BinaryJedis jedis = pooledJedis.getObject(); try { return jedis.isConnected() && jedis.ping().equals("PONG"); } catch (final Exception e) { return false; } }
From source file:org.jivesoftware.openfire.websocket.XMPPPPacketReaderFactory.java
@Override public boolean validateObject(PooledObject<XMPPPacketReader> po) { // reset the input for the pooled parser try {/*from ww w .jav a 2 s . c o m*/ po.getObject().getXPPParser().resetInput(); return true; } catch (XmlPullParserException xppe) { Log.error("Failed to reset pooled parser; evicting from pool", xppe); return false; } }