Examples of PoolableObjectFactory


Examples of org.apache.commons.pool.PoolableObjectFactory

   
    private List testFactorySequenceStates = new ArrayList(5);
    public void testFactorySequence() throws Exception {
        // setup
        // We need a factory that tracks method call sequence.
        PoolableObjectFactory pof = new PoolableObjectFactory() {
            public Object makeObject() throws Exception {
                testFactorySequenceStates.add("makeObject");
                return new Object();
            }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory


    public void testBorrowWithSometimesInvalidObjects() throws Exception {
        ObjectPool pool = new StackObjectPool(20);
        pool.setFactory(
            new PoolableObjectFactory() {
                // factory makes Integer objects
                int counter = 0;
                public Object makeObject() { return new Integer(counter++); }
                public void destroyObject(Object obj) { }
                public boolean validateObject(Object obj) {
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

    private final List destroyed = new ArrayList();
    public void testReturnObjectDiscardOrder() throws Exception {
        // setup
        // We need a factory that tracks what was discarded.
        PoolableObjectFactory pof = new PoolableObjectFactory() {
            int i = 0;
            public Object makeObject() throws Exception {
                return new Integer(i++);
            }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

    private List testFactorySequenceStates = new ArrayList(5);
    public void testFactorySequence() throws Exception {
        // setup
        // We need a factory that tracks method call sequence.
        PoolableObjectFactory pof = new PoolableObjectFactory() {
            public Object makeObject() throws Exception {
                testFactorySequenceStates.add("makeObject");
                return new Object();
            }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

        return new TestSuite(TestSoftReferenceObjectPool.class);
    }

    protected ObjectPool makeEmptyPool(int cap) {
        return new SoftReferenceObjectPool(
            new PoolableObjectFactory()  {
                int counter = 0;
                public Object makeObject() { return String.valueOf(counter++); }
                public void destroyObject(Object obj) { }
                public boolean validateObject(Object obj) { return true; }
                public void activateObject(Object obj) { }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

    private List testFactorySequenceStates = new ArrayList(5);
    public void testFactorySequence() throws Exception {
        // setup
        // We need a factory that tracks method call sequence.
        PoolableObjectFactory pof = new PoolableObjectFactory() {
            public Object makeObject() throws Exception {
                testFactorySequenceStates.add("makeObject");
                return new Object();
            }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

    }

    public void testBorrowReturnWithSometimesInvalidObjects() throws Exception {
        ObjectPool pool = new StackObjectPool(20);
        pool.setFactory(
            new PoolableObjectFactory() {
                int counter = 0;
                public Object makeObject() { return new Integer(counter++); }
                public void destroyObject(Object obj) { }
                public boolean validateObject(Object obj) {
                    if(obj instanceof Integer) {
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

        return new TestSuite(TestSoftReferenceObjectPool.class);
    }

    protected ObjectPool makeEmptyPool(int cap) {
        return new SoftReferenceObjectPool(
            new PoolableObjectFactory()  {
                int counter = 0;
                public Object makeObject() { return String.valueOf(counter++); }
                public void destroyObject(Object obj) { }
                public boolean validateObject(Object obj) { return true; }
                public void activateObject(Object obj) { }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory

    }

    ObjectPool getPool() {
        if (workers == null) {
            // create pool
            PoolableObjectFactory objectFactory = new AuthorityPoolableObjectFactory();
            ObjectPoolFactory poolFactory = new GenericObjectPoolFactory(objectFactory, poolConfig);
            this.setPool(poolFactory.createPool());
        }
        return workers;
    }
View Full Code Here

Examples of org.apache.commons.pool.PoolableObjectFactory


    public void testBorrowWithSometimesInvalidObjects() throws Exception {
        ObjectPool pool = new StackObjectPool(20);
        pool.setFactory(
            new PoolableObjectFactory() {
                // factory makes Integer objects
                int counter = 0;
                public Object makeObject() { return new Integer(counter++); }
                public void destroyObject(Object obj) { }
                public boolean validateObject(Object obj) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.