All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.PlovercrestEngineBuilder Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
 */

package com.kolibrifx.plovercrest.server;

import com.kolibrifx.plovercrest.server.internal.EventDispatcher;
import com.kolibrifx.plovercrest.server.internal.ThreadedEventDispatcher;
import com.kolibrifx.plovercrest.server.internal.engine.LeastRecentlyUsedCache;

public class PlovercrestEngineBuilder {
    private final String dataPath;
    private EventDispatcher dispatcher = null;
    private LeastRecentlyUsedCache cache =
            new LeastRecentlyUsedCache<>(PlovercrestEngine.DEFAULT_TABLE_CACHE_SIZE);

    public PlovercrestEngineBuilder(final String dataPath) {
        this.dataPath = dataPath;
    }

    /**
     * Note: the {@link PlovercrestEngine} will take ownership of the given dispatcher.
     */
    public PlovercrestEngineBuilder dispatcher(final EventDispatcher dispatcher) {
        this.dispatcher = dispatcher;
        return this;
    }

    public PlovercrestEngineBuilder cache(final LeastRecentlyUsedCache cache) {
        this.cache = cache;
        return this;
    }

    public PlovercrestEngine build() {
        return new PlovercrestEngine(dataPath, dispatcher == null ? new ThreadedEventDispatcher() : dispatcher, cache);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy