Save This Page
Home » » » [javadoc | source]
class: ControlListener [javadoc | source]

All Implemented Interfaces:

The ControlListener class is a helper class for the Main 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 &endash; localhost:63000 by default &endash; 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.
Field Summary
static final  String COMMAND_STOP     
static final  String COMMAND_STATUS     
 ControlListener(Main slingMain,
    String listenSpec) 
    Creates an instance of this control support class.

    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:63000. If the host name is missing it defaults to localhost.

    slingMain - 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.
Method from Summary:
listen,   run,   shutdownServer,   statusServer
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from Detail:
  void listen() 
    Implements the server side of the control connection starting a thread listening on the host and port configured on setup of this instance.
 public  void run() 
    Implements the server thread receiving commands from clients and acting upon them.
  void shutdownServer() 
    Implements the client side of the control connection sending the command to shutdown Sling.
  void statusServer() 
    Implements the client side of the control connection sending the command to check whether Sling is active.