Class AbstractChannel
- java.lang.Object
-
- net.schmizz.sshj.connection.channel.AbstractChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ErrorNotifiable,SSHPacketHandler,Channel
- Direct Known Subclasses:
AbstractDirectChannel,AbstractForwardedChannel
public abstract class AbstractChannel extends java.lang.Object implements Channel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractChannel.TransportRunnable-
Nested 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
Fields Modifier and Type Field Description protected Event<ConnectionException>closeEventChannel close eventprotected ConnectionconnConnection layerprotected org.slf4j.Loggerlogprotected LoggerFactoryloggerFactoryLoggerprotected Window.LocallwinLocal windowprotected Event<ConnectionException>openEventChannel open eventprotected Window.RemoterwinRemote windowprotected TransporttransTransport layer
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractChannel(Connection conn, java.lang.String type)protectedAbstractChannel(Connection conn, java.lang.String type, java.nio.charset.Charset remoteCharset)
-
Method Summary
Modifier and Type Method Description voidclose()Close this channel.protected voidcloseAllStreams()Called when all I/O streams should be closed.protected voideofInputStreams()Called when EOF has been received.protected voidfinishOff()booleangetAutoExpand()intgetID()java.io.InputStreamgetInputStream()intgetLocalMaxPacketSize()longgetLocalWinSize()LoggerFactorygetLoggerFactory()Get the LoggerFactory associated with the SSH client.java.io.OutputStreamgetOutputStream()intgetRecipient()java.nio.charset.CharsetgetRemoteCharset()intgetRemoteMaxPacketSize()longgetRemoteWinSize()java.lang.StringgetType()protected voidgotExtendedData(SSHPacket buf)protected voidgotUnknown(Message msg, SSHPacket buf)voidhandle(Message msg, SSHPacket buf)Delegate handling of some SSH packet to this object.protected voidhandleRequest(java.lang.String reqType, SSHPacket buf)protected voidinit(int recipient, long remoteWinSize, long remoteMaxPacketSize)booleanisEOF()Returns whether EOF has been received.booleanisOpen()voidjoin()voidjoin(long timeout, java.util.concurrent.TimeUnit unit)protected SSHPacketnewBuffer(Message cmd)voidnotifyError(SSHException error)Notifies this object of anerror.protected voidreceiveInto(ChannelInputStream stream, SSHPacket buf)protected Event<ConnectionException>sendChannelRequest(java.lang.String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific)protected voidsendClose()voidsetAutoExpand(boolean autoExpand)Set whether local window should automatically expand when data is received, irrespective of whether data has been read from that stream.java.lang.StringtoString()
-
-
-
Field Detail
-
loggerFactory
protected final LoggerFactory loggerFactory
Logger
-
log
protected final org.slf4j.Logger log
-
trans
protected final Transport trans
Transport layer
-
conn
protected final Connection conn
Connection layer
-
openEvent
protected final Event<ConnectionException> openEvent
Channel open event
-
closeEvent
protected final Event<ConnectionException> closeEvent
Channel close event
-
lwin
protected final Window.Local lwin
Local window
-
rwin
protected Window.Remote rwin
Remote window
-
-
Constructor Detail
-
AbstractChannel
protected AbstractChannel(Connection conn, java.lang.String type)
-
AbstractChannel
protected AbstractChannel(Connection conn, java.lang.String type, java.nio.charset.Charset remoteCharset)
-
-
Method Detail
-
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:
Channel.setAutoExpand(boolean)
-
getInputStream
public java.io.InputStream 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
public java.io.OutputStream 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
public java.nio.charset.Charset 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
public java.lang.String getType()
-
handle
public void handle(Message msg, SSHPacket buf) throws SSHException
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
public boolean isEOF()
Description copied from interface:ChannelReturns whether EOF has been received.
-
getLoggerFactory
public LoggerFactory getLoggerFactory()
Description copied from interface:ChannelGet the LoggerFactory associated with the SSH client.- Specified by:
getLoggerFactoryin interfaceChannel
-
closeAllStreams
protected void closeAllStreams()
Called when all I/O streams should be closed. Subclasses can override but must call super.
-
notifyError
public void notifyError(SSHException error)
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
public void close() throws ConnectionException, TransportExceptionDescription copied from interface:ChannelClose this channel.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfacejava.io.Closeable- Throws:
ConnectionExceptionTransportException
-
join
public void join() throws ConnectionException- Specified by:
joinin interfaceChannel- Throws:
ConnectionException
-
join
public void join(long timeout, java.util.concurrent.TimeUnit unit) throws ConnectionException- Specified by:
joinin interfaceChannel- Throws:
ConnectionException
-
sendClose
protected void sendClose() throws TransportException- Throws:
TransportException
-
isOpen
public boolean isOpen()
-
finishOff
protected void finishOff()
-
gotExtendedData
protected void gotExtendedData(SSHPacket buf) throws SSHException
- Throws:
SSHException
-
gotUnknown
protected void gotUnknown(Message msg, SSHPacket buf) throws ConnectionException, TransportException
-
handleRequest
protected void handleRequest(java.lang.String reqType, SSHPacket buf) throws ConnectionException, TransportException
-
receiveInto
protected void receiveInto(ChannelInputStream stream, SSHPacket buf) throws SSHException
- Throws:
SSHException
-
sendChannelRequest
protected Event<ConnectionException> sendChannelRequest(java.lang.String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific) throws TransportException
- Throws:
TransportException
-
eofInputStreams
protected void eofInputStreams()
Called when EOF has been received. Subclasses can override but must call super.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-