org.glassfish.grizzly
Interface Connection<L>

All Superinterfaces:
AttributeStorage, Closeable, Readable<L>, Writable<L>
All Known Subinterfaces:
NIOConnection
All Known Implementing Classes:
AbstractNIOConnection, TCPNIOConnection, TCPNIOServerConnection, UDPNIOConnection, UDPNIOServerConnection

public interface Connection<L>
extends Readable<L>, Writable<L>, Closeable, AttributeStorage

Common interface, which represents any kind of connection.

Author:
Alexey Stashok

Method Summary
 void close()
          Close the Connection
 void configureBlocking(boolean isBlocking)
          Returns the Connection mode.
 L getLocalAddress()
          Get the connection local address
 L getPeerAddress()
          Get the connection peer address
 Processor getProcessor()
          Gets the default Processor, which will process Connection I/O events.
 ProcessorSelector getProcessorSelector()
          Gets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.
 int getReadBufferSize()
          Get the default size of Buffers, which will be allocated for reading data from Connection.
 StreamReader getStreamReader()
          Get the Connection StreamReader, to read data from the Connection.
 StreamWriter getStreamWriter()
          Get the Connection StreamWriter, to write data to the Connection.
 Transport getTransport()
          Get the Transport, to which this Connection belongs to.
 int getWriteBufferSize()
          Get the default size of Buffers, which will be allocated for writing data to Connection.
 boolean isBlocking()
          Sets the Connection mode.
 boolean isOpen()
          Is Connection open and ready.
 void setProcessor(Processor preferableProcessor)
          Sets the default Processor, which will process Connection I/O events.
 void setProcessorSelector(ProcessorSelector preferableProcessorSelector)
          Sets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.
 void setReadBufferSize(int readBufferSize)
          Set the default size of Buffers, which will be allocated for reading data from Connection.
 void setWriteBufferSize(int writeBufferSize)
          Set the default size of Buffers, which will be allocated for writing data to Connection.
 
Methods inherited from interface org.glassfish.grizzly.Readable
read, read, read, read
 
Methods inherited from interface org.glassfish.grizzly.Writable
write, write, write, write
 
Methods inherited from interface org.glassfish.grizzly.attributes.AttributeStorage
getAttributes, obtainAttributes
 

Method Detail

getTransport

Transport getTransport()
Get the Transport, to which this Connection belongs to.

Returns:
the Transport, to which this Connection belongs to.

isOpen

boolean isOpen()
Is Connection open and ready. Returns true, if connection is open and ready, or false otherwise.

Returns:
true, if connection is open and ready, or false otherwise.

configureBlocking

void configureBlocking(boolean isBlocking)
Returns the Connection mode. true, if Connection is operating in blocking mode, or false otherwise.


isBlocking

boolean isBlocking()
Sets the Connection mode.

Parameters:
isBlocking - the Connection mode. true, if Connection should operate in blocking mode, or false otherwise.

getProcessor

Processor getProcessor()
Gets the default Processor, which will process Connection I/O events. If Processor is null, - then Transport will try to get Processor using Connection's ProcessorSelector.select(IOEvent, Connection). If ProcessorSelector, associated withthe Connection is also null - Transport will try to get Processor using own settings.

Returns:
the default Processor, which will process Connection I/O events.

setProcessor

void setProcessor(Processor preferableProcessor)
Sets the default Processor, which will process Connection I/O events. If Processor is null, - then Transport will try to get Processor using Connection's ProcessorSelector.select(IOEvent, Connection). If ProcessorSelector, associated withthe Connection is also null - Transport will try to get Processor using own settings.

Parameters:
preferableProcessor - the default Processor, which will process Connection I/O events.

getProcessorSelector

ProcessorSelector getProcessorSelector()
Gets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

Returns:
the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

setProcessorSelector

void setProcessorSelector(ProcessorSelector preferableProcessorSelector)
Sets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

Parameters:
preferableProcessorSelector - the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

getPeerAddress

L getPeerAddress()
Get the connection peer address

Returns:
the connection peer address

getLocalAddress

L getLocalAddress()
Get the connection local address

Returns:
the connection local address

close

void close()
           throws IOException
Close the Connection

Specified by:
close in interface Closeable
Throws:
java.io.IOException, - if I/O error was detected during Connection closing.
IOException

getStreamReader

StreamReader getStreamReader()
Get the Connection StreamReader, to read data from the Connection.

Returns:
the Connection StreamReader, to read data from the Connection.

getStreamWriter

StreamWriter getStreamWriter()
Get the Connection StreamWriter, to write data to the Connection.

Returns:
the Connection StreamWriter, to write data to the Connection.

getReadBufferSize

int getReadBufferSize()
Get the default size of Buffers, which will be allocated for reading data from Connection.

Returns:
the default size of Buffers, which will be allocated for reading data from Connection.

setReadBufferSize

void setReadBufferSize(int readBufferSize)
Set the default size of Buffers, which will be allocated for reading data from Connection.

Parameters:
readBufferSize - the default size of Buffers, which will be allocated for reading data from Connection.

getWriteBufferSize

int getWriteBufferSize()
Get the default size of Buffers, which will be allocated for writing data to Connection.

Returns:
the default size of Buffers, which will be allocated for writing data to Connection.

setWriteBufferSize

void setWriteBufferSize(int writeBufferSize)
Set the default size of Buffers, which will be allocated for writing data to Connection.

Parameters:
writeBufferSize - the default size of Buffers, which will be allocated for writing data to Connection.


Copyright © 2009 SUN Microsystems. All Rights Reserved.