com.peterphi.std.guice.common.daemon.GuiceDaemonRegistry Maven / Gradle / Ivy
package com.peterphi.std.guice.common.daemon;
import com.google.inject.Singleton;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Singleton
public final class GuiceDaemonRegistry
{
private Set daemons = new HashSet<>();
public synchronized void register(GuiceDaemon daemon)
{
daemons.add(daemon);
}
public synchronized void unregister(GuiceDaemon daemon)
{
daemons.remove(daemon);
}
public synchronized List getDaemons()
{
return daemons.stream()
.filter(d -> !(d instanceof GuiceRecurringDaemon))
.collect(Collectors.toList());
}
/**
* Return a list of all
*
* @return
*/
public synchronized List getRecurring()
{
return daemons.stream()
.filter(d -> d instanceof GuiceRecurringDaemon)
.map(d -> (GuiceRecurringDaemon) d)
.collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy