Class TransportChannel

java.lang.Object
org.simpleframework.transport.TransportChannel
All Implemented Interfaces:
Channel

public class TransportChannel extends Object implements Channel
The TransportChannel provides a means to deliver and receive content over a transport. This essentially provides two adapters which enable simpler communication with the underlying transport. They hide the complexities involved with buffering and resetting data written to and read from the socket.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Certificate
    This is the certificate associated with this SSL channel.
    private final ByteCursor
    This is used to provide a cursor view on the input.
    private final SSLEngine
    This is the engine that is used to secure the transport.
    private final Trace
    This is the trace used to monitor events on the channel.
    private final Transport
    This represents the underlying transport that is to be used.
    private final ByteWriter
    This is used to provide a blocking means for sending data.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the TransportChannel object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Because the channel represents a duplex means of communication there needs to be a means to close it down.
    This returns the Map of attributes used to hold connection information for the channel.
    This is used to acquire the SSL certificate used for security.
    This provides a ByteCursor for this channel.
    This is the connected socket channel associated with this.
    This gets the Trace object associated with the channel.
    This provides a ByteWriter for the channel.
    boolean
    This is used to determine if the channel is secure and that data read from and data written to the request is encrypted.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • certificate

      private final Certificate certificate
      This is the certificate associated with this SSL channel.
    • transport

      private final Transport transport
      This represents the underlying transport that is to be used.
    • engine

      private final SSLEngine engine
      This is the engine that is used to secure the transport.
    • cursor

      private final ByteCursor cursor
      This is used to provide a cursor view on the input.
    • writer

      private final ByteWriter writer
      This is used to provide a blocking means for sending data.
    • trace

      private final Trace trace
      This is the trace used to monitor events on the channel.
  • Constructor Details

    • TransportChannel

      public TransportChannel(Transport transport) throws IOException
      Constructor for the TransportChannel object. The transport channel basically wraps a channel and provides a means to send and receive data using specialized adapters. These adapters provide a simpler means for communicating over the network to the connected client.
      Parameters:
      transport - this is the underlying transport to be used
      Throws:
      IOException
  • Method Details

    • isSecure

      public boolean isSecure()
      This is used to determine if the channel is secure and that data read from and data written to the request is encrypted. Channels transferred over SSL are considered secure and will have this return true, otherwise it will return false.
      Specified by:
      isSecure in interface Channel
      Returns:
      true if this is secure for reading and writing
    • getCertificate

      public Certificate getCertificate()
      This is used to acquire the SSL certificate used for security. If the socket is connected to an SSL transport this returns an SSL certificate which was provided during the secure handshake between the client and server. If not certificates are present in the provided instance, a challenge can be issued.
      Specified by:
      getCertificate in interface Channel
      Returns:
      the SSL certificate provided by a secure transport
    • getTrace

      public Trace getTrace()
      This gets the Trace object associated with the channel. The trace is used to log various events for the life of the transaction such as low level read and write events as well as milestone events and errors.
      Specified by:
      getTrace in interface Channel
      Returns:
      this returns the trace associated with the socket
    • getSocket

      public SocketChannel getSocket()
      This is the connected socket channel associated with this. In order to determine if content can be read or written to or from the channel this socket can be used with a selector. This provides a means to react to I/O events as they occur rather than polling the channel which is generally less performant.
      Specified by:
      getSocket in interface Channel
      Returns:
      this returns the connected socket channel
    • getAttributes

      public Map getAttributes()
      This returns the Map of attributes used to hold connection information for the channel. The attributes here are taken from the pipeline attributes and may contain details such as SSL certificates or other such useful information.
      Specified by:
      getAttributes in interface Channel
      Returns:
      returns the attributes associated with the channel
    • getCursor

      public ByteCursor getCursor()
      This provides a ByteCursor for this channel. The cursor provides a seekable view of the input buffer and will allow the server kernel to peek into the input buffer without having to take the data from the input. This allows overflow to be pushed back on to the cursor for subsequent reads.
      Specified by:
      getCursor in interface Channel
      Returns:
      this returns the input cursor for the channel
    • getWriter

      public ByteWriter getWriter()
      This provides a ByteWriter for the channel. This is used to provide a blocking output mechanism for the channel. Enabling blocking reads ensures that output buffering can be limited to an extent, which ensures that memory remains low at high load periods. Writes to the sender may result in the data being copied and queued until the socket is write ready.
      Specified by:
      getWriter in interface Channel
      Returns:
      this returns the output sender for this channel
    • close

      public void close()
      Because the channel represents a duplex means of communication there needs to be a means to close it down. This provides such a means. By closing the channel the cursor and sender will no longer send or receive data to or from the network. The client will also be signalled that the connection has been severed.
      Specified by:
      close in interface Channel