com.netgrif.application.engine.elastic.service.MaxSizeHashMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of application-engine Show documentation
Show all versions of application-engine Show documentation
System provides workflow management functions including user, role and data management.
package com.netgrif.application.engine.elastic.service;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class MaxSizeHashMap extends LinkedHashMap {
private final long maxSize;
MaxSizeHashMap(long maxSize) {
super(16, 0.75f, true);
this.maxSize = maxSize;
}
@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
return size() > maxSize;
}
@Override
public ExecutorService get(Object o) {
ExecutorService executor = super.get(o);
if (executor == null) {
executor = Executors.newSingleThreadExecutor();
put((String) o, executor);
}
return executor;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy