[jboss-cvs] JBossCache/src/org/jboss/cache/demo ...

Galder Zamarreno galder.zamarreno at jboss.com
Mon May 21 16:03:43 EDT 2007


  User: gzamarreno
  Date: 07/05/21 16:03:43

  Modified:    src/org/jboss/cache/demo  JBossCacheGUI.java
  Log:
  [JBCACHE-1060] Removed implicit increation of adding child node to root if a node does not exist. nodeCreated() now executes in the same running thread to avoid scroll to visible path concurrency issues. nodeCreated() does not access back the cache, so this shouldn't lead to any deadlock issues.
  
  Revision  Changes    Path
  1.5       +44 -32    JBossCache/src/org/jboss/cache/demo/JBossCacheGUI.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JBossCacheGUI.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/demo/JBossCacheGUI.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- JBossCacheGUI.java	21 May 2007 15:22:30 -0000	1.4
  +++ JBossCacheGUI.java	21 May 2007 20:03:43 -0000	1.5
  @@ -170,12 +170,16 @@
               {
                  log.trace("clicked GUI");
               }
  -            ;
   
               final int selRow = jtree.getRowForLocation(e.getX(), e.getY());
               final TreePath selPath = jtree.getPathForLocation(e.getX(), e.getY());
               if (selRow != -1)
               {
  +               if (log.isTraceEnabled())
  +               {
  +                  log.trace("clicked on node in GUI");
  +               };
  +
                  Runnable r = new Runnable()
                  {
                     public void run()
  @@ -313,9 +317,8 @@
      {
         if (log.isTraceEnabled())
         {
  -         log.trace("table contents changed: " + evt);
  +         log.trace("table contents changed, event type is: " + evt.getType());
         }
  -      ;
   
         int row, col;
         String key, val;
  @@ -332,6 +335,11 @@
            {
               try
               {
  +               if (log.isTraceEnabled())
  +               {
  +                  log.trace("updating node: " + selected_node + " with new values [k=" + key + ",v=" + val + "]");
  +               }
  +
                  selected_node.put(key, val);
                  Map<String, String> data = selected_node.getData();
                  populateTable(data);
  @@ -360,6 +368,8 @@
               {
                  Map<String, String> data;
                  selected_node = getNode(evt.getPath().getPath());
  +               if (selected_node != null)
  +               {
                  data = selected_node.getData();
                  if (data != null)
                  {
  @@ -374,6 +384,7 @@
                     validate();
                  }
               }
  +            }
               catch (TimeoutException te)
               {
                  String message = "Unable to update GUI due to a timeout trying to acquire lock on a node." +
  @@ -421,10 +432,9 @@
   
      public void nodeCreated(final Fqn fqn, final boolean pre, boolean isLocal)
      {
  -      Runnable r = new Runnable()
  -      {
  -         public void run()
  -         {
  +      /* Updating the GUI upon node creation should be done sequentially to avoid concurrency issues when
  +      adding multiple nodes at the same time, for example for PojoCache, where attaching a pojo creates several nodes.
  +      Creating several visual nodes in paralell and trying to scroll to them is not a thread safe operation */
               if (pre)
               {
                  JBossCacheGUI.DisplayNode n;
  @@ -438,9 +448,6 @@
                  }
               }
            }
  -      };
  -      executor.execute(r);
  -   }
   
      public void nodeModified(final Fqn fqn, final boolean pre, final boolean isLocal, ModificationType modType, final Map data)
      {
  @@ -464,6 +471,11 @@
   
      public void nodeRemoved(final Fqn fqn, final boolean pre, boolean isLocal, Map data)
      {
  +      if (log.isTraceEnabled())
  +      {
  +         log.trace("node removed, updating GUI");
  +      }
  +
         Runnable r = new Runnable()
         {
            public void run()
  @@ -611,8 +623,8 @@
         }
         else
         {
  -         // implicit creation
  -         return root.addChild(fqnToPath);
  +         /* No implicit creation, otherwise removing GUI selected nodes will be recreated */
  +         return null;
         }
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list