net.officefloor.plugin.socket.server.ssl.protocol
Class SslConnectionHandler<CH extends ConnectionHandler>

java.lang.Object
  extended by net.officefloor.plugin.socket.server.ssl.protocol.SslConnectionHandler<CH>
All Implemented Interfaces:
ConnectionHandler, ConnectionHandlerContext, IdleContext, ReadContext, TemporaryByteArrayFactory, WriteContext

public class SslConnectionHandler<CH extends ConnectionHandler>
extends Object
implements ConnectionHandler, TemporaryByteArrayFactory, ReadContext, WriteContext, IdleContext

SSL ConnectionHandler.

Author:
Daniel Sagenschneider

Constructor Summary
SslConnectionHandler(Connection connection, SSLEngine engine, BufferSquirtFactory bufferSquirtFactory, SslTaskExecutor taskExecutor, ServerSocketHandler<CH> wrappedServerSocketHandler)
          Initiate.
 
Method Summary
 byte[] createDestinationByteArray(int minimumSize)
           Creates a byte array that will be at least the size specified (it may however be bigger to allow reuse of byte array instances).
 byte[] createSourceByteArray(int minimumSize)
           Creates a byte array that will be at least the size specified (it may however be bigger to allow reuse of byte array instances).
 Object getContextObject()
          Obtains the context bound object.
 InputBufferStream getInputBufferStream()
          Obtains the InputBufferStream to read data from the client.
 long getTime()
           Obtains the current time in milliseconds.
 CH getWrappedConnectionHandler()
          Obtains the wrapped ConnectionHandler.
 void handleIdleConnection(IdleContext context)
          Handles a Connection being idled.
 void handleRead(ReadContext context)
          Handles a read from the SocketChannel.
 void handleWrite(WriteContext context)
          Handles a potential write to the SocketChannel.
 void processRequest(Object attachment)
          Flags that the request has been received.
 void setCloseConnection(boolean isClose)
          Flags to close the Connection.
 void setContextObject(Object contextObject)
          Specifies the context bound object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SslConnectionHandler

public SslConnectionHandler(Connection connection,
                            SSLEngine engine,
                            BufferSquirtFactory bufferSquirtFactory,
                            SslTaskExecutor taskExecutor,
                            ServerSocketHandler<CH> wrappedServerSocketHandler)
Initiate.

Parameters:
connection - Connection.
engine - SSLEngine.
bufferSquirtFactory - BufferSquirtFactory.
taskExecutor - SslTaskExecutor.
wrappedServerSocketHandler - Wrapped ServerSocketHandler.
Method Detail

getWrappedConnectionHandler

public CH getWrappedConnectionHandler()
Obtains the wrapped ConnectionHandler.

Returns:
Wrapped ConnectionHandler.

handleRead

public void handleRead(ReadContext context)
                throws IOException
Description copied from interface: ConnectionHandler
Handles a read from the SocketChannel.

Specified by:
handleRead in interface ConnectionHandler
Parameters:
context - ReadContext.
Throws:
IOException - If fails to obtain data from the ReadContext.

handleWrite

public void handleWrite(WriteContext context)
                 throws IOException
Description copied from interface: ConnectionHandler
Handles a potential write to the SocketChannel.

Specified by:
handleWrite in interface ConnectionHandler
Parameters:
context - WriteContext.
Throws:
IOException - If fails to handle write.

handleIdleConnection

public void handleIdleConnection(IdleContext context)
                          throws IOException
Description copied from interface: ConnectionHandler
Handles a Connection being idled.

Specified by:
handleIdleConnection in interface ConnectionHandler
Parameters:
context - IdleContext.
Throws:
IOException - If fails to handle idle Connection. Possibly from attempting to close it.

createDestinationByteArray

public byte[] createDestinationByteArray(int minimumSize)
Description copied from interface: TemporaryByteArrayFactory

Creates a byte array that will be at least the size specified (it may however be bigger to allow reuse of byte array instances).

This will always be a different byte array to that returned from other methods of this interface.

Specified by:
createDestinationByteArray in interface TemporaryByteArrayFactory
Parameters:
minimumSize - Minimum size for the returned byte array.
Returns:
Temporary byte array.

createSourceByteArray

public byte[] createSourceByteArray(int minimumSize)
Description copied from interface: TemporaryByteArrayFactory

Creates a byte array that will be at least the size specified (it may however be bigger to allow reuse of byte array instances).

This will always be a different byte array to that returned from other methods of this interface.

Specified by:
createSourceByteArray in interface TemporaryByteArrayFactory
Parameters:
minimumSize - Minimum size for the returned byte array.
Returns:
Temporary byte array.

getTime

public long getTime()
Description copied from interface: ConnectionHandlerContext

Obtains the current time in milliseconds.

This should return similar to System.currentTimeMillis() but is provided to cache time for multiple quick operations that require only estimates of time.

Note CPU operations should be in the nanoseconds.

Specified by:
getTime in interface ConnectionHandlerContext
Returns:
Time measured in milliseconds.

setCloseConnection

public void setCloseConnection(boolean isClose)
Description copied from interface: ConnectionHandlerContext
Flags to close the Connection.

Specified by:
setCloseConnection in interface ConnectionHandlerContext
Parameters:
isClose - true to close the Connection.

getContextObject

public Object getContextObject()
Description copied from interface: ConnectionHandlerContext
Obtains the context bound object.

Specified by:
getContextObject in interface ConnectionHandlerContext
Returns:
Context bound object.

setContextObject

public void setContextObject(Object contextObject)
Description copied from interface: ConnectionHandlerContext
Specifies the context bound object.

Specified by:
setContextObject in interface ConnectionHandlerContext
Parameters:
contextObject - Context bound object.

getInputBufferStream

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

Specified by:
getInputBufferStream in interface ReadContext
Returns:
InputBufferStream.

processRequest

public void processRequest(Object attachment)
                    throws IOException
Description copied from interface: ReadContext
Flags that the request has been received. This will subsequently have the Server process the request.

Specified by:
processRequest in interface ReadContext
Parameters:
attachment - Optional attachment for the request. May be null.
Throws:
IOException - If fails to process request.


Copyright © 2005-2011. All Rights Reserved.