Package com.thoughtworks.proxy.toys.pool

Examples of com.thoughtworks.proxy.toys.pool.Pool


* @author Jörg Schaible
*/
public class PoolToyExample {

    public static void packageOverviewExample1() {
        Pool pool = new Pool(Checksum.class, new Resetter() {
            public boolean reset(final Object object) {
                ((Checksum)object).reset();
                return true;
            }
        });
        pool.add(new CRC32());
        if (true) {
            Checksum checksum = (Checksum)pool.get();
            checksum.update("JUnit".getBytes(), 0, 5);
            System.out.println("CRC32 checksum of \"JUnit\": " + checksum.getValue());
        }
        if (true) {
            Checksum checksum = (Checksum)pool.get();
            if (checksum == null) {
                System.out.println("No checksum available, force gc ...");
                System.gc();
            }
            checksum = (Checksum)pool.get();
            System.out.println("CRC32 of an resetted checksum: " + checksum.getValue());
            ((Poolable)checksum).returnInstanceToPool();
        }
    }
View Full Code Here


        components = new ArrayList<Object>();

        final Class type = delegate.getComponentKey() instanceof Class ? (Class)delegate
                .getComponentKey() : delegate.getComponentImplementation();
        final Resetter resetter = context.getResetter();
        this.pool = new Pool(type, delegateHasLifecylce ? new LifecycleResetter(
                this, resetter) : resetter, context.getProxyFactory(), serializationMode);
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.proxy.toys.pool.Pool

Copyright © 2018 www.massapicom. 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.