From 4bb5ff428b255cafabf3613501196496acd9cb8c Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 30 Jul 2007 14:49:00 +0000
Subject: [PATCH] Modify the HelpSubCommandHandler so that it is no longer a singleton. Being a singleton meant that multiple instances of dsconfig would share the same help sub-system and re-initialize it, potentially causing problems.

---
 opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java |  100 +++++++++++++++++++------------------------------
 1 files changed, 39 insertions(+), 61 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
index 7cee8cc..663839d 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
@@ -392,67 +392,9 @@
    * @throws ArgumentException
    *           If the sub-command could not be created successfully.
    */
-  public static synchronized HelpSubCommandHandler create(
-      ConsoleApplication app, SubCommandArgumentParser parser)
-      throws ArgumentException {
-    if (INSTANCE == null) {
-      INSTANCE = new HelpSubCommandHandler(app, parser);
-    }
-    return INSTANCE;
-  }
-
-
-
-  /**
-   * Gets the application-wide help sub-command handler.
-   *
-   * @return Returns the application-wide help sub-command handler.
-   */
-  public static synchronized HelpSubCommandHandler getInstance() {
-    if (INSTANCE == null) {
-      throw new RuntimeException("Help sub-command handler not initialized");
-    } else {
-      return INSTANCE;
-    }
-  }
-
-
-
-  // The singleton instance.
-  private static HelpSubCommandHandler INSTANCE = null;
-
-  // The sub-command associated with this handler.
-  private final SubCommand subCommand;
-
-  // The argument which should be used to specify the type of managed
-  // object to be retrieved.
-  private final StringArgument typeArgument;
-
-  // A table listing all the available types of managed object.
-  private final Map<String, AbstractManagedObjectDefinition<?, ?>> types;
-
-  // Private constructor.
-  private HelpSubCommandHandler(ConsoleApplication app,
+  public static HelpSubCommandHandler create(ConsoleApplication app,
       SubCommandArgumentParser parser) throws ArgumentException {
-    super(app);
-
-    // Create the sub-command.
-    String name = "list-properties";
-    int descriptionID = MSGID_DSCFG_DESCRIPTION_SUBCMD_HELPPROP;
-    this.subCommand = new SubCommand(parser, name, false, 0, 0, null,
-        descriptionID);
-
-    this.typeArgument = new StringArgument(OPTION_DSCFG_LONG_TYPE,
-        OPTION_DSCFG_SHORT_TYPE, OPTION_DSCFG_LONG_TYPE, false, false, true,
-        "{TYPE}", null, null, MSGID_DSCFG_DESCRIPTION_HELP_TYPE);
-    this.subCommand.addArgument(this.typeArgument);
-
-    // Register common arguments.
-    registerAdvancedModeArgument(this.subCommand,
-        MSGID_DSCFG_DESCRIPTION_ADVANCED_HELP);
-    registerPropertyNameArgument(this.subCommand);
-
-    this.types = new TreeMap<String, AbstractManagedObjectDefinition<?, ?>>();
+    return new HelpSubCommandHandler(app, parser);
   }
 
 
@@ -468,7 +410,7 @@
    * @param out
    *          The output stream.
    */
-  public void displayVerboseSingleProperty(
+  public static void displayVerboseSingleProperty(
       AbstractManagedObjectDefinition<?, ?> d, String name, PrintStream out) {
     PropertyDefinition<?> pd = d.getPropertyDefinition(name);
 
@@ -573,6 +515,42 @@
 
 
 
+  // The sub-command associated with this handler.
+  private final SubCommand subCommand;
+
+  // The argument which should be used to specify the type of managed
+  // object to be retrieved.
+  private final StringArgument typeArgument;
+
+  // A table listing all the available types of managed object.
+  private final Map<String, AbstractManagedObjectDefinition<?, ?>> types;
+
+  // Private constructor.
+  private HelpSubCommandHandler(ConsoleApplication app,
+      SubCommandArgumentParser parser) throws ArgumentException {
+    super(app);
+
+    // Create the sub-command.
+    String name = "list-properties";
+    int descriptionID = MSGID_DSCFG_DESCRIPTION_SUBCMD_HELPPROP;
+    this.subCommand = new SubCommand(parser, name, false, 0, 0, null,
+        descriptionID);
+
+    this.typeArgument = new StringArgument(OPTION_DSCFG_LONG_TYPE,
+        OPTION_DSCFG_SHORT_TYPE, OPTION_DSCFG_LONG_TYPE, false, false, true,
+        "{TYPE}", null, null, MSGID_DSCFG_DESCRIPTION_HELP_TYPE);
+    this.subCommand.addArgument(this.typeArgument);
+
+    // Register common arguments.
+    registerAdvancedModeArgument(this.subCommand,
+        MSGID_DSCFG_DESCRIPTION_ADVANCED_HELP);
+    registerPropertyNameArgument(this.subCommand);
+
+    this.types = new TreeMap<String, AbstractManagedObjectDefinition<?, ?>>();
+  }
+
+
+
   /**
    * {@inheritDoc}
    */

--
Gitblit v1.10.0