From f69073494ea82a068fc9ab2886277535c5c055d9 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 14 Aug 2009 12:05:06 +0000
Subject: [PATCH] Extend a method in InstallerHelper to be able to specify the different scripts and heap options to be used when creating the default java properties file.

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java |   82 ++++++++++++++++++++++++++---------------
 1 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
index fbdabb1..4cd5a5e 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
@@ -100,12 +100,6 @@
   private static final int MAX_ID_VALUE = Short.MAX_VALUE;
   private static final String DOMAIN_BASE_NAME = "domain ";
 
-  private static final String INITIAL_CLIENT_HEAP_ARG = "-Xms8m";
-
-  private static final String SERVER_HEAP_ARGS = "-Xms128m -Xmx256m";
-
-  private static final long SERVER_MAX_HEAP_BYTES = 256 * 1024 * 1024;
-
   /**
    * Invokes the method ConfigureDS.configMain with the provided parameters.
    * @param args the arguments to be passed to ConfigureDS.configMain.
@@ -877,6 +871,53 @@
    */
   public void writeSetOpenDSJavaHome(String installPath) throws IOException
   {
+    final String initialClientHeapArg = "-Xms8m";
+    final String serverHeapArgs = "-Xms128m -Xmx256m";
+    final long serverMaxHeapBytes = 256 * 1024 * 1024;
+    // Scripts to which we will pass -client argument
+    final String[] clientScripts =
+    {
+        "backup.online", "base64", "create-rc-script", "dsconfig",
+        "dsreplication", "dsframework", "export-ldif.online",
+        "import-ldif.online", "ldapcompare", "ldapdelete",
+        "ldapmodify", "ldappasswordmodify", "ldapsearch", "list-backends",
+        "manage-account", "manage-tasks", "restore.online", "stop-ds",
+        "status", "control-panel", "uninstall", "setup"
+    };
+
+    // Scripts to which we will pass -server argument
+    final String[] serverScripts =
+    {
+        "backup.offline", "encode-password", "export-ldif.offline",
+        "import-ldif.offline", "ldif-diff", "ldifmodify", "ldifsearch",
+        "make-ldif", "rebuild-index", "restore.offline", "start-ds",
+        "upgrade", "verify-index", "dbtest"
+    };
+    writeSetOpenDSJavaHome(installPath, initialClientHeapArg,
+        serverHeapArgs, serverMaxHeapBytes, clientScripts, serverScripts);
+  }
+
+  /**
+   * Writes the set-java-home file that is used by the scripts to set the
+   * java home and the java arguments.
+   * @param installPath the install path of the server.
+   * @param initialClientHeapArg the argument to be used to set the initial
+   * heap for the client scripts.
+   * @param serverHeapArgs the argument to be used to set the server scripts
+   * heap sizes.
+   * @param serverMaxHeapBytes the maximum size of the heap for the server
+   * scripts.
+   * @param clientScripts the scripts where the client properties are set.
+   * @param serverScripts the scripts where the server properties are set.
+   * @throws IOException if an error occurred writing the file.
+   */
+  public void writeSetOpenDSJavaHome(String installPath,
+      String initialClientHeapArg,
+      String serverHeapArgs,
+      long serverMaxHeapBytes,
+      String[] clientScripts,
+      String[] serverScripts) throws IOException
+  {
     String javaHome = System.getProperty("java.home");
     if ((javaHome == null) || (javaHome.length() == 0))
     {
@@ -931,35 +972,16 @@
       boolean supportsServer = supportsServer(javaHome, installPath);
 
       boolean supportsClientInitialHeap =
-        supportsOption(INITIAL_CLIENT_HEAP_ARG, javaHome, installPath);
+        supportsOption(initialClientHeapArg, javaHome, installPath);
       boolean supportsServerInitialHeap = false;
       // If the current max memory is bigger than the max heap we want to set,
       // assume that the JVM ergonomics are going to be able to allocate enough
       // memory.
-      if (Runtime.getRuntime().maxMemory() < SERVER_MAX_HEAP_BYTES)
+      if (Runtime.getRuntime().maxMemory() < serverMaxHeapBytes)
       {
         supportsServerInitialHeap =
-          supportsOption(SERVER_HEAP_ARGS, javaHome, installPath);
+          supportsOption(serverHeapArgs, javaHome, installPath);
       }
-      // Scripts to which we will pass -client argument
-      String[] clientScripts =
-      {
-          "backup.online", "base64", "create-rc-script", "dsconfig",
-          "dsreplication", "dsframework", "export-ldif.online",
-          "import-ldif.online", "ldapcompare", "ldapdelete",
-          "ldapmodify", "ldappasswordmodify", "ldapsearch", "list-backends",
-          "manage-account", "manage-tasks", "restore.online", "stop-ds",
-          "status", "control-panel", "uninstall", "setup"
-      };
-
-      // Scripts to which we will pass -server argument
-      String[] serverScripts =
-      {
-          "backup.offline", "encode-password", "export-ldif.offline",
-          "import-ldif.offline", "ldif-diff", "ldifmodify", "ldifsearch",
-          "make-ldif", "rebuild-index", "restore.offline", "start-ds",
-          "upgrade", "verify-index", "dbtest"
-      };
 
       if (supportsServer || supportsServerInitialHeap)
       {
@@ -977,7 +999,7 @@
             {
               arg += " ";
             }
-            arg += SERVER_HEAP_ARGS;
+            arg += serverHeapArgs;
           }
           writer.write(serverScripts[i]+".java-args="+arg);
         }
@@ -1007,7 +1029,7 @@
             {
               arg += " ";
             }
-            arg += INITIAL_CLIENT_HEAP_ARG;
+            arg += initialClientHeapArg;
           }
           writer.write(clientScripts[i]+".java-args="+arg);
         }

--
Gitblit v1.10.0