Top Description Inners Fields Constructors Methods
org.apache.sshd.common.future

public Class GlobalRequestFuture

extends DefaultSshFuture<GlobalRequestFuture>
implements HasException, SshFutureListener<IoWriteFuture>
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.future.SshFutureListener, org.apache.sshd.common.util.SshdEventListener, java.util.EventListener, org.apache.sshd.common.future.HasException
Imports
org.apache.sshd.common.SshConstants, .SshException, org.apache.sshd.common.io.IoWriteFuture, org.apache.sshd.common.util.buffer.Buffer

A DefaultSshFuture that can be used to wait for the reply of an SSH_MSG_GLOBAL_REQUEST sent with want-reply = true.
See Also
org.apache.sshd.common.session.Session#request(Buffer, String, ReplyHandler)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
GlobalRequestFuture.ReplyHandler

A ReplyHandler is invoked asynchronously when the reply for a request with want-reply = true is received.

Field Summary

Modifier and TypeField and Description
private final GlobalRequestFuture.ReplyHandler
private long

Constructor Summary

AccessConstructor and Description
public
GlobalRequestFuture(String
the request identifier
request
)

Creates a new GlobalRequestFuture for a global request.

public
GlobalRequestFuture(String
the request identifier
request
,
GlobalRequestFuture.ReplyHandler
the ReplyHandler, or null
handler
)

Creates a new GlobalRequestFuture for a global request.

Method Summary

Modifier and TypeMethod and Description
public Buffer

Returns:

the Buffer, or null if the request was not successful or the reply was not received yet
getBuffer
()

Obtains the reply Buffer if the request was successful.

public Throwable

Returns:

a failure reason, or null if there isn't one or if the request did not fail
getException
()

Implements org.apache.sshd.common.future.HasException.getException.

Retrieves an exception if the request failed.

public GlobalRequestFuture.ReplyHandler

Returns:

the handler, or null if none was set
getHandler
()

Retrieves the ReplyHandler of this future, if any.

public String
public long

Returns:

the sequence number
getSequenceNumber
()

Retrieves this future's packet sequence number.

public void
operationComplete(IoWriteFuture
The source SshFuture which called this callback.
future
)

Implements org.apache.sshd.common.future.SshFutureListener.operationComplete.

Invoked when the operation associated with the SshFuture has been completed even if you add the listener after the completion.

public void
setSequenceNumber(long
the packet sequence number
number
)

Sets the packet sequence number of the global request represented by this future.

public String
toString()

Overrides org.apache.sshd.common.future.DefaultSshFuture.toString.

Returns a string representation of the object.

Inherited from org.apache.sshd.common.future.DefaultSshFuture:
addListenerawait0createCancellationgetNumRegisteredListenersgetValueisDonenotifyListenersonValueSetremoveListenersetValue

Field Detail

handlerback to summary
private final GlobalRequestFuture.ReplyHandler handler
sequenceNumberback to summary
private long sequenceNumber

Constructor Detail

GlobalRequestFutureback to summary
public GlobalRequestFuture(String request)

Creates a new GlobalRequestFuture for a global request. Synchronization occurs on the future itself. The future will be fulfilled once the reply has been received or an error occurred.

Parameters
request:String

the request identifier

GlobalRequestFutureback to summary
public GlobalRequestFuture(String request, GlobalRequestFuture.ReplyHandler handler)

Creates a new GlobalRequestFuture for a global request. Synchronization occurs on the future itself. The future will be fulfilled once the request has been sent, or an error occurred during sending. The framework will invoke the handler once the reply has been received. For global requests with want-reply = false, the handler will be invoked with an empty buffer if the request was successfully sent.

Parameters
request:String

the request identifier

handler:GlobalRequestFuture.ReplyHandler

the ReplyHandler, or null

Method Detail

getBufferback to summary
public Buffer getBuffer()

Obtains the reply Buffer if the request was successful. If called after isDone() is true, a non-null result means the request was successful.

Returns:Buffer

the Buffer, or null if the request was not successful or the reply was not received yet

getExceptionback to summary
public Throwable getException()

Implements org.apache.sshd.common.future.HasException.getException.

Retrieves an exception if the request failed. If called after isDone() is true, a null result means the request did not fail.

Returns:Throwable

a failure reason, or null if there isn't one or if the request did not fail

Annotations
@Override
getHandlerback to summary
public GlobalRequestFuture.ReplyHandler getHandler()

Retrieves the ReplyHandler of this future, if any.

Returns:GlobalRequestFuture.ReplyHandler

the handler, or null if none was set

getIdback to summary
public String getId()

Overrides org.apache.sshd.common.future.AbstractSshFuture.getId.

Implements org.apache.sshd.common.future.WaitableFuture.getId.

Returns:String

Doc from org.apache.sshd.common.future.WaitableFuture.getId.

Some identifier useful as toString() value

Annotations
@Override
getSequenceNumberback to summary
public long getSequenceNumber()

Retrieves this future's packet sequence number.

Returns:long

the sequence number

operationCompleteback to summary
public void operationComplete(IoWriteFuture future)

Implements org.apache.sshd.common.future.SshFutureListener.operationComplete.

Doc from org.apache.sshd.common.future.SshFutureListener.operationComplete.

Invoked when the operation associated with the SshFuture has been completed even if you add the listener after the completion.

Parameters
future:IoWriteFuture

The source SshFuture which called this callback.

Annotations
@Override
setSequenceNumberback to summary
public void setSequenceNumber(long number)

Sets the packet sequence number of the global request represented by this future.

Parameters
number:long

the packet sequence number

Exceptions
IllegalArgumentException:
if the number given is not an unsigned 32bit value
toStringback to summary
public String toString()

Overrides org.apache.sshd.common.future.DefaultSshFuture.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.apache.sshd.common.future back to summary

public Interface GlobalRequestFuture.ReplyHandler

Annotations
@FunctionalInterface

A ReplyHandler is invoked asynchronously when the reply for a request with want-reply = true is received. It is not invoked if the request could not be sent; to catch such cases DefaultSshFuture#await(CancelOption[]) the GlobalRequestFuture and check GlobalRequestFuture#getException().

Method Summary

Modifier and TypeMethod and Description
public void
accept(int cmd, Buffer
the Buffer received
buffer
)

Invoked by the framework upon reception of the reply.

Method Detail

acceptback to summary
public void accept(int cmd, Buffer buffer)

Invoked by the framework upon reception of the reply. If the global request was sent with want-reply = false, it is invoked with SshConstants#SSH_MSG_REQUEST_SUCCESS and an empty buffer after the request was successfully sent.

Parameters
cmd:int

the command received, can be one of SshConstants#SSH_MSG_REQUEST_SUCCESS, SshConstants#SSH_MSG_UNIMPLEMENTED, or SshConstants#SSH_MSG_REQUEST_FAILURE

buffer:Buffer

the Buffer received