Package

Source Code of CleanPrefs

import java.util.prefs.Preferences;

/**
* Use this class to quickly clean all Java Preferences for either the
* agent, the server or both. Pass in command line argument "agent" to
* clean only the agent preferences; pass in "server" to clean only the
* server preferences; do not pass in anything to clean both agent and
* server preferences.
*/
public class CleanPrefs
{
   public static final void main( String[] args )
   throws Exception
   {
      if ( ( args == null ) || ( args.length <= 0 ) )
      {
         cleanAgent();
         cleanServer();
      }
      else if ( "agent".equals( args[0] ) )
      {
         cleanAgent();
      }
      else if ( "server".equals( args[0] ) )
      {
         cleanServer();
      }
      else
      {
         System.out.println( CleanPrefs.class.getName() + " [server|agent]" );
         System.out.println( "Not specifying anything will imply both are to be cleaned." );
      }
   }

   public static final void cleanAgent()
   throws Exception
   {
      Preferences node = getNode( "rhq-agent" );
      node.removeNode();
      node.flush();
   }

   public static final void cleanServer()
   throws Exception
   {
      Preferences node = getNode( "rhq-server" );
      node.removeNode();
      node.flush();
   }

   public static final Preferences getNode( String name )
   {
      Preferences node = Preferences.userRoot().node( name );
      System.out.println( "Cleaning " + node );
      return node;
   }
}
TOP

Related Classes of CleanPrefs

TOP
Copyright © 2018 www.massapi.com. 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.