001
014
015 package com.liferay.portal.cache.ehcache;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.InstanceFactory;
020 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
021 import com.liferay.portal.util.PropsValues;
022
023 import java.util.Properties;
024
025 import net.sf.ehcache.event.CacheEventListener;
026 import net.sf.ehcache.event.CacheEventListenerFactory;
027
028
031 public class LiferayCacheEventListenerFactory
032 extends CacheEventListenerFactory {
033
034 public LiferayCacheEventListenerFactory() {
035 String className = PropsValues.EHCACHE_CACHE_EVENT_LISTENER_FACTORY;
036
037 if (_log.isDebugEnabled()) {
038 _log.debug("Instantiating " + className + " " + hashCode());
039 }
040
041 try {
042 _cacheEventListenerFactory =
043 (CacheEventListenerFactory)InstanceFactory.newInstance(
044 PortalClassLoaderUtil.getClassLoader(), className);
045 }
046 catch (Exception e) {
047 throw new RuntimeException(e);
048 }
049 }
050
051 @Override
052 public CacheEventListener createCacheEventListener(Properties properties) {
053 return _cacheEventListenerFactory.createCacheEventListener(properties);
054 }
055
056 private static final Log _log = LogFactoryUtil.getLog(
057 LiferayCacheEventListenerFactory.class);
058
059 private final CacheEventListenerFactory _cacheEventListenerFactory;
060
061 }