Class ConfigureWindowsService
- All Implemented Interfaces:
Closeable
,AutoCloseable
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Return codes for the method disableService.static enum
Return codes for the method enableService.static enum
Return codes for the method stopService.Nested classes/interfaces inherited from class com.forgerock.opendj.cli.Tool
com.forgerock.opendj.cli.Tool.Style
-
Constructor Summary
ConstructorDescriptionConfigureWindowsService
(OutputStream out, OutputStream err) Creates a newConfigureWindowsService
with provided streams to log commands output. -
Method Summary
Modifier and TypeMethodDescriptioncleanupService
(String serviceName) Cleans up a service for a given service name.Disables OpenDJ to run as a windows service.Enables OpenDJ to run as a windows service.static boolean
Returnstrue
if the running server runs as a windows service.static void
Configures the Windows service for this instance on this machine.com.forgerock.opendj.cli.ReturnCode
Configures the Windows service for this instance on this machine.Checks if OpenDJ is enabled as a windows service and if it is write the serviceName in the output stream (if it is not null).Invokes the net start on the service corresponding to this server, it writes information and error messages in the provided streams.Invokes the net stop on the service corresponding to this server, it writes information and error messages in the provided streams.Methods inherited from class com.forgerock.opendj.cli.Tool
askPort, close, confirmAction, enableConsoleLoggingIfVerbose, errPrintln, errPrintln, errPrintln, errPrintlnSurroundedByBlankLines, errPrintVerboseMessage, flush, flushLogStream, getErrorStream, getErrStream, getInputStream, getOutputStream, isFullyInteractive, isQuiet, isScriptFriendly, isVerbose, logVerboseMessage, mayPrompt, parseArguments, pressReturnToContinue, print, println, println, println, printlnNoWrap, printlnSurroundedByBlankLines, printNoWrap, readInput, readInput, readInputAllowEmpty, readLineOfInput, readPassword, readValidatedInput, readValidatedInputOrThrow, report
-
Constructor Details
-
ConfigureWindowsService
Creates a newConfigureWindowsService
with provided streams to log commands output.- Parameters:
out
- The stream to use to log command information messageserr
- The stream to use to log command error messages
-
-
Method Details
-
main
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.
-
isRunningAsWindowsService
public static boolean isRunningAsWindowsService()Returnstrue
if the running server runs as a windows service.- Returns:
true
if the running server runs as a windows service
-
run
public com.forgerock.opendj.cli.ReturnCode run(String... args) throws com.forgerock.opendj.cli.ClientException 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.- Overrides:
run
in classcom.forgerock.opendj.cli.Tool
- Parameters:
args
- The command-line arguments provided to this program.- Returns:
- the integer code describing if the operation could be completed or not.
- Throws:
com.forgerock.opendj.cli.ClientException
- If an error occurs while running the tool.
-
enableService
Enables OpenDJ to run as a windows service.- Returns:
SERVICE_ENABLE_SUCCESS
,SERVICE_ENABLE_ERROR
,SERVICE_NAME_ALREADY_IN_USE
orSERVICE_ALREADY_ENABLED
depending on whether the service could be enabled or not.
-
disableService
Disables OpenDJ to run as a windows service.- Returns:
SERVICE_DISABLE_SUCCESS
,SERVICE_DISABLE_ERROR
,SERVICE_MARKED_FOR_DELETION
orSERVICE_ALREADY_DISABLED
depending on whether the service could be disabled or not.
-
cleanupService
public org.opends.server.tools.ConfigureWindowsService.CleanupServiceReturnCode cleanupService(String serviceName) Cleans up a service for a given service name.- Parameters:
serviceName
- the service name to be cleaned up.- Returns:
SERVICE_CLEANUP_SUCCESS
,SERVICE_NOT_FOUND
,SERVICE_MARKED_FOR_DELETION
orSERVICE_CLEANUP_ERROR
depending on whether the service could be found or not.
-
serviceState
Checks if OpenDJ is enabled as a windows service and if it is write the serviceName in the output stream (if it is not null).- Returns:
SERVICE_STATE_ENABLED
,SERVICE_STATE_DISABLED
orSERVICE_STATE_ERROR
depending on the state of the service.
-
startService
Invokes the net start on the service corresponding to this server, it writes information and error messages in the provided streams.- Returns:
SERVICE_START_SUCCESSFUL
,SERVICE_NOT_FOUND
,SERVICE_ALREADY_STARTED
orSERVICE_START_ERROR
depending on whether the service could be stopped or not.
-
stopService
Invokes the net stop on the service corresponding to this server, it writes information and error messages in the provided streams.- Returns:
SERVICE_STOP_SUCCESSFUL
,SERVICE_NOT_FOUND
orSERVICE_STOP_ERROR
depending on whether the service could be stopped or not.
-