From 5816e0a75fa8d2de1978dc63fc324633ef273ec4 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 18 Jan 2010 22:27:40 +0000
Subject: [PATCH] Fix for issue 3901 (Setup fails when inserting a server in a replication topology with large umount of data) - Add a 'Runtime Options' step in the wizard. By default this will contain just two labels and two buttons: Server Runtime Options: Use Default <button to change> Import Options: Use Default <button to change>
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java | 375 ++++---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 90 +
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/FieldName.java | 10
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java | 1
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java | 4
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java | 8
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 9
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java | 124 ++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java | 4
opendj-sdk/opends/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java | 6
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java | 7
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java | 131 ++
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java | 4
opendj-sdk/opends/src/messages/messages/quicksetup.properties | 105 ++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/JavaArguments.java | 327 +++++++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java | 8
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java | 12
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/RuntimeOptionsPanel.java | 468 ++++++++++
opendj-sdk/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java | 936 ++++++++++++++++++++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/URLWorker.java | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/UIKeyStore.java | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java | 4
opendj-sdk/opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java | 4
31 files changed, 2,440 insertions(+), 229 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index b18c8fe..8c1b313 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.guitools.controlpanel.datamodel;
@@ -475,7 +475,7 @@
org.opends.server.util.DynamicConstants.FULL_VERSION_STRING);
String installPath = Utilities.getInstallPathFromClasspath();
desc.setInstallPath(installPath);
- desc.setInstancePath(Utils.getInstancePathFromClasspath(installPath));
+ desc.setInstancePath(Utils.getInstancePathFromInstallPath(installPath));
boolean windowsServiceEnabled = false;
if (Utilities.isWindows())
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
index 189a8c4..dff3d5a 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -1785,7 +1785,7 @@
if (instanceRootDirectory == null)
{
instanceRootDirectory = new File(
- Utils.getInstancePathFromClasspath(installPath));
+ Utils.getInstancePathFromInstallPath(installPath));
}
return instanceRootDirectory;
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
index 469cea1..516a8d5 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.guitools.uninstaller;
@@ -603,7 +603,7 @@
* {@inheritDoc}
*/
public String getInstancePath() {
- return getInstancePathFromClasspath(getInstallPathFromClasspath());
+ return getInstancePathFromInstallPath(getInstallPathFromClasspath());
}
/**
@@ -1165,7 +1165,7 @@
}
String instancePath =
- Utils.getInstancePathFromClasspath(installFile.getAbsolutePath());
+ Utils.getInstancePathFromInstallPath(installFile.getAbsolutePath());
File instanceFile = new File(instancePath);
try
{
@@ -1173,7 +1173,7 @@
} catch (Exception e)
{
instancePath =
- Utils.getInstancePathFromClasspath(installFile.getAbsolutePath());
+ Utils.getInstancePathFromInstallPath(installFile.getAbsolutePath());
}
InstallationFilesToDeleteFilter filter =
diff --git a/opendj-sdk/opends/src/messages/messages/quicksetup.properties b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
index 3fc032e..ccfcfc6 100644
--- a/opendj-sdk/opends/src/messages/messages/quicksetup.properties
+++ b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
@@ -842,6 +842,7 @@
INFO_REPLICATION_PORT_LABEL=Replication Port:
INFO_REPLICATION_PORT_TOOLTIP=The port that will be used to send and receive \
replication updates between this server and the other servers.
+INFO_RUNTIME_OPTIONS_LABEL=Runtime Options:
INFO_RETRY_BUTTON_LABEL=Retry
INFO_REVERSION_CANCELED=Reversion canceled.
INFO_REVERSION_ORACLE_EI_ACTION=Reversion from version %s to version %s \
@@ -887,6 +888,10 @@
INFO_REVIEW_STEP=Review
INFO_REVIEW_DISPLAY_TEXT=Show Summary
INFO_REVIEW_DISPLAY_EQUIVALENT_COMMAND=Show Equivalent Command-Line
+INFO_EDIT_JAVA_PROPERTIES_LINE=Before launching the command-lines described \
+ below, edit the file '%s' and add the following line:%n%s
+INFO_EDIT_JAVA_PROPERTIES_LINES=Before launching the command-lines described \
+ below, edit the file '%s' and add the following lines:%n%s
INFO_INSTALL_SETUP_EQUIVALENT_COMMAND_LINE=Equivalent non-interactive \
command-line to setup server:
INFO_INSTALL_ENABLE_REPLICATION_EQUIVALENT_COMMAND_LINE=Equivalent \
@@ -966,7 +971,7 @@
INFO_SHUTDOWN_DIRECTORY_MANAGER_CANCEL_BUTTON_TOOLTIP=Close this window
INFO_SHUTDOWN_DIRECTORY_MANAGER_DIALOG_MSG=<b>Directory Server is \
Running</b><br>The server is currently running and must be stopped before \
- uninstallation can continue. Provide the information below to allow the \
+ uninstall can continue. Provide the information below to allow the \
uninstaller to shut it down. You can also click Cancel and then shut the \
server down yourself.
INFO_SHUTDOWN_DIRECTORY_MANAGER_DIALOG_TITLE=Authentication Required
@@ -1376,10 +1381,10 @@
java.properties file and then run the dsjavaproperties script to specify the \
java version to be used.
SEVERE_ERR_INVALID_JAVA_ARGS=The java arguments used in the server \
- installation in '%s' do not seem to be compatible with the JVM used to run \
- the upgrader (%s).%n%nTo fix this problem delete the file %s and click on \
- 'Next' again.%nOnce the upgrader finishes you will have to set again the \
- java arguments by running the command-line %s.
+ installation in '%s' do not seem to be compatible with the Java virtual \
+ machine used to run the upgrader (%s).%n%nTo fix this problem delete the file \
+ %s and click on 'Next' again.%nOnce the upgrader finishes you will have to \
+ set again the java arguments by running the command-line %s.
INFO_ADS_CONTEXT_EXCEPTION_MSG=Registration information error. Error type: \
'%s'.
INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG=Registration information error. \
@@ -1390,3 +1395,93 @@
server %s but not in server %s:%n%s%nThe merge can only be performed if these \
administrators are defined in server %s. Use the command-line dsframework \
to do so.
+INFO_INITIAL_MEMORY_LABEL=Initial Memory:
+INFO_INITIAL_MEMORY_TOOLTIP=Provide the initial memory in megabytes that \
+ the Java process will use.
+INFO_MAX_MEMORY_LABEL=Maximum Memory:
+INFO_MAX_MEMORY_TOOLTIP=Provide the maximum memory in megabytes that the Java \
+ process will be allowed to use.
+INFO_OTHER_JAVA_ARGUMENTS_LABEL=Other Java Arguments:
+INFO_OTHER_JAVA_ARGUMENTS_TOOLTIP=Provide other java arguments that will be \
+ used by the Java process.
+INFO_MEGABYTE_LABEL=Megabytes
+INFO_JAVA_ARGUMENTS_OK_BUTTON_TOOLTIP=Close this dialog and accept the \
+ provided java arguments.
+INFO_JAVA_ARGUMENTS_CANCEL_BUTTON_TOOLTIP=Close this dialog and discard \
+ the provide java arguments.
+INFO_JAVA_ARGUMENTS_LEAVE_EMPTY=Leave empty to use the default value of the \
+ Java virtual machine.
+MILD_ERR_INITIAL_MEMORY_VALUE=The initial memory value must be a positive \
+ integer.
+MILD_ERR_MAX_MEMORY_VALUE=The maximum memory value must be a positive integer.
+MILD_ERR_MEMORY_VALUE_EXTENDED=Could not use the provided memory values. \
+ Check that the running Java virtual machine supports to specify the %s and \
+ %s arguments and that there is enough memory in the machine to use the \
+ provided values.
+MILD_ERR_INITIAL_MEMORY_VALUE_EXTENDED=Could not use the provided initial \
+ memory value. Check that the running Java virtual machine supports to \
+ specify the %s argument and that there is enough memory in the machine to use \
+ the provided value.
+MILD_ERR_MAX_MEMORY_VALUE_EXTENDED=Could not use the provided maximum memory \
+ value. Check that the running Java virtual machine supports to specify the \
+ %s argument and that there is enough memory in the machine to use the \
+ provided value.
+MILD_ERR_MEMORY_32_BIT_LIMIT=Note that 32-bit Java virtual machines do not \
+ support memory values higher than 2 gigabytes.
+MILD_ERR_GENERIC_JAVA_ARGUMENT=Could not use the arguments '%s' using the \
+ running Java virtual machine. Check that the Java virtual machine supports \
+ this argument.
+MILD_ERR_MAX_MEMORY_BIGGER_THAN_INITIAL_MEMORY=The maximum memory value must \
+ be higher than the initial memory value.
+MILD_ERR_MEMORY_AND_OTHER_ARGUMENTS_NOT_COMPATIBLE=The provided memory \
+ arguments and the 'Other Java Arguments' were checked successfully \
+ separately. However there was an error running them simultaneously. Check \
+ that the provided arguments are compatible with the memory values.
+INFO_JAVA_ARGUMENTS_CANNOT_BE_CHECKED_IN_WEBSTART=In the Java Webstart setup, \
+ the provided Java arguments are not thoroughly tested till the server is \
+ actually configured.\nIf the provided arguments cannot be used, the default \
+ java arguments will be used to configure.\n\nDo you want to continue?
+INFO_JAVA_RUNTIME_OPTIONS_PANEL_TITLE=Runtime Options
+INFO_JAVA_RUNTIME_OPTIONS_PANEL_STEP=Runtime Options
+INFO_JAVA_RUNTIME_OPTIONS_PANEL_INSTRUCTIONS=Specify the runtime options that \
+ the Java virtual machine will use to run the server and the import tool.
+INFO_JAVA_RUNTIME_CHANGE_LABEL=Change...
+INFO_JAVA_RUNTIME_CHANGE_SERVER_TOOLTIP=Click to configure the runtime \
+ options that will be used to run the server.
+INFO_JAVA_RUNTIME_CHANGE_IMPORT_TOOLTIP=Click to configure the runtime \
+ options that will be used to run the import utility.
+INFO_SERVER_RUNTIME_ARGS_LABEL=Server Runtime Settings:
+INFO_IMPORT_RUNTIME_ARGS_LABEL=Import Runtime Settings:
+INFO_DEFAULT_JAVA_ARGUMENTS=Use Default
+INFO_USE_CUSTOM_IMPORT_RUNTIME=Use Custom Values for Import (%s)
+INFO_USE_CUSTOM_SERVER_RUNTIME=Use Custom Values for Server Runtime (%s)
+INFO_USE_JVM_DEFAULT_SETTINGS=Use Default JVM Settings
+INFO_INITIAL_MEMORY=%d Mb Initial Memory
+INFO_MAXIMUM_MEMORY=%d Mb Max Memory
+INFO_MEMORY_PLACEHOLDER=memorySizeInMb
+INFO_ADDITIONAL_ARGUMENTS=Java arguments: %s
+INFO_SERVER_JAVA_ARGUMENTS_TITLE=Server Runtime Settings
+INFO_SERVER_JAVA_ARGUMENTS_MSG=Specify the memory and java arguments that \
+ will be used to run the server.
+INFO_IMPORT_JAVA_ARGUMENTS_TITLE=Import Runtime Settings
+INFO_IMPORT_JAVA_ARGUMENTS_MSG=Specify the memory and java arguments that \
+ will be used when importing data to the server.
+INFO_JAVA_RUNTIME_SETTINGS_TITLE=Java Runtime Settings
+INFO_IMPORT_FILE_WARNING_UPDATE_RUNTIME_ARGS=Considering the size of the \
+ provided LDIF file, the default runtime settings might not be enough to \
+ be able to manage that volume of data. It is recommended to increase the \
+ maximum memory allowed for both the server runtime and the import.<br><br>\
+ Check the documentation for more information about how to tune the server.
+INFO_AUTOMATICALLY_GENERATED_DATA_WARNING_UPDATE_RUNTIME_ARGS=Considering the \
+ number of entries that will be automatically generated and imported to the \
+ server, the default runtime settings might not be enough to \
+ be able to manage that volume of data. It is recommended to increase the \
+ maximum memory allowed for both the server runtime and the import.<br><br>\
+ Check the documentation for more information about how to tune the server.
+INFO_REPLICATED_ENTRIES_WARNING_UPDATE_RUNTIME_ARGS=Considering the number \
+ of entries defined in the suffixes of the replicated remote servers, the \
+ default runtime settings might not be enough to be able to manage that \
+ volume of data. It is recommended to increase the maximum memory allowed for \
+ the server runtime.<br><br>Check the documentation for more information \
+ about how to tune the server.
+
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
index f541134..7957aa9 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup;
@@ -440,7 +440,7 @@
installRoot = Utils.getInstallPathFromClasspath();
}
if (instanceRoot == null) {
- instanceRoot = Utils.getInstancePathFromClasspath(installRoot);
+ instanceRoot = Utils.getInstancePathFromInstallPath(installRoot);
}
local = new Installation(installRoot, instanceRoot);
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/JavaArguments.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/JavaArguments.java
new file mode 100644
index 0000000..8b2eafe
--- /dev/null
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/JavaArguments.java
@@ -0,0 +1,327 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2010 Sun Microsystems, Inc.
+ */
+package org.opends.quicksetup;
+
+import static org.opends.messages.QuickSetupMessages.*;
+
+import java.awt.Font;
+import java.util.ArrayList;
+
+import org.opends.messages.Message;
+import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.util.Utils;
+
+/**
+ * A class used to describe the java arguments for a given command-line.
+ *
+ */
+public class JavaArguments
+{
+ private int maxMemory = -1;
+ private int initialMemory = -1;
+ private String[] additionalArguments = {};
+
+ /**
+ * Returns the maximum memory allowed to execute the command-line.
+ * @return the maximum memory allowed to execute the command-line.
+ */
+ public int getMaxMemory()
+ {
+ return maxMemory;
+ }
+
+ /**
+ * Sets the maximum memory allowed to execute the command-line.
+ * @param maxMemory the maximum memory allowed to execute the command-line.
+ */
+ public void setMaxMemory(int maxMemory)
+ {
+ this.maxMemory = maxMemory;
+ }
+
+ /**
+ * Returns the initial memory allowed to execute the command-line.
+ * @return the initial memory allowed to execute the command-line.
+ */
+ public int getInitialMemory()
+ {
+ return initialMemory;
+ }
+
+ /**
+ * Sets the initial memory allowed to execute the command-line.
+ * @param initialMemory the initial memory allowed to execute the
+ * command-line.
+ */
+ public void setInitialMemory(int initialMemory)
+ {
+ this.initialMemory = initialMemory;
+ }
+
+ /**
+ * Returns the additional arguments to be used when executing the
+ * command-line.
+ * @return the additional arguments to be used when executing the
+ * command-line.
+ */
+ public String[] getAdditionalArguments()
+ {
+ return additionalArguments;
+ }
+
+ /**
+ * Sets the additional arguments to be used when executing the
+ * command-line.
+ * @param additionalArguments the additional arguments to be used when
+ * executing the command-line. It cannot be null.
+ */
+ public void setAdditionalArguments(String[] additionalArguments)
+ {
+ if (additionalArguments == null)
+ {
+ throw new IllegalArgumentException("additionalArguments cannot be null.");
+ }
+ this.additionalArguments = additionalArguments;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override()
+ public boolean equals(Object o)
+ {
+ boolean equals = o == this;
+ if (!equals)
+ {
+ equals = o instanceof JavaArguments;
+ if (equals)
+ {
+ equals = initialMemory == ((JavaArguments)o).initialMemory;
+ }
+ if (equals)
+ {
+ equals = maxMemory == ((JavaArguments)o).maxMemory;
+ }
+ if (equals)
+ {
+ equals = additionalArguments.length ==
+ ((JavaArguments)o).additionalArguments.length;
+ }
+ if (equals)
+ {
+ String[] args = ((JavaArguments)o).additionalArguments;
+ for (int i=0 ; i<args.length ; i++)
+ {
+ if (!args[i].equals(additionalArguments[i]))
+ {
+ equals = false;
+ break;
+ }
+ }
+ }
+ }
+ return equals;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override()
+ public int hashCode()
+ {
+ int hashCode = 44 + initialMemory + maxMemory;
+ for (String arg : additionalArguments)
+ {
+ hashCode += arg.hashCode();
+ }
+ return hashCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override()
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Initial Memory: "+initialMemory+" Max Memory: "+maxMemory);
+ int i=1;
+ for (String arg : additionalArguments)
+ {
+ sb.append(" arg "+i+": "+arg);
+ i++;
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns the message in HTML format to be used in a JLabel representing a
+ * java arguments object.
+ * @param javaArguments the java arguments to be represented.
+ * @param defaultJavaArguments the default values for the java arguments.
+ * @param font the font to be used.
+ * @return the message representing a java arguments object.
+ */
+ public static Message getMessageForJLabel(JavaArguments javaArguments,
+ JavaArguments defaultJavaArguments, Font font)
+ {
+ Message msg = getMessage(javaArguments, defaultJavaArguments);
+ String s = msg.toString();
+ if (s.indexOf("<br>") != -1)
+ {
+ msg = Message.raw("<html>"+UIFactory.applyFontToHtml(s, font));
+ }
+ return msg;
+ }
+
+ /**
+ * Returns the message in HTML format to be used in a representing a
+ * java arguments object. Note that no formatting of font is done.
+ * @param javaArguments the java arguments to be represented.
+ * @param defaultJavaArguments the default values for the java arguments.
+ * @return the message representing a java arguments object.
+ */
+ public static Message getMessage(JavaArguments javaArguments,
+ JavaArguments defaultJavaArguments)
+ {
+ Message msg;
+ if (javaArguments.equals(defaultJavaArguments))
+ {
+ msg = INFO_DEFAULT_JAVA_ARGUMENTS.get();
+ }
+ else
+ {
+ ArrayList<Message> lines = new ArrayList<Message>();
+ if (javaArguments.getInitialMemory() != -1)
+ {
+ lines.add(INFO_INITIAL_MEMORY.get(javaArguments.getInitialMemory()));
+ }
+ if (javaArguments.getMaxMemory() != -1)
+ {
+ lines.add(INFO_MAXIMUM_MEMORY.get(javaArguments.getMaxMemory()));
+ }
+ if (javaArguments.getAdditionalArguments().length > 0)
+ {
+ StringBuilder sb = new StringBuilder();
+ for (String arg : javaArguments.getAdditionalArguments())
+ {
+ if (sb.length() > 0)
+ {
+ sb.append(" ");
+ }
+ sb.append(arg);
+ }
+ lines.add(INFO_ADDITIONAL_ARGUMENTS.get(sb.toString()));
+ }
+ if (lines.isEmpty())
+ {
+ msg = INFO_USE_JVM_DEFAULT_SETTINGS.get();
+ }
+ else if (lines.size() == 1)
+ {
+ msg = lines.get(0);
+ }
+ else
+ {
+ StringBuilder sb = new StringBuilder();
+ for (Message line : lines)
+ {
+ if (sb.length() > 0)
+ {
+ sb.append("<br>");
+ }
+ sb.append(line);
+ }
+ msg = Message.raw(sb.toString());
+ }
+ }
+ return msg;
+ }
+
+ /**
+ * Returns a String representation of the arguments (the String that must
+ * be passed when invoking java).
+ * @return a String representation of the arguments (the String that must
+ * be passed when invoking java).
+ */
+ public String getStringArguments()
+ {
+ ArrayList<String> l = new ArrayList<String>();
+ if (initialMemory != -1)
+ {
+ l.add(Utils.escapeCommandLineValue(
+ getInitialMemoryArgument(initialMemory)));
+ }
+ if (maxMemory != -1)
+ {
+ l.add(Utils.escapeCommandLineValue(getMaxMemoryArgument(maxMemory)));
+ }
+ for (String arg : additionalArguments)
+ {
+ l.add(Utils.escapeCommandLineValue(arg));
+ }
+ return Utils.getStringFromCollection(l, " ");
+ }
+
+ /**
+ * Returns the java argument to specify the initial memory to be used.
+ * @param value the value in megabytes to be specified.
+ * @return the java argument to specify the initial memory to be used.
+ */
+ public static String getInitialMemoryArgument(int value)
+ {
+ return "-Xms"+value+"m";
+ }
+
+ /**
+ * Returns a generic initial memory argument (to be used in messages).
+ * @return a generic initial memory argument (to be used in messages).
+ */
+ public static String getInitialMemoryGenericArgument()
+ {
+ return "-Xms<"+INFO_MEMORY_PLACEHOLDER.get()+">";
+ }
+
+ /**
+ * Returns the java argument to specify the maximum memory that can be used.
+ * @param value the value in megabytes to be specified.
+ * @return the java argument to specify the maximum memory that can be used.
+ */
+ public static String getMaxMemoryArgument(int value)
+ {
+ return "-Xmx"+value+"m";
+ }
+
+ /**
+ * Returns a generic maximum memory argument (to be used in messages).
+ * @return a generic maximum memory argument (to be used in messages).
+ */
+ public static String getMaxMemoryGenericArgument()
+ {
+ return "-Xms<"+INFO_MEMORY_PLACEHOLDER.get()+">";
+ }
+}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
index 723819d..817812c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup;
@@ -90,7 +90,7 @@
}
String instanceDirname = Utils
- .getInstancePathFromClasspath(installDirName);
+ .getInstancePathFromInstallPath(installDirName);
instanceLegalDirName = instanceDirname + File.separator + "Legal";
File instanceLegalDir = new File(instanceLegalDirName);
if (!instanceLegalDir.exists())
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java
index 5767d54..80905eb 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup;
@@ -81,6 +81,11 @@
NEW_SUFFIX_OPTIONS(INFO_DATA_OPTIONS_STEP.get()),
/**
+ * Runtime options panel for the install.
+ */
+ RUNTIME_OPTIONS(INFO_JAVA_RUNTIME_OPTIONS_PANEL_STEP.get()),
+
+ /**
* Review panel for the install.
*/
REVIEW(INFO_REVIEW_STEP.get()),
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
index ae7d42a..468978c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup;
@@ -31,6 +31,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Set;
import org.opends.admin.ads.ServerDescriptor;
import org.opends.admin.ads.SuffixDescriptor;
@@ -96,9 +97,23 @@
private String configurationClass;
+ private Map<String, JavaArguments> hmJavaArguments;
+ private Map<String, JavaArguments> hmDefaultJavaArguments;
+
private static String defaultHostName;
/**
+ * The script name to be used to get and set the java arguments for the
+ * server runtime.
+ */
+ public static String SERVER_SCRIPT_NAME = "start-ds";
+ /**
+ * The script name to be used to get and set the java arguments for the
+ * (off-line) import.
+ */
+ public static String IMPORT_SCRIPT_NAME = "import-ldif.offline";
+
+ /**
* Creates a user data object with default values.
*/
public UserData() {
@@ -149,6 +164,8 @@
remoteWithNoReplicationPort =
new HashMap<ServerDescriptor, AuthenticationData>();
+
+ createDefaultJavaArguments();
}
/**
@@ -759,4 +776,109 @@
{
this.configurationClass = configurationClass;
}
+
+ /**
+ * Returns the different script names for which there are java arguments.
+ * @return the different script names for which there are java arguments.
+ */
+ public Set<String> getScriptNamesForJavaArguments()
+ {
+ return hmJavaArguments.keySet();
+ }
+
+ /**
+ * Returns the java arguments associated with a script name. Returns
+ * <CODE>null</CODE> if no java arguments are defined.
+ * @param scriptName the script name.
+ * @return the java arguments associated with a script name.
+ */
+ public JavaArguments getJavaArguments(String scriptName)
+ {
+ return hmJavaArguments.get(scriptName);
+ }
+
+ /**
+ * Returns the default java arguments associated with a script name. Returns
+ * <CODE>null</CODE> if no java arguments are defined.
+ * @param scriptName the script name.
+ * @return the default java arguments associated with a script name.
+ */
+ public JavaArguments getDefaultJavaArguments(String scriptName)
+ {
+ return hmDefaultJavaArguments.get(scriptName);
+ }
+
+ /**
+ * Sets the java arguments associated with a script name.
+ * @param scriptName the script name.
+ * @param args the java arguments associated with a script name.
+ */
+ public void setJavaArguments(String scriptName, JavaArguments args)
+ {
+ hmJavaArguments.put(scriptName, args);
+ }
+
+
+
+ private void createDefaultJavaArguments()
+ {
+ hmJavaArguments = new HashMap<String, JavaArguments>();
+ int maxMemoryMb = 256;
+ final int maxMemoryBytes = maxMemoryMb * 1024 * 1024;
+ // 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.
+ long currentMaxMemoryBytes = Runtime.getRuntime().maxMemory();
+ if (currentMaxMemoryBytes > maxMemoryBytes)
+ {
+ maxMemoryMb = -1;
+ }
+ for (String clientScript : getClientScripts())
+ {
+ JavaArguments javaArgument = new JavaArguments();
+ javaArgument.setInitialMemory(8);
+ javaArgument.setAdditionalArguments(new String[] {"-client"});
+ hmJavaArguments.put(clientScript, javaArgument);
+ }
+ for (String serverScript : getServerScripts())
+ {
+ JavaArguments javaArgument = new JavaArguments();
+ javaArgument.setInitialMemory(128);
+ javaArgument.setMaxMemory(256);
+ javaArgument.setAdditionalArguments(new String[] {"-server"});
+ hmJavaArguments.put(serverScript, javaArgument);
+ }
+
+ JavaArguments controlPanelJavaArgument = new JavaArguments();
+ controlPanelJavaArgument.setInitialMemory(64);
+ controlPanelJavaArgument.setMaxMemory(128);
+ controlPanelJavaArgument.setAdditionalArguments(new String[] {"-client"});
+ hmJavaArguments.put("control-panel", controlPanelJavaArgument);
+
+ hmDefaultJavaArguments =
+ new HashMap<String, JavaArguments>(hmJavaArguments);
+ }
+
+ private String[] getClientScripts()
+ {
+ return new String[] {
+ "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", "uninstall", "setup"
+ };
+ }
+
+ private String[] getServerScripts()
+ {
+ return new String[]
+ {
+ "backup.offline", "encode-password", "export-ldif.offline",
+ IMPORT_SCRIPT_NAME, "ldif-diff", "ldifmodify", "ldifsearch",
+ "make-ldif", "rebuild-index", "restore.offline", SERVER_SCRIPT_NAME,
+ "upgrade", "verify-index", "dbtest"
+ };
+ }
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index 805d43e..e4f57d6 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.installer;
@@ -62,6 +62,7 @@
import org.opends.quicksetup.ButtonName;
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.JavaArguments;
import org.opends.quicksetup.LicenseFile;
import org.opends.quicksetup.ProgressStep;
import org.opends.quicksetup.QuickSetupLog;
@@ -89,6 +90,7 @@
import org.opends.quicksetup.installer.ui.InstallWelcomePanel;
import org.opends.quicksetup.installer.ui.InstallLicensePanel;
import org.opends.quicksetup.installer.ui.RemoteReplicationPortsPanel;
+import org.opends.quicksetup.installer.ui.RuntimeOptionsPanel;
import org.opends.quicksetup.installer.ui.ServerSettingsPanel;
import org.opends.quicksetup.installer.ui.SuffixesToReplicatePanel;
import org.opends.server.util.SetupUtils;
@@ -149,7 +151,15 @@
private static final int MIN_NUMBER_ENTRIES = 1;
- private static final int MAX_NUMBER_ENTRIES = 10000;
+ private static final int MAX_NUMBER_ENTRIES = 10000000;
+
+ // If the user decides to import more than this number of entries, the
+ // import process of automatically generated data will be verbose.
+ private static final int THRESOLD_AUTOMATIC_DATA_VERBOSE = 20000;
+
+ // If the user decides to import a number of entries higher than this
+ // threshold, the start process will be verbose.
+ private static final int NENTRIES_THRESOLD_FOR_VERBOSE_START = 100000;
/** Set of progress steps that have been completed. */
protected Set<InstallProgressStep>
@@ -204,6 +214,7 @@
lstSteps.add(SUFFIXES_OPTIONS);
lstSteps.add(REMOTE_REPLICATION_PORTS);
lstSteps.add(NEW_SUFFIX_OPTIONS);
+ lstSteps.add(RUNTIME_OPTIONS);
lstSteps.add(REVIEW);
lstSteps.add(PROGRESS);
lstSteps.add(FINISHED);
@@ -531,6 +542,8 @@
p = new RemoteReplicationPortsPanel(this);
} else if (step == NEW_SUFFIX_OPTIONS) {
p = new DataOptionsPanel(this);
+ } else if (step == RUNTIME_OPTIONS) {
+ p = new RuntimeOptionsPanel(this);
} else if (step == REVIEW) {
p = new InstallReviewPanel(this);
} else if (step == PROGRESS) {
@@ -694,7 +707,7 @@
}
else
{
- next = Step.REVIEW;
+ next = Step.RUNTIME_OPTIONS;
}
break;
default:
@@ -703,7 +716,7 @@
}
else if (step == Step.REMOTE_REPLICATION_PORTS)
{
- next = Step.REVIEW;
+ next = Step.RUNTIME_OPTIONS;
}
else
{
@@ -735,6 +748,7 @@
orderedSteps.add(SUFFIXES_OPTIONS);
orderedSteps.add(REMOTE_REPLICATION_PORTS);
orderedSteps.add(NEW_SUFFIX_OPTIONS);
+ orderedSteps.add(RUNTIME_OPTIONS);
orderedSteps.add(REVIEW);
orderedSteps.add(PROGRESS);
orderedSteps.add(FINISHED);
@@ -1422,7 +1436,7 @@
File templatePath = createTemplateFile();
int nEntries = getUserData().getNewSuffixOptions().getNumberEntries();
MessageBuilder mb = new MessageBuilder();
- if (isVerbose())
+ if (isVerbose() || (nEntries > THRESOLD_AUTOMATIC_DATA_VERBOSE))
{
mb.append(getFormattedProgress(
INFO_PROGRESS_IMPORT_AUTOMATICALLY_GENERATED.get(
@@ -2216,7 +2230,7 @@
// This isn't likely to happen, and it's not a serious problem even if
// it does.
InstallerHelper helper = new InstallerHelper();
- helper.writeSetOpenDSJavaHome(getInstallationPath());
+ helper.writeSetOpenDSJavaHome(getUserData(), getInstallationPath());
} catch (Exception e) {
LOG.log(Level.WARNING, "Error writing OpenDS Java Home file: "+e, e);
}
@@ -2260,6 +2274,10 @@
{
updateUserDataForNewSuffixOptionsPanel(qs);
}
+ else if (cStep == RUNTIME_OPTIONS)
+ {
+ updateUserDataForRuntimeOptionsPanel(qs);
+ }
else if (cStep == REVIEW)
{
updateUserDataForReviewPanel(qs);
@@ -2812,6 +2830,49 @@
}
/**
+ * Returns <CODE>true</CODE> if the start server must be launched in verbose
+ * mode and <CODE>false</CODE> otherwise. The verbose flag is not enough
+ * because in the case where many entries have been imported, the startup
+ * phase can take long.
+ * @return <CODE>true</CODE> if the start server must be launched in verbose
+ * mode and <CODE>false</CODE> otherwise.
+ */
+ protected boolean isStartVerbose()
+ {
+ if (isVerbose())
+ {
+ return true;
+ }
+ boolean manyEntriesToImport = false;
+ NewSuffixOptions.Type type = getUserData().getNewSuffixOptions().getType();
+ if (type == NewSuffixOptions.Type.IMPORT_FROM_LDIF_FILE)
+ {
+ long mbTotalSize = 0;
+ LinkedList<String> ldifPaths =
+ getUserData().getNewSuffixOptions().getLDIFPaths();
+ for (String ldifPath : ldifPaths)
+ {
+ File f = new File(ldifPath);
+ mbTotalSize += f.length();
+ }
+ // Assume entries of 1kb
+ if (mbTotalSize > NENTRIES_THRESOLD_FOR_VERBOSE_START * 1024)
+ {
+ manyEntriesToImport = true;
+ }
+ }
+ else if (type == NewSuffixOptions.Type.IMPORT_AUTOMATICALLY_GENERATED_DATA)
+ {
+ int nEntries = getUserData().getNewSuffixOptions().getNumberEntries();
+ if (nEntries > NENTRIES_THRESOLD_FOR_VERBOSE_START)
+ {
+ manyEntriesToImport = true;
+ }
+ }
+ return manyEntriesToImport;
+ }
+
+ /**
* Returns <CODE>true</CODE> if we must stop the server and
* <CODE>false</CODE> otherwise.
* The server might be stopped if the user asked not to start it at the
@@ -4104,6 +4165,19 @@
/**
+ * Update the userData object according to the content of the runtime options
+ * panel.
+ *
+ */
+ private void updateUserDataForRuntimeOptionsPanel(QuickSetup qs)
+ {
+ getUserData().setJavaArguments(UserData.SERVER_SCRIPT_NAME,
+ ((JavaArguments)qs.getFieldValue(FieldName.SERVER_JAVA_ARGUMENTS)));
+ getUserData().setJavaArguments(UserData.IMPORT_SCRIPT_NAME,
+ ((JavaArguments)qs.getFieldValue(FieldName.IMPORT_JAVA_ARGUMENTS)));
+ }
+
+ /**
* Update the userData object according to the content of the review
* panel.
*
@@ -4119,7 +4193,7 @@
/**
* Returns the number of free disk space in bytes required to install Open DS
*
- * For the moment we just return 15 Megabytes. TODO we might want to have
+ * For the moment we just return 20 Megabytes. TODO we might want to have
* something dynamic to calculate the required free disk space for the
* installation.
*
@@ -4127,7 +4201,7 @@
*/
private long getRequiredInstallSpace()
{
- return 15 * 1024 * 1024;
+ return 20 * 1024 * 1024;
}
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 dd75dcb..b174184 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
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.installer;
@@ -31,12 +31,14 @@
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
@@ -50,7 +52,9 @@
import org.opends.quicksetup.Application;
import org.opends.quicksetup.ApplicationException;
import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.JavaArguments;
import org.opends.quicksetup.ReturnCode;
+import org.opends.quicksetup.UserData;
import org.opends.quicksetup.util.OutputReader;
import org.opends.quicksetup.util.Utils;
@@ -449,7 +453,7 @@
/**
* Configures the replication on a given server.
- * @param remoteCtx the conection to the server where we want to configure
+ * @param remoteCtx the connection to the server where we want to configure
* the replication.
* @param replicationServers a Map where the key value is the base dn and
* the value is the list of replication servers for that base dn (or domain).
@@ -893,142 +897,189 @@
/**
* 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 uData the data provided by the user.
+ * @param installPath where the server is installed.
* @throws IOException if an error occurred writing the file.
*/
- public void writeSetOpenDSJavaHome(String installPath) throws IOException
+ public void writeSetOpenDSJavaHome(UserData uData,
+ String installPath) throws IOException
{
- final String clientHeapArgs = "-Xms8m";
- final String controlPanelHeapArgs = "-Xms64m -Xmx128m";
- 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", "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"
- };
-
String javaHome = System.getProperty("java.home");
if ((javaHome == null) || (javaHome.length() == 0))
{
javaHome = System.getenv(SetupUtils.OPENDS_JAVA_HOME);
}
- boolean supportsClient = supportsClient(javaHome, installPath);
- boolean supportsServer = supportsServer(javaHome, installPath);
-
- boolean supportsClientHeap =
- supportsOption(clientHeapArgs, javaHome, installPath);
- boolean supportsControlPanelHeap =
- supportsOption(controlPanelHeapArgs, javaHome, installPath);
- boolean supportsServerHeap = 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() < serverMaxHeapBytes)
+ // Try to transform things if necessary. The following map has as key
+ // the original JavaArgument object and as value the 'transformed'
+ // JavaArgument.
+ Map<JavaArguments, JavaArguments> hmJavaArguments =
+ new HashMap<JavaArguments, JavaArguments>();
+ for (String script : uData.getScriptNamesForJavaArguments())
{
- supportsServerHeap =
- supportsOption(serverHeapArgs, javaHome, installPath);
- }
-
- Map<String, String> args = new HashMap<String, String>();
-
- StringBuffer sbClientArgs = new StringBuffer();
- if (supportsClient)
- {
- sbClientArgs.append("-client");
- }
- if (supportsClientHeap)
- {
- if (sbClientArgs.length() > 0)
+ JavaArguments origJavaArguments = uData.getJavaArguments(script);
+ if (hmJavaArguments.get(origJavaArguments) == null)
{
- sbClientArgs.append(" ");
+ if (Utils.supportsOption(origJavaArguments.getStringArguments(),
+ javaHome, installPath))
+ {
+ // The argument works, so just use it.
+ hmJavaArguments.put(origJavaArguments, origJavaArguments);
+ }
+ else
+ {
+ // We have to fix it somehow: test separately memory and other
+ // arguments to see if something works.
+ JavaArguments transformedArguments =
+ getBestEffortArguments(origJavaArguments, javaHome, installPath);
+ hmJavaArguments.put(origJavaArguments, transformedArguments);
+ }
}
- sbClientArgs.append(clientHeapArgs);
- }
- String clientArgs = sbClientArgs.toString();
- for (String clientScript : clientScripts)
- {
- args.put(clientScript, clientArgs);
+ else
+ {
+ // Already checked if supported.
+ }
}
- StringBuffer sbControlPanelArgs = new StringBuffer();
- if (supportsClient)
- {
- sbControlPanelArgs.append("-client");
- }
- if (supportsControlPanelHeap)
- {
- if (sbControlPanelArgs.length() > 0)
- {
- sbControlPanelArgs.append(" ");
- }
- sbControlPanelArgs.append(controlPanelHeapArgs);
- }
- String controlPanelArgs = sbControlPanelArgs.toString();
- args.put("control-panel", controlPanelArgs);
+ Properties fileProperties = getJavaPropertiesFileContents(
+ getPropertiesFileName(installPath));
+ Map<String, JavaArguments> args = new HashMap<String, JavaArguments>();
+ Map<String, String> otherProperties = new HashMap<String, String>();
- StringBuffer sbServerArgs = new StringBuffer();
- if (supportsServer)
+ for (String script : uData.getScriptNamesForJavaArguments())
{
- sbServerArgs.append("-server");
- }
- if (supportsServerHeap)
- {
- if (sbServerArgs.length() > 0)
+ JavaArguments origJavaArgument = uData.getJavaArguments(script);
+ JavaArguments transformedJavaArg = hmJavaArguments.get(origJavaArgument);
+ JavaArguments defaultJavaArg = uData.getDefaultJavaArguments(script);
+
+ // Apply the following policy: overwrite the values in the file only
+ // if the values provided by the user are not the default ones.
+
+ String propertiesKey = getJavaArgPropertyForScript(script);
+ if (origJavaArgument.equals(defaultJavaArg) &&
+ fileProperties.containsKey(propertiesKey))
{
- sbServerArgs.append(" ");
+ otherProperties.put(script, fileProperties.getProperty(propertiesKey));
}
- sbServerArgs.append(serverHeapArgs);
+ else
+ {
+ args.put(script, transformedJavaArg);
+ }
}
- String serverArgs = sbServerArgs.toString();
- for (String serverScript : serverScripts)
+
+ if (!fileProperties.containsKey("overwrite-env-java-home"))
{
- args.put(serverScript, serverArgs);
+ otherProperties.put("overwrite-env-java-home", "false");
}
- writeSetOpenDSJavaHome(installPath, javaHome, args);
+ if (!fileProperties.containsKey("overwrite-env-java-args"))
+ {
+ otherProperties.put("overwrite-env-java-home", "false");
+ }
+ if (!fileProperties.containsKey("default.java-home"))
+ {
+ otherProperties.put("default.java-home=", javaHome);
+ }
+
+ writeSetOpenDSJavaHome(installPath, javaHome, args, otherProperties);
}
/**
- * 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 javaHome the java home to be used.
- * @param arguments a Map containing as key the name of the script and as
- * value, the java arguments to be set for the script.
- * @throws IOException if an error occurred writing the file.
+ * Tries to figure out a new JavaArguments object that works, based on the
+ * provided JavaArguments. It is more efficient to call this method if we
+ * are sure that the provided JavaArguments object does not work.
+ * @param origJavaArguments the java arguments that does not work.
+ * @param javaHome the java home to be used to test the java arguments.
+ * @param installPath the install path.
+ * @return a working JavaArguments object.
*/
- public void writeSetOpenDSJavaHome(String installPath,
- String javaHome,
- Map<String, String> arguments) throws IOException
+ private JavaArguments getBestEffortArguments(JavaArguments origJavaArguments,
+ String javaHome, String installPath)
{
- String configDir = Utils.getPath(Utils
- .getInstancePathFromClasspath(installPath),
- Installation.CONFIG_PATH_RELATIVE);
- String propertiesFile = Utils.getPath(
- configDir, Installation.DEFAULT_JAVA_PROPERTIES_FILE);
- boolean propertiesFileModified = false;
+ JavaArguments memArgs = new JavaArguments();
+ memArgs.setInitialMemory(origJavaArguments.getInitialMemory());
+ memArgs.setMaxMemory(origJavaArguments.getMaxMemory());
+ String m = memArgs.getStringArguments();
+ boolean supportsMemory = false;
+ if (m.length() > 0)
+ {
+ supportsMemory = Utils.supportsOption(m, javaHome, installPath);
+ }
+
+ JavaArguments additionalArgs = new JavaArguments();
+ additionalArgs.setAdditionalArguments(
+ origJavaArguments.getAdditionalArguments());
+ String a = additionalArgs.getStringArguments();
+ boolean supportsAdditional = false;
+ if (a.length() > 0)
+ {
+ supportsAdditional = Utils.supportsOption(a, javaHome, installPath);
+ }
+
+ JavaArguments javaArgs = new JavaArguments();
+ if (supportsMemory)
+ {
+ javaArgs.setInitialMemory(origJavaArguments.getInitialMemory());
+ javaArgs.setMaxMemory(origJavaArguments.getMaxMemory());
+ }
+ else
+ {
+ // Try to figure out a smaller amount of memory.
+ long currentMaxMemory = Runtime.getRuntime().maxMemory();
+ int maxMemory = origJavaArguments.getMaxMemory();
+ if (maxMemory != -1)
+ {
+ maxMemory = maxMemory / 2;
+ while ((1024 * 1024 * maxMemory) < currentMaxMemory &&
+ !Utils.supportsOption(JavaArguments.getMaxMemoryArgument(maxMemory),
+ javaHome, installPath))
+ {
+ maxMemory = maxMemory / 2;
+ }
+ if ((1024 * 1024 * maxMemory) > currentMaxMemory)
+ {
+ // Supports this option.
+ javaArgs.setMaxMemory(maxMemory);
+ }
+ }
+ }
+ if (supportsAdditional)
+ {
+ javaArgs.setAdditionalArguments(
+ origJavaArguments.getAdditionalArguments());
+ }
+ return javaArgs;
+ }
+
+ private List<String> getJavaPropertiesFileComments(String propertiesFile)
+ throws IOException
+ {
+ ArrayList<String> commentLines = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new FileReader(propertiesFile));
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ String trimmedLine = line.trim();
+ if (trimmedLine.startsWith("#") || (trimmedLine.length() == 0))
+ {
+ commentLines.add(line);
+ }
+ else
+ {
+ break;
+ }
+ }
+ return commentLines;
+ }
+
+ private Properties getJavaPropertiesFileContents(String propertiesFile)
+ throws IOException
+ {
FileInputStream fs = null;
+ Properties fileProperties = new Properties();
try
{
fs = new FileInputStream(propertiesFile);
- Properties properties = new Properties();
- properties.load(fs);
- propertiesFileModified = properties.keySet().size() > 0;
+ fileProperties.load(fs);
}
catch (Throwable t)
{
@@ -1046,39 +1097,64 @@
}
}
}
- BufferedWriter writer = new BufferedWriter(new FileWriter(propertiesFile,
- true));
+ return fileProperties;
+ }
- if (!propertiesFileModified)
+ private String getPropertiesFileName(String installPath)
+ {
+ String configDir = Utils.getPath(Utils
+ .getInstancePathFromInstallPath(installPath),
+ Installation.CONFIG_PATH_RELATIVE);
+ String propertiesFile = Utils.getPath(
+ configDir, Installation.DEFAULT_JAVA_PROPERTIES_FILE);
+ return propertiesFile;
+ }
+
+ /**
+ * 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 javaHome the java home to be used.
+ * @param arguments a Map containing as key the name of the script and as
+ * value, the java arguments to be set for the script.
+ * @param otherProperties other properties that must be set in the file.
+ * @throws IOException if an error occurred writing the file.
+ */
+ private void writeSetOpenDSJavaHome(String installPath,
+ String javaHome,
+ Map<String, JavaArguments> arguments,
+ Map<String, String> otherProperties) throws IOException
+ {
+ String propertiesFile = getPropertiesFileName(installPath);
+ List<String> commentLines = getJavaPropertiesFileComments(propertiesFile);
+ BufferedWriter writer = new BufferedWriter(
+ new FileWriter(propertiesFile, false));
+
+ for (String line: commentLines)
{
- writer.newLine();
- writer.write("overwrite-env-java-home=false");
- writer.newLine();
- writer.write("overwrite-env-java-args=false");
- writer.newLine();
- writer.newLine();
- writer.write("default.java-home="+javaHome);
- writer.newLine();
+ writer.write(line);
writer.newLine();
- for (String scriptName : arguments.keySet())
- {
- String argument = arguments.get(scriptName);
- writer.newLine();
- writer.write(scriptName+".java-args="+argument);
- }
-
- if (!arguments.isEmpty())
- {
- writer.newLine();
- writer.newLine();
- }
-
- writer.close();
}
+
+ for (String key : otherProperties.keySet())
+ {
+ writer.write(key+"="+otherProperties.get(key));
+ writer.newLine();
+ }
+
+
+ for (String scriptName : arguments.keySet())
+ {
+ String argument = arguments.get(scriptName).getStringArguments();
+ writer.newLine();
+ writer.write(getJavaArgPropertyForScript(scriptName)+"="+argument);
+ }
+ writer.close();
+
String destinationFile;
String libDir = Utils.getPath(Utils.
- getInstancePathFromClasspath(installPath),
+ getInstancePathFromInstallPath(installPath),
Installation.LIBRARIES_PATH_RELATIVE);
if (Utils.isWindows())
{
@@ -1113,6 +1189,11 @@
}
}
+ private String getJavaArgPropertyForScript(String scriptName)
+ {
+ return scriptName+".java-args";
+ }
+
/**
* If the log message is of type "[03/Apr/2008:21:25:43 +0200] category=JEB
* severity=NOTICE msgID=8847454 Processed 1 entries, imported 0, skipped 1,
@@ -1140,32 +1221,6 @@
}
return parsedMsg;
}
-
- /**
- * Tells whether the provided java installation supports the server option
- * or not.
- * @param javaHome the java installation path.
- * @param installPath the install path of the server.
- * @return <CODE>true</CODE> if the provided java installation supports the
- * server option and <CODE>false</CODE> otherwise.
- */
- private boolean supportsServer(String javaHome, String installPath)
- {
- return supportsOption("-server", javaHome, installPath);
- }
-
- /**
- * Tells whether the provided java installation supports the client option
- * or not.
- * @param javaHome the java installation path.
- * @param installPath the install path of the server.
- * @return <CODE>true</CODE> if the provided java installation supports the
- * client option and <CODE>false</CODE> otherwise.
- */
- private boolean supportsClient(String javaHome, String installPath)
- {
- return supportsOption("-client", javaHome, installPath);
- }
}
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
index 3c476b7..8fa59a4 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
@@ -143,7 +143,7 @@
}
try
{
- new ServerController(this).startServer(!isVerbose());
+ new ServerController(this).startServer(!isStartVerbose());
}
catch (ApplicationException ae)
{
@@ -555,7 +555,7 @@
public String getInstancePath()
{
String installPath = Utils.getInstallPathFromClasspath();
- return Utils.getInstancePathFromClasspath(installPath);
+ return Utils.getInstancePathFromInstallPath(installPath);
}
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
index a138bf0..4c73132 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
@@ -33,12 +33,14 @@
import org.opends.admin.ads.ServerDescriptor;
import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.JavaArguments;
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.installer.AuthenticationData;
import org.opends.quicksetup.installer.DataReplicationOptions;
import org.opends.quicksetup.installer.SuffixesToReplicateOptions;
import org.opends.quicksetup.ui.*;
import org.opends.quicksetup.util.HtmlProgressMessageFormatter;
+import org.opends.quicksetup.util.ProgressMessageFormatter;
import org.opends.quicksetup.util.Utils;
import javax.swing.*;
@@ -141,6 +143,9 @@
getField(FieldName.REPLICATION_PORT).setVisible(true);
getLabel(FieldName.REPLICATION_PORT).setVisible(true);
}
+
+ setFieldValue(FieldName.SERVER_JAVA_ARGUMENTS, getRuntimeString(userData));
+
checkStartWarningLabel();
updateEquivalentCommand(userData);
@@ -329,6 +334,11 @@
LabelFieldDescriptor.FieldType.READ_ONLY,
LabelFieldDescriptor.LabelType.PRIMARY, 0));
+ hm.put(FieldName.SERVER_JAVA_ARGUMENTS, new LabelFieldDescriptor(
+ INFO_RUNTIME_OPTIONS_LABEL.get(), null,
+ LabelFieldDescriptor.FieldType.READ_ONLY,
+ LabelFieldDescriptor.LabelType.PRIMARY, 0));
+
for (FieldName fieldName : hm.keySet())
{
LabelFieldDescriptor desc = hm.get(fieldName);
@@ -378,7 +388,7 @@
/**
* Returns the String representing the replication port configuration.
- * @param userInstallData the DataOptions of the user.
+ * @param userInstallData the install data provided of the user.
* @return the localized string describing the Replication Ports chosen by
* the user.
*/
@@ -460,6 +470,53 @@
}
return buf.toString();
}
+
+ /**
+ * Returns the String representing the runtime configuration.
+ * @param userData the DataOptions of the user.
+ * @return the localized string describing the runtime options chosen by the
+ * user.
+ */
+ private String getRuntimeString(UserData userData)
+ {
+ String s;
+ JavaArguments serverArguments =
+ userData.getJavaArguments(UserData.SERVER_SCRIPT_NAME);
+ JavaArguments importArguments =
+ userData.getJavaArguments(UserData.IMPORT_SCRIPT_NAME);
+
+
+ boolean defaultServer =
+ userData.getDefaultJavaArguments(UserData.SERVER_SCRIPT_NAME).equals(
+ serverArguments);
+ boolean defaultImport =
+ userData.getDefaultJavaArguments(UserData.IMPORT_SCRIPT_NAME).equals(
+ importArguments);
+
+ if (defaultServer && defaultImport)
+ {
+ s = INFO_DEFAULT_JAVA_ARGUMENTS.get().toString();
+ }
+ else if (defaultServer)
+ {
+ s = INFO_USE_CUSTOM_IMPORT_RUNTIME.get(
+ importArguments.getStringArguments()).toString();
+ }
+ else if (defaultImport)
+ {
+ s = INFO_USE_CUSTOM_SERVER_RUNTIME.get(
+ serverArguments.getStringArguments()).toString();
+ }
+ else
+ {
+ s = INFO_USE_CUSTOM_SERVER_RUNTIME.get(
+ serverArguments.getStringArguments())+"\n"+
+ INFO_USE_CUSTOM_IMPORT_RUNTIME.get(
+ importArguments.getStringArguments());
+ }
+ return s;
+ }
+
/**
* Returns and creates the fields panel.
* @return the fields panel.
@@ -521,7 +578,8 @@
FieldName.SERVER_PORT, FieldName.ADMIN_CONNECTOR_PORT,
FieldName.SECURITY_OPTIONS,
FieldName.DIRECTORY_MANAGER_DN, FieldName.GLOBAL_ADMINISTRATOR_UID,
- FieldName.DATA_OPTIONS, FieldName.REPLICATION_PORT
+ FieldName.DATA_OPTIONS, FieldName.REPLICATION_PORT,
+ FieldName.SERVER_JAVA_ARGUMENTS
};
}
else
@@ -533,7 +591,7 @@
FieldName.ADMIN_CONNECTOR_PORT,
FieldName.SECURITY_OPTIONS, FieldName.DIRECTORY_MANAGER_DN,
FieldName.GLOBAL_ADMINISTRATOR_UID, FieldName.DATA_OPTIONS,
- FieldName.REPLICATION_PORT
+ FieldName.REPLICATION_PORT, FieldName.SERVER_JAVA_ARGUMENTS
};
}
@@ -696,6 +754,14 @@
HtmlProgressMessageFormatter formatter =
new HtmlProgressMessageFormatter();
StringBuilder sb = new StringBuilder();
+
+ String s = getEquivalentJavaPropertiesProcedure(userData, formatter);
+ if (s != null && s.length() > 0)
+ {
+ sb.append(s);
+ sb.append(formatter.getTaskSeparator());
+ }
+
sb.append(formatter.getFormattedProgress(
INFO_INSTALL_SETUP_EQUIVALENT_COMMAND_LINE.get()));
sb.append(formatter.getLineBreak());
@@ -780,4 +846,63 @@
}
equivalentCommandPane.setText(sb.toString());
}
+
+ private String getEquivalentJavaPropertiesProcedure(
+ UserData userData,
+ ProgressMessageFormatter formatter)
+ {
+ StringBuilder sb = new StringBuilder();
+ JavaArguments serverArguments =
+ userData.getJavaArguments(UserData.SERVER_SCRIPT_NAME);
+ JavaArguments importArguments =
+ userData.getJavaArguments(UserData.IMPORT_SCRIPT_NAME);
+
+ ArrayList<String> linesToAdd = new ArrayList<String>();
+
+ boolean defaultServer =
+ userData.getDefaultJavaArguments(UserData.SERVER_SCRIPT_NAME).equals(
+ serverArguments);
+ boolean defaultImport =
+ userData.getDefaultJavaArguments(UserData.IMPORT_SCRIPT_NAME).equals(
+ importArguments);
+
+ if (!defaultServer)
+ {
+ linesToAdd.add(UserData.SERVER_SCRIPT_NAME+": "+
+ serverArguments.getStringArguments());
+ }
+ if (!defaultImport)
+ {
+ linesToAdd.add(UserData.IMPORT_SCRIPT_NAME+": "+
+ importArguments.getStringArguments());
+ }
+
+ if (linesToAdd.size() == 1)
+ {
+ String arg0 = getJavaPropertiesFilePath(userData);
+ String arg1 = linesToAdd.get(0);
+ sb.append(formatter.getFormattedProgress(
+ INFO_EDIT_JAVA_PROPERTIES_LINE.get(arg0, arg1)));
+ }
+ else if (linesToAdd.size() > 1)
+ {
+ String arg0 = getJavaPropertiesFilePath(userData);
+ String arg1 = Utils.getStringFromCollection(linesToAdd, "\n");
+ sb.append(
+ formatter.getFormattedProgress(INFO_EDIT_JAVA_PROPERTIES_LINES.get(
+ arg0, arg1)));
+ }
+
+ return sb.toString();
+ }
+
+ private String getJavaPropertiesFilePath(UserData userData)
+ {
+ String configDir = Utils.getPath(Utils
+ .getInstancePathFromInstallPath(userData.getServerLocation()),
+ Installation.CONFIG_PATH_RELATIVE);
+ String propertiesFile = Utils.getPath(
+ configDir, Installation.DEFAULT_JAVA_PROPERTIES_FILE);
+ return propertiesFile;
+ }
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java
new file mode 100644
index 0000000..948fb03
--- /dev/null
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java
@@ -0,0 +1,936 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup.installer.ui;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.text.JTextComponent;
+
+import org.opends.quicksetup.JavaArguments;
+import org.opends.quicksetup.event.MinimumSizeComponentListener;
+import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.ui.Utilities;
+import org.opends.quicksetup.util.BackgroundTask;
+import org.opends.quicksetup.util.Utils;
+import org.opends.server.util.SetupUtils;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
+
+import static org.opends.messages.QuickSetupMessages.*;
+
+/**
+ * This class is a dialog that appears when the user wants to configure
+ * java parameters in the runtime settings panel.
+ */
+public class JavaArgumentsDialog extends JDialog
+{
+ private static final long serialVersionUID = -7950773258109643264L;
+ private JLabel lInitialMemory;
+ private JLabel lMaxMemory;
+ private JLabel lOtherArguments;
+
+ private JTextField tfInitialMemory;
+ private JTextField tfMaxMemory;
+ private JTextField tfOtherArguments;
+
+ private JButton cancelButton;
+ private JButton okButton;
+
+ private boolean isCancelled = true;
+
+ private Message message;
+
+ private JavaArguments javaArguments;
+
+ private JPanel inputContainer;
+
+ private static final String INPUT_PANEL = "input";
+ private static final String CHECKING_PANEL = "checking";
+
+ private boolean isCheckingVisible;
+
+ private final int MAX_VALUE_32_BIT = 2048;
+
+ private static boolean userAgreedWithWebStart;
+
+ /**
+ * Constructor of the JavaArgumentsDialog.
+ * @param parent the parent frame for this dialog.
+ * @param javaArguments the java arguments used to populate this dialog.
+ * @param title the title of the dialog.
+ * @param message the message to be displayed in top.
+ * @throws IllegalArgumentException if options is null.
+ */
+ public JavaArgumentsDialog(JFrame parent, JavaArguments javaArguments,
+ Message title, Message message)
+ throws IllegalArgumentException
+ {
+ super(parent);
+ if (javaArguments == null)
+ {
+ throw new IllegalArgumentException("javaArguments cannot be null.");
+ }
+ if (title == null)
+ {
+ throw new IllegalArgumentException("title cannot be null.");
+ }
+ if (message == null)
+ {
+ throw new IllegalArgumentException("message cannot be null.");
+ }
+ setTitle(title.toString());
+ this.message = message;
+ this.javaArguments = javaArguments;
+ getContentPane().add(createPanel());
+ pack();
+
+ updateContents();
+
+ int minWidth = (int) getPreferredSize().getWidth();
+ int minHeight = (int) getPreferredSize().getHeight();
+ addComponentListener(new MinimumSizeComponentListener(this, minWidth,
+ minHeight));
+ getRootPane().setDefaultButton(okButton);
+
+ addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
+ {
+ cancelClicked();
+ }
+ });
+ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+
+ Utilities.centerOnComponent(this, parent);
+ }
+
+ /**
+ * Returns <CODE>true</CODE> if the user clicked on cancel and
+ * <CODE>false</CODE> otherwise.
+ * @return <CODE>true</CODE> if the user clicked on cancel and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean isCancelled()
+ {
+ return isCancelled;
+ }
+
+ /**
+ * Returns the java arguments object representing the input of the user
+ * in this panel. The method assumes that the values in the panel are
+ * valid.
+ * @return the java arguments object representing the input of the user
+ * in this panel.
+ */
+ public JavaArguments getJavaArguments()
+ {
+ JavaArguments javaArguments = new JavaArguments();
+
+ String sMaxMemory = tfMaxMemory.getText().trim();
+ if (sMaxMemory.length() > 0)
+ {
+ javaArguments.setMaxMemory(Integer.parseInt(sMaxMemory));
+ }
+ String sInitialMemory = tfInitialMemory.getText().trim();
+ if (sInitialMemory.length() > 0)
+ {
+ javaArguments.setInitialMemory(Integer.parseInt(sInitialMemory));
+ }
+ String[] args = getOtherArguments();
+ if (args.length > 0)
+ {
+ javaArguments.setAdditionalArguments(args);
+ }
+ return javaArguments;
+ }
+
+ private String[] getOtherArguments()
+ {
+ String sArgs = this.tfOtherArguments.getText().trim();
+ if (sArgs.length() > 0)
+ {
+ String[] args = sArgs.split(" ");
+ ArrayList<String> array = new ArrayList<String>();
+ for (String arg : args)
+ {
+ if (arg.length() > 0)
+ {
+ array.add(arg);
+ }
+ }
+ String[] fArgs = new String[array.size()];
+ array.toArray(fArgs);
+ return fArgs;
+ }
+ else
+ {
+ return new String[]{};
+ }
+ }
+
+ /**
+ * Creates and returns the panel of the dialog.
+ * @return the panel of the dialog.
+ */
+ private JPanel createPanel()
+ {
+ GridBagConstraints gbc = new GridBagConstraints();
+
+ JPanel contentPanel = new JPanel(new GridBagLayout());
+ contentPanel.setBackground(UIFactory.DEFAULT_BACKGROUND);
+
+ JPanel topPanel = new JPanel(new GridBagLayout());
+ topPanel.setBorder(UIFactory.DIALOG_PANEL_BORDER);
+ topPanel.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND);
+ Insets insets = UIFactory.getCurrentStepPanelInsets();
+ insets.bottom = 0;
+ gbc.insets = insets;
+ gbc.fill = GridBagConstraints.BOTH;
+ gbc.weightx = 1.0;
+ gbc.weighty = 0.0;
+ gbc.gridwidth = 3;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ Message title = INFO_JAVA_RUNTIME_SETTINGS_TITLE.get();
+ JLabel l =
+ UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, title,
+ UIFactory.TextStyle.TITLE);
+ l.setOpaque(false);
+ topPanel.add(l, gbc);
+
+ JTextComponent instructionsPane =
+ UIFactory.makeHtmlPane(message, UIFactory.INSTRUCTIONS_FONT);
+ instructionsPane.setOpaque(false);
+ instructionsPane.setEditable(false);
+
+ gbc.gridy ++;
+ gbc.insets.top = UIFactory.TOP_INSET_INPUT_SUBPANEL;
+ topPanel.add(instructionsPane, gbc);
+
+ gbc.gridy ++;
+ gbc.insets.top = UIFactory.TOP_INSET_INPUT_SUBPANEL;
+ gbc.insets.bottom = UIFactory.TOP_INSET_INPUT_SUBPANEL;
+
+ inputContainer = new JPanel(new CardLayout());
+ inputContainer.setOpaque(false);
+ inputContainer.add(createInputPanel(), INPUT_PANEL);
+ JPanel checkingPanel = UIFactory.makeJPanel();
+ checkingPanel.setLayout(new GridBagLayout());
+ checkingPanel.add(UIFactory.makeJLabel(UIFactory.IconType.WAIT,
+ INFO_GENERAL_CHECKING_DATA.get(),
+ UIFactory.TextStyle.PRIMARY_FIELD_VALID),
+ new GridBagConstraints());
+ inputContainer.add(checkingPanel, CHECKING_PANEL);
+
+ topPanel.add(inputContainer, gbc);
+ gbc.weighty = 1.0;
+ gbc.gridy ++;
+ gbc.insets = UIFactory.getEmptyInsets();
+ topPanel.add(Box.createVerticalGlue(), gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ contentPanel.add(topPanel, gbc);
+ gbc.weighty = 0.0;
+ gbc.gridy ++;
+ gbc.insets = UIFactory.getButtonsPanelInsets();
+ contentPanel.add(createButtonsPanel(), gbc);
+
+ return contentPanel;
+ }
+
+ /**
+ * Creates and returns the input sub panel: the panel with all the widgets
+ * that are used to define the security options.
+ * @return the input sub panel.
+ */
+ private Component createInputPanel()
+ {
+ JPanel inputPanel = new JPanel(new GridBagLayout());
+ inputPanel.setOpaque(false);
+
+ lInitialMemory = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_INITIAL_MEMORY_LABEL.get(),
+ UIFactory.TextStyle.PRIMARY_FIELD_VALID);
+ lInitialMemory.setOpaque(false);
+ tfInitialMemory = UIFactory.makeJTextField(Message.EMPTY,
+ INFO_INITIAL_MEMORY_TOOLTIP.get(), 10, UIFactory.TextStyle.TEXTFIELD);
+ lInitialMemory.setLabelFor(tfInitialMemory);
+
+ lMaxMemory = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_MAX_MEMORY_LABEL.get(),
+ UIFactory.TextStyle.PRIMARY_FIELD_VALID);
+ lMaxMemory.setOpaque(false);
+ tfMaxMemory = UIFactory.makeJTextField(Message.EMPTY,
+ INFO_MAX_MEMORY_TOOLTIP.get(), 10, UIFactory.TextStyle.TEXTFIELD);
+ lMaxMemory.setLabelFor(tfMaxMemory);
+
+ lOtherArguments = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_OTHER_JAVA_ARGUMENTS_LABEL.get(),
+ UIFactory.TextStyle.PRIMARY_FIELD_VALID);
+ lOtherArguments.setOpaque(false);
+ tfOtherArguments = UIFactory.makeJTextField(Message.EMPTY,
+ INFO_OTHER_JAVA_ARGUMENTS_TOOLTIP.get(), 30,
+ UIFactory.TextStyle.TEXTFIELD);
+ lOtherArguments.setLabelFor(tfOtherArguments);
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.weightx = 0.0;
+ inputPanel.add(lInitialMemory, gbc);
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ inputPanel.add(tfInitialMemory, gbc);
+ gbc.weightx = 0.0;
+ gbc.gridx = 2;
+ gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD;
+ JLabel lMb = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_MEGABYTE_LABEL.get(),
+ UIFactory.TextStyle.SECONDARY_FIELD_VALID);
+ lMb.setOpaque(false);
+ inputPanel.add(lMb, gbc);
+ gbc.gridx = 1;
+ gbc.gridy ++;
+ gbc.gridwidth = 2;
+ gbc.insets.top = 3;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ inputPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_JAVA_ARGUMENTS_LEAVE_EMPTY.get(),
+ UIFactory.TextStyle.INLINE_HELP), gbc);
+
+ gbc.gridy ++;
+ gbc.gridwidth = 1;
+ gbc.gridx = 0;
+ gbc.weightx = 0.0;
+ gbc.insets.left = 0;
+ gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
+ inputPanel.add(lMaxMemory, gbc);
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ inputPanel.add(tfMaxMemory, gbc);
+ gbc.weightx = 0.0;
+ gbc.gridx = 2;
+ gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD;
+ lMb = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_MEGABYTE_LABEL.get(),
+ UIFactory.TextStyle.SECONDARY_FIELD_VALID);
+ lMb.setOpaque(false);
+ inputPanel.add(lMb, gbc);
+ gbc.gridx = 1;
+ gbc.gridy ++;
+ gbc.gridwidth = 2;
+ gbc.insets.top = 3;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ inputPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_JAVA_ARGUMENTS_LEAVE_EMPTY.get(),
+ UIFactory.TextStyle.INLINE_HELP), gbc);
+
+ gbc.gridy ++;
+ gbc.gridwidth = 1;
+ gbc.gridx = 0;
+ gbc.weightx = 0.0;
+ gbc.insets.left = 0;
+ gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
+ inputPanel.add(lOtherArguments, gbc);
+ gbc.gridx = 1;
+ gbc.weightx = 1.0;
+ gbc.gridwidth = 2;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ inputPanel.add(tfOtherArguments, gbc);
+
+ gbc.gridy ++;
+ gbc.gridx = 0;
+ gbc.weighty = 1.0;
+ gbc.insets = UIFactory.getEmptyInsets();
+ inputPanel.add(Box.createVerticalGlue(), gbc);
+
+ return inputPanel;
+ }
+
+ /**
+ * Creates and returns the buttons OK/CANCEL sub panel.
+ * @return the buttons OK/CANCEL sub panel.
+ */
+ private Component createButtonsPanel()
+ {
+ JPanel buttonsPanel = new JPanel(new GridBagLayout());
+ buttonsPanel.setOpaque(false);
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.gridwidth = 4;
+ gbc.insets = UIFactory.getEmptyInsets();
+ gbc.insets.left = UIFactory.getCurrentStepPanelInsets().left;
+ buttonsPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ null, UIFactory.TextStyle.NO_STYLE), gbc);
+ gbc.weightx = 1.0;
+ gbc.gridwidth--;
+ gbc.insets.left = 0;
+ buttonsPanel.add(Box.createHorizontalGlue(), gbc);
+ gbc.gridwidth = GridBagConstraints.RELATIVE;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.weightx = 0.0;
+ okButton =
+ UIFactory.makeJButton(INFO_OK_BUTTON_LABEL.get(),
+ INFO_JAVA_ARGUMENTS_OK_BUTTON_TOOLTIP.get());
+ buttonsPanel.add(okButton, gbc);
+ okButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ okClicked();
+ }
+ });
+
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS;
+ cancelButton =
+ UIFactory.makeJButton(INFO_CANCEL_BUTTON_LABEL.get(),
+ INFO_JAVA_ARGUMENTS_CANCEL_BUTTON_TOOLTIP.get());
+ buttonsPanel.add(cancelButton, gbc);
+ cancelButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ cancelClicked();
+ }
+ });
+
+ return buttonsPanel;
+ }
+
+ /**
+ * Method called when user clicks on cancel.
+ *
+ */
+ private void cancelClicked()
+ {
+ isCancelled = true;
+ dispose();
+ }
+
+ /**
+ * Method called when user clicks on OK.
+ *
+ */
+ private void okClicked()
+ {
+ BackgroundTask<ArrayList<Message>> worker =
+ new BackgroundTask<ArrayList<Message>>()
+ {
+ @Override
+ public ArrayList<Message> processBackgroundTask()
+ {
+ setValidLater(lInitialMemory, true);
+ setValidLater(lMaxMemory, true);
+ setValidLater(lOtherArguments, true);
+ int initialMemory = -1;
+ int maxMemory = -1;
+ ArrayList<Message> errorMsgs = new ArrayList<Message>();
+ try
+ {
+ String sInitialMemory = tfInitialMemory.getText().trim();
+ if (sInitialMemory.length() > 0)
+ {
+ initialMemory = Integer.parseInt(sInitialMemory);
+ if (initialMemory <= 0)
+ {
+ initialMemory = -1;
+ errorMsgs.add(ERR_INITIAL_MEMORY_VALUE.get());
+ setValidLater(lInitialMemory, false);
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ errorMsgs.add(ERR_INITIAL_MEMORY_VALUE.get());
+ setValidLater(lInitialMemory, false);
+ }
+ try
+ {
+ String sMaxMemory = tfMaxMemory.getText().trim();
+ if (sMaxMemory.length() > 0)
+ {
+ maxMemory = Integer.parseInt(sMaxMemory);
+ if (maxMemory <= 0)
+ {
+ maxMemory = -1;
+ errorMsgs.add(ERR_MAX_MEMORY_VALUE.get());
+ setValidLater(lMaxMemory, false);
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ errorMsgs.add(ERR_MAX_MEMORY_VALUE.get());
+ setValidLater(lMaxMemory, false);
+ }
+ if (maxMemory != -1 && initialMemory != -1)
+ {
+ if (initialMemory > maxMemory)
+ {
+ errorMsgs.add(ERR_MAX_MEMORY_BIGGER_THAN_INITIAL_MEMORY.get());
+ setValidLater(lMaxMemory, false);
+ setValidLater(lInitialMemory, false);
+ }
+ }
+ if (errorMsgs.isEmpty())
+ {
+ // Try the options together, often there are interdependencies.
+ ArrayList<Message> allErrors = new ArrayList<Message>();
+ checkAllArgumentsTogether(initialMemory, maxMemory, allErrors);
+
+ if (!allErrors.isEmpty())
+ {
+ ArrayList<Message> memoryErrors = new ArrayList<Message>();
+ checkMemoryArguments(initialMemory, maxMemory, memoryErrors);
+ ArrayList<Message> otherErrors = new ArrayList<Message>();
+ checkOtherArguments(otherErrors);
+
+ if (!memoryErrors.isEmpty())
+ {
+ errorMsgs.addAll(memoryErrors);
+ if (!otherErrors.isEmpty())
+ {
+ errorMsgs.addAll(otherErrors);
+ }
+ }
+ else
+ {
+ if (!otherErrors.isEmpty())
+ {
+ errorMsgs.addAll(otherErrors);
+ }
+ else
+ {
+ setValidLater(lInitialMemory, false);
+ setValidLater(lMaxMemory, false);
+ setValidLater(lOtherArguments, false);
+ // It appears that the arguments are not compatible together.
+ errorMsgs.add(
+ ERR_MEMORY_AND_OTHER_ARGUMENTS_NOT_COMPATIBLE.get());
+ }
+ }
+ }
+ }
+ return errorMsgs;
+ }
+
+ @Override
+ public void backgroundTaskCompleted(ArrayList<Message> returnValue,
+ Throwable throwable)
+ {
+ setCheckingVisible(false);
+ if (throwable != null)
+ {
+ // Bug
+ throwable.printStackTrace();
+ displayError(
+ Utils.getThrowableMsg(INFO_BUG_MSG.get(), throwable),
+ INFO_ERROR_TITLE.get());
+ cancelButton.setEnabled(true);
+ okButton.setEnabled(true);
+ }
+ else
+ {
+ cancelButton.setEnabled(true);
+ okButton.setEnabled(true);
+
+ if (returnValue.size() > 0)
+ {
+ displayError(Utils.getMessageFromCollection(returnValue, "\n"),
+ INFO_ERROR_TITLE.get());
+ }
+ else
+ {
+ if (displayWebStartWarningIfRequired())
+ {
+ isCancelled = false;
+ dispose();
+ }
+ }
+ }
+ }
+ };
+ setCheckingVisible(true);
+ cancelButton.setEnabled(false);
+ okButton.setEnabled(false);
+ worker.startBackgroundTask();
+ }
+
+ /**
+ * Displays an error message dialog.
+ *
+ * @param msg
+ * the error message.
+ * @param title
+ * the title for the dialog.
+ */
+ private void displayError(Message msg, Message title)
+ {
+ Utilities.displayError(this, msg, title);
+ toFront();
+ }
+
+ /**
+ * Displays a confirmation dialog and returns <CODE>true</CODE> if the user
+ * accepts the message displayed in the dialog and <CODE>false</CODE>
+ * otherwise.
+ *
+ * @param msg
+ * the error message.
+ * @param title
+ * the title for the dialog.
+ * @return <CODE>true</CODE> if the user accepts the message displayed in the
+ * dialog and <CODE>false</CODE> otherwise.
+ */
+ private boolean displayConfirmationDialog(Message msg, Message title)
+ {
+ toFront();
+ return Utilities.displayConfirmation(this, msg, title);
+ }
+
+ /**
+ * Updates the widgets on the dialog with the contents of the securityOptions
+ * object.
+ *
+ */
+ private void updateContents()
+ {
+ if (javaArguments.getInitialMemory() > 0)
+ {
+ tfInitialMemory.setText(String.valueOf(javaArguments.getInitialMemory()));
+ }
+ else
+ {
+ tfInitialMemory.setText("");
+ }
+ if (javaArguments.getMaxMemory() > 0)
+ {
+ tfMaxMemory.setText(String.valueOf(javaArguments.getMaxMemory()));
+ }
+ else
+ {
+ tfMaxMemory.setText("");
+ }
+ if (javaArguments.getAdditionalArguments() != null)
+ {
+ StringBuilder sb = new StringBuilder();
+ for (String arg : javaArguments.getAdditionalArguments())
+ {
+ if (sb.length() > 0)
+ {
+ sb.append(" ");
+ }
+ sb.append(arg);
+ }
+ tfOtherArguments.setText(sb.toString());
+ }
+ else
+ {
+ tfOtherArguments.setText("");
+ }
+ }
+
+ /**
+ * Method that updates the text style of a provided component by calling
+ * SwingUtilities.invokeLater. This method is aimed to be called outside
+ * the event thread (calling it from the event thread will also work though).
+ * @param comp the component to be updated.
+ * @param valid whether to use a TextStyle to mark the component as valid
+ * or as invalid.
+ */
+ private void setValidLater(final JComponent comp, final boolean valid)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ UIFactory.setTextStyle(comp,
+ valid ? UIFactory.TextStyle.PRIMARY_FIELD_VALID :
+ UIFactory.TextStyle.PRIMARY_FIELD_INVALID);
+ }
+ });
+ }
+
+ /**
+ * This method displays a working progress icon in the panel.
+ * @param visible whether the icon must be displayed or not.
+ */
+ private void setCheckingVisible(boolean visible)
+ {
+ if (visible != isCheckingVisible && inputContainer != null)
+ {
+ CardLayout cl = (CardLayout) inputContainer.getLayout();
+ if (visible)
+ {
+ cl.show(inputContainer, CHECKING_PANEL);
+ }
+ else
+ {
+ cl.show(inputContainer, INPUT_PANEL);
+ }
+ isCheckingVisible = visible;
+ }
+ }
+
+ /**
+ * Method written for testing purposes.
+ * @param args the arguments to be passed to the test program.
+ */
+ public static void main(String[] args)
+ {
+ try
+ {
+ JavaArguments javaArgs = new JavaArguments();
+ javaArgs.setInitialMemory(100);
+ javaArgs.setMaxMemory(99);
+ javaArgs.setAdditionalArguments(new String[]{"" , "-client", "-XX"});
+ // UIFactory.initialize();
+ JavaArgumentsDialog dlg = new JavaArgumentsDialog(new JFrame(), javaArgs,
+ Message.raw("my title"),
+ Message.raw("Set the java arguments for the test command-line."));
+ dlg.pack();
+ dlg.setVisible(true);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private final static String INSTALL_PATH =
+ Utils.getInstallPathFromClasspath();
+
+ private void checkOptions(String options, Collection<Message> errorMsgs,
+ JLabel l, Message errorMsg)
+ {
+ checkOptions(options, errorMsgs, new JLabel[]{l}, errorMsg);
+ }
+
+ private void checkOptions(String options, Collection<Message> errorMsgs,
+ JLabel[] ls, Message errorMsg)
+ {
+ if (!Utils.isWebStart())
+ {
+ String javaHome = System.getProperty("java.home");
+ if ((javaHome == null) || (javaHome.length() == 0))
+ {
+ javaHome = System.getenv(SetupUtils.OPENDS_JAVA_HOME);
+ }
+ if (!Utils.supportsOption(options, javaHome, INSTALL_PATH))
+ {
+ for (JLabel l : ls)
+ {
+ setValidLater(l, false);
+ }
+ errorMsgs.add(errorMsg);
+ }
+ }
+ }
+
+ private Message getMemoryErrorMessage(Message msg, int memValue)
+ {
+ if (memValue < MAX_VALUE_32_BIT)
+ {
+ return msg;
+ }
+ else
+ {
+ MessageBuilder mb = new MessageBuilder();
+ mb.append(msg);
+ mb.append(" ");
+ mb.append(ERR_MEMORY_32_BIT_LIMIT.get());
+ return mb.toMessage();
+ }
+ }
+
+ private void checkMemoryArguments(int initialMemory, int maxMemory,
+ Collection<Message> errorMsgs)
+ {
+ setValidLater(lInitialMemory, true);
+ setValidLater(lMaxMemory, true);
+ if (initialMemory != -1)
+ {
+ if (maxMemory != -1)
+ {
+ Message msg = getMemoryErrorMessage(ERR_MEMORY_VALUE_EXTENDED.get(
+ JavaArguments.getInitialMemoryGenericArgument(),
+ JavaArguments.getMaxMemoryGenericArgument()), maxMemory);
+ String sMemory =
+ JavaArguments.getInitialMemoryArgument(initialMemory) + " "+
+ JavaArguments.getMaxMemoryArgument(maxMemory);
+ checkOptions(sMemory,
+ errorMsgs,
+ new JLabel[] {lInitialMemory, lMaxMemory},
+ msg);
+ }
+ else
+ {
+ Message msg = getMemoryErrorMessage(
+ ERR_INITIAL_MEMORY_VALUE_EXTENDED.get(
+ JavaArguments.getInitialMemoryGenericArgument()),
+ initialMemory);
+ checkOptions(JavaArguments.getInitialMemoryArgument(initialMemory),
+ errorMsgs,
+ lInitialMemory,
+ msg);
+ }
+ }
+ else if (maxMemory != -1)
+ {
+ Message msg = getMemoryErrorMessage(
+ ERR_MAX_MEMORY_VALUE_EXTENDED.get(
+ JavaArguments.getInitialMemoryGenericArgument()), maxMemory);
+ checkOptions(JavaArguments.getMaxMemoryArgument(maxMemory),
+ errorMsgs,
+ lMaxMemory,
+ msg);
+ }
+ }
+
+ private void checkAllArgumentsTogether(int initialMemory, int maxMemory,
+ Collection<Message> errorMsgs)
+ {
+ setValidLater(lInitialMemory, true);
+ setValidLater(lMaxMemory, true);
+ setValidLater(lOtherArguments, true);
+ ArrayList<JLabel> ls = new ArrayList<JLabel>();
+ StringBuilder sb = new StringBuilder();
+
+ if (initialMemory != -1)
+ {
+ if (maxMemory != -1)
+ {
+ String sMemory =
+ JavaArguments.getInitialMemoryArgument(initialMemory) + " "+
+ JavaArguments.getMaxMemoryArgument(maxMemory);
+ sb.append(sMemory);
+ ls.add(lInitialMemory);
+ ls.add(lMaxMemory);
+ }
+ else
+ {
+ sb.append(JavaArguments.getInitialMemoryArgument(initialMemory));
+ ls.add(lInitialMemory);
+ }
+ }
+ else if (maxMemory != -1)
+ {
+ sb.append(JavaArguments.getMaxMemoryArgument(maxMemory));
+ ls.add(lMaxMemory);
+ }
+
+ String[] otherArgs = getOtherArguments();
+ if (otherArgs.length > 0)
+ {
+ ls.add(lOtherArguments);
+ for (String arg : otherArgs)
+ {
+ if (sb.length() > 0)
+ {
+ sb.append(" ");
+ }
+ sb.append(arg);
+ }
+ }
+ if (sb.length() > 0)
+ {
+ checkOptions(sb.toString(), errorMsgs, ls.toArray(new JLabel[]{}),
+ ERR_GENERIC_JAVA_ARGUMENT.get(sb.toString()));
+ }
+ }
+
+ private void checkOtherArguments(Collection<Message> errorMsgs)
+ {
+ setValidLater(lOtherArguments, true);
+ ArrayList<JLabel> ls = new ArrayList<JLabel>();
+ StringBuilder sb = new StringBuilder();
+
+ String[] otherArgs = getOtherArguments();
+ if (otherArgs.length > 0)
+ {
+ ls.add(lOtherArguments);
+ for (String arg : otherArgs)
+ {
+ if (sb.length() > 0)
+ {
+ sb.append(" ");
+ }
+ sb.append(arg);
+ }
+ }
+ if (sb.length() > 0)
+ {
+ checkOptions(sb.toString(), errorMsgs, lOtherArguments,
+ ERR_GENERIC_JAVA_ARGUMENT.get(sb.toString()));
+ }
+ }
+
+ private boolean displayWebStartWarningIfRequired()
+ {
+ boolean returnValue = true;
+ if (Utils.isWebStart() && !userAgreedWithWebStart)
+ {
+ JavaArguments args = getJavaArguments();
+ if (!args.equals(javaArguments) &&
+ ((args.getInitialMemory() != -1) ||
+ (args.getMaxMemory() != -1) ||
+ (args.getAdditionalArguments().length > 0)))
+ {
+ returnValue = displayConfirmationDialog(
+ INFO_JAVA_ARGUMENTS_CANNOT_BE_CHECKED_IN_WEBSTART.get(),
+ INFO_CONFIRMATION_TITLE.get());
+ userAgreedWithWebStart = returnValue;
+ }
+ }
+ return returnValue;
+ }
+}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/RuntimeOptionsPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/RuntimeOptionsPanel.java
new file mode 100644
index 0000000..8d14e7e
--- /dev/null
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/ui/RuntimeOptionsPanel.java
@@ -0,0 +1,468 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2010 Sun Microsystems, Inc.
+ */
+package org.opends.quicksetup.installer.ui;
+
+import static org.opends.messages.QuickSetupMessages.*;
+
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.io.File;
+import java.util.Set;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.opends.admin.ads.ReplicaDescriptor;
+import org.opends.admin.ads.SuffixDescriptor;
+import org.opends.messages.Message;
+import org.opends.quicksetup.JavaArguments;
+import org.opends.quicksetup.UserData;
+import org.opends.quicksetup.installer.DataReplicationOptions;
+import org.opends.quicksetup.installer.NewSuffixOptions;
+import org.opends.quicksetup.installer.SuffixesToReplicateOptions;
+import org.opends.quicksetup.ui.FieldName;
+import org.opends.quicksetup.ui.GuiApplication;
+import org.opends.quicksetup.ui.QuickSetupStepPanel;
+import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.util.HtmlProgressMessageFormatter;
+
+/**
+ * The panel where the user specifies the runtime settings.
+ *
+ */
+public class RuntimeOptionsPanel extends QuickSetupStepPanel
+{
+ private static final long serialVersionUID = -8303034619200476754L;
+
+ private JButton bServer;
+ private JButton bImport;
+ private JLabel lServer;
+ private JLabel lImport;
+ private JEditorPane warning;
+ private Component lastFocusComponent;
+
+ private JavaArguments serverJavaArgs;
+ private JavaArguments importJavaArgs;
+
+ private JavaArguments defaultServerJavaArgs;
+ private JavaArguments defaultImportJavaArgs;
+
+ // The size of the LDIF file to be imported used as threshold to display
+ // a warning message, telling the user to update the import runtime
+ // settings.
+ private long WARNING_THRESOLD_FOR_IMPORT = 200 * 1024 * 1024;
+
+ private int WARNING_THRESOLD_AUTOMATICALLY_GENERATED_IMPORT = 100000;
+
+ private int WARNING_THRESOLD_REPLICATED_ENTRIES = 100000;
+
+ /**
+ * Constructor of the panel.
+ * @param application Application represented by this panel and used to
+ * initialize the fields of the panel.
+ */
+ public RuntimeOptionsPanel(GuiApplication application)
+ {
+ super(application);
+ createComponents();
+ addFocusListeners();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Component createInputPanel()
+ {
+ JPanel panel = new JPanel(new GridBagLayout());
+ panel.setOpaque(false);
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridwidth = 4;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
+ gbc.insets.bottom = UIFactory.TOP_INSET_PRIMARY_FIELD;
+ gbc.weightx = 1.0;
+ panel.add(warning, gbc);
+ warning.setVisible(false);
+
+ gbc.gridy ++;
+ gbc.gridwidth = 1;
+ gbc.weightx = 0.0;
+ gbc.insets.bottom = 0;
+
+ JLabel l = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_SERVER_RUNTIME_ARGS_LABEL.get(),
+ UIFactory.TextStyle.PRIMARY_FIELD_VALID);
+ int serverInsetsTop = Math.abs(
+ bServer.getPreferredSize().height -
+ l.getPreferredSize().height) / 2;
+
+ gbc.insets.top = serverInsetsTop;
+ panel.add(l, gbc);
+ gbc.gridx ++;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ gbc.weightx = 0.5;
+ panel.add(lServer, gbc);
+ gbc.gridx ++;
+ gbc.insets.top = 0;
+ gbc.weightx = 0.0;
+ panel.add(bServer, gbc);
+ gbc.gridx ++;
+ gbc.weightx = 1.0;
+ gbc.insets.left = 0;
+ panel.add(Box.createHorizontalGlue(), gbc);
+
+ gbc.gridy++;
+ gbc.gridx = 0;
+ gbc.weightx = 0.0;
+
+ l = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_IMPORT_RUNTIME_ARGS_LABEL.get(),
+ UIFactory.TextStyle.PRIMARY_FIELD_VALID);
+ int importInsetsTop = Math.abs(
+ bImport.getPreferredSize().height -
+ l.getPreferredSize().height) / 2;
+ gbc.insets.top = importInsetsTop;
+ panel.add(l, gbc);
+ gbc.gridx ++;
+ gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+ gbc.weightx = 0.5;
+ panel.add(lImport, gbc);
+ gbc.gridx ++;
+ gbc.insets.top = 0;
+ gbc.weightx = 0.0;
+ panel.add(bImport, gbc);
+ gbc.gridx ++;
+ gbc.weightx = 1.0;
+ gbc.insets.left = 0;
+ panel.add(Box.createHorizontalGlue(), gbc);
+
+ gbc.gridx = 0;
+ gbc.gridwidth = 4;
+ gbc.gridy ++;
+ gbc.insets = UIFactory.getEmptyInsets();
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ gbc.fill = GridBagConstraints.VERTICAL;
+ panel.add(Box.createVerticalGlue(), gbc);
+
+ return panel;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Message getInstructions()
+ {
+ return INFO_JAVA_RUNTIME_OPTIONS_PANEL_INSTRUCTIONS.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Message getTitle()
+ {
+ return INFO_JAVA_RUNTIME_OPTIONS_PANEL_TITLE.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object getFieldValue(FieldName fieldName)
+ {
+ Object value = null;
+ if (fieldName == FieldName.SERVER_JAVA_ARGUMENTS)
+ {
+ value = serverJavaArgs;
+ }
+ else if (fieldName == FieldName.IMPORT_JAVA_ARGUMENTS)
+ {
+ value = importJavaArgs;
+ }
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void beginDisplay(UserData uData)
+ {
+ if (defaultServerJavaArgs == null)
+ {
+ defaultServerJavaArgs =
+ uData.getDefaultJavaArguments(UserData.SERVER_SCRIPT_NAME);
+ }
+ if (defaultImportJavaArgs == null)
+ {
+ defaultImportJavaArgs =
+ uData.getDefaultJavaArguments(UserData.IMPORT_SCRIPT_NAME);
+ }
+ boolean updatePanel = false;
+ if (serverJavaArgs == null)
+ {
+ serverJavaArgs = uData.getJavaArguments(UserData.SERVER_SCRIPT_NAME);
+ updatePanel = true;
+ }
+ if (importJavaArgs == null)
+ {
+ importJavaArgs = uData.getJavaArguments(UserData.IMPORT_SCRIPT_NAME);
+ updatePanel = true;
+ }
+ if (updatePanel)
+ {
+ lServer.setText(JavaArguments.getMessageForJLabel(
+ serverJavaArgs, defaultServerJavaArgs,
+ UIFactory.SECONDARY_FIELD_VALID_FONT).toString());
+ lImport.setText(JavaArguments.getMessageForJLabel(
+ importJavaArgs, defaultImportJavaArgs,
+ UIFactory.SECONDARY_FIELD_VALID_FONT).toString());
+ }
+
+ updateWarningMessage(uData);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void endDisplay()
+ {
+ if (lastFocusComponent != null)
+ {
+ lastFocusComponent.requestFocusInWindow();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean requiresScroll()
+ {
+ return false;
+ }
+
+ /**
+ * Adds the required focus listeners to the fields.
+ */
+ private void addFocusListeners()
+ {
+ FocusListener l = new FocusListener()
+ {
+ public void focusGained(FocusEvent e)
+ {
+ lastFocusComponent = e.getComponent();
+ }
+
+ public void focusLost(FocusEvent e)
+ {
+ }
+ };
+
+ bServer.addFocusListener(l);
+ bImport.addFocusListener(l);
+ lastFocusComponent = bServer;
+ }
+
+ private void changeServerClicked()
+ {
+ JavaArgumentsDialog dlg = new JavaArgumentsDialog(
+ getFrame(), serverJavaArgs,
+ INFO_SERVER_JAVA_ARGUMENTS_TITLE.get(),
+ INFO_SERVER_JAVA_ARGUMENTS_MSG.get());
+ dlg.pack();
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ if (!dlg.isCancelled())
+ {
+ serverJavaArgs = dlg.getJavaArguments();
+ lServer.setText(JavaArguments.getMessageForJLabel(
+ serverJavaArgs, defaultServerJavaArgs,
+ UIFactory.SECONDARY_FIELD_VALID_FONT).toString());
+ }
+ }
+
+ private void changeImportClicked()
+ {
+ JavaArgumentsDialog dlg = new JavaArgumentsDialog(
+ getFrame(), importJavaArgs,
+ INFO_IMPORT_JAVA_ARGUMENTS_TITLE.get(),
+ INFO_IMPORT_JAVA_ARGUMENTS_MSG.get());
+ dlg.pack();
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ if (!dlg.isCancelled())
+ {
+ importJavaArgs = dlg.getJavaArguments();
+ lImport.setText(JavaArguments.getMessageForJLabel(
+ importJavaArgs, defaultImportJavaArgs,
+ UIFactory.SECONDARY_FIELD_VALID_FONT).toString());
+ }
+ }
+
+ private void createComponents()
+ {
+ warning = UIFactory.makeHtmlPane(Message.EMPTY,
+ UIFactory.INSTRUCTIONS_FONT);
+ warning.setOpaque(false);
+
+ lServer = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ Message.EMPTY, UIFactory.TextStyle.SECONDARY_FIELD_VALID);
+ bServer = UIFactory.makeJButton(INFO_JAVA_RUNTIME_CHANGE_LABEL.get(),
+ INFO_JAVA_RUNTIME_CHANGE_SERVER_TOOLTIP.get());
+ bServer.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ changeServerClicked();
+ }
+ });
+
+ lImport = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ Message.EMPTY, UIFactory.TextStyle.SECONDARY_FIELD_VALID);
+ bImport = UIFactory.makeJButton(INFO_JAVA_RUNTIME_CHANGE_LABEL.get(),
+ INFO_JAVA_RUNTIME_CHANGE_IMPORT_TOOLTIP.get());
+ bImport.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ changeImportClicked();
+ }
+ });
+ }
+
+ private JFrame getFrame()
+ {
+ Component mainWindow = getMainWindow();
+ JFrame frame = null;
+ if (mainWindow instanceof JFrame)
+ {
+ frame = (JFrame)mainWindow;
+ }
+ return frame;
+ }
+
+ private void updateWarningMessage(UserData uData)
+ {
+ Message msg = null;
+
+ boolean createSuffix = false;
+
+ DataReplicationOptions repl = uData.getReplicationOptions();
+
+ SuffixesToReplicateOptions suf = uData.getSuffixesToReplicateOptions();
+
+ createSuffix =
+ repl.getType() == DataReplicationOptions.Type.FIRST_IN_TOPOLOGY ||
+ repl.getType() == DataReplicationOptions.Type.STANDALONE ||
+ suf.getType() == SuffixesToReplicateOptions.Type.NEW_SUFFIX_IN_TOPOLOGY;
+
+ if (createSuffix)
+ {
+ NewSuffixOptions options = uData.getNewSuffixOptions();
+
+ switch (options.getType())
+ {
+ case IMPORT_FROM_LDIF_FILE:
+ File ldifFile = new File(options.getLDIFPaths().getFirst());
+ if (ldifFile.length() > WARNING_THRESOLD_FOR_IMPORT)
+ {
+ msg = INFO_IMPORT_FILE_WARNING_UPDATE_RUNTIME_ARGS.get();
+ }
+ break;
+
+ case IMPORT_AUTOMATICALLY_GENERATED_DATA:
+ if (options.getNumberEntries() >
+ WARNING_THRESOLD_AUTOMATICALLY_GENERATED_IMPORT)
+ {
+ msg =
+ INFO_AUTOMATICALLY_GENERATED_DATA_WARNING_UPDATE_RUNTIME_ARGS.
+ get();
+ }
+ break;
+ }
+ }
+ else if (repl.getType() == DataReplicationOptions.Type.IN_EXISTING_TOPOLOGY)
+ {
+ int maxReplicatedEntries = 0;
+
+ Set<SuffixDescriptor> suffixes = suf.getSuffixes();
+ for (SuffixDescriptor suffix : suffixes)
+ {
+ int suffixEntries = 0;
+ for (ReplicaDescriptor replica : suffix.getReplicas())
+ {
+ suffixEntries = Math.max(suffixEntries, replica.getEntries());
+ }
+ maxReplicatedEntries += suffixEntries;
+ }
+
+ if (maxReplicatedEntries > WARNING_THRESOLD_REPLICATED_ENTRIES)
+ {
+ msg = INFO_REPLICATED_ENTRIES_WARNING_UPDATE_RUNTIME_ARGS.get();
+ }
+ }
+
+ if (msg != null)
+ {
+ HtmlProgressMessageFormatter formatter =
+ new HtmlProgressMessageFormatter();
+ StringBuilder buf = new StringBuilder();
+ String space = formatter.getSpace().toString();
+ String lBreak = formatter.getLineBreak().toString();
+ String title = UIFactory.applyFontToHtml(
+ INFO_GENERAL_WARNING.get().toString(),
+ UIFactory.TITLE_FONT);
+ String details = UIFactory.applyFontToHtml(msg.toString(),
+ UIFactory.SECONDARY_FIELD_VALID_FONT);
+ buf.append(UIFactory.getIconHtml(UIFactory.IconType.WARNING_LARGE) +
+ space + space + title + lBreak + lBreak)
+ .append(details);
+ String s = "<form>"+UIFactory.applyErrorBackgroundToHtml(buf.toString())+
+ "</form>";
+
+ warning.setText(s);
+ warning.setVisible(true);
+ }
+ else
+ {
+ warning.setText("");
+ warning.setVisible(false);
+ }
+ }
+}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
index 88ff6d4..d8f89cd 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -185,7 +185,7 @@
}
try
{
- new ServerController(this).startServer(!isVerbose());
+ new ServerController(this).startServer(!isStartVerbose());
}
catch (ApplicationException ae)
{
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/FieldName.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/FieldName.java
index d6da08b..37e3b4a 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/FieldName.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/FieldName.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.ui;
@@ -160,6 +160,14 @@
*/
REMOTE_REPLICATION_SECURE,
/**
+ * The value associated with this is a JavaArguments object.
+ */
+ SERVER_JAVA_ARGUMENTS,
+ /**
+ * The value associated with this is a JavaArguments object.
+ */
+ IMPORT_JAVA_ARGUMENTS,
+ /**
* The value associated with this is a Boolean.
*/
SERVER_START_INSTALLER,
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
index e73c3d4..6abd022 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.ui;
@@ -258,13 +258,13 @@
{
final WizardStep cStep = getCurrentStep();
application.nextClicked(cStep, this);
- BackgroundTask worker = new NextClickedBackgroundTask(cStep);
+ BackgroundTask<?> worker = new NextClickedBackgroundTask(cStep);
getDialog().workerStarted();
worker.startBackgroundTask();
}
private void updateUserData(final WizardStep cStep) {
- BackgroundTask worker = new BackgroundTask() {
+ BackgroundTask<?> worker = new BackgroundTask<Object>() {
public Object processBackgroundTask() throws UserDataException {
try {
application.updateUserData(cStep, QuickSetup.this);
@@ -373,7 +373,7 @@
private void launchStatusPanelClicked()
{
- BackgroundTask worker = new BackgroundTask()
+ BackgroundTask<Object> worker = new BackgroundTask<Object>()
{
public Object processBackgroundTask() throws UserDataException {
try
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java
index 33a34db..41546c7 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java
@@ -63,6 +63,7 @@
public abstract class QuickSetupStepPanel extends QuickSetupPanel
implements HyperlinkListener
{
+ private static final long serialVersionUID = -1983448318085588324L;
private JPanel inputContainer;
private Component inputPanel;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java
index ff7b77f..7bb1ef9 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/Utilities.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.ui;
@@ -146,7 +146,7 @@
* @return <CODE>true</CODE> if the user confirms the message, or
* <CODE>false</CODE> if not.
*/
- public static boolean displayConfirmation(JFrame parent, Message msg,
+ public static boolean displayConfirmation(Component parent, Message msg,
Message title)
{
return JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
index 282d8a7..bb1ed5f 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.upgrader;
@@ -197,7 +197,7 @@
* {@inheritDoc}
*/
public String getInstancePath() {
- return Utils.getInstancePathFromClasspath(getInstallationPath());
+ return Utils.getInstancePathFromInstallPath(getInstallationPath());
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
index c8d2d5e..10900b4 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
@@ -390,7 +390,7 @@
*/
public String getInstancePath() {
String installPath = getInstallationPath() ;
- return Utils.getInstancePathFromClasspath(installPath);
+ return Utils.getInstancePathFromInstallPath(installPath);
}
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index 8c10df1..d4ae2d3 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -401,7 +401,7 @@
return null;
}
- return Utils.getInstancePathFromClasspath(installPath);
+ return Utils.getInstancePathFromInstallPath(installPath);
}
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java
index c027563..6974003 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/BackgroundTask.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.util;
@@ -43,7 +43,7 @@
*/
public final void startBackgroundTask()
{
- BackgroundTaskThread taskThread = new BackgroundTaskThread<T>(this);
+ BackgroundTaskThread<T> taskThread = new BackgroundTaskThread<T>(this);
taskThread.start();
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
index 0f18997..60b8e84 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.util;
@@ -88,11 +88,11 @@
*/
static private boolean serverHasBeenStarted = false;
- static private ErrorLogPublisher startupErrorPublisher;
+ static private ErrorLogPublisher<?> startupErrorPublisher;
- static private AccessLogPublisher startupAccessPublisher;
+ static private AccessLogPublisher<?> startupAccessPublisher;
- static private DebugLogPublisher startupDebugPublisher;
+ static private DebugLogPublisher<?> startupDebugPublisher;
/**
* Pushes messages published by the server loggers into OperationOutput.
@@ -110,10 +110,6 @@
// do nothing
}
- ServerControllerTextWriter(OperationOutput output) {
- setOutput(output);
- }
-
public void setOutput(OperationOutput ouput) {
this.output = ouput;
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/UIKeyStore.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/UIKeyStore.java
index e91e250..7889f06 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/UIKeyStore.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/UIKeyStore.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.util;
@@ -260,7 +260,7 @@
private static String getLocalAdminTrustStorePath()
{
String instancePath =
- Utils.getInstancePathFromClasspath(Utils.getInstallPathFromClasspath());
+ Utils.getInstancePathFromInstallPath(Utils.getInstallPathFromClasspath());
return instancePath + File.separator + "config" +
File.separator + "admin-truststore";
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/URLWorker.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/URLWorker.java
index 2b81459..209d655 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/URLWorker.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/URLWorker.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.quicksetup.util;
@@ -46,7 +46,7 @@
* QuickSetupStepPanel passed in the constructor.
*
*/
-public class URLWorker extends BackgroundTask
+public class URLWorker extends BackgroundTask<Object>
{
private QuickSetupStepPanel panel;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index efa8c20..0e48c73 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -968,8 +968,7 @@
// should use xcalcs but it does not come in the windows default install...
// :-(
// This method is not called for the moment, but the code works, so that is
- // why
- // is kept.
+ // why is kept.
private static int changePermissionsWindows(String path, String unixPerm)
throws IOException, InterruptedException
{
@@ -1315,7 +1314,7 @@
* @param installPath The installation path
* @return the path of the installation of the directory server.
*/
- public static String getInstancePathFromClasspath(String installPath)
+ public static String getInstancePathFromInstallPath(String installPath)
{
String instancePathFileName = Installation.INSTANCE_LOCATION_PATH;
File configureScriptPath = new File(installPath + File.separator +
@@ -2230,7 +2229,7 @@
{
builder.append(formatter.getSpace());
builder.append(formatter.getFormattedProgress(Message.raw(
- escapeValue(s))));
+ escapeCommandLineValue(s))));
}
}
return builder.toString();
@@ -2247,7 +2246,7 @@
* @param value the String to be treated.
* @return the transformed value.
*/
- private static String escapeValue(String value)
+ public static String escapeCommandLineValue(String value)
{
StringBuilder b = new StringBuilder();
if (Utils.isUnix())
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
index 33c49ed..673bacc 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.server.tools;
@@ -778,7 +778,7 @@
// Use this instead of Installation.getLocal() because making that call
// starts a new JVM and the command-line becomes less responsive.
String a = Utils.getInstallPathFromClasspath();
- String root = Utils.getInstancePathFromClasspath(a);
+ String root = Utils.getInstancePathFromInstallPath(a);
String configDir = Utils.getPath(root, Installation.CONFIG_PATH_RELATIVE);
return Utils.getPath(configDir, Installation.CURRENT_CONFIG_FILE_NAME);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
index 8afc9a5..553563c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2007-2008 Sun Microsystems, Inc.
+ * Copyright 2007-2010 Sun Microsystems, Inc.
*/
package org.opends.server.tools;
@@ -164,7 +164,7 @@
// Use this instead of Installation.getLocal() because making that call
// starts a new JVM and the command-line becomes less responsive.
String installPath = Utils.getInstallPathFromClasspath();
- String root = Utils.getInstancePathFromClasspath(installPath);
+ String root = Utils.getInstancePathFromInstallPath(installPath);
if (root != null)
{
String libDir = Utils.getPath(root, Installation.LIBRARIES_PATH_RELATIVE);
@@ -208,7 +208,7 @@
// Use this instead of Installation.getLocal() because making that call
// starts a new JVM and the command-line becomes less responsive.
String installPath = Utils.getInstallPathFromClasspath();
- String root = Utils.getInstancePathFromClasspath(installPath);
+ String root = Utils.getInstancePathFromInstallPath(installPath);
if (root != null)
{
String configDir = Utils.getPath(root, Installation.CONFIG_PATH_RELATIVE);
diff --git a/opendj-sdk/opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java b/opendj-sdk/opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java
index ee6aa25..bea22cd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/types/DirectoryEnvironmentConfig.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.server.types;
@@ -224,7 +224,7 @@
*/
public static File getInstanceRootFromServerRoot(File serverRoot)
{
- return new File(Utils.getInstancePathFromClasspath(
+ return new File(Utils.getInstancePathFromInstallPath(
serverRoot.getAbsolutePath()));
}
--
Gitblit v1.10.0