Class ConfigureWindowsService


  • public class ConfigureWindowsService
    extends Object
    This class is used to configure the Windows service for this instance on this machine. This tool allows to enable and disable OpenDJ to run as a Windows service and allows to know if OpenDJ is running as a Windows service or not. Some comments about Vista: In Vista, when we launch the subcommands that require administrator privileges (enable, disable and cleanup) we cannot use the administrator launcher binary directly from Java (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6410605) so we use winlauncher.exe. When we launch subcommands that required administrator privileges we must launch a binary containing the manifest that specifies that we require administrator privileges (requireAdministrator value): if UAC is enabled, the user will be asked for confirmation. To minimize the number of confirmation that the user must provide when launching the state subcommand we will use a binary whose manifest does not contain the requireAdministrator value. See the files under src/build-tools/windows for more details.
    • Field Detail

      • LAUNCHER_OPTION

        public static final String LAUNCHER_OPTION
        Option to be used when calling the launchers.
        See Also:
        Constant Field Values
      • SERVICE_ENABLE_SUCCESS

        public static final int SERVICE_ENABLE_SUCCESS
        The service was successfully enabled.
        See Also:
        Constant Field Values
      • SERVICE_ALREADY_ENABLED

        public static final int SERVICE_ALREADY_ENABLED
        The service was already enabled.
        See Also:
        Constant Field Values
      • SERVICE_DISABLE_SUCCESS

        public static final int SERVICE_DISABLE_SUCCESS
        The service was successfully disabled.
        See Also:
        Constant Field Values
      • SERVICE_ALREADY_DISABLED

        public static final int SERVICE_ALREADY_DISABLED
        The service was already disabled.
        See Also:
        Constant Field Values
      • SERVICE_DISABLE_ERROR

        public static final int SERVICE_DISABLE_ERROR
        An error occurred disabling the service.
        See Also:
        Constant Field Values
      • SERVICE_STATE_ENABLED

        public static final int SERVICE_STATE_ENABLED
        The service is enabled.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ConfigureWindowsService

        public ConfigureWindowsService()
    • Method Detail

      • main

        public static void main​(String[] args)
        Configures the Windows service for this instance on this machine. This tool allows to enable and disable OpenDJ to run as a Windows service and allows to know if OpenDJ is running as a Windows service or not.
        Parameters:
        args - The command-line arguments provided to this program.
      • enableService

        public static int enableService​(PrintStream out,
                                        PrintStream err)
        Enables OpenDJ to run as a windows service.
        Parameters:
        out - the stream used to write the standard output.
        err - the stream used to write the error output.
        Returns:
        SERVICE_ENABLE_SUCCESS, SERVICE_ENABLE_ERROR, SERVICE_NAME_ALREADY_IN_USE or SERVICE_ALREADY_ENABLED depending on whether the service could be enabled or not.
      • disableService

        public static int disableService​(PrintStream out,
                                         PrintStream err)
        Disables OpenDJ to run as a windows service.
        Parameters:
        out - the stream used to write the standard output.
        err - the stream used to write the error output.
        Returns:
        SERVICE_DISABLE_SUCCESS, SERVICE_DISABLE_ERROR, SERVICE_MARKED_FOR_DELETION or SERVICE_ALREADY_DISABLED depending on whether the service could be disabled or not.
      • serviceState

        public static int serviceState()
        Checks if OpenDJ is enabled as a windows service.
        Returns:
        SERVICE_STATE_ENABLED, SERVICE_STATE_DISABLED or SERVICE_STATE_ERROR depending on the state of the service.
      • getLauncherAdministratorBinaryFullPath

        public static String getLauncherAdministratorBinaryFullPath()
        Returns the full path of the executable that has a manifest requiring administrator privileges used by this class to perform operations related to the service.
        Returns:
        the full path of the executable that has a manifest requiring administrator privileges used by this class to perform operations related to the service.
      • getLauncherBinaryFullPath

        public static String getLauncherBinaryFullPath()
        Returns the full path of the executable that has a manifest requiring administrator privileges used by this class to perform operations related to the service.
        Returns:
        the full path of the executable that has a manifest requiring administrator privileges used by this class to perform operations related to the service.