view src/org/dancres/blitz/entry/LeaseTrackerFactory.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
line wrap: on
line source

package org.dancres.blitz.entry;

import java.io.IOException;

import org.dancres.blitz.lease.LeaseReaper;
import org.dancres.blitz.lease.ReapFilter;

import org.dancres.blitz.oid.Allocator;

class LeaseTrackerFactory {
    /**
       Create a LeaseTracker capable of managing all leases for a particular
       entry type which is using a particular Allocator instance to assign ids.
     */
    static LeaseTracker getTracker(String aType, Allocator anAllocator)
        throws IOException {

        if (EntryRepositoryFactory.getReaper().isActive())
            return new LeaseTrackerImpl(aType,
                                        anAllocator.getMaxZoneId());
        else
            return new NullTrackerImpl(aType);
    }

    private static class NullTrackerImpl implements LeaseTracker {
        private String theType;

        NullTrackerImpl(String aType) {
            // System.err.println("NullTracker: " + aType);
            theType = aType;
        }

        public void bringOutTheDead(EntryReaper aReaper) {
            // Do nothing
        }

        public void delete(PersistentEntry anEntry) throws IOException {
            // Do nothing
        }

        public void update(PersistentEntry anEntry) throws IOException {
            // Do nothing
        }

        public void write(PersistentEntry anEntry) throws IOException {
            // Do nothing
        }

        public void close() throws IOException {
            // Do nothing
        }

        public void delete() throws IOException {
            // Do nothing
        }
    }
}