[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...

Manik Surtani msurtani at jboss.com
Fri Sep 15 20:23:35 EDT 2006


  User: msurtani
  Date: 06/09/15 20:23:35

  Added:       tests/functional/org/jboss/cache/loader 
                        DummyInMemoryCacheLoader.java
  Log:
  Updates to the move() API plus more UTs
  
  Revision  Changes    Path
  1.1      date: 2006/09/16 00:23:35;  author: msurtani;  state: Exp;JBossCache/tests/functional/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
  
  Index: DummyInMemoryCacheLoader.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.cache.loader;
  
  import org.jboss.cache.Fqn;
  import org.jboss.cache.Modification;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.Properties;
  import java.util.Set;
  
  /**
   * Dummy cache loader that stores data in memory
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
   */
  public class DummyInMemoryCacheLoader extends AbstractCacheLoader
  {
     private Map<Fqn, Node> nodes = new HashMap<Fqn, Node>();
  
     public void setConfig(Properties properties)
     {
     }
  
     public Set getChildrenNames(Fqn fqn) throws Exception
     {
        return nodes.get(fqn).children.keySet();
     }
  
     public Map get(Fqn name) throws Exception
     {
        return nodes.get(name).data;
     }
  
     public boolean exists(Fqn name) throws Exception
     {
        return nodes.containsKey(name);
     }
  
     public Object put(Fqn name, Object key, Object value) throws Exception
     {
        Node n = nodes.get(name);
        if (n == null) n = new Node();
        n.fqn = name;
        Object old = n.data.put(key, value);
        nodes.put(name, n);
        return old;
     }
  
     public void put(Fqn name, Map attributes) throws Exception
     {
        Node n = nodes.get(name);
        if (n == null) n = new Node();
        n.fqn = name;
        n.data.putAll(attributes);
        nodes.put(name, n);
  
     }
  
     public Object remove(Fqn fqn, Object key) throws Exception
     {
        Node n = nodes.get(fqn);
        if (n == null) n = new Node();
        n.fqn = fqn;
        Object old = n.data.remove(key);
        nodes.put(fqn, n);
        return old;
     }
  
     public void remove(Fqn fqn) throws Exception
     {
        nodes.remove(fqn);
     }
  
     public void removeData(Fqn fqn) throws Exception
     {
        Node n = nodes.get(fqn);
        if (n == null) n = new Node();
        n.fqn = fqn;
        n.data.clear();
        nodes.put(fqn, n);
     }
  
     public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
     {
     }
  
     public void commit(Object tx) throws Exception
     {
     }
  
     public void rollback(Object tx)
     {
     }
  
     public void create() throws Exception
     {
     }
  
     public void start() throws Exception
     {
     }
  
     public void stop()
     {
     }
  
     public void destroy()
     {
     }
  
  
     public class Node
     {
        Map data = new HashMap();
        Map children = new HashMap();
        Fqn fqn;
     }
  
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list