Search in sources :

Example 1 with CacheMBeanException

use of com.adobe.acs.commons.util.impl.exception.CacheMBeanException in project acs-aem-commons by Adobe-Consulting-Services.

the class AbstractCacheMBean method getCacheContents.

@Override
public final TabularData getCacheContents() throws CacheMBeanException {
    try {
        final CompositeType cacheEntryType = getCacheEntryType();
        final TabularDataSupport tabularData = new TabularDataSupport(new TabularType("Cache Entries", "Cache Entries", cacheEntryType, new String[] { JMX_PN_CACHEKEY }));
        Map<K, V> cacheAsMap = getCacheAsMap();
        for (final Map.Entry<K, V> entry : cacheAsMap.entrySet()) {
            final Map<String, Object> data = new HashMap<String, Object>();
            data.put(JMX_PN_CACHEKEY, entry.getKey().toString());
            V cacheObj = entry.getValue();
            if (cacheObj != null) {
                addCacheData(data, cacheObj);
            }
            tabularData.put(new CompositeDataSupport(cacheEntryType, data));
        }
        return tabularData;
    } catch (OpenDataException ex) {
        throw new CacheMBeanException("Error getting the cache contents", ex);
    }
}
Also used : HashMap(java.util.HashMap) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CacheMBeanException(com.adobe.acs.commons.util.impl.exception.CacheMBeanException) HashMap(java.util.HashMap) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

CacheMBeanException (com.adobe.acs.commons.util.impl.exception.CacheMBeanException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)1 CompositeType (javax.management.openmbean.CompositeType)1 OpenDataException (javax.management.openmbean.OpenDataException)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 TabularType (javax.management.openmbean.TabularType)1