io.tracee.backend.threadlocalstore.ThreadLocalTraceeBackend Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tracee-threadlocal-store Show documentation
Show all versions of tracee-threadlocal-store Show documentation
This is a simple implementation of a tracee backend. It might be used for system where no supported
logging framework is present or for test purpose.
package io.tracee.backend.threadlocalstore;
import io.tracee.BackendBase;
import java.util.HashMap;
import java.util.Map;
class ThreadLocalTraceeBackend extends BackendBase {
private final ThreadLocalMap threadLocalMap;
public ThreadLocalTraceeBackend() {
this.threadLocalMap = new ThreadLocalMap();
}
@Override
public boolean containsKey(String key) {
return threadLocalMap.get().containsKey(key);
}
@Override
public int size() {
return threadLocalMap.get().size();
}
@Override
public boolean isEmpty() {
return threadLocalMap.get().isEmpty();
}
@Override
public String get(String key) {
return threadLocalMap.get().get(key);
}
@Override
public void put(String key, String value) {
threadLocalMap.get().put(key, value);
}
@Override
public void remove(String key) {
threadLocalMap.get().remove(key);
}
@Override
public void clear() {
threadLocalMap.get().clear();
}
@Override
public void putAll(Map extends String, ? extends String> entries) {
threadLocalMap.get().putAll(entries);
}
@Override
public Map copyToMap() {
return new HashMap(threadLocalMap.get());
}
ThreadLocalMap getThreadLocalMap() {
return threadLocalMap;
}
}