class RecyclingSerialBinding<K> extends SerialBinding<K> {
    /**
     * Thread-local cache of reusable FastOutputStream
     */
    protected ThreadLocal<FastOutputStream> fastOutputStreamHolder
     = new ThreadLocal<FastOutputStream>();
    
    private ClassCatalog classCatalog;
    private Class<K> baseClass;

    /**
     * Constructor. Save parameters locally, as superclass 
     * fields are private. 
     * 
     * @param classCatalog is the catalog to hold shared class information
     *
     * @param baseClass is the base class for serialized objects stored using
     * this binding
     */
    @SuppressWarnings("unchecked")
    public RecyclingSerialBinding(ClassCatalog classCatalog, Class baseClass) {
        super(classCatalog, baseClass);
        this.classCatalog = classCatalog;
        this.baseClass = baseClass;
    }

    /**
     * Copies superclass simply to allow different source for FastOoutputStream.
     * 
     * @see com.sleepycat.bind.serial.SerialBinding#entryToObject
     */
    public void objectToEntry(Object object, DatabaseEntry entry) {<FILL_FUNCTION_BODY>}

    /**
     * Get the cached (and likely pre-grown to efficient size) FastOutputStream,
     * creating it if necessary. 
     * 
     * @return FastOutputStream
     */
    private FastOutputStream getFastOutputStream() {
        FastOutputStream fo = (FastOutputStream) fastOutputStreamHolder.get();
        if (fo == null) {
            fo = new FastOutputStream();
            fastOutputStreamHolder.set(fo);
        }
        fo.reset();
        return fo;
    }
}


        if (baseClass != null && !baseClass.isInstance(object)) {
            throw new IllegalArgumentException(
                        "Data object class (" + object.getClass() +
                        ") not an instance of binding's base class (" +
                        baseClass + ')');
        }
        FastOutputStream fo = getFastOutputStream();
        try {
            SerialOutput jos = new SerialOutput(fo, classCatalog);
            jos.writeObject(object);
        } catch (IOException e) {
            throw new RuntimeExceptionWrapper(e);
        }

        byte[] hdr = SerialOutput.getStreamHeader();
        entry.setData(fo.getBufferBytes(), hdr.length,
                     fo.getBufferLength() - hdr.length);
    
<no_super_class>