Class AbstractChannel
java.lang.Object
net.schmizz.sshj.connection.channel.AbstractChannel
- All Implemented Interfaces:
Closeable, AutoCloseable, ErrorNotifiable, SSHPacketHandler, Channel
- Direct Known Subclasses:
AbstractDirectChannel, AbstractForwardedChannel
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface Channel
Channel.Direct, Channel.ForwardedNested classes/interfaces inherited from interface ErrorNotifiable
ErrorNotifiable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final Queue<Event<ConnectionException>> protected final Event<ConnectionException> Channel close eventprivate booleanWhether we have already sent a CHANNEL_CLOSE request to the serverprotected final ConnectionConnection layerprivate booleanprivate final intChannel IDprivate final ChannelInputStreamstdout streamprotected final org.slf4j.Loggerprotected final LoggerFactoryLoggerprotected final Window.LocalLocal windowprivate final ReentrantLockprotected final Event<ConnectionException> Channel open eventprivate ChannelOutputStreamstdin streamprivate intRemote recipient IDprivate static final intprivate final CharsetRemote character setprotected Window.RemoteRemote windowprotected final TransportTransport layerprivate final StringChannel type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractChannel(Connection conn, String type) protectedAbstractChannel(Connection conn, String type, Charset remoteCharset) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this channel.protected voidCalled when all I/O streams should be closed.protected voidCalled when EOF has been received.protected voidbooleanintgetID()intlongGet the LoggerFactory associated with the SSH client.intintlonggetType()private voidprivate voidgotClose()private voidgotEOF()protected voidgotExtendedData(SSHPacket buf) private voidgotResponse(boolean success) protected voidgotUnknown(Message msg, SSHPacket buf) private voidvoidDelegate handling of some SSH packet to this object.protected voidhandleRequest(String reqType, SSHPacket buf) protected voidinit(int recipient, long remoteWinSize, long remoteMaxPacketSize) booleanisEOF()Returns whether EOF has been received.booleanisOpen()voidjoin()voidprotected SSHPacketvoidnotifyError(SSHException error) Notifies this object of anerror.protected voidreceiveInto(ChannelInputStream stream, SSHPacket buf) protected Event<ConnectionException> sendChannelRequest(String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific) protected voidvoidsetAutoExpand(boolean autoExpand) Set whether local window should automatically expand when data is received, irrespective of whether data has been read from that stream.toString()(package private) booleanwhileOpen(AbstractChannel.TransportRunnable runnable)
-
Field Details
-
REMOTE_MAX_PACKET_SIZE_CEILING
private static final int REMOTE_MAX_PACKET_SIZE_CEILING- See Also:
-
loggerFactory
Logger -
log
protected final org.slf4j.Logger log -
trans
Transport layer -
conn
Connection layer -
type
Channel type -
id
private final int idChannel ID -
recipient
private int recipientRemote recipient ID -
remoteCharset
Remote character set -
eof
private boolean eof -
chanReqResponseEvents
-
openCloseLock
-
openEvent
Channel open event -
closeEvent
Channel close event -
closeRequested
private boolean closeRequestedWhether we have already sent a CHANNEL_CLOSE request to the server -
lwin
Local window -
in
stdout stream -
rwin
Remote window -
out
stdin stream -
autoExpand
private volatile boolean autoExpand
-
-
Constructor Details
-
AbstractChannel
-
AbstractChannel
-
-
Method Details
-
init
protected void init(int recipient, long remoteWinSize, long remoteMaxPacketSize) -
getAutoExpand
public boolean getAutoExpand()- Specified by:
getAutoExpandin interfaceChannel- Returns:
- whether auto-expansion of local window is set.
- See Also:
-
getID
-
getInputStream
- Specified by:
getInputStreamin interfaceChannel- Returns:
- the
InputStreamfor this channel.
-
getLocalMaxPacketSize
public int getLocalMaxPacketSize()- Specified by:
getLocalMaxPacketSizein interfaceChannel- Returns:
- the maximum packet size that we have specified.
-
getLocalWinSize
public long getLocalWinSize()- Specified by:
getLocalWinSizein interfaceChannel- Returns:
- the current local window size.
-
getOutputStream
- Specified by:
getOutputStreamin interfaceChannel- Returns:
- an
OutputStreamfor this channel.
-
getRecipient
public int getRecipient()- Specified by:
getRecipientin interfaceChannel- Returns:
- the channel ID at the remote end.
-
getRemoteCharset
- Specified by:
getRemoteCharsetin interfaceChannel- Returns:
- the character set used to communicate with the remote machine for certain strings (like paths).
-
getRemoteMaxPacketSize
public int getRemoteMaxPacketSize()- Specified by:
getRemoteMaxPacketSizein interfaceChannel- Returns:
- the maximum packet size as specified by the remote end.
-
getRemoteWinSize
public long getRemoteWinSize()- Specified by:
getRemoteWinSizein interfaceChannel- Returns:
- the current remote window size.
-
getType
-
handle
Description copied from interface:SSHPacketHandlerDelegate handling of some SSH packet to this object.- Specified by:
handlein interfaceSSHPacketHandler- Parameters:
msg- the SSHmessage identifierbuf-SSHPacketcontaining rest of the request- Throws:
SSHException- if there is a non-recoverable error
-
isEOF
-
getLoggerFactory
Description copied from interface:ChannelGet the LoggerFactory associated with the SSH client.- Specified by:
getLoggerFactoryin interfaceChannel
-
gotClose
- Throws:
TransportException
-
closeAllStreams
protected void closeAllStreams()Called when all I/O streams should be closed. Subclasses can override but must call super. -
notifyError
Description copied from interface:ErrorNotifiableNotifies this object of anerror.- Specified by:
notifyErrorin interfaceErrorNotifiable
-
setAutoExpand
public void setAutoExpand(boolean autoExpand) Description copied from interface:ChannelSet whether local window should automatically expand when data is received, irrespective of whether data has been read from that stream. This is useful e.g. when a remote command produces a lot of output that would fill the local window but you are not interested in reading from itsInputStream.- Specified by:
setAutoExpandin interfaceChannel- Parameters:
autoExpand- whether local windows should automatically expand
-
close
Description copied from interface:ChannelClose this channel.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
ConnectionExceptionTransportException
-
join
- Specified by:
joinin interfaceChannel- Throws:
ConnectionException
-
join
- Specified by:
joinin interfaceChannel- Throws:
ConnectionException
-
sendClose
- Throws:
TransportException
-
isOpen
-
whileOpen
boolean whileOpen(AbstractChannel.TransportRunnable runnable) throws TransportException, ConnectionException -
gotChannelRequest
-
gotWindowAdjustment
- Throws:
ConnectionException
-
finishOff
protected void finishOff() -
gotExtendedData
- Throws:
SSHException
-
gotUnknown
protected void gotUnknown(Message msg, SSHPacket buf) throws ConnectionException, TransportException -
handleRequest
protected void handleRequest(String reqType, SSHPacket buf) throws ConnectionException, TransportException -
newBuffer
-
receiveInto
- Throws:
SSHException
-
sendChannelRequest
protected Event<ConnectionException> sendChannelRequest(String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific) throws TransportException - Throws:
TransportException
-
gotResponse
- Throws:
ConnectionException
-
gotEOF
- Throws:
TransportException
-
eofInputStreams
protected void eofInputStreams()Called when EOF has been received. Subclasses can override but must call super. -
toString
-