Example usage for com.google.common.cache RemovalNotification toString

List of usage examples for com.google.common.cache RemovalNotification toString

Introduction

In this page you can find the example usage for com.google.common.cache RemovalNotification toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of the form {key}={value}.

Usage

From source file:com.heliosapm.jmx.cache.CacheStatistics.java

/**
 * {@inheritDoc}/*  ww  w  .  j  a v a2s  .c  o m*/
 * @see com.google.common.cache.RemovalListener#onRemoval(com.google.common.cache.RemovalNotification)
 */
@Override
public void onRemoval(RemovalNotification<Object, Object> removal) {
    final Notification notif = new Notification("cache.removal", objectName, sequence.incrementAndGet(),
            System.currentTimeMillis(), "Cache entry [" + removal.toString() + "] removed from cache ["
                    + cacheName + "]. Cause:" + removal.getCause().name());
    final JSONObject json = new JSONObject();
    json.put("event", "cache.removal");
    json.put("cacheName", cacheName);
    json.put("key", removal.getKey());
    json.put("value", removal.getValue());
    json.put("cause", removal.getCause().name());
    notif.setUserData(json.toString());
    sendNotification(notif);
}