/* * JBoss, Home of Professional Open Source * Copyright 2011 Red Hat Inc. and/or its affiliates and other * contributors as indicated by the @author tags. All rights reserved. * See the copyright.txt in the distribution for a full listing of * individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package com.nexge.timer; import org.infinispan.notifications.Listener; import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated; import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved; import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent; import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent; import org.infinispan.util.logging.Log; import org.infinispan.util.logging.LogFactory; /** * An Infinispan listener that simply logs cache entries being created and * removed * */ @Listener public class LoggingListener { private Log log = LogFactory.getLog(LoggingListener.class); @CacheEntryCreated public void observeAdd(CacheEntryCreatedEvent event) { if (!event.isPre()) // So that message is only logged after operation succeeded log.infof("Cache entry with key %s added in cache %s", event.getKey(), event.getCache()); } @CacheEntryRemoved public void observeRemove(CacheEntryRemovedEvent event) { log.infof("Cache entry with key %s removed in cache %s", event.getKey(), event.getCache()); } }