Example usage for org.apache.commons.pool2.impl DefaultPooledObject DefaultPooledObject

List of usage examples for org.apache.commons.pool2.impl DefaultPooledObject DefaultPooledObject

Introduction

In this page you can find the example usage for org.apache.commons.pool2.impl DefaultPooledObject DefaultPooledObject.

Prototype

public DefaultPooledObject(T object) 

Source Link

Document

Create a new instance that wraps the provided object so that the pool can track the state of the pooled object.

Usage

From source file:org.geosdi.geoplatform.connector.api.pool.GPPoolConnectorFactory.java

/**
 * @param value/*from  w w w . ja  v  a2s  .  c  om*/
 * @return {@link PooledObject<C>}
 */
@Override
public PooledObject<C> wrap(C value) {
    return new DefaultPooledObject<C>(value);
}

From source file:org.geosdi.geoplatform.gml.api.jaxb.context.pool.GMLUnmarshallerFactory.java

/**
 * @param obj/*from w ww . j a v  a  2  s.  c  o  m*/
 * @return {@link PooledObject<GMLUnmarshaller>}
 */
@Override
public PooledObject<GMLUnmarshaller> wrap(GMLUnmarshaller obj) {
    return new DefaultPooledObject<GMLUnmarshaller>(obj);
}

From source file:org.geosdi.geoplatform.gml.impl.v311.jaxb.context.pool.GMLMarshallerFactoryV311.java

/**
 * @param obj//ww  w  .  j a  va 2 s .  com
 * @return {@link PooledObject<GMLMarshaller>}
 */
@Override
public PooledObject<GMLMarshaller> wrap(GMLMarshaller obj) {
    return new DefaultPooledObject<GMLMarshaller>(obj);
}

From source file:org.geosdi.geoplatform.jaxb.pool.factory.GPJAXBContextCachePoolFactory.java

/**
 * Wrap the provided instance with an implementation of
 * {@link PooledObject}.//from  www .  j  av  a  2  s. co m
 *
 * @param value the instance to wrap
 * @return The provided instance, wrapped by a {@link PooledObject}
 */
@Override
public PooledObject<JAXBContext> wrap(JAXBContext value) {
    return new DefaultPooledObject<>(value);
}

From source file:org.geosdi.geoplatform.jaxb.pool.factory.GPMarshallerFactory.java

@Override
public PooledObject<Marshaller> wrap(Marshaller obj) {
    return new DefaultPooledObject(obj);
}

From source file:org.geosdi.geoplatform.jaxb.pool.factory.GPUnmarshallerFactory.java

@Override
public PooledObject<Unmarshaller> wrap(Unmarshaller obj) {
    return new DefaultPooledObject(obj);
}

From source file:org.helios.rindle.store.redis.ExtendedJedisFactory.java

/**
 * {@inheritDoc}// w w w .  ja  v a 2s.  c  o  m
 * @see org.apache.commons.pool2.PooledObjectFactory#makeObject()
 */

@Override
public PooledObject<ExtendedJedis> makeObject() throws Exception {
    final String _clientName = clientName + "#" + connectionSerial.incrementAndGet();
    final ExtendedJedis jedis = new ExtendedJedis(this.host, this.port, this.timeout, _clientName, pool);

    jedis.connect();
    if (null != this.password) {
        jedis.auth(this.password);
    }
    if (database != 0) {
        jedis.select(database);
    }
    listener.onConnect(jedis);
    return new DefaultPooledObject<ExtendedJedis>(jedis);
}

From source file:org.jfastcgi.client.PoolFactory.java

@Override
public PooledObject<ISocket> wrap(final ISocket obj) {
    return new DefaultPooledObject<ISocket>(obj);
}

From source file:org.jivesoftware.openfire.websocket.XMPPPPacketReaderFactory.java

@Override
public PooledObject<XMPPPacketReader> wrap(XMPPPacketReader reader) {
    return new DefaultPooledObject<XMPPPacketReader>(reader);
}

From source file:org.jmxtrans.embedded.util.pool.ManagedGenericKeyedObjectPoolTest.java

@Test
public void testMbeanAttributeAccess() throws Exception {
    BaseKeyedPooledObjectFactory<String, String> factory = new BaseKeyedPooledObjectFactory<String, String>() {
        @Override/*  w  ww .  j  a va 2s .co  m*/
        public String create(String key) throws Exception {
            return key;
        }

        @Override
        public PooledObject<String> wrap(String value) {
            return new DefaultPooledObject<String>(value);
        }
    };
    GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
    config.setJmxNameBase("org.jmxtrans.embedded:type=GenericKeyedObjectPool,writer=MyWriter,name=");
    config.setJmxNamePrefix("my-host_1234");
    GenericKeyedObjectPool<String, String> objectPool = new GenericKeyedObjectPool<String, String>(factory,
            config);

    ObjectName objectName = new ObjectName(
            "org.jmxtrans.embedded:type=GenericKeyedObjectPool,writer=MyWriter,name=my-host_1234");
    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    try {
        Object numIdle = mbeanServer.getAttribute(objectName, "NumIdle");
        assertThat(numIdle, instanceOf(Number.class));

    } finally {
        mbeanServer.unregisterMBean(objectName);
    }
}