Class AbstractChannelExitRequestHandler<V>
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.channel.AbstractRequestHandler<Channel>
org.apache.sshd.common.channel.AbstractChannelRequestHandler
org.apache.sshd.client.channel.exit.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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.sshd.common.channel.RequestHandler
RequestHandler.Result
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicReference<V>
protected final EventNotifier<? super String>
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
Fields inherited from interface org.apache.sshd.common.channel.ChannelRequestHandler
CHANN2HNDLR
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractChannelExitRequestHandler
(AtomicReference<V> holder, EventNotifier<? super String> notifier) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected void
notifyStateChanged
(Channel channel, String request, V value) Notifies that some change has been made to the data in the holder.Process an SSH request.protected abstract V
processRequestValue
(Channel channel, String request, Buffer buffer) Invoked by default fromprocess(Channel, String, boolean, Buffer)
when a request matching the handler's name is receivedMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.sshd.common.NamedResource
getName
-
Field Details
-
holder
-
notifier
-
-
Constructor Details
-
AbstractChannelExitRequestHandler
protected AbstractChannelExitRequestHandler(AtomicReference<V> holder, EventNotifier<? super String> notifier) - Parameters:
holder
- AnAtomicReference
that will hold the extracted request datanotifier
- AnEventNotifier
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 interfaceChannelRequestHandler
- Specified by:
process
in interfaceRequestHandler<V>
- Parameters:
channel
- The input parameterrequest
- The request stringwantReply
- Whether a reply is requestedbuffer
- TheBuffer
with request specific data- Returns:
- The
RequestHandler.Result
- Throws:
Exception
- If failed to handle the request - Note: in order to signal an unsupported request theRequestHandler.Result.Unsupported
value should be returned
-
processRequestValue
protected abstract V processRequestValue(Channel channel, String request, Buffer buffer) throws Exception Invoked by default fromprocess(Channel, String, boolean, Buffer)
when a request matching the handler's name is received- Parameters:
channel
- TheChannel
through which the request was receivedrequest
- The received request - Note: guaranteed to match the handler's name if invoked fromprocess(Channel, String, boolean, Buffer)
buffer
- The receivedBuffer
for extracting the data- Returns:
- The extracted data - if
null
then request is ignored andUnsupported
is returned - Throws:
Exception
- If failed to process the received request buffer
-
notifyStateChanged
Notifies that some change has been made to the data in the holder. The reported event is obtained via thegetEvent(Channel, String, Object)
call- Parameters:
channel
- TheChannel
through which the request was receivedrequest
- The processed requestvalue
- The processed value
-
getEvent
- Parameters:
channel
- TheChannel
through which the request was receivedrequest
- The processed requestvalue
- The processed value- Returns:
- The event name to be used - default:
NamedResource.getName()
value
-