Commit fd80bdd4 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Changed constructor of DefaultCachingComponent to provide the host

parent f18fef10
......@@ -25,10 +25,21 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName;
import de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.CachingComponent;
public class DefaultCachingComponent implements CachingComponent {
public class DefaultCachingComponent implements CachingComponent, ConnectivityListener {
private Map<Class<? extends Object>, List<Object>> _cache = new HashMap<>();
private Host _host;
public DefaultCachingComponent(Host pHost) {
_host = pHost;
_host.getNetworkComponent().getByName(NetInterfaceName.WIFI).addConnectivityListener(this);
}
@Override
public <T> List<T> getCacheEntries(Class<T> pCacheEntryClass) {
......@@ -53,4 +64,30 @@ public class DefaultCachingComponent implements CachingComponent {
_cache.get(pCacheEntry.getClass()).add(pCacheEntry);
}
@Override
public void initialize() {
_cache.clear();
}
@Override
public void shutdown() {
}
@Override
public Host getHost() {
return _host;
}
@Override
public void wentOnline(Host pHost, NetInterface pNetInterface) {
_cache.clear();
}
@Override
public void wentOffline(Host pHost, NetInterface pNetInterface) {
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment