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, anEventNotifier
can be invoked indicating the processed event.- Author:
- Apache MINA SSHD Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.channel.RequestHandler
RequestHandler.Result
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicReference<V>
holder
protected EventNotifier<? super String>
notifier
-
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
Constructors Modifier Constructor Description protected
AbstractChannelExitRequestHandler(AtomicReference<V> holder, EventNotifier<? super String> notifier)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
getEvent(Channel channel, String request, V value)
protected void
notifyStateChanged(Channel channel, String request, V value)
Notifies that some change has been made to the data in the holder.RequestHandler.Result
process(Channel channel, String request, boolean wantReply, Buffer buffer)
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 received-
Methods 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 Detail
-
holder
protected final AtomicReference<V> holder
-
notifier
protected final EventNotifier<? super String> notifier
-
-
Constructor Detail
-
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 Detail
-
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
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 thegetEvent(Channel, String, Object)
call- Parameters:
channel
- TheChannel
through which the request was receivedrequest
- The processed requestvalue
- The processed value
-
-