|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.nio.AbstractNIOConnection
public abstract class AbstractNIOConnection
Common Connection implementation for Java NIO Connections.
| Field Summary | |
|---|---|
protected AsyncQueue<AsyncReadQueueRecord> |
asyncReadQueue
|
protected AsyncQueue<AsyncWriteQueueRecord> |
asyncWriteQueue
|
protected AttributeHolder |
attributes
|
protected SelectableChannel |
channel
|
protected boolean |
isBlocking
|
protected AtomicBoolean |
isClosed
|
protected Processor |
processor
|
protected ProcessorSelector |
processorSelector
|
protected int |
readBufferSize
|
protected SelectionKey |
selectionKey
|
protected SelectorRunner |
selectorRunner
|
protected NIOTransport |
transport
|
protected int |
writeBufferSize
|
| Constructor Summary | |
|---|---|
AbstractNIOConnection(NIOTransport transport)
|
|
| Method Summary | |
|---|---|
void |
close()
Close the Connection |
void |
configureBlocking(boolean isBlocking)
Returns the Connection mode. |
void |
disableIOEvent(IOEvent ioEvent)
|
void |
enableIOEvent(IOEvent ioEvent)
|
AsyncQueue<AsyncReadQueueRecord> |
getAsyncReadQueue()
|
AsyncQueue<AsyncWriteQueueRecord> |
getAsyncWriteQueue()
|
AttributeHolder |
getAttributes()
Get associated AttributeHolder. |
SelectableChannel |
getChannel()
|
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. |
SelectionKey |
getSelectionKey()
|
SelectorRunner |
getSelectorRunner()
|
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. |
AttributeHolder |
obtainAttributes()
Get associated AttributeHolder. |
protected abstract void |
preClose()
|
Future<ReadResult<Buffer,SocketAddress>> |
read()
Method reads data. |
Future<ReadResult<Buffer,SocketAddress>> |
read(Buffer buffer)
Method reads data to the buffer. |
Future<ReadResult<Buffer,SocketAddress>> |
read(Buffer buffer,
CompletionHandler<ReadResult<Buffer,SocketAddress>> completionHandler)
Method reads data to the buffer. |
protected void |
setChannel(SelectableChannel channel)
|
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. |
protected void |
setSelectionKey(SelectionKey selectionKey)
|
protected void |
setSelectorRunner(SelectorRunner selectorRunner)
|
void |
setWriteBufferSize(int writeBufferSize)
Set the default size of Buffers, which will be allocated for
writing data to Connection. |
Future<WriteResult<Buffer,SocketAddress>> |
write(Buffer buffer)
Method writes the buffer. |
Future<WriteResult<Buffer,SocketAddress>> |
write(Buffer buffer,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler)
Method writes the buffer. |
Future<WriteResult<Buffer,SocketAddress>> |
write(SocketAddress dstAddress,
Buffer buffer)
Method writes the buffer to the specific address. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.grizzly.Connection |
|---|
getLocalAddress, getPeerAddress, getStreamReader, getStreamWriter |
| Methods inherited from interface com.sun.grizzly.Readable |
|---|
read |
| Methods inherited from interface com.sun.grizzly.Writable |
|---|
write |
| Field Detail |
|---|
protected final NIOTransport transport
protected int readBufferSize
protected int writeBufferSize
protected SelectorRunner selectorRunner
protected SelectableChannel channel
protected SelectionKey selectionKey
protected Processor processor
protected ProcessorSelector processorSelector
protected final AttributeHolder attributes
protected final AsyncQueue<AsyncReadQueueRecord> asyncReadQueue
protected final AsyncQueue<AsyncWriteQueueRecord> asyncWriteQueue
protected AtomicBoolean isClosed
protected boolean isBlocking
| Constructor Detail |
|---|
public AbstractNIOConnection(NIOTransport transport)
| Method Detail |
|---|
public void configureBlocking(boolean isBlocking)
ConnectionConnection mode.
true, if Connection is operating in blocking mode, or
false otherwise.
configureBlocking in interface Connection<SocketAddress>public boolean isBlocking()
ConnectionConnection mode.
isBlocking in interface Connection<SocketAddress>public Transport getTransport()
ConnectionTransport, to which this Connection belongs to.
getTransport in interface Connection<SocketAddress>Transport, to which this Connection belongs to.public int getReadBufferSize()
ConnectionBuffers, which will be allocated for
reading data from Connection.
getReadBufferSize in interface Connection<SocketAddress>Buffers, which will be allocated for
reading data from Connection.public void setReadBufferSize(int readBufferSize)
ConnectionBuffers, which will be allocated for
reading data from Connection.
setReadBufferSize in interface Connection<SocketAddress>readBufferSize - the default size of Buffers, which will
be allocated for reading data from Connection.public int getWriteBufferSize()
ConnectionBuffers, which will be allocated for
writing data to Connection.
getWriteBufferSize in interface Connection<SocketAddress>Buffers, which will be allocated for
writing data to Connection.public void setWriteBufferSize(int writeBufferSize)
ConnectionBuffers, which will be allocated for
writing data to Connection.
setWriteBufferSize in interface Connection<SocketAddress>writeBufferSize - the default size of Buffers, which will
be allocated for writing data to Connection.public SelectorRunner getSelectorRunner()
getSelectorRunner in interface NIOConnectionprotected void setSelectorRunner(SelectorRunner selectorRunner)
public SelectableChannel getChannel()
getChannel in interface NIOConnectionprotected void setChannel(SelectableChannel channel)
public SelectionKey getSelectionKey()
getSelectionKey in interface NIOConnectionprotected void setSelectionKey(SelectionKey selectionKey)
public Processor getProcessor()
ConnectionProcessor, 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.
getProcessor in interface Connection<SocketAddress>Processor, which will process
Connection I/O events.public void setProcessor(Processor preferableProcessor)
ConnectionProcessor, 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.
setProcessor in interface Connection<SocketAddress>preferableProcessor - the default Processor, which will
process Connection I/O events.public ProcessorSelector getProcessorSelector()
ConnectionProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Connection's Processor is null.
getProcessorSelector in interface Connection<SocketAddress>ProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Connection's Processor is null.public void setProcessorSelector(ProcessorSelector preferableProcessorSelector)
ConnectionProcessorSelector, which will be used to get
Processor to process Connection I/O events, in case if
this Connection's Processor is null.
setProcessorSelector in interface Connection<SocketAddress>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.public AsyncQueue<AsyncReadQueueRecord> getAsyncReadQueue()
public AsyncQueue<AsyncWriteQueueRecord> getAsyncWriteQueue()
public AttributeHolder getAttributes()
AttributeStorageAttributeHolder.
Implementation may return null if AttributeHolder wasn't
initialized yet.
getAttributes in interface AttributeStorageAttributeHolder.
Implementation may return null if AttributeHolder wasn't
initialized yet.public AttributeHolder obtainAttributes()
AttributeStorageAttributeHolder.
Unlike AttributeStorage.getAttributes() - method never
returns null.
obtainAttributes in interface AttributeStorageAttributeHolder.
Unlike AttributeStorage.getAttributes() - method never
returns null.
public Future<ReadResult<Buffer,SocketAddress>> read()
throws IOException
Readable
read in interface Readable<SocketAddress>Future, using which it's possible to check the result
IOException
public Future<ReadResult<Buffer,SocketAddress>> read(Buffer buffer)
throws IOException
Readable
read in interface Readable<SocketAddress>buffer - the buffer, where data will be read
Future, using which it's possible to check the result
IOException
public Future<ReadResult<Buffer,SocketAddress>> read(Buffer buffer,
CompletionHandler<ReadResult<Buffer,SocketAddress>> completionHandler)
throws IOException
Readable
read in interface Readable<SocketAddress>buffer - the buffer, where data will be readcompletionHandler - CompletionHandler,
which will get notified, when read will be completed
Future, using which it's possible to check the result
IOException
public Future<WriteResult<Buffer,SocketAddress>> write(Buffer buffer)
throws IOException
Writable
write in interface Writable<SocketAddress>buffer - the buffer, from which the data will be written
Future, using which it's possible to check the
result
IOException
public Future<WriteResult<Buffer,SocketAddress>> write(Buffer buffer,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler)
throws IOException
Writable
write in interface Writable<SocketAddress>buffer - the buffer, from which the data will be writtencompletionHandler - CompletionHandler,
which will get notified, when write will be completed
Future, using which it's possible to check the
result
IOException
public Future<WriteResult<Buffer,SocketAddress>> write(SocketAddress dstAddress,
Buffer buffer)
throws IOException
Writable
write in interface Writable<SocketAddress>dstAddress - the destination address the buffer will be
sent tobuffer - the buffer, from which the data will be written
Future, using which it's possible to check the
result
IOExceptionpublic boolean isOpen()
ConnectionConnection open and ready.
Returns true, if connection is open and ready, or false
otherwise.
isOpen in interface Connection<SocketAddress>
public void close()
throws IOException
ConnectionConnection
close in interface Connection<SocketAddress>close in interface CloseableIOExceptionprotected abstract void preClose()
public void enableIOEvent(IOEvent ioEvent)
throws IOException
enableIOEvent in interface NIOConnectionIOException
public void disableIOEvent(IOEvent ioEvent)
throws IOException
disableIOEvent in interface NIOConnectionIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||