org.opends.server.tools
Class ConfigureWindowsService

java.lang.Object
  extended by org.opends.server.tools.ConfigureWindowsService

public class ConfigureWindowsService
extends java.lang.Object

This class is used to configure the Windows service for this instance on this machine. This tool allows to enable and disable OpenDS to run as a Windows service and allows to know if OpenDS 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 Summary
static java.lang.String LAUNCHER_OPTION
          Option to be used when calling the launchers.
static int SERVICE_ALREADY_DISABLED
          The service was already disabled.
static int SERVICE_ALREADY_ENABLED
          The service was already enabled.
static int SERVICE_CLEANUP_ERROR
          An error occurred cleaning up the service.
static int SERVICE_CLEANUP_MARKED_FOR_DELETION
          The service is marked for deletion.
static int SERVICE_CLEANUP_SUCCESS
          The service cleanup worked.
static int SERVICE_DISABLE_ERROR
          An error occurred disabling the service.
static int SERVICE_DISABLE_SUCCESS
          The service was successfully disabled.
static int SERVICE_ENABLE_ERROR
          An error occurred enabling the service.
static int SERVICE_ENABLE_SUCCESS
          The service was successfully enabled.
static int SERVICE_MARKED_FOR_DELETION
          The service is marked for deletion.
static int SERVICE_NAME_ALREADY_IN_USE
          The service name was already in use.
static int SERVICE_NOT_FOUND
          The service could not be found.
static int SERVICE_STATE_DISABLED
          The service is disabled.
static int SERVICE_STATE_ENABLED
          The service is enabled.
static int SERVICE_STATE_ERROR
          An error occurred checking the service state.
 
Constructor Summary
ConfigureWindowsService()
           
 
Method Summary
static int cleanupService(java.lang.String serviceName, java.io.PrintStream out, java.io.PrintStream err)
          Cleans up a service for a given service name.
static int configureWindowsService(java.lang.String[] args, java.io.OutputStream outStream, java.io.OutputStream errStream)
          Configures the Windows service for this instance on this machine.
static int disableService(java.io.PrintStream out, java.io.PrintStream err)
          Disables OpenDS to run as a windows service.
static int enableService(java.io.PrintStream out, java.io.PrintStream err)
          Enables OpenDS to run as a windows service.
static java.lang.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.
static java.lang.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.
static void main(java.lang.String[] args)
          Configures the Windows service for this instance on this machine.
static int serviceState(java.io.PrintStream out, java.io.PrintStream err)
          Checks if OpenDS is enabled as a windows service and if it is write the serviceName in the output stream (if it is not null).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAUNCHER_OPTION

public static final java.lang.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_NAME_ALREADY_IN_USE

public static final int SERVICE_NAME_ALREADY_IN_USE
The service name was already in use.

See Also:
Constant Field Values

SERVICE_ENABLE_ERROR

public static final int SERVICE_ENABLE_ERROR
An error occurred enabling the service.

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_MARKED_FOR_DELETION

public static final int SERVICE_MARKED_FOR_DELETION
The service is marked for deletion.

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

SERVICE_STATE_DISABLED

public static final int SERVICE_STATE_DISABLED
The service is disabled.

See Also:
Constant Field Values

SERVICE_STATE_ERROR

public static final int SERVICE_STATE_ERROR
An error occurred checking the service state.

See Also:
Constant Field Values

SERVICE_CLEANUP_SUCCESS

public static final int SERVICE_CLEANUP_SUCCESS
The service cleanup worked.

See Also:
Constant Field Values

SERVICE_NOT_FOUND

public static final int SERVICE_NOT_FOUND
The service could not be found.

See Also:
Constant Field Values

SERVICE_CLEANUP_ERROR

public static final int SERVICE_CLEANUP_ERROR
An error occurred cleaning up the service.

See Also:
Constant Field Values

SERVICE_CLEANUP_MARKED_FOR_DELETION

public static final int SERVICE_CLEANUP_MARKED_FOR_DELETION
The service is marked for deletion.

See Also:
Constant Field Values
Constructor Detail

ConfigureWindowsService

public ConfigureWindowsService()
Method Detail

main

public static void main(java.lang.String[] args)
Configures the Windows service for this instance on this machine. This tool allows to enable and disable OpenDS to run as a Windows service and allows to know if OpenDS is running as a Windows service or not.

Parameters:
args - The command-line arguments provided to this program.

configureWindowsService

public static int configureWindowsService(java.lang.String[] args,
                                          java.io.OutputStream outStream,
                                          java.io.OutputStream errStream)
Configures the Windows service for this instance on this machine. This tool allows to enable and disable OpenDS to run as a Windows service and allows to know if OpenDS is running as a Windows service or not.

Parameters:
args - The command-line arguments provided to this program.
outStream - the stream used to write the standard output.
errStream - the stream used to write the error output.
Returns:
the integer code describing if the operation could be completed or not.

enableService

public static int enableService(java.io.PrintStream out,
                                java.io.PrintStream err)
Enables OpenDS 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(java.io.PrintStream out,
                                 java.io.PrintStream err)
Disables OpenDS 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.

cleanupService

public static int cleanupService(java.lang.String serviceName,
                                 java.io.PrintStream out,
                                 java.io.PrintStream err)
Cleans up a service for a given service name.

Parameters:
serviceName - the service name to be cleaned up.
out - the stream used to write the standard output.
err - the stream used to write the error output.
Returns:
SERVICE_CLEANUP_SUCCESS, SERVICE_NOT_FOUND, SERVICE_MARKED_FOR_DELETION or SERVICE_CLEANUP_ERROR depending on whether the service could be found or not.

serviceState

public static int serviceState(java.io.PrintStream out,
                               java.io.PrintStream err)
Checks if OpenDS is enabled as a windows service and if it is write the serviceName in the output stream (if it is not null).

Parameters:
out - the stream used to write the standard output.
err - the stream used to write the error output.
Returns:
SERVICE_STATE_ENABLED, SERVICE_STATE_DISABLED or SERVICE_STATE_ERROR depending on the state of the service.

getLauncherAdministratorBinaryFullPath

public static java.lang.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 java.lang.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.