[jboss-cvs] CacheBenchFwk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers ...

Manik Surtani manik at jboss.org
Thu May 17 05:38:04 EDT 2007


  User: msurtani
  Date: 07/05/17 05:38:04

  Modified:    cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers 
                        EHCacheWrapper.java
  Log:
  fixed stuff
  
  Revision  Changes    Path
  1.2       +12 -11    CacheBenchFwk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers/EHCacheWrapper.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EHCacheWrapper.java
  ===================================================================
  RCS file: /cvsroot/jboss/CacheBenchFwk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers/EHCacheWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- EHCacheWrapper.java	17 May 2007 08:13:45 -0000	1.1
  +++ EHCacheWrapper.java	17 May 2007 09:38:04 -0000	1.2
  @@ -3,6 +3,7 @@
   import net.sf.ehcache.Cache;
   import net.sf.ehcache.CacheManager;
   import net.sf.ehcache.Element;
  +import net.sf.ehcache.Ehcache;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.cachebench.SerializableCacheWrapper;
  @@ -16,12 +17,12 @@
    * An implementation of SerializableCacheWrapper that uses EHCache as an underlying implementation.
    *
    * @author Manik Surtani (manik at surtani.org)
  - * @version $Id: EHCacheWrapper.java,v 1.1 2007/05/17 08:13:45 msurtani Exp $
  + * @version $Id: EHCacheWrapper.java,v 1.2 2007/05/17 09:38:04 msurtani Exp $
    */
   public class EHCacheWrapper implements SerializableCacheWrapper
   {
      private CacheManager manager;
  -   private Cache cache;
  +   private Ehcache cache;
      private Log logger = LogFactory.getLog("org.cachebench.cachewrappers.EHCacheWrapper");
   
      /* (non-Javadoc)
  @@ -29,8 +30,9 @@
      */
      public void init(Properties parameters) throws Exception
      {
  -      logger.debug("Initializing the cache");
  -      URL url = getClass().getResource(parameters.getProperty("config"));
  +      logger.debug("Initializing the cache with props " + parameters);
  +      URL url = getClass().getClassLoader().getResource(parameters.getProperty("config"));
  +      logger.debug("Config URL = " + url);
         manager = CacheManager.create(url);
         logger.debug("Finish Initializing the cache");
      }
  @@ -40,9 +42,10 @@
      */
      public void setUp() throws Exception
      {
  -      CacheManager manager = CacheManager.create();
  -      manager.addCache("cache");
  +      logger.info("Caches avbl:");
  +      for (String s : manager.getCacheNames()) logger.info("    * " + s);
         cache = manager.getCache("cache");
  +      logger.info("Using named cache " + cache);
      }
   
      /* (non-Javadoc)
  @@ -80,7 +83,7 @@
      */
      public void put(Object key, Object value) throws Exception
      {
  -      logger.warn("Put: Does not deal with non-Serializables, should not be called.");
  +      throw new Exception("Put: Does not deal with non-Serializables, should not be called.");
      }
   
      /* (non-Javadoc)
  @@ -88,14 +91,12 @@
      */
      public Object get(Object key) throws Exception
      {
  -      logger.warn("Get: Does not deal with non-Serializables, should not be called.");
  -      return null;
  +      throw new Exception("Get: Does not deal with non-Serializables, should not be called.");
      }
   
      public int getNumMembers()
      {
  -      // EHCache does not expose a mechanism for providing the number of cluster members, as far as I can see ... !
  -      return -1;
  +      return manager.getCacheManagerPeerProvider().listRemoteCachePeers(cache).size();
      }
   
      public String getInfo()
  
  
  



More information about the jboss-cvs-commits mailing list