public final class ConfigureWindowsService
extends com.forgerock.opendj.cli.Tool
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.
Modifier and Type | Class and Description |
---|---|
static class |
ConfigureWindowsService.CleanupServiceReturnCode
Return codes for the method cleanupService.
|
static class |
ConfigureWindowsService.DisableServiceReturnCode
Return codes for the method disableService.
|
static class |
ConfigureWindowsService.EnableServiceReturnCode
Return codes for the method enableService.
|
static class |
ConfigureWindowsService.ServiceStateReturnCode
Return codes for the method serviceState.
|
static class |
ConfigureWindowsService.StartServiceReturnCode
Return codes for the method startService.
|
static class |
ConfigureWindowsService.StopServiceReturnCode
Return codes for the method stopService.
|
Constructor and Description |
---|
ConfigureWindowsService(OutputStream out,
OutputStream err)
Creates a new
ConfigureWindowsService with provided streams to log commands output. |
Modifier and Type | Method and Description |
---|---|
ConfigureWindowsService.CleanupServiceReturnCode |
cleanupService(String serviceName)
Cleans up a service for a given service name.
|
ConfigureWindowsService.DisableServiceReturnCode |
disableService()
Disables OpenDJ to run as a windows service.
|
ConfigureWindowsService.EnableServiceReturnCode |
enableService()
Enables OpenDJ to run as a windows service.
|
static boolean |
isRunningAsWindowsService()
Returns
true if the running server runs as a windows service. |
static void |
main(String[] args)
Configures the Windows service for this instance on this machine.
|
com.forgerock.opendj.cli.ReturnCode |
run(String... args)
Configures the Windows service for this instance on this machine.
|
ConfigureWindowsService.ServiceStateReturnCode |
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).
|
ConfigureWindowsService.StartServiceReturnCode |
startService()
Invokes the net start on the service corresponding to this server, it writes information and error messages in
the provided streams.
|
ConfigureWindowsService.StopServiceReturnCode |
stopService()
Invokes the net stop on the service corresponding to this server, it writes information and error messages in the
provided streams.
|
askConfirmation, 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, println, printlnNoWrap, printlnSurroundedByBlankLines, printNoWrap, readInput, readInput, readInputAllowEmpty, readLineOfInput, readPassword, readPassword, readValidatedInput, readValidatedInput, report
public ConfigureWindowsService(OutputStream out, OutputStream err)
ConfigureWindowsService
with provided streams to log commands output.out
- The stream to use to log command information messageserr
- The stream to use to log command error messagespublic static void main(String[] args)
args
- The command-line arguments provided to this program.public static boolean isRunningAsWindowsService()
true
if the running server runs as a windows service.true
if the running server runs as a windows servicepublic com.forgerock.opendj.cli.ReturnCode run(String... args) throws com.forgerock.opendj.cli.ClientException
run
in class com.forgerock.opendj.cli.Tool
args
- The command-line arguments provided to this program.com.forgerock.opendj.cli.ClientException
- If an error occurs while running the tool.public ConfigureWindowsService.EnableServiceReturnCode enableService()
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.public ConfigureWindowsService.DisableServiceReturnCode disableService()
SERVICE_DISABLE_SUCCESS
, SERVICE_DISABLE_ERROR
,
SERVICE_MARKED_FOR_DELETION
or SERVICE_ALREADY_DISABLED
depending on whether
the service could be disabled or not.public ConfigureWindowsService.CleanupServiceReturnCode cleanupService(String serviceName)
serviceName
- the service name to be cleaned up.SERVICE_CLEANUP_SUCCESS
, SERVICE_NOT_FOUND
,
SERVICE_MARKED_FOR_DELETION
or SERVICE_CLEANUP_ERROR
depending on whether the
service could be found or not.public ConfigureWindowsService.ServiceStateReturnCode serviceState()
SERVICE_STATE_ENABLED
, SERVICE_STATE_DISABLED
or
SERVICE_STATE_ERROR
depending on the state of the service.public ConfigureWindowsService.StartServiceReturnCode startService()
SERVICE_START_SUCCESSFUL
, SERVICE_NOT_FOUND
,
SERVICE_ALREADY_STARTED
or SERVICE_START_ERROR
depending on whether the service
could be stopped or not.public ConfigureWindowsService.StopServiceReturnCode stopService()
SERVICE_STOP_SUCCESSFUL
, SERVICE_NOT_FOUND
or SERVICE_STOP_ERROR
depending on whether the service could be stopped or not.Copyright 2010-2022 ForgeRock AS.