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, anEventNotifiercan 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>holderprotected 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 protectedAbstractChannelExitRequestHandler(AtomicReference<V> holder, EventNotifier<? super String> notifier)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringgetEvent(Channel channel, String request, V value)protected voidnotifyStateChanged(Channel channel, String request, V value)Notifies that some change has been made to the data in the holder.RequestHandler.Resultprocess(Channel channel, String request, boolean wantReply, Buffer buffer)Process an SSH request.protected abstract VprocessRequestValue(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- AnAtomicReferencethat will hold the extracted request datanotifier- AnEventNotifierto 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:RequestHandlerProcess 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:
processin interfaceChannelRequestHandler- Specified by:
processin interfaceRequestHandler<V>- Parameters:
channel- The input parameterrequest- The request stringwantReply- Whether a reply is requestedbuffer- TheBufferwith 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.Unsupportedvalue 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- TheChannelthrough 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 receivedBufferfor extracting the data- Returns:
- The extracted data - if
nullthen request is ignored andUnsupportedis 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- TheChannelthrough which the request was receivedrequest- The processed requestvalue- The processed value
-
-