Instantiate the only CacheFactory impl suitable for the given OS

This commit is contained in:
Peter Palaga
2021-01-24 15:17:58 +01:00
parent 5c6edb1f35
commit d563a27139

View File

@@ -15,7 +15,6 @@
*/
package org.mvndaemon.mvnd.cache.factory;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.eclipse.sisu.Priority;
@@ -26,15 +25,15 @@ import org.mvndaemon.mvnd.common.Os;
@Priority(10)
public class DefaultCacheFactory implements CacheFactory {
@Inject
WatchServiceCacheFactory watchServiceCacheFactory;
@Inject
TimestampCacheFactory timestampCacheFactory;
private final CacheFactory delegate;
public DefaultCacheFactory() {
this.delegate = Os.current() == Os.WINDOWS ? new WatchServiceCacheFactory() : new TimestampCacheFactory();
}
@Override
public <K, V extends CacheRecord> Cache<K, V> newCache() {
CacheFactory factory = Os.current() == Os.WINDOWS ? watchServiceCacheFactory : timestampCacheFactory;
return factory.newCache();
return delegate.newCache();
}
}