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

Manik Surtani msurtani at jboss.com
Thu Sep 7 09:52:29 EDT 2006


  User: msurtani
  Date: 06/09/07 09:52:29

  Modified:    src/org/jboss/cache      TreeCache.java TreeCacheMBean.java
                        TreeCacheProxyImpl.java TreeCacheView.java
                        TreeCacheViewMBean.java
  Log:
  cleaned up jmx interfaces, fixed tx and gtx allocation problems
  
  Revision  Changes    Path
  1.240     +10 -33    JBossCache/src/org/jboss/cache/TreeCache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
  retrieving revision 1.239
  retrieving revision 1.240
  diff -u -b -r1.239 -r1.240
  --- TreeCache.java	6 Sep 2006 15:30:55 -0000	1.239
  +++ TreeCache.java	7 Sep 2006 13:52:28 -0000	1.240
  @@ -18,6 +18,7 @@
   import org.jboss.cache.factories.NodeFactory;
   import org.jboss.cache.interceptors.Interceptor;
   import org.jboss.cache.jmx.CacheMBean;
  +import org.jboss.cache.jmx.JmxUtil;
   import org.jboss.cache.loader.CacheLoader;
   import org.jboss.cache.loader.CacheLoaderManager;
   import org.jboss.cache.loader.NodeData;
  @@ -39,7 +40,6 @@
   import org.jboss.cache.notifications.Notifier;
   import org.jboss.cache.optimistic.DataVersion;
   import org.jboss.cache.statetransfer.StateTransferManager;
  -import org.jboss.cache.util.MBeanConfigurator;
   import org.jboss.invocation.MarshalledValueOutputStream;
   import org.jgroups.Address;
   import org.jgroups.Channel;
  @@ -60,7 +60,6 @@
   
   import javax.management.MBeanOperationInfo;
   import javax.management.MBeanServer;
  -import javax.management.MBeanServerFactory;
   import javax.management.ObjectName;
   import javax.transaction.Status;
   import javax.transaction.SystemException;
  @@ -94,7 +93,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Id: TreeCache.java,v 1.239 2006/09/06 15:30:55 msurtani Exp $
  + * @version $Id: TreeCache.java,v 1.240 2006/09/07 13:52:28 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -102,7 +101,6 @@
   {
      private static final String CREATE_MUX_CHANNEL = "createMultiplexerChannel";
      private static final String[] MUX_TYPES = {"java.lang.String", "java.lang.String"};
  -   private static final String JBOSS_SERVER_DOMAIN = "jboss";
   
      // Quite poor, but for now, root may be re-initialised when setNodeLockingOptimistic() is called.
      // this is because if node locking is optimistic, we need to use OptimisticTreeNodes rather than TreeNodes.
  @@ -627,13 +625,16 @@
   
         // build interceptor chain
         interceptor_chain = new InterceptorChainFactory().buildInterceptorChain(this);
  +
  +      isStandalone = getConfiguration().getServiceName() == null || getConfiguration().getServiceName().equals("");
  +
         // register interceptor mbeans
         if (configuration.isUseInterceptorMbeans())
         {
  -         MBeanServer mbserver = getMBeanServer();
  +         MBeanServer mbserver = JmxUtil.getMBeanServer();
            if (mbserver != null)
            {
  -            MBeanConfigurator.registerInterceptors(mbserver, this, isStandalone);
  +            JmxUtil.registerInterceptors(mbserver, this, isStandalone);
            }
         }
   
  @@ -780,12 +781,12 @@
         // unregister interceptor mbeans
         if (configuration.isUseInterceptorMbeans())
         {
  -         MBeanServer mbserver = getMBeanServer();
  +         MBeanServer mbserver = JmxUtil.getMBeanServer();
            if (mbserver != null)
            {
               try
               {
  -               MBeanConfigurator.unregisterInterceptors(mbserver, this, isStandalone);
  +               JmxUtil.unregisterInterceptors(mbserver, this, isStandalone);
               }
               catch (Exception e)
               {
  @@ -4357,7 +4358,7 @@
            return null;
         }
   
  -      MBeanServer mbserver = getMBeanServer();
  +      MBeanServer mbserver = JmxUtil.getMBeanServer();
         if (mbserver == null)
         {
            log.warn("Multiplexer service specified but MBean server not found." +
  @@ -4408,28 +4409,4 @@
            return null;
         }
      }
  -
  -   private MBeanServer getMBeanServer()
  -   {
  -      ArrayList servers = MBeanServerFactory.findMBeanServer(null);
  -      if (servers == null || servers.size() == 0)
  -      {
  -         return null;
  -      }
  -
  -      // return 'jboss' server if available
  -      for (int i = 0; i < servers.size(); i++)
  -      {
  -         MBeanServer server = (MBeanServer) servers.get(i);
  -         if (server.getDefaultDomain().equalsIgnoreCase(JBOSS_SERVER_DOMAIN))
  -         {
  -            return server;
  -         }
  -      }
  -
  -      // return first available server
  -      return (MBeanServer) servers.get(0);
  -
  -   }
  -
   }
  
  
  
  1.39      +921 -912  JBossCache/src/org/jboss/cache/TreeCacheMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheMBean.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -b -r1.38 -r1.39
  --- TreeCacheMBean.java	19 Jul 2006 08:29:18 -0000	1.38
  +++ TreeCacheMBean.java	7 Sep 2006 13:52:28 -0000	1.39
  @@ -7,11 +7,11 @@
   package org.jboss.cache;
   
   import org.jboss.cache.config.Option;
  +import org.jboss.cache.jmx.LifeCycle;
  +import org.jboss.cache.loader.CacheLoader;
   import org.jboss.cache.marshall.RegionNameConflictException;
   import org.jboss.cache.marshall.RegionNotFoundException;
   import org.jboss.cache.marshall.TreeCacheMarshaller;
  -import org.jboss.cache.loader.CacheLoader;
  -import org.jboss.system.ServiceMBean;
   import org.w3c.dom.Element;
   
   import java.lang.reflect.Method;
  @@ -26,9 +26,9 @@
    *
    * @author Bela Ban
    * @author Ben Wang
  - * @version $Id: TreeCacheMBean.java,v 1.38 2006/07/19 08:29:18 msurtani Exp $
  + * @version $Id: TreeCacheMBean.java,v 1.39 2006/09/07 13:52:28 msurtani Exp $
    */
  -public interface TreeCacheMBean extends ServiceMBean
  +public interface TreeCacheMBean extends LifeCycle
   {
   
      Object getLocalAddress();
  @@ -59,7 +59,7 @@
        * {@link #registerClassLoader(String, ClassLoader)} or
        * {@link #activateRegion(String)}
        * </p>
  -     *
  +    * <p/>
        * TreeCacheMarshaller is ALWAYS used.  This is now synonymous with setUseRegionBasedMarshalling()
        *
        * @deprecated
  @@ -70,25 +70,27 @@
        * Gets whether a {@link TreeCacheMarshaller} instance should be used
        * to manage different classloaders to use for unmarshalling replicated
        * objects.
  -     *
  +    * <p/>
        * TreeCacheMarshaller is ALWAYS used.  This is now synonymous with getUseRegionBasedMarshalling()
  +    *
        * @deprecated
        */
       boolean getUseMarshalling();
   
       /**
        * Sets whether marshalling uses scoped class loaders on a per region basis.
  -     * <p />
  +    * <p/>
        * This property must be set to <code>true</code> before any call to
        * {@link #registerClassLoader(String, ClassLoader)} or
        * {@link #activateRegion(String)}
  -
  +    *
        * @param isTrue
        */
       void setUseRegionBasedMarshalling(boolean isTrue);
   
       /**
        * Tests whether region based marshaling s used.
  +    *
        * @return true if region based marshalling is used.
        */
       boolean getUseRegionBasedMarshalling();
  @@ -275,14 +277,13 @@
        * transfer or a call to {@link #activateRegion(String)}.  Different
        * releases of JBossCache may format this data differently; this property
        * identifies the format version being used by this cache instance.
  -     * <p>
  +    * <p/>
        * The default value for this property is
        * {@link TreeCache#DEFAULT_REPLICATION_VERSION}.
        * </p>
        *
        * @return    a short identifying JBossCache release; e.g. <code>124</code>
        *            for JBossCache 1.2.4
  -     *
        * @deprecated use {@link #getReplicationVersion()} instead
        */
       short getStateTransferVersion();
  @@ -298,7 +299,6 @@
        *
        * @param version a short identifying JBossCache release;
        *                e.g. <code>124</code> for JBossCache 1.2.4
  -     *
        * @deprecated use {@link #setReplicationVersion(String)} instead
        */
       void setStateTransferVersion(short version);
  @@ -308,7 +308,7 @@
        * transfer or a call to {@link #activateRegion(String)}.  Different
        * releases of JBossCache may format this data differently; this property
        * identifies the format version being used by this cache instance.
  -     * <p>
  +    * <p/>
        * The default value for this property is
        * {@link TreeCache#DEFAULT_REPLICATION_VERSION}.
        * </p>
  @@ -710,10 +710,9 @@
        * Sets whether the entire tree is inactive upon startup, only responding
        * to replication messages after {@link #activateRegion(String)} is
        * called to activate one or more parts of the tree.
  -     * <p>
  +    * <p/>
        * This property is only relevant if {@link #getUseMarshalling()} is
        * <code>true</code>.
  -     *
        */
       void setInactiveOnStartup(boolean inactiveOnStartup);
   
  @@ -755,6 +754,7 @@
       /**
        * The same as calling remove(Fqn) except that you can pass in options for this specific method invocation.
        * {@link Option}
  +    *
        * @param fqn
        * @param option
        * @throws CacheException
  @@ -764,6 +764,7 @@
       /**
        * The same as calling remove(Fqn, Object) except that you can pass in options for this specific method invocation.
        * {@link Option}
  +    *
        * @param fqn
        * @param key
        * @param option
  @@ -774,6 +775,7 @@
       /**
        * The same as calling getChildrenNames(Fqn) except that you can pass in options for this specific method invocation.
        * {@link Option}
  +    *
        * @param fqn
        * @param option
        * @return
  @@ -784,6 +786,7 @@
       /**
        * The same as calling put(Fqn, Map) except that you can pass in options for this specific method invocation.
        * {@link Option}
  +    *
        * @param fqn
        * @param data
        * @param option
  @@ -794,6 +797,7 @@
       /**
        * The same as calling put(Fqn, Object, Object) except that you can pass in options for this specific method invocation.
        * {@link Option}
  +    *
        * @param fqn
        * @param key
        * @param value
  @@ -913,24 +917,28 @@
   
       /**
        * provided for backward compat.  Use getCacheLoaderConfiguration() instead.
  +    *
        * @deprecated
        */
       Properties getCacheLoaderConfig();
   
       /**
        * Sets the buddy replication configuration element
  +    *
        * @param config
        */
       void setBuddyReplicationConfig(Element config);
   
       /**
        * Retrieves the buddy replication cofiguration element
  +    *
        * @return config
        */
       Element getBuddyReplicationConfig();
   
       /**
        * Retrieves the JGroups multiplexer service name if defined.
  +    *
        * @return the multiplexer service name
        */
       String getMultiplexerService();
  @@ -945,6 +953,7 @@
       
       /**
        * Retrieves the JGroups multiplexer stack name if defined.
  +    *
        * @return the multiplexer stack name
        */
       String getMultiplexerStack();
  
  
  
  1.28      +1 -0      JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheProxyImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -b -r1.27 -r1.28
  --- TreeCacheProxyImpl.java	6 Sep 2006 15:30:55 -0000	1.27
  +++ TreeCacheProxyImpl.java	7 Sep 2006 13:52:28 -0000	1.28
  @@ -300,6 +300,7 @@
   
      public Node addChild(Fqn f)
      {
  +      if (log.isTraceEnabled()) log.trace("Adding child " + f + "  to parent " + currentNode.getFqn());
         if (treeCache.getInvocationContext().getOptionOverrides().isBypassInterceptorChain())
         {
            TreeCacheProxyImpl retval = null;
  
  
  
  1.14      +502 -364  JBossCache/src/org/jboss/cache/TreeCacheView.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheView.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheView.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- TreeCacheView.java	16 Aug 2006 10:52:51 -0000	1.13
  +++ TreeCacheView.java	7 Sep 2006 13:52:28 -0000	1.14
  @@ -12,7 +12,6 @@
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.config.Configuration;
   import org.jboss.mx.util.MBeanProxyExt;
  -import org.jboss.system.ServiceMBeanSupport;
   import org.jgroups.View;
   
   import javax.management.MBeanServer;
  @@ -55,56 +54,63 @@
    * The view itself caches only the nodes, but doesn't cache any of the data (HashMap) associated with it. When
    * data needs to be displayed, the underlying tree will be accessed directly.
    *
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
    * @author<a href="mailto:bela at jboss.org">Bela Ban</a> March 27 2003
    */
  -public class TreeCacheView extends ServiceMBeanSupport implements TreeCacheViewMBean {
  +public class TreeCacheView implements TreeCacheViewMBean
  +{
      /**
       * Reference to the TreeCache MBean (the model for this view)
       */
  -   ObjectName cache_service=null;
  -   TreeCacheGui gui=null;
  +   ObjectName cache_service = null;
  +   TreeCacheGui gui = null;
      TreeCacheMBean cache;
  +   Log log = LogFactory.getLog(TreeCacheView.class);
   
   
  -   public TreeCacheView() throws Exception {
  +   public TreeCacheView() throws Exception
  +   {
         super();
         init(null);
      }
   
  -   public TreeCacheView(String cache_service) throws Exception {
  +   public TreeCacheView(String cache_service) throws Exception
  +   {
         init(cache_service);
      }
   
   
  -   public void create() throws Exception {
  -      super.create();
  +   public void create()
  +   {
      }
   
  -   public void start() throws Exception {
  -      super.start();
  -      if(gui == null) {
  +   public void start() throws Exception
  +   {
  +      if (gui == null)
  +      {
            log.info("start(): creating the GUI");
  -         gui=new TreeCacheGui(cache);
  +         gui = new TreeCacheGui(cache);
         }
      }
   
  -   public void stop() {
  -      super.stop();
  -      if(gui != null) {
  +   public void stop()
  +   {
  +      if (gui != null)
  +      {
            log.info("stop(): disposing the GUI");
            gui.dispose();
  -         gui=null;
  +         gui = null;
         }
      }
   
      /**
       */
  -   public void destroy() {
  -      super.destroy();
  +   public void destroy()
  +   {
      }
   
  -   public String getCacheService() {
  +   public String getCacheService()
  +   {
         return cache_service != null ? cache_service.toString() : null;
      }
   
  @@ -112,102 +118,119 @@
       * @param cache_service
       * @throws Exception
       */
  -   public void setCacheService(String cache_service) throws Exception {
  +   public void setCacheService(String cache_service) throws Exception
  +   {
         init(cache_service);
      }
   
   
  -   void init(String cache_service) throws Exception {
  -      MBeanServer srv=null;
  +   void init(String cache_service) throws Exception
  +   {
  +      MBeanServer srv = null;
   
  -      if(cache_service != null)
  -         this.cache_service=new ObjectName(cache_service);
  +      if (cache_service != null)
  +         this.cache_service = new ObjectName(cache_service);
         else
            return;
   
         // is this the right way to get hold of the JBoss MBeanServer ?
  -      List servers=MBeanServerFactory.findMBeanServer(null);
  -      if(servers == null || servers.size() == 0)
  +      List servers = MBeanServerFactory.findMBeanServer(null);
  +      if (servers == null || servers.size() == 0)
            throw new Exception("TreeCacheView.init(): no MBeanServers found");
  -      srv=(MBeanServer)servers.get(0);
  +      srv = (MBeanServer) servers.get(0);
         log.info("init(): found MBeanServer " + srv);
  -      cache=(TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, cache_service, srv);
  +      cache = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class, cache_service, srv);
      }
   
   
  -   void populateTree(String dir) throws Exception {
  -      File file=new File(dir);
  +   void populateTree(String dir) throws Exception
  +   {
  +      File file = new File(dir);
   
  -      if(!file.exists()) return;
  +      if (!file.exists()) return;
   
         put(dir, null);
   
  -      if(file.isDirectory()) {
  -         String[] children=file.list();
  -         if(children != null && children.length > 0) {
  -            for(int i=0; i < children.length; i++)
  +      if (file.isDirectory())
  +      {
  +         String[] children = file.list();
  +         if (children != null && children.length > 0)
  +         {
  +            for (int i = 0; i < children.length; i++)
                  populateTree(dir + "/" + children[i]);
            }
         }
      }
   
  -   void put(String fqn, Map m) {
  -      try {
  +   void put(String fqn, Map m)
  +   {
  +      try
  +      {
            cache.put(fqn, m);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheView.put(): " + t);
         }
      }
   
   
  -   public static void main(String args[]) {
  -      TreeCache tree=null;
  +   public static void main(String args[])
  +   {
  +      TreeCache tree = null;
         TreeCacheView demo;
  -      String start_directory=null;
  -      String mbean_name="jboss.cache:service=TreeCache";
  -      String props=getDefaultProps();
  +      String start_directory = null;
  +      String mbean_name = "jboss.cache:service=TreeCache";
  +      String props = getDefaultProps();
         MBeanServer srv;
         Log log;
  -      boolean use_queue=false;
  -      int queue_interval=5000;
  -      int queue_max_elements=100;
  +      boolean use_queue = false;
  +      int queue_interval = 5000;
  +      int queue_max_elements = 100;
   
   
  -      for(int i=0; i < args.length; i++) {
  -         if(args[i].equals("-mbean_name")) {
  -            mbean_name=args[++i];
  +      for (int i = 0; i < args.length; i++)
  +      {
  +         if (args[i].equals("-mbean_name"))
  +         {
  +            mbean_name = args[++i];
               continue;
            }
  -         if(args[i].equals("-props")) {
  -            props=args[++i];
  +         if (args[i].equals("-props"))
  +         {
  +            props = args[++i];
               continue;
            }
  -         if(args[i].equals("-start_directory")) {
  -            start_directory=args[++i];
  +         if (args[i].equals("-start_directory"))
  +         {
  +            start_directory = args[++i];
               continue;
            }
  -         if(args[i].equals("-use_queue")) {
  -            use_queue=true;
  +         if (args[i].equals("-use_queue"))
  +         {
  +            use_queue = true;
               continue;
            }
  -         if(args[i].equals("-queue_interval")) {
  -            queue_interval=Integer.parseInt(args[++i]);
  -            use_queue=true;
  +         if (args[i].equals("-queue_interval"))
  +         {
  +            queue_interval = Integer.parseInt(args[++i]);
  +            use_queue = true;
               continue;
            }
  -         if(args[i].equals("-queue_max_elements")) {
  -            queue_max_elements=Integer.parseInt(args[++i]);
  -            use_queue=true;
  +         if (args[i].equals("-queue_max_elements"))
  +         {
  +            queue_max_elements = Integer.parseInt(args[++i]);
  +            use_queue = true;
               continue;
            }
            help();
            return;
         }
   
  -      try {
  -         log=LogFactory.getLog(TreeCache.class);
  -         srv=MBeanServerFactory.createMBeanServer();
  +      try
  +      {
  +         log = LogFactory.getLog(TreeCache.class);
  +         srv = MBeanServerFactory.createMBeanServer();
   
   //            String  FACTORY="org.jboss.cache.transaction.DummyContextFactory";
   //            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
  @@ -215,14 +238,15 @@
   //            DummyTransactionManager.getInstance();
   
   
  -         tree=new TreeCache();
  +         tree = new TreeCache();
            Configuration c = new Configuration();
            c.setClusterName("TreeCacheGroup");
            c.setClusterConfig(props);
            c.setInitialStateRetrievalTimeout(10000);
            c.setCacheMode("REPL_ASYNC");
   
  -         if(use_queue) {
  +         if (use_queue)
  +         {
               c.setUseReplQueue(true);
               c.setReplQueueInterval(queue_interval);
               c.setReplQueueMaxElements(queue_max_elements);
  @@ -244,31 +268,37 @@
   //            tree.put("/a/b1/chat2", null);
   //            tree.put("/a/b1/chat5", null);
   
  -         demo=new TreeCacheView(mbean_name);
  +         demo = new TreeCacheView(mbean_name);
            demo.create();
            demo.start();
  -         if(start_directory != null && start_directory.length() > 0) {
  +         if (start_directory != null && start_directory.length() > 0)
  +         {
               demo.populateTree(start_directory);
            }
         }
  -      catch(Exception ex) {
  +      catch (Exception ex)
  +      {
            ex.printStackTrace();
         }
      }
   
  -   static class ShutdownThread extends Thread {
  -      TreeCache tree=null;
  +   static class ShutdownThread extends Thread
  +   {
  +      TreeCache tree = null;
   
  -      ShutdownThread(TreeCache tree) {
  -         this.tree=tree;
  +      ShutdownThread(TreeCache tree)
  +      {
  +         this.tree = tree;
         }
   
  -      public void run() {
  +      public void run()
  +      {
            tree.stop();
         }
      }
   
  -   private static String getDefaultProps() {
  +   private static String getDefaultProps()
  +   {
         return
                 "UDP(ip_mcast=true;ip_ttl=64;loopback=false;mcast_addr=228.1.2.3;" +
                 "mcast_port=45566;mcast_recv_buf_size=80000;mcast_send_buf_size=150000;" +
  @@ -287,7 +317,8 @@
      }
   
   
  -   static void help() {
  +   static void help()
  +   {
         System.out.println("TreeCacheView [-help] " +
                 "[-mbean_name <name of TreeCache MBean>] " +
                 "[-start_directory <dirname>] [-props <props>] " +
  @@ -296,34 +327,38 @@
      }
   
   
  -   public static class MyListener extends AbstractCacheListener {}
  +   public static class MyListener extends AbstractCacheListener
  +   {
  +   }
   
   
   }
   
   
   class TreeCacheGui extends JFrame implements WindowListener, CacheListener,
  -        TreeSelectionListener, TableModelListener {
  +        TreeSelectionListener, TableModelListener
  +{
      private static final long serialVersionUID = 8576324868563647538L;
      TreeCacheMBean cache;
  -   DefaultTreeModel tree_model=null;
  -   Log log=LogFactory.getLog(getClass());
  -   JTree jtree=null;
  -   DefaultTableModel table_model=new DefaultTableModel();
  -   JTable table=new JTable(table_model);
  -   MyNode root=new MyNode(SEP);
  -   String selected_node=null;
  -   JPanel tablePanel=null;
  -   JMenu operationsMenu=null;
  -   JPopupMenu operationsPopup=null;
  -   JMenuBar menubar=null;
  -   static final String SEP=Fqn.SEPARATOR;
  -   private static final int KEY_COL_WIDTH=20;
  -   private static final int VAL_COL_WIDTH=300;
  +   DefaultTreeModel tree_model = null;
  +   Log log = LogFactory.getLog(getClass());
  +   JTree jtree = null;
  +   DefaultTableModel table_model = new DefaultTableModel();
  +   JTable table = new JTable(table_model);
  +   MyNode root = new MyNode(SEP);
  +   String selected_node = null;
  +   JPanel tablePanel = null;
  +   JMenu operationsMenu = null;
  +   JPopupMenu operationsPopup = null;
  +   JMenuBar menubar = null;
  +   static final String SEP = Fqn.SEPARATOR;
  +   private static final int KEY_COL_WIDTH = 20;
  +   private static final int VAL_COL_WIDTH = 300;
   
   
  -   public TreeCacheGui(TreeCacheMBean cache) throws Exception {
  -      this.cache=cache;
  +   public TreeCacheGui(TreeCacheMBean cache) throws Exception
  +   {
  +      this.cache = cache;
   
         //server.invoke(cache_service, "addTreeCacheListener",
         //            new Object[]{this},
  @@ -332,12 +367,12 @@
         addNotify();
         setTitle("TreeCacheGui: mbr=" + getLocalAddress());
   
  -      tree_model=new DefaultTreeModel(root);
  -      jtree=new JTree(tree_model);
  +      tree_model = new DefaultTreeModel(root);
  +      jtree = new JTree(tree_model);
         jtree.setDoubleBuffered(true);
         jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   
  -      JScrollPane scroll_pane=new JScrollPane(jtree);
  +      JScrollPane scroll_pane = new JScrollPane(jtree);
   
         populateTree();
   
  @@ -349,7 +384,7 @@
   
         setTableColumnWidths();
   
  -      tablePanel=new JPanel();
  +      tablePanel = new JPanel();
         tablePanel.setLayout(new BorderLayout());
         tablePanel.add(table.getTableHeader(), BorderLayout.NORTH);
         tablePanel.add(table, BorderLayout.CENTER);
  @@ -358,15 +393,19 @@
   
         jtree.addTreeSelectionListener(this);//REVISIT
   
  -      MouseListener ml=new MouseAdapter() {
  -         public void mouseClicked(MouseEvent e) {
  -            int selRow=jtree.getRowForLocation(e.getX(), e.getY());
  -            TreePath selPath=jtree.getPathForLocation(e.getX(), e.getY());
  -            if(selRow != -1) {
  -               selected_node=makeFQN(selPath.getPath());
  +      MouseListener ml = new MouseAdapter()
  +      {
  +         public void mouseClicked(MouseEvent e)
  +         {
  +            int selRow = jtree.getRowForLocation(e.getX(), e.getY());
  +            TreePath selPath = jtree.getPathForLocation(e.getX(), e.getY());
  +            if (selRow != -1)
  +            {
  +               selected_node = makeFQN(selPath.getPath());
                  jtree.setSelectionPath(selPath);
   
  -               if(e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK) {
  +               if (e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK)
  +               {
                     operationsPopup.show(e.getComponent(),
                             e.getX(), e.getY());
                  }
  @@ -385,62 +424,78 @@
         setVisible(true);
      }
   
  -   void setSystemExit(boolean flag) {
  +   void setSystemExit(boolean flag)
  +   {
      }
   
  -   public void windowClosed(WindowEvent event) {
  +   public void windowClosed(WindowEvent event)
  +   {
      }
   
  -   public void windowDeiconified(WindowEvent event) {
  +   public void windowDeiconified(WindowEvent event)
  +   {
      }
   
  -   public void windowIconified(WindowEvent event) {
  +   public void windowIconified(WindowEvent event)
  +   {
      }
   
  -   public void windowActivated(WindowEvent event) {
  +   public void windowActivated(WindowEvent event)
  +   {
      }
   
  -   public void windowDeactivated(WindowEvent event) {
  +   public void windowDeactivated(WindowEvent event)
  +   {
      }
   
  -   public void windowOpened(WindowEvent event) {
  +   public void windowOpened(WindowEvent event)
  +   {
      }
   
  -   public void windowClosing(WindowEvent event) {
  +   public void windowClosing(WindowEvent event)
  +   {
         dispose();
      }
   
   
  -   public void tableChanged(TableModelEvent evt) {
  +   public void tableChanged(TableModelEvent evt)
  +   {
         int row, col;
         String key, val;
   
  -      if(evt.getType() == TableModelEvent.UPDATE) {
  -         row=evt.getFirstRow();
  -         col=evt.getColumn();
  -         if(col == 0) {  // set()
  -            key=(String)table_model.getValueAt(row, col);
  -            val=(String)table_model.getValueAt(row, col + 1);
  -            if(key != null && val != null) {
  +      if (evt.getType() == TableModelEvent.UPDATE)
  +      {
  +         row = evt.getFirstRow();
  +         col = evt.getColumn();
  +         if (col == 0)
  +         {  // set()
  +            key = (String) table_model.getValueAt(row, col);
  +            val = (String) table_model.getValueAt(row, col + 1);
  +            if (key != null && val != null)
  +            {
                  // tree.put(selected_node, key, val);
   
   //                        server.invoke(cache_service, "put",
   //                                      new Object[]{selected_node, key, val},
   //                                      new String[]{String.class.getName(),
   //                                      String.class.getName(), Object.class.getName()});
  -               try {
  +               try
  +               {
                     cache.put(selected_node, key, val);
                  }
  -               catch(Exception e) {
  +               catch (Exception e)
  +               {
                     e.printStackTrace();
                  }
   
               }
            }
  -         else {          // add()
  -            key=(String)table_model.getValueAt(row, col - 1);
  -            val=(String)table.getValueAt(row, col);
  -            if(key != null && val != null) {
  +         else
  +         {          // add()
  +            key = (String) table_model.getValueAt(row, col - 1);
  +            val = (String) table.getValueAt(row, col);
  +            if (key != null && val != null)
  +            {
                  put(selected_node, key, val);
               }
            }
  @@ -448,46 +503,50 @@
      }
   
   
  -   public void valueChanged(TreeSelectionEvent evt) {
  -      TreePath path=evt.getPath();
  -      String fqn=SEP;
  +   public void valueChanged(TreeSelectionEvent evt)
  +   {
  +      TreePath path = evt.getPath();
  +      String fqn = SEP;
         String component_name;
  -      Map data=null;
  +      Map data = null;
   
  -      for(int i=0; i < path.getPathCount(); i++) {
  -         component_name=((MyNode)path.getPathComponent(i)).name;
  -         if(component_name.equals(SEP))
  +      for (int i = 0; i < path.getPathCount(); i++)
  +      {
  +         component_name = ((MyNode) path.getPathComponent(i)).name;
  +         if (component_name.equals(SEP))
               continue;
  -         if(fqn.equals(SEP))
  -            fqn+=component_name;
  +         if (fqn.equals(SEP))
  +            fqn += component_name;
            else
  -            fqn=fqn + SEP + component_name;
  +            fqn = fqn + SEP + component_name;
         }
  -      data=getData(fqn);
  -      if(data != null) {
  +      data = getData(fqn);
  +      if (data != null)
  +      {
            getContentPane().add(tablePanel, BorderLayout.SOUTH);
            populateTable(data);
            validate();
         }
  -      else {
  +      else
  +      {
            clearTable();
            getContentPane().remove(tablePanel);
            validate();
         }
      }
   
  -
  -
      /* ------------------ ReplicatedTree.ReplicatedTreeListener interface ------------ */
   
  -   public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal) {
  +   public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
  +   {
         if (!pre)
         {
             MyNode n, p;
   
  -          n=root.add(fqn.toString());
  -          if(n != null) {
  -             p=(MyNode)n.getParent();
  +         n = root.add(fqn.toString());
  +         if (n != null)
  +         {
  +            p = (MyNode) n.getParent();
                tree_model.reload(p);
                jtree.scrollPathToVisible(new TreePath(n.getPath()));
             }
  @@ -501,10 +560,11 @@
             MyNode n;
             TreeNode par;
   
  -          n=root.findNode(fqn.toString());
  -          if(n != null) {
  +         n = root.findNode(fqn.toString());
  +         if (n != null)
  +         {
                n.removeAllChildren();
  -             par=n.getParent();
  +            par = n.getParent();
                n.removeFromParent();
                tree_model.reload(par);
             }
  @@ -533,7 +593,8 @@
          nodeRemoved(fqn, pre, isLocal, null);
       }
   
  -   public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data) {
  +   public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
  +   {
         // Map data;
         //data=getData(fqn);
         //populateTable(data); REVISIT
  @@ -554,11 +615,15 @@
      {
      }
   
  -   public void viewChange(final View new_view) {
  -      new Thread() {
  -         public void run() {
  +   public void viewChange(final View new_view)
  +   {
  +      new Thread()
  +      {
  +         public void run()
  +         {
               Vector mbrship;
  -            if(new_view != null && (mbrship=new_view.getMembers()) != null) {
  +            if (new_view != null && (mbrship = new_view.getMembers()) != null)
  +            {
                  _put(SEP, "members", mbrship);
                  _put(SEP, "coordinator", mbrship.firstElement());
               }
  @@ -566,31 +631,29 @@
         }.start();
      }
   
  -
  -
  -
      /* ---------------- End of ReplicatedTree.ReplicatedTreeListener interface -------- */
   
      /*----------------- Runnable implementation to make View change calles in AWT Thread ---*/
   
  -   public void run() {
  +   public void run()
  +   {
   
      }
   
  -
  -
      /* ----------------------------- Private Methods ---------------------------------- */
   
      /**
       * Fetches all data from underlying tree model and display it graphically
       */
  -   void init() {
  -      Vector mbrship=null;
  +   void init()
  +   {
  +      Vector mbrship = null;
   
         addGuiNode(SEP);
   
  -      mbrship=getMembers() != null ? (Vector)getMembers().clone() : null;
  -      if(mbrship != null && mbrship.size() > 0) {
  +      mbrship = getMembers() != null ? (Vector) getMembers().clone() : null;
  +      if (mbrship != null && mbrship.size() > 0)
  +      {
            _put(SEP, "members", mbrship);
            _put(SEP, "coordinator", mbrship.firstElement());
         }
  @@ -600,7 +663,8 @@
      /**
       * Fetches all data from underlying tree model and display it graphically
       */
  -   private void populateTree() {
  +   private void populateTree()
  +   {
         addGuiNode(SEP);
      }
   
  @@ -608,50 +672,57 @@
      /**
       * Recursively adds GUI nodes starting from fqn
       */
  -   void addGuiNode(String fqn) {
  +   void addGuiNode(String fqn)
  +   {
         Set children;
         String child_name;
   
  -      if(fqn == null) return;
  +      if (fqn == null) return;
   
         // 1 . Add myself
         root.add(fqn);
   
         // 2. Then add my children
  -      children=getChildrenNames(fqn);
  -      if(children != null) {
  -         for(Iterator it=children.iterator(); it.hasNext();) {
  -            child_name=it.next().toString();
  +      children = getChildrenNames(fqn);
  +      if (children != null)
  +      {
  +         for (Iterator it = children.iterator(); it.hasNext();)
  +         {
  +            child_name = it.next().toString();
               addGuiNode(fqn + SEP + child_name);
            }
         }
      }
   
   
  -   String makeFQN(Object[] path) {
  -      StringBuffer sb=new StringBuffer("");
  +   String makeFQN(Object[] path)
  +   {
  +      StringBuffer sb = new StringBuffer("");
         String tmp_name;
   
  -      if(path == null) return null;
  -      for(int i=0; i < path.length; i++) {
  -         tmp_name=((MyNode)path[i]).name;
  -         if(tmp_name.equals(SEP))
  +      if (path == null) return null;
  +      for (int i = 0; i < path.length; i++)
  +      {
  +         tmp_name = ((MyNode) path[i]).name;
  +         if (tmp_name.equals(SEP))
               continue;
            else
               sb.append(SEP + tmp_name);
         }
  -      tmp_name=sb.toString();
  -      if(tmp_name.length() == 0)
  +      tmp_name = sb.toString();
  +      if (tmp_name.length() == 0)
            return SEP;
         else
            return tmp_name;
      }
   
  -   void clearTable() {
  -      int num_rows=table.getRowCount();
  +   void clearTable()
  +   {
  +      int num_rows = table.getRowCount();
   
  -      if(num_rows > 0) {
  -         for(int i=0; i < num_rows; i++)
  +      if (num_rows > 0)
  +      {
  +         for (int i = 0; i < num_rows; i++)
               table_model.removeRow(0);
            table_model.fireTableRowsDeleted(0, num_rows - 1);
            repaint();
  @@ -659,22 +730,25 @@
      }
   
   
  -   void populateTable(Map data) {
  -      String key, strval="<null>";
  +   void populateTable(Map data)
  +   {
  +      String key, strval = "<null>";
         Object val;
  -      int num_rows=0;
  +      int num_rows = 0;
         Map.Entry entry;
   
  -      if(data == null) return;
  -      num_rows=data.size();
  +      if (data == null) return;
  +      num_rows = data.size();
         clearTable();
   
  -      if(num_rows > 0) {
  -         for(Iterator it=data.entrySet().iterator(); it.hasNext();) {
  -            entry=(Map.Entry)it.next();
  -            key=(String)entry.getKey();
  -            val=entry.getValue();
  -            if(val != null) strval=val.toString();
  +      if (num_rows > 0)
  +      {
  +         for (Iterator it = data.entrySet().iterator(); it.hasNext();)
  +         {
  +            entry = (Map.Entry) it.next();
  +            key = (String) entry.getKey();
  +            val = entry.getValue();
  +            if (val != null) strval = val.toString();
               table_model.addRow(new Object[]{key, strval});
            }
            table_model.fireTableRowsInserted(0, num_rows - 1);
  @@ -682,30 +756,32 @@
         }
      }
   
  -   private void setTableColumnWidths() {
  +   private void setTableColumnWidths()
  +   {
         table.sizeColumnsToFit(JTable.AUTO_RESIZE_NEXT_COLUMN);
  -      TableColumn column=null;
  -      column=table.getColumnModel().getColumn(0);
  +      TableColumn column = null;
  +      column = table.getColumnModel().getColumn(0);
         column.setMinWidth(KEY_COL_WIDTH);
         column.setPreferredWidth(KEY_COL_WIDTH);
  -      column=table.getColumnModel().getColumn(1);
  +      column = table.getColumnModel().getColumn(1);
         column.setPreferredWidth(VAL_COL_WIDTH);
      }
   
  -   private void createMenus() {
  -      menubar=new JMenuBar();
  -      operationsMenu=new JMenu("Operations");
  -      AddNodeAction addNode=new AddNodeAction();
  +   private void createMenus()
  +   {
  +      menubar = new JMenuBar();
  +      operationsMenu = new JMenu("Operations");
  +      AddNodeAction addNode = new AddNodeAction();
         addNode.putValue(AbstractAction.NAME, "Add to this node");
  -      RemoveNodeAction removeNode=new RemoveNodeAction();
  +      RemoveNodeAction removeNode = new RemoveNodeAction();
         removeNode.putValue(AbstractAction.NAME, "Remove this node");
  -      AddModifyDataForNodeAction addModAction=new AddModifyDataForNodeAction();
  +      AddModifyDataForNodeAction addModAction = new AddModifyDataForNodeAction();
         addModAction.putValue(AbstractAction.NAME, "Add/Modify data");
  -      PrintLockInfoAction print_locks=new PrintLockInfoAction();
  +      PrintLockInfoAction print_locks = new PrintLockInfoAction();
         print_locks.putValue(AbstractAction.NAME, "Print lock information (stdout)");
  -      ReleaseAllLocksAction release_locks=new ReleaseAllLocksAction();
  +      ReleaseAllLocksAction release_locks = new ReleaseAllLocksAction();
         release_locks.putValue(AbstractAction.NAME, "Release all locks");
  -      ExitAction exitAction=new ExitAction();
  +      ExitAction exitAction = new ExitAction();
         exitAction.putValue(AbstractAction.NAME, "Exit");
         operationsMenu.add(addNode);
         operationsMenu.add(removeNode);
  @@ -716,133 +792,164 @@
         menubar.add(operationsMenu);
         setJMenuBar(menubar);
   
  -      operationsPopup=new JPopupMenu();
  +      operationsPopup = new JPopupMenu();
         operationsPopup.add(addNode);
         operationsPopup.add(removeNode);
         operationsPopup.add(addModAction);
      }
   
  -   Object getLocalAddress() {
  -      try {
  +   Object getLocalAddress()
  +   {
  +      try
  +      {
            return cache.getLocalAddress();
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.getLocalAddress(): " + t);
            return null;
         }
      }
   
  -   Map getData(String fqn) {
  +   Map getData(String fqn)
  +   {
         Map data;
         Set keys;
         String key;
         Object value;
   
  -      if(fqn == null) return null;
  -      keys=getKeys(fqn);
  -      if(keys == null) return null;
  -      data=new HashMap();
  -      for(Iterator it=keys.iterator(); it.hasNext();) {
  -         key=(String)it.next();
  -         value=get(fqn, key);
  -         if(value != null)
  +      if (fqn == null) return null;
  +      keys = getKeys(fqn);
  +      if (keys == null) return null;
  +      data = new HashMap();
  +      for (Iterator it = keys.iterator(); it.hasNext();)
  +      {
  +         key = (String) it.next();
  +         value = get(fqn, key);
  +         if (value != null)
               data.put(key, value);
         }
         return data;
      }
   
   
  -   void put(String fqn, Map m) {
  -      try {
  +   void put(String fqn, Map m)
  +   {
  +      try
  +      {
            cache.put(fqn, m);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.put(): " + t);
         }
      }
   
   
  -   void put(String fqn, String key, Object value) {
  -      try {
  +   void put(String fqn, String key, Object value)
  +   {
  +      try
  +      {
            cache.put(fqn, key, value);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.put(): " + t);
         }
      }
   
  -   void _put(String fqn, String key, Object value) {
  -      try {
  +   void _put(String fqn, String key, Object value)
  +   {
  +      try
  +      {
            cache._put(null, fqn, key, value, false);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui._put(): " + t);
         }
      }
   
  -   Set getKeys(String fqn) {
  -      try {
  +   Set getKeys(String fqn)
  +   {
  +      try
  +      {
            return cache.getKeys(fqn);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.getKeys(): " + t);
            return null;
         }
      }
   
  -   Object get(String fqn, String key) {
  -      try {
  +   Object get(String fqn, String key)
  +   {
  +      try
  +      {
            return cache.get(fqn, key);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.get(): " + t);
            return null;
         }
      }
   
  -   Set getChildrenNames(String fqn) {
  -      try {
  +   Set getChildrenNames(String fqn)
  +   {
  +      try
  +      {
            return cache.getChildrenNames(fqn);
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.getChildrenNames(): " + t);
            return null;
         }
      }
   
  -   Vector getMembers() {
  -      try {
  +   Vector getMembers()
  +   {
  +      try
  +      {
            return cache.getMembers();
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            log.error("TreeCacheGui.getMembers(): " + t);
            return null;
         }
      }
   
  -
      /* -------------------------- End of Private Methods ------------------------------ */
   
      /*----------------------- Actions ---------------------------*/
  -   class ExitAction extends AbstractAction {
  +   class ExitAction extends AbstractAction
  +   {
         private static final long serialVersionUID = 8895044368299888998L;
  -      public void actionPerformed(ActionEvent e) {
  +
  +      public void actionPerformed(ActionEvent e)
  +      {
            dispose();
         }
      }
   
  -   class AddNodeAction extends AbstractAction {
  +   class AddNodeAction extends AbstractAction
  +   {
         private static final long serialVersionUID = 5568518714172267901L;
  -      public void actionPerformed(ActionEvent e) {
  -         JTextField fqnTextField=new JTextField();
  -         if(selected_node != null)
  +
  +      public void actionPerformed(ActionEvent e)
  +      {
  +         JTextField fqnTextField = new JTextField();
  +         if (selected_node != null)
               fqnTextField.setText(selected_node);
  -         Object[] information={"Enter fully qualified name",
  +         Object[] information = {"Enter fully qualified name",
                                  fqnTextField};
  -         final String btnString1="OK";
  -         final String btnString2="Cancel";
  -         Object[] options={btnString1, btnString2};
  -         int userChoice=JOptionPane.showOptionDialog(null,
  +         final String btnString1 = "OK";
  +         final String btnString2 = "Cancel";
  +         Object[] options = {btnString1, btnString2};
  +         int userChoice = JOptionPane.showOptionDialog(null,
                    information,
                    "Add DataNode",
                    JOptionPane.YES_NO_OPTION,
  @@ -850,53 +957,70 @@
                    null,
                    options,
                    options[0]);
  -         if(userChoice == 0) {
  -            String userInput=fqnTextField.getText();
  +         if (userChoice == 0)
  +         {
  +            String userInput = fqnTextField.getText();
               put(userInput, null);
            }
         }
      }
   
   
  -   class PrintLockInfoAction extends AbstractAction {
  +   class PrintLockInfoAction extends AbstractAction
  +   {
         private static final long serialVersionUID = 5577441016277949170L;
  -      public void actionPerformed(ActionEvent e) {
  +
  +      public void actionPerformed(ActionEvent e)
  +      {
            System.out.println("\n*** lock information ****\n" + cache.printLockInfo());
         }
      }
   
  -   class ReleaseAllLocksAction extends AbstractAction {
  +   class ReleaseAllLocksAction extends AbstractAction
  +   {
         private static final long serialVersionUID = 3796901116451916116L;
  -      public void actionPerformed(ActionEvent e) {
  +
  +      public void actionPerformed(ActionEvent e)
  +      {
            cache.releaseAllLocks("/");
         }
      }
   
  -   class RemoveNodeAction extends AbstractAction {
  +   class RemoveNodeAction extends AbstractAction
  +   {
         private static final long serialVersionUID = 8985697625953238855L;
  -      public void actionPerformed(ActionEvent e) {
  +
  +      public void actionPerformed(ActionEvent e)
  +      {
            //remove(selected_node);
  -         try {
  +         try
  +         {
               //server.invoke(cache_service, "remove",
               //            new Object[]{selected_node},
               //          new String[]{STRING});
               cache.remove(selected_node);
            }
  -         catch(Throwable t) {
  +         catch (Throwable t)
  +         {
               log.error("RemoveNodeAction.actionPerformed(): " + t);
            }
         }
      }
   
  -   class AddModifyDataForNodeAction extends AbstractAction {
  +   class AddModifyDataForNodeAction extends AbstractAction
  +   {
         private static final long serialVersionUID = 3593129982953807846L;
  -      public void actionPerformed(ActionEvent e) {
  -         Map data=getData(selected_node);
  -         if(data != null) {
  +
  +      public void actionPerformed(ActionEvent e)
  +      {
  +         Map data = getData(selected_node);
  +         if (data != null)
  +         {
            }
  -         else {
  +         else
  +         {
               clearTable();
  -            data=new HashMap();
  +            data = new HashMap();
               data.put("Add Key", "Add Value");
   
            }
  @@ -908,13 +1032,15 @@
      }
   
   
  -   class MyNode extends DefaultMutableTreeNode {
  +   class MyNode extends DefaultMutableTreeNode
  +   {
         private static final long serialVersionUID = 1578599138419577069L;
  -      String name="<unnamed>";
  +      String name = "<unnamed>";
   
   
  -      MyNode(String name) {
  -         this.name=name;
  +      MyNode(String name)
  +      {
  +         this.name = name;
         }
   
   
  @@ -922,24 +1048,27 @@
          * Adds a new node to the view. Intermediary nodes will be created if they don't yet exist.
          * Returns the first node that was created or null if node already existed
          */
  -      public MyNode add(String fqn) {
  -         MyNode curr, n, ret=null;
  +      public MyNode add(String fqn)
  +      {
  +         MyNode curr, n, ret = null;
            StringTokenizer tok;
            String child_name;
   
  -         if(fqn == null) return null;
  -         curr=this;
  -         tok=new StringTokenizer(fqn, TreeCacheGui.SEP);
  -
  -         while(tok.hasMoreTokens()) {
  -            child_name=tok.nextToken();
  -            n=curr.findChild(child_name);
  -            if(n == null) {
  -               n=new MyNode(child_name);
  -               if(ret == null) ret=n;
  +         if (fqn == null) return null;
  +         curr = this;
  +         tok = new StringTokenizer(fqn, TreeCacheGui.SEP);
  +
  +         while (tok.hasMoreTokens())
  +         {
  +            child_name = tok.nextToken();
  +            n = curr.findChild(child_name);
  +            if (n == null)
  +            {
  +               n = new MyNode(child_name);
  +               if (ret == null) ret = n;
                  curr.add(n);
               }
  -            curr=n;
  +            curr = n;
            }
            return ret;
         }
  @@ -948,83 +1077,92 @@
         /**
          * Removes a node from the view. Child nodes will be removed as well
          */
  -      public void remove(String fqn) {
  +      public void remove(String fqn)
  +      {
            removeFromParent();
         }
   
   
  -      MyNode findNode(String fqn) {
  +      MyNode findNode(String fqn)
  +      {
            MyNode curr, n;
            StringTokenizer tok;
            String child_name;
   
  -         if(fqn == null) return null;
  -         curr=this;
  -         tok=new StringTokenizer(fqn, TreeCacheGui.SEP);
  -
  -         while(tok.hasMoreTokens()) {
  -            child_name=tok.nextToken();
  -            n=curr.findChild(child_name);
  -            if(n == null)
  +         if (fqn == null) return null;
  +         curr = this;
  +         tok = new StringTokenizer(fqn, TreeCacheGui.SEP);
  +
  +         while (tok.hasMoreTokens())
  +         {
  +            child_name = tok.nextToken();
  +            n = curr.findChild(child_name);
  +            if (n == null)
                  return null;
  -            curr=n;
  +            curr = n;
            }
            return curr;
         }
   
   
  -      MyNode findChild(String relative_name) {
  +      MyNode findChild(String relative_name)
  +      {
            MyNode child;
   
  -         if(relative_name == null || getChildCount() == 0)
  +         if (relative_name == null || getChildCount() == 0)
               return null;
  -         for(int i=0; i < getChildCount(); i++) {
  -            child=(MyNode)getChildAt(i);
  -            if(child.name == null) {
  +         for (int i = 0; i < getChildCount(); i++)
  +         {
  +            child = (MyNode) getChildAt(i);
  +            if (child.name == null)
  +            {
                  continue;
               }
   
  -            if(child.name.equals(relative_name))
  +            if (child.name.equals(relative_name))
                  return child;
            }
            return null;
         }
   
   
  -      String print(int indent) {
  -         StringBuffer sb=new StringBuffer();
  +      String print(int indent)
  +      {
  +         StringBuffer sb = new StringBuffer();
   
  -         for(int i=0; i < indent; i++)
  +         for (int i = 0; i < indent; i++)
               sb.append(" ");
  -         if(!isRoot()) {
  -            if(name == null)
  +         if (!isRoot())
  +         {
  +            if (name == null)
                  sb.append("/<unnamed>");
  -            else {
  +            else
  +            {
                  sb.append(TreeCacheGui.SEP + name);
               }
            }
            sb.append("\n");
  -         if(getChildCount() > 0) {
  -            if(isRoot())
  -               indent=0;
  +         if (getChildCount() > 0)
  +         {
  +            if (isRoot())
  +               indent = 0;
               else
  -               indent+=4;
  -            for(int i=0; i < getChildCount(); i++)
  -               sb.append(((MyNode)getChildAt(i)).print(indent));
  +               indent += 4;
  +            for (int i = 0; i < getChildCount(); i++)
  +               sb.append(((MyNode) getChildAt(i)).print(indent));
            }
            return sb.toString();
         }
   
   
  -      public String toString() {
  +      public String toString()
  +      {
            return name;
         }
   
      }
   
   
  -
  -
   }
   
   
  
  
  
  1.3       +7 -12     JBossCache/src/org/jboss/cache/TreeCacheViewMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheViewMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheViewMBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- TreeCacheViewMBean.java	31 May 2006 14:08:39 -0000	1.2
  +++ TreeCacheViewMBean.java	7 Sep 2006 13:52:28 -0000	1.3
  @@ -6,21 +6,16 @@
    */
   package org.jboss.cache;
   
  +import org.jboss.cache.jmx.LifeCycle;
  +
   /**
    * MBean interface.
  + *
    * @author <a href="mailto:bela at jboss.org">Bela Ban</a> March 27 2003
    */
  -public interface TreeCacheViewMBean extends org.jboss.system.ServiceMBean {
  -
  -  void create() throws java.lang.Exception;
  -
  -  void start() throws java.lang.Exception;
  -
  -  void stop() ;
  -
  -  void destroy() ;
  -
  -  java.lang.String getCacheService() ;
  +public interface TreeCacheViewMBean extends LifeCycle
  +{
  +   java.lang.String getCacheService();
   
     void setCacheService(java.lang.String cache_service) throws java.lang.Exception;
   
  
  
  



More information about the jboss-cvs-commits mailing list