Class AbstractChannelExitRequestHandler<V>

Type Parameters:
V - Type of data being extracted from the request when processed
All Implemented Interfaces:
ChannelRequestHandler, RequestHandler<Channel>, NamedResource
Direct Known Subclasses:
ExitSignalChannelRequestHandler, ExitStatusChannelRequestHandler

public abstract class AbstractChannelExitRequestHandler<V> extends AbstractChannelRequestHandler implements NamedResource
Provides a common base class for channel request handlers that deal with various "exit-XXX" requests. Once such a request has been successfully processed, an EventNotifier can be invoked indicating the processed event.
  • Field Details

  • Constructor Details

    • AbstractChannelExitRequestHandler

      protected AbstractChannelExitRequestHandler(AtomicReference<V> holder, EventNotifier<? super String> notifier)
      Parameters:
      holder - An AtomicReference that will hold the extracted request data
      notifier - An EventNotifier to be invoked when request is successfully processed and the holder has been updated with the processed request data
  • Method Details

    • process

      public RequestHandler.Result process(Channel channel, String request, boolean wantReply, Buffer buffer) throws Exception
      Description copied from interface: RequestHandler
      Process an SSH request. If an exception is thrown, the ConnectionService will send a failure message if needed and the request will be considered handled.
      Specified by:
      process in interface ChannelRequestHandler
      Specified by:
      process in interface RequestHandler<V>
      Parameters:
      channel - The input parameter
      request - The request string
      wantReply - Whether a reply is requested
      buffer - The Buffer with request specific data
      Returns:
      The RequestHandler.Result
      Throws:
      Exception - If failed to handle the request - Note: in order to signal an unsupported request the RequestHandler.Result.Unsupported value should be returned
    • processRequestValue

      protected abstract V processRequestValue(Channel channel, String request, Buffer buffer) throws Exception
      Invoked by default from process(Channel, String, boolean, Buffer) when a request matching the handler's name is received
      Parameters:
      channel - The Channel through which the request was received
      request - The received request - Note: guaranteed to match the handler's name if invoked from process(Channel, String, boolean, Buffer)
      buffer - The received Buffer for extracting the data
      Returns:
      The extracted data - if null then request is ignored and Unsupported is returned
      Throws:
      Exception - If failed to process the received request buffer
    • notifyStateChanged

      protected void notifyStateChanged(Channel channel, String request, V value)
      Notifies that some change has been made to the data in the holder. The reported event is obtained via the getEvent(Channel, String, Object) call
      Parameters:
      channel - The Channel through which the request was received
      request - The processed request
      value - The processed value
    • getEvent

      protected String getEvent(Channel channel, String request, V value)
      Parameters:
      channel - The Channel through which the request was received
      request - The processed request
      value - The processed value
      Returns:
      The event name to be used - default: NamedResource.getName() value