Code example for MapMaker

0
 * @author Dhanji R. Prasanna (dhanji@gmail.com) 
 */ 
@ThreadSafe 
@Singleton 
class InMemorySystemMetrics implements SystemMetrics { 
  private final ConcurrentMap<Class<?>, Metric> pages = new MapMaker().weakKeys().makeMap();
  private final AtomicBoolean active = new AtomicBoolean(false);
 
  private final Logger log = Logger.getLogger(SystemMetrics.class.getName());
 
  public void logPageRenderTime(Class<?> page, long time) {
    Metric metric = putIfAbsent(page);
 
    // Requests fight it out for who wins this set(). 
    metric.lastRenderTime.set(time);
  } 
 
  public void logErrorsAndWarnings(Class<?> page, List<CompileError> errors, List<CompileError> warnings) {
    Metric metric = putIfAbsent(page);