Package org.jboss.cache

Examples of org.jboss.cache.Modification


      args=methodCall.getArgs();
      switch (methodCall.getMethodId())
      {
         case MethodDeclarations.putDataMethodLocal_id:
            return new Modification(Modification.PUT_DATA,
                  (Fqn)args[1],      // fqn
                  (Map)args[2]);     // data
         case MethodDeclarations.putDataEraseMethodLocal_id:
            return new Modification(Modification.PUT_DATA_ERASE,
                  (Fqn)args[1],      // fqn
                  (Map)args[2]);     // data
         case MethodDeclarations.putKeyValMethodLocal_id:
            return new Modification(Modification.PUT_KEY_VALUE,
                  (Fqn)args[1],      // fqn
                  args[2],           // key
                  args[3]);          // value
         case MethodDeclarations.removeNodeMethodLocal_id:
            return new Modification(Modification.REMOVE_NODE,
                  (Fqn)args[1]);     // fqn
         case MethodDeclarations.removeKeyMethodLocal_id:
            return new Modification(Modification.REMOVE_KEY_VALUE,
                  (Fqn)args[1],      // fqn
                  args[2]);          // key
         case MethodDeclarations.removeDataMethodLocal_id:
            return new Modification(Modification.REMOVE_DATA,
                  (Fqn)args[1]);     // fqn
         default :
            throw new Exception("method call " + method.getName() + " cannot be converted to a modification");
      }
   }
View Full Code Here


      loader.put(list);
      checkModifications(list);

      /* REMOVE_KEY_VALUE */
      list = new ArrayList();
      Modification mod = new Modification();
      mod.setType(Modification.REMOVE_KEY_VALUE);
      mod.setFqn(FQN);
      mod.setKey("one");
      list.add(mod);
      loader.put(list);
      checkModifications(list);

      /* REMOVE_NODE */
      list = new ArrayList();
      mod = new Modification();
      mod.setType(Modification.REMOVE_NODE);
      mod.setFqn(FQN);
      list.add(mod);
      loader.put(list);
      checkModifications(list);
      assertEquals(null, loader.get(FQN));

      /* REMOVE_DATA */
      loader.put(FQN, "one", "two");
      list = new ArrayList();
      mod = new Modification();
      mod.setType(Modification.REMOVE_DATA);
      mod.setFqn(FQN);
      list.add(mod);
      loader.put(list);
      checkModifications(list);
      assertNotNull(loader.get(FQN));
      assertEquals(0, loader.get(FQN).size());
View Full Code Here

    */
   private List createUpdates() {

      List list = new ArrayList();

      Modification mod = new Modification();
      mod.setType(Modification.PUT_KEY_VALUE);
      mod.setFqn(FQN);
      mod.setKey("one");
      mod.setValue("two");
      list.add(mod);

      mod = new Modification();
      mod.setType(Modification.PUT_KEY_VALUE);
      mod.setFqn(FQN);
      mod.setKey("three");
      mod.setValue("four");
      list.add(mod);

      Map map = new HashMap();
      map.put("five", "six");
      map.put("seven", "eight");
      mod = new Modification();
      mod.setType(Modification.PUT_DATA);
      mod.setFqn(FQN);
      mod.setData(map);
      list.add(mod);

      return list;
   }
View Full Code Here

    */
   private void checkModifications(List list)
      throws Exception {

      for (int i = 0; i < list.size(); i += 1) {
         Modification mod = (Modification) list.get(i);
         Fqn fqn = mod.getFqn();
         switch (mod.getType()) {
         case Modification.PUT_KEY_VALUE:
            assertEquals(mod.getValue(), loader.get(fqn).get(mod.getKey()));
            break;
         case Modification.PUT_DATA:
            Map map = mod.getData();
            for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
               Object key = iter.next();
               assertEquals(map.get(key), loader.get(fqn).get(key));
            }
            break;
         case Modification.REMOVE_KEY_VALUE:
            assertEquals(null, loader.get(fqn).get(mod.getKey()));
            break;
         case Modification.REMOVE_DATA:
            assertTrue(loader.exists(fqn));
            assertNotNull(loader.get(fqn));
            assertEquals(0, loader.get(fqn).size());
View Full Code Here

       CacheLoader loader = cache.getCacheLoader();
       Fqn fqn = Fqn.fromString("/a/b/c/d");
       HashMap map = new HashMap();
       map.put("c", "d");
       // Three kinds of puts!
       Modification mod = new Modification(Modification.PUT_KEY_VALUE, fqn, "e", "f");
       loader.put(fqn, "a", "b");
       loader.put(fqn, map);
       loader.put(Collections.singletonList(mod));
       assertEquals("put right away", 3, loader.get(fqn).size());
       loader.remove(fqn);
View Full Code Here

      if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data is " + n.data);
   }

   public void put(List modifications) throws Exception
   {
      Modification m;
      for(Iterator it = modifications.iterator(); it.hasNext();)
      {
         m = (Modification)it.next();
         switch (m.getType())
         {
            case Modification.PUT_DATA:
               put(m.getFqn(), m.getData());
               break;
            case Modification.PUT_DATA_ERASE:
               removeData(m.getFqn());
               put(m.getFqn(), m.getData());
               break;
            case Modification.PUT_KEY_VALUE:
               put(m.getFqn(), m.getKey(), m.getValue());
               break;
            case Modification.REMOVE_DATA:
               removeData(m.getFqn());
               break;
            case Modification.REMOVE_KEY_VALUE:
               remove(m.getFqn(), m.getKey());
               break;
            case Modification.REMOVE_NODE:
               remove(m.getFqn());
               break;
            default:
               throw new CacheException("Unknown modificatiobn " + m.getType());
         }
      }
   }
View Full Code Here

    */
   private List createUpdates() {

      List list = new ArrayList();

      Modification mod = new Modification();
      mod.setType(Modification.PUT_KEY_VALUE);
      mod.setFqn(FQN);
      mod.setKey("one");
      mod.setValue("two");
      list.add(mod);

      mod = new Modification();
      mod.setType(Modification.PUT_KEY_VALUE);
      mod.setFqn(FQN);
      mod.setKey("three");
      mod.setValue("four");
      list.add(mod);

      Map map = new HashMap();
      map.put("five", "six");
      map.put("seven", "eight");
      mod = new Modification();
      mod.setType(Modification.PUT_DATA);
      mod.setFqn(FQN);
      mod.setData(map);
      list.add(mod);

      return list;
   }
View Full Code Here

    */
   private void checkModifications(List list)
      throws Exception {

      for (int i = 0; i < list.size(); i += 1) {
         Modification mod = (Modification) list.get(i);
         Fqn fqn = mod.getFqn();
         switch (mod.getType()) {
         case Modification.PUT_KEY_VALUE:
            assertEquals(mod.getValue(), loader.get(fqn).get(mod.getKey()));
            break;
         case Modification.PUT_DATA:
            Map map = mod.getData();
            for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
               Object key = iter.next();
               assertEquals(map.get(key), loader.get(fqn).get(key));
            }
            break;
         case Modification.REMOVE_KEY_VALUE:
            assertEquals(null, loader.get(fqn).get(mod.getKey()));
            break;
         case Modification.REMOVE_DATA:
            map = loader.get(fqn);
            assertNotNull(map);
            assertTrue(map.isEmpty());
View Full Code Here

      addDelay();
      checkModifications(list);

      /* REMOVE_KEY_VALUE */
      list = new ArrayList();
      Modification mod = new Modification();
      mod.setType(Modification.REMOVE_KEY_VALUE);
      mod.setFqn(FQN);
      mod.setKey("one");
      list.add(mod);
      loader.put(list);
      addDelay();
      checkModifications(list);

      /* REMOVE_NODE */
      list = new ArrayList();
      mod = new Modification();
      mod.setType(Modification.REMOVE_NODE);
      mod.setFqn(FQN);
      list.add(mod);
      loader.put(list);
      addDelay();
      checkModifications(list);
      assertEquals(null, loader.get(FQN));

      /* REMOVE_DATA */
      loader.put(FQN, "one", "two");
      list = new ArrayList();
      mod = new Modification();
      mod.setType(Modification.REMOVE_DATA);
      mod.setFqn(FQN);
      list.add(mod);
      loader.put(list);
      addDelay();
      checkModifications(list);
   }
View Full Code Here

         args=methodCall.getArgs();
         switch (methodCall.getMethodId())
         {
            case MethodDeclarations.removeNodeMethodLocal_id:
               // just remove it from loader, don't trigger activation processing
               Modification mod=new Modification(Modification.REMOVE_NODE, (Fqn)args[1]);
               cache_loader_modifications.add(mod);
               break;
            case MethodDeclarations.putDataMethodLocal_id:
            case MethodDeclarations.putDataEraseMethodLocal_id:
            case MethodDeclarations.putKeyValMethodLocal_id:
View Full Code Here

TOP

Related Classes of org.jboss.cache.Modification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.