net.schmizz.sshj.connection.channel
Class AbstractChannel

java.lang.Object
  extended by net.schmizz.sshj.connection.channel.AbstractChannel
All Implemented Interfaces:
Closeable, ErrorNotifiable, SSHPacketHandler, Channel
Direct Known Subclasses:
AbstractDirectChannel, AbstractForwardedChannel

public abstract class AbstractChannel
extends Object
implements Channel


Nested Class Summary
 
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
protected  Event<ConnectionException> close
          Channel close event
protected  Connection conn
          Connection layer
protected  org.slf4j.Logger log
          Logger
protected  Window.Local lwin
          Local window
protected  Event<ConnectionException> open
          Channel open event
protected  Window.Remote rwin
          Remote window
protected  Transport trans
          Transport layer
 
Constructor Summary
protected AbstractChannel(Connection conn, String type)
           
 
Method Summary
 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()
           
 InputStream getInputStream()
           
 int getLocalMaxPacketSize()
           
 long getLocalWinSize()
           
 OutputStream getOutputStream()
           
 int getRecipient()
           
 int getRemoteMaxPacketSize()
           
 long getRemoteWinSize()
           
 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(String reqType, SSHPacket buf)
           
protected  void init(int recipient, long remoteWinSize, long remoteMaxPacketSize)
           
 boolean isOpen()
           
 void join()
           
 void join(int timeout, TimeUnit unit)
           
protected  SSHPacket newBuffer(Message cmd)
           
 void notifyError(SSHException error)
          Notifies this object of an error.
protected  void receiveInto(ChannelInputStream stream, SSHPacket buf)
           
protected  Event<ConnectionException> sendChannelRequest(String reqType, boolean wantReply, Buffer.PlainBuffer reqSpecific)
           
protected  void sendClose()
           
 void sendEOF()
          Sends an EOF message to the server for this channel; indicating that no more data will be sent by us.
 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected final org.slf4j.Logger log
Logger


trans

protected final Transport trans
Transport layer


conn

protected final Connection conn
Connection layer


open

protected final Event<ConnectionException> open
Channel open event


close

protected final Event<ConnectionException> close
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,
                          String type)
Method Detail

init

protected void init(int recipient,
                    long remoteWinSize,
                    long remoteMaxPacketSize)

getAutoExpand

public boolean getAutoExpand()
Specified by:
getAutoExpand in interface Channel
Returns:
whether auto-expansion of local window is set.
See Also:
Channel.setAutoExpand(boolean)

getID

public int getID()
Specified by:
getID in interface Channel
Returns:
the channel ID

getInputStream

public InputStream getInputStream()
Specified by:
getInputStream in interface Channel
Returns:
the InputStream for this channel.

getLocalMaxPacketSize

public int getLocalMaxPacketSize()
Specified by:
getLocalMaxPacketSize in interface Channel
Returns:
the maximum packet size that we have specified.

getLocalWinSize

public long getLocalWinSize()
Specified by:
getLocalWinSize in interface Channel
Returns:
the current local window size.

getOutputStream

public OutputStream getOutputStream()
Specified by:
getOutputStream in interface Channel
Returns:
an OutputStream for this channel.

getRecipient

public int getRecipient()
Specified by:
getRecipient in interface Channel
Returns:
the channel ID at the remote end.

getRemoteMaxPacketSize

public int getRemoteMaxPacketSize()
Specified by:
getRemoteMaxPacketSize in interface Channel
Returns:
the maximum packet size as specified by the remote end.

getRemoteWinSize

public long getRemoteWinSize()
Specified by:
getRemoteWinSize in interface Channel
Returns:
the current remote window size.

getType

public String getType()
Specified by:
getType in interface Channel
Returns:
the channel type identifier.

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 interface SSHPacketHandler
Parameters:
msg - the SSH message identifier
buf - SSHPacket containing rest of the request
Throws:
ConnectionException
TransportException

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 an error.

Specified by:
notifyError in interface ErrorNotifiable

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 its InputStream.

Specified by:
setAutoExpand in interface Channel
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 interface Closeable
Specified by:
close in interface Channel
Throws:
ConnectionException
TransportException

join

public void join()
          throws ConnectionException
Specified by:
join in interface Channel
Throws:
ConnectionException

join

public void join(int timeout,
                 TimeUnit unit)
          throws ConnectionException
Specified by:
join in interface Channel
Throws:
ConnectionException

sendClose

protected void sendClose()
                  throws TransportException
Throws:
TransportException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Channel
Returns:
whether the channel is open.

finishOff

protected void finishOff()

gotExtendedData

protected void gotExtendedData(SSHPacket buf)
                        throws ConnectionException,
                               TransportException
Throws:
ConnectionException
TransportException

gotUnknown

protected void gotUnknown(Message msg,
                          SSHPacket buf)
                   throws ConnectionException,
                          TransportException
Throws:
ConnectionException
TransportException

handleRequest

protected void handleRequest(String reqType,
                             SSHPacket buf)
                      throws ConnectionException,
                             TransportException
Throws:
ConnectionException
TransportException

newBuffer

protected SSHPacket newBuffer(Message cmd)

receiveInto

protected void receiveInto(ChannelInputStream stream,
                           SSHPacket buf)
                    throws ConnectionException,
                           TransportException
Throws:
ConnectionException
TransportException

sendChannelRequest

protected Event<ConnectionException> sendChannelRequest(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.


sendEOF

public void sendEOF()
             throws TransportException
Description copied from interface: Channel
Sends an EOF message to the server for this channel; indicating that no more data will be sent by us. The OutputStream for this channel will be closed and no longer usable.

Specified by:
sendEOF in interface Channel
Throws:
TransportException - if there is an error sending the EOF message

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012. All Rights Reserved.