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 net.schmizz.sshj.connection.channel.Channel
Channel.Direct, Channel.Forwarded
Nested classes/interfaces inherited from interface net.schmizz.sshj.common.ErrorNotifiable
ErrorNotifiable.Util
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final Queue
<Event<ConnectionException>> protected final Event
<ConnectionException> Channel close eventprivate boolean
Whether we have already sent a CHANNEL_CLOSE request to the serverprotected final Connection
Connection layerprivate boolean
private final int
Channel IDprivate final ChannelInputStream
stdout streamprotected final org.slf4j.Logger
protected final LoggerFactory
Loggerprotected final Window.Local
Local windowprivate final ReentrantLock
protected final Event
<ConnectionException> Channel open eventprivate ChannelOutputStream
stdin streamprivate int
Remote recipient IDprivate static final int
private final Charset
Remote character setprotected Window.Remote
Remote windowprotected final Transport
Transport layerprivate final String
Channel type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractChannel
(Connection conn, String type) protected
AbstractChannel
(Connection conn, String type, Charset remoteCharset) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this channel.protected void
Called when all I/O streams should be closed.protected void
Called when EOF has been received.protected void
boolean
int
getID()
int
long
Get the LoggerFactory associated with the SSH client.int
int
long
getType()
private void
private void
gotClose()
private void
gotEOF()
protected void
gotExtendedData
(SSHPacket buf) private void
gotResponse
(boolean success) protected void
gotUnknown
(Message msg, SSHPacket buf) private void
void
Delegate handling of some SSH packet to this object.protected void
handleRequest
(String reqType, SSHPacket buf) protected void
init
(int recipient, long remoteWinSize, long remoteMaxPacketSize) boolean
isEOF()
Returns whether EOF has been received.boolean
isOpen()
void
join()
void
protected SSHPacket
void
notifyError
(SSHException error) Notifies this object of anerror
.protected void
receiveInto
(ChannelInputStream stream, SSHPacket buf) protected Event
<ConnectionException> sendChannelRequest
(String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific) protected void
void
setAutoExpand
(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) boolean
whileOpen
(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:
getAutoExpand
in interfaceChannel
- Returns:
- whether auto-expansion of local window is set.
- See Also:
-
getID
public int getID() -
getInputStream
- Specified by:
getInputStream
in interfaceChannel
- Returns:
- the
InputStream
for this channel.
-
getLocalMaxPacketSize
public int getLocalMaxPacketSize()- Specified by:
getLocalMaxPacketSize
in interfaceChannel
- Returns:
- the maximum packet size that we have specified.
-
getLocalWinSize
public long getLocalWinSize()- Specified by:
getLocalWinSize
in interfaceChannel
- Returns:
- the current local window size.
-
getOutputStream
- Specified by:
getOutputStream
in interfaceChannel
- Returns:
- an
OutputStream
for this channel.
-
getRecipient
public int getRecipient()- Specified by:
getRecipient
in interfaceChannel
- Returns:
- the channel ID at the remote end.
-
getRemoteCharset
- Specified by:
getRemoteCharset
in interfaceChannel
- Returns:
- the character set used to communicate with the remote machine for certain strings (like paths).
-
getRemoteMaxPacketSize
public int getRemoteMaxPacketSize()- Specified by:
getRemoteMaxPacketSize
in interfaceChannel
- Returns:
- the maximum packet size as specified by the remote end.
-
getRemoteWinSize
public long getRemoteWinSize()- Specified by:
getRemoteWinSize
in interfaceChannel
- Returns:
- the current remote window size.
-
getType
-
handle
Description copied from interface:SSHPacketHandler
Delegate handling of some SSH packet to this object.- Specified by:
handle
in interfaceSSHPacketHandler
- Parameters:
msg
- the SSHmessage identifier
buf
-SSHPacket
containing rest of the request- Throws:
SSHException
- if there is a non-recoverable error
-
isEOF
public boolean isEOF()Description copied from interface:Channel
Returns whether EOF has been received. -
getLoggerFactory
Description copied from interface:Channel
Get the LoggerFactory associated with the SSH client.- Specified by:
getLoggerFactory
in 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:ErrorNotifiable
Notifies this object of anerror
.- Specified by:
notifyError
in interfaceErrorNotifiable
-
setAutoExpand
public void setAutoExpand(boolean autoExpand) Description copied from interface:Channel
Set 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:
setAutoExpand
in interfaceChannel
- Parameters:
autoExpand
- whether local windows should automatically expand
-
close
Description copied from interface:Channel
Close this channel.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
ConnectionException
TransportException
-
join
- Specified by:
join
in interfaceChannel
- Throws:
ConnectionException
-
join
- Specified by:
join
in interfaceChannel
- Throws:
ConnectionException
-
sendClose
- Throws:
TransportException
-
isOpen
public boolean 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
-