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 interface
AbstractChannel.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>
closeEvent
Channel close eventprotected Connection
conn
Connection layerprotected org.slf4j.Logger
log
protected LoggerFactory
loggerFactory
Loggerprotected Window.Local
lwin
Local windowprotected Event<ConnectionException>
openEvent
Channel open eventprotected Window.Remote
rwin
Remote windowprotected Transport
trans
Transport layer
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractChannel(Connection conn, java.lang.String type)
protected
AbstractChannel(Connection conn, java.lang.String type, java.nio.charset.Charset remoteCharset)
-
Method Summary
Modifier and Type Method Description void
close()
Close this channel.protected void
closeAllStreams()
Called when all I/O streams should be closed.protected void
eofInputStreams()
Called when EOF has been received.protected void
finishOff()
boolean
getAutoExpand()
int
getID()
java.io.InputStream
getInputStream()
int
getLocalMaxPacketSize()
long
getLocalWinSize()
LoggerFactory
getLoggerFactory()
Get the LoggerFactory associated with the SSH client.java.io.OutputStream
getOutputStream()
int
getRecipient()
java.nio.charset.Charset
getRemoteCharset()
int
getRemoteMaxPacketSize()
long
getRemoteWinSize()
java.lang.String
getType()
protected void
gotExtendedData(SSHPacket buf)
protected void
gotUnknown(Message msg, SSHPacket buf)
void
handle(Message msg, SSHPacket buf)
Delegate handling of some SSH packet to this object.protected void
handleRequest(java.lang.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
join(long timeout, java.util.concurrent.TimeUnit unit)
protected SSHPacket
newBuffer(Message cmd)
void
notifyError(SSHException error)
Notifies this object of anerror
.protected void
receiveInto(ChannelInputStream stream, SSHPacket buf)
protected Event<ConnectionException>
sendChannelRequest(java.lang.String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific)
protected void
sendClose()
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.java.lang.String
toString()
-
-
-
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:
getAutoExpand
in interfaceChannel
- Returns:
- whether auto-expansion of local window is set.
- See Also:
Channel.setAutoExpand(boolean)
-
getInputStream
public java.io.InputStream 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
public java.io.OutputStream 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
public java.nio.charset.Charset 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
public java.lang.String getType()
-
handle
public void handle(Message msg, SSHPacket buf) throws ConnectionException, TransportException
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:
ConnectionException
TransportException
-
isEOF
public boolean isEOF()
Description copied from interface:Channel
Returns whether EOF has been received.
-
getLoggerFactory
public LoggerFactory getLoggerFactory()
Description copied from interface:Channel
Get the LoggerFactory associated with the SSH client.- Specified by:
getLoggerFactory
in 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: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
public void close() throws ConnectionException, TransportException
Description copied from interface:Channel
Close this channel.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
ConnectionException
TransportException
-
join
public void join() throws ConnectionException
- Specified by:
join
in interfaceChannel
- Throws:
ConnectionException
-
join
public void join(long timeout, java.util.concurrent.TimeUnit unit) throws ConnectionException
- Specified by:
join
in 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 ConnectionException, TransportException
-
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 ConnectionException, TransportException
-
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:
toString
in classjava.lang.Object
-
-