Class AbstractChannelExitRequestHandler<V>

    • Field Detail

      • holder

        protected final java.util.concurrent.atomic.AtomicReference<V> holder
      • notifier

        protected final EventNotifier<? super java.lang.String> notifier
    • Constructor Detail

      • AbstractChannelExitRequestHandler

        protected AbstractChannelExitRequestHandler​(java.util.concurrent.atomic.AtomicReference<V> holder,
                                                    EventNotifier<? super java.lang.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 Detail

      • process

        public RequestHandler.Result process​(Channel channel,
                                             java.lang.String request,
                                             boolean wantReply,
                                             Buffer buffer)
                                      throws java.lang.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:
        java.lang.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,
                                                 java.lang.String request,
                                                 Buffer buffer)
                                          throws java.lang.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:
        java.lang.Exception - If failed to process the received request buffer
      • notifyStateChanged

        protected void notifyStateChanged​(Channel channel,
                                          java.lang.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 java.lang.String getEvent​(Channel channel,
                                            java.lang.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