public class ControlListener extends Object implements Runnable
ControlListener
class is a helper class for the ControlTarget
class to support in Sling standalone application process communication. This
class implements the client and server sides of a TCP/IP based communication
channel to control a running Sling application.
The server side listens for commands on a configurable host and port
localhost:63000
by default supporting the following
commands:
Command | Description |
---|---|
status |
Request status information. Currently only OK is sent back. If no connection can be created to the server the client assumes Sling is not running. |
stop |
Requests Sling to shutdown. |
Constructor and Description |
---|
ControlListener(ControlTarget controlTarget,
String listenSpec)
Creates an instance of this control support class.
|
Modifier and Type | Method and Description |
---|---|
int |
dumpThreads()
Implements the client side of the control connection sending the command
to retrieve a thread dump.
|
boolean |
listen()
Implements the server side of the control connection starting a thread
listening on the host and port configured on setup of this instance.
|
void |
run()
Implements the server thread receiving commands from clients and acting
upon them.
|
int |
shutdownServer()
Implements the client side of the control connection sending the command
to shutdown Sling.
|
int |
statusServer()
Implements the client side of the control connection sending the command
to check whether Sling is active.
|
public ControlListener(ControlTarget controlTarget, String listenSpec)
The host (name or address) and port number of the socket is defined by
the listenSpec
parameter. This parameter is defined as
[ host ":" ] port
. If the parameter is empty or
null
it defaults to localhost:0. If the host name
is missing it defaults to localhost.
controlTarget
- The Main class reference. This is only required if this
instance is used for the server side to listen for remote stop
commands. Otherwise this argument may be null
.listenSpec
- The specification for the host and port for the socket
connection. See above for the format of this parameter.public boolean listen()
public int shutdownServer()
public int statusServer()
public int dumpThreads()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.