net.officefloor.plugin.socket.server.impl
Class ConnectionImpl<CH extends ConnectionHandler>

java.lang.Object
  extended by net.officefloor.plugin.socket.server.impl.ConnectionImpl<CH>
All Implemented Interfaces:
Connection, BufferPopulator, BufferProcessor

public class ConnectionImpl<CH extends ConnectionHandler>
extends Object
implements Connection, BufferProcessor, BufferPopulator

Implementation of a Connection.

Author:
Daniel Sagenschneider

Constructor Summary
ConnectionImpl(NonblockingSocketChannel nonblockingSocketChannel, ServerSocketHandler<CH> serverSocketHandler, BufferSquirtFactory bufferSquirtFactory)
          Initiate.
 
Method Summary
 InputBufferStream getInputBufferStream()
          Obtains the InputBufferStream to obtain data from the client.
 InetSocketAddress getLocalAddress()
          Obtains the local address for the Connection.
 Object getLock()
          Obtains the lock to synchronize for using this Connection.
 OutputBufferStream getOutputBufferStream()
          Obtains the OutputBufferStream to write data to the client.
 InetSocketAddress getRemoteAddress()
          Obtains the remote address for the Connection.
 boolean isSecure()
          Indicates if the connection is over a secure channel (e.g.
 void populate(ByteBuffer buffer)
          Populates the ByteBuffer.
 void process(ByteBuffer buffer)
          Processes the ByteBuffer from the InputBufferStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionImpl

public ConnectionImpl(NonblockingSocketChannel nonblockingSocketChannel,
                      ServerSocketHandler<CH> serverSocketHandler,
                      BufferSquirtFactory bufferSquirtFactory)
Initiate.

Parameters:
nonblockingSocketChannel - NonblockingSocketChannel.
serverSocketHandler - ServerSocketHandler.
bufferSquirtFactory - BufferSquirtFactory.
Method Detail

populate

public void populate(ByteBuffer buffer)
              throws IOException
Description copied from interface: BufferPopulator
Populates the ByteBuffer.

Specified by:
populate in interface BufferPopulator
Parameters:
buffer - ByteBuffer to be populated.
Throws:
IOException - Failure to populate the ByteBuffer.

process

public void process(ByteBuffer buffer)
             throws IOException
Description copied from interface: BufferProcessor
Processes the ByteBuffer from the InputBufferStream.

Specified by:
process in interface BufferProcessor
Parameters:
buffer - ByteBuffer from the InputBufferStream.
Throws:
IOException - If fails to process the ByteBuffer.

getLock

public Object getLock()
Description copied from interface: Connection
Obtains the lock to synchronize for using this Connection.

Specified by:
getLock in interface Connection
Returns:
Lock for this Connection.

getLocalAddress

public InetSocketAddress getLocalAddress()
Description copied from interface: Connection
Obtains the local address for the Connection.

Specified by:
getLocalAddress in interface Connection
Returns:
InetSocketAddress describing the local Socket for the Connection.

getRemoteAddress

public InetSocketAddress getRemoteAddress()
Description copied from interface: Connection
Obtains the remote address for the Connection.

Specified by:
getRemoteAddress in interface Connection
Returns:
InetSocketAddress describing the remote Socket for the Connection.

isSecure

public boolean isSecure()
Description copied from interface: Connection
Indicates if the connection is over a secure channel (e.g. utilising SSL).

Specified by:
isSecure in interface Connection
Returns:
true if connection is over a secure channel.

getInputBufferStream

public InputBufferStream getInputBufferStream()
Description copied from interface: Connection
Obtains the InputBufferStream to obtain data from the client.

Specified by:
getInputBufferStream in interface Connection
Returns:
InputBufferStream.

getOutputBufferStream

public OutputBufferStream getOutputBufferStream()
Description copied from interface: Connection
Obtains the OutputBufferStream to write data to the client.

Specified by:
getOutputBufferStream in interface Connection
Returns:
OutputBufferStream.


Copyright © 2005-2011. All Rights Reserved.