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
logFields inherited from interface org.apache.sshd.common.channel.ChannelRequestHandler
CHANN2HNDLRFields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractChannelExitRequestHandler(AtomicReference<V> holder, EventNotifier<? super String> notifier) -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringprotected voidnotifyStateChanged(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 VprocessRequestValue(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, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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- 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 Details
-
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
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
-
getEvent
- Parameters:
channel- TheChannelthrough which the request was receivedrequest- The processed requestvalue- The processed value- Returns:
- The event name to be used - default:
NamedResource.getName()value
-