1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.cache.ehcache;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.InstanceFactory;
20  import com.liferay.portal.util.PropsValues;
21  
22  import java.util.Properties;
23  
24  import net.sf.ehcache.event.CacheEventListener;
25  import net.sf.ehcache.event.CacheEventListenerFactory;
26  
27  /**
28   * <a href="LiferayCacheEventListenerFactory.java.html"><b><i>View Source</i>
29   * </b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class LiferayCacheEventListenerFactory
34      extends CacheEventListenerFactory {
35  
36      public LiferayCacheEventListenerFactory() {
37          String className = PropsValues.EHCACHE_CACHE_EVENT_LISTENER_FACTORY;
38  
39          if (_log.isDebugEnabled()) {
40              _log.debug("Instantiating " + className + " " + this.hashCode());
41          }
42  
43          try {
44              _cacheEventListenerFactory =
45                  (CacheEventListenerFactory)InstanceFactory.newInstance(
46                      className);
47          }
48          catch (Exception e) {
49              throw new RuntimeException(e);
50          }
51      }
52  
53      public CacheEventListener createCacheEventListener(Properties properties) {
54          return _cacheEventListenerFactory.createCacheEventListener(properties);
55      }
56  
57      private static Log _log = LogFactoryUtil.getLog(
58          LiferayCacheEventListenerFactory.class);
59  
60      private CacheEventListenerFactory _cacheEventListenerFactory;
61  
62  }