|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.AbstractConnectorHandler<E,K>
public abstract class AbstractConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
Abstract ConnectorHandler
definition, which preimplements common
getter/setter methods.
Field Summary | |
---|---|
protected K |
callbackHandler
A CallbackHandler handler invoked by the SelectorHandler
when a non blocking operation is ready to be processed. |
protected Controller |
controller
The internal Controller used (in case not specified). |
protected InputReader |
inputStream
A blocking InputStream that use a pool of Selector
to execute a blocking read operation. |
protected boolean |
isConnected
Is the connection established. |
protected Controller.Protocol |
protocol
The ConnectorHandler Controller.Protocol . |
protected E |
selectorHandler
The underlying SelectorHandler used to mange SelectionKeys. |
protected SelectableChannel |
underlyingChannel
The connection's SelectableChannel. |
Constructor Summary | |
---|---|
AbstractConnectorHandler()
|
Method Summary | |
---|---|
void |
connect(SocketAddress remoteAddress)
Connect to hostname:port. |
void |
connect(SocketAddress remoteAddress,
K callbackHandler)
Connect to hostname:port. |
void |
connect(SocketAddress remoteAddress,
K callbackHandler,
E selectorHandler)
Connect to hostname:port. |
void |
connect(SocketAddress remoteAddress,
SocketAddress localAddress,
K callbackHandler)
Connect to hostname:port. |
K |
getCallbackHandler()
Return the CallbackHandler . |
Controller |
getController()
Return the Controller |
E |
getSelectorHandler()
Return the associated SelectorHandler . |
SelectableChannel |
getUnderlyingChannel()
Return the current SelectableChannel used. |
boolean |
isConnected()
Is the underlying channel connected. |
Controller.Protocol |
protocol()
Get the ConnectorHandler Controller.Protocol . |
void |
protocol(Controller.Protocol protocol)
Set the ConnectorHandler Controller.Protocol . |
long |
read(ByteBuffer byteBuffer,
boolean blocking)
Read bytes. |
Future<AsyncQueueReadUnit> |
readFromAsyncQueue(ByteBuffer buffer,
AsyncReadCallbackHandler callbackHandler)
Method reads data to the ByteBuffer using async read queue. |
Future<AsyncQueueReadUnit> |
readFromAsyncQueue(ByteBuffer buffer,
AsyncReadCallbackHandler callbackHandler,
AsyncReadCondition condition)
Method reads data to the ByteBuffer using async read queue. |
Future<AsyncQueueReadUnit> |
readFromAsyncQueue(ByteBuffer buffer,
AsyncReadCallbackHandler callbackHandler,
AsyncReadCondition condition,
AsyncQueueDataProcessor readPostProcessor)
Method reads data to the ByteBuffer using async read queue. |
void |
setCallbackHandler(K callbackHandler)
Set the CallbackHandler . |
void |
setController(Controller controller)
Set the Controller to use with this instance. |
void |
setSelectorHandler(E selectorHandler)
Set the associated SelectorHandler |
void |
setUnderlyingChannel(SelectableChannel underlyingChannel)
Set the SelectableChannel . |
long |
write(ByteBuffer byteBuffer,
boolean blocking)
Writes bytes. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(ByteBuffer buffer)
Method writes ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler)
Method writes ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler,
AsyncQueueDataProcessor writePreProcessor)
Method writes ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler,
AsyncQueueDataProcessor writePreProcessor,
ByteBufferCloner cloner)
Method writes ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(SocketAddress dstAddress,
ByteBuffer buffer)
Method sends ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(SocketAddress dstAddress,
ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler)
Method sends ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(SocketAddress dstAddress,
ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler,
AsyncQueueDataProcessor writePreProcessor)
Method sends ByteBuffer using async write queue. |
Future<AsyncQueueWriteUnit> |
writeToAsyncQueue(SocketAddress dstAddress,
ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler,
AsyncQueueDataProcessor writePreProcessor,
ByteBufferCloner cloner)
Method sends ByteBuffer using async write queue. |
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.ConnectorHandler |
---|
close, connect, connect, finishConnect |
Field Detail |
---|
protected Controller.Protocol protocol
Controller.Protocol
.
protected Controller controller
protected E extends SelectorHandler selectorHandler
protected K extends CallbackHandler callbackHandler
CallbackHandler
handler invoked by the SelectorHandler
when a non blocking operation is ready to be processed.
protected SelectableChannel underlyingChannel
protected volatile boolean isConnected
protected InputReader inputStream
InputStream
that use a pool of Selector
to execute a blocking read operation.
Constructor Detail |
---|
public AbstractConnectorHandler()
Method Detail |
---|
public Controller.Protocol protocol()
Controller.Protocol
.
protocol
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
Controller.Protocol
.public void protocol(Controller.Protocol protocol)
Controller.Protocol
.
protocol
- the ConnectorHandler Controller.Protocol
.public void setController(Controller controller)
Controller
to use with this instance.
setController
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
controller
- the Controller
to use with this instance.public Controller getController()
Controller
getController
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
Controller
public E getSelectorHandler()
SelectorHandler
.
getSelectorHandler
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
SelectorHandler
.public void connect(SocketAddress remoteAddress, K callbackHandler) throws IOException
Controller
will invoke
the CallBackHandler.
connect
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
remoteAddress
- remote address to connectcallbackHandler
- the handler invoked by its associated SelectorHandler
when
a non blocking operation is ready to be handled. When null, all
read and write operation will be delegated to the default
ProtocolChain
and its list of ProtocolFilter
. When null, this ConnectorHandler
will create an instance of DefaultCallbackHandler
.
IOException
public void connect(SocketAddress remoteAddress) throws IOException
connect
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
remoteAddress
- remote address to connect
IOException
public void connect(SocketAddress remoteAddress, K callbackHandler, E selectorHandler) throws IOException
Controller
will invoke
the CallBackHandler.
connect
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
remoteAddress
- remote address to connectcallbackHandler
- the handler invoked by its associated SelectorHandler
when
a non blocking operation is ready to be handled. When null, all
read and write operation will be delegated to the default
ProtocolChain
and its list of ProtocolFilter
. When null, this ConnectorHandler
will create an instance of DefaultCallbackHandler
.selectorHandler
- an instance of SelectorHandler.
IOException
public void connect(SocketAddress remoteAddress, SocketAddress localAddress, K callbackHandler) throws IOException
Controller
will invoke
the CallBackHandler.
connect
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
remoteAddress
- remote address to connectlocalAddress
- local address to bindcallbackHandler
- the handler invoked by its associated SelectorHandler
when
a non blocking operation is ready to be handled. When null, all
read and write operation will be delegated to the default
ProtocolChain
and its list of ProtocolFilter
. When null, this ConnectorHandler
will create an instance of DefaultCallbackHandler
.
IOException
public void setSelectorHandler(E selectorHandler)
SelectorHandler
selectorHandler
- the associated SelectorHandler
.public SelectableChannel getUnderlyingChannel()
SelectableChannel
used.
getUnderlyingChannel
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
SelectableChannel
used.public void setUnderlyingChannel(SelectableChannel underlyingChannel)
SelectableChannel
.
underlyingChannel
- the SelectableChannel
to use.public K getCallbackHandler()
CallbackHandler
.
getCallbackHandler
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
CallbackHandler
.public void setCallbackHandler(K callbackHandler)
CallbackHandler
.
setCallbackHandler
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
callbackHandler
- the CallbackHandler
.public boolean isConnected()
isConnected
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
public long read(ByteBuffer byteBuffer, boolean blocking) throws IOException
Selector
will be used to read bytes.
read
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
byteBuffer
- The byteBuffer to store bytes.blocking
- true if a a pool of temporary Selector
is required to handle a blocking read.
IOException
public long write(ByteBuffer byteBuffer, boolean blocking) throws IOException
Selector
will be used to writes bytes.
write
in interface ConnectorHandler<E extends SelectorHandler,K extends CallbackHandler>
byteBuffer
- The byteBuffer to write.blocking
- true if a a pool of temporary Selector
is required to handle a blocking write.
IOException
public Future<AsyncQueueReadUnit> readFromAsyncQueue(ByteBuffer buffer, AsyncReadCallbackHandler callbackHandler) throws IOException
ByteBuffer
using async read queue.
First, if read queue is empty - it tries to read to the
ByteBuffer
directly (without putting to the queue).
If associated read queue is not empty or after direct reading
ByteBuffer
still has remaining place for next read -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct reading - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a reading queue - exception notification will come via
AsyncReadCallbackHandler.onIOException()
readFromAsyncQueue
in interface AsyncQueueReadable
buffer
- ByteBuffer
callbackHandler
- AsyncReadCallbackHandler
,
which will get notified, when
ByteBuffer
will get full
ByteBuffer
was read completely,
false if read operation was put to queue
IOException
public Future<AsyncQueueReadUnit> readFromAsyncQueue(ByteBuffer buffer, AsyncReadCallbackHandler callbackHandler, AsyncReadCondition condition) throws IOException
ByteBuffer
using async read queue.
First, if read queue is empty - it tries to read to the
ByteBuffer
directly (without putting to the queue).
If associated read queue is not empty or after direct reading
ByteBuffer
still has remaining place for next read -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct reading - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a reading queue - exception notification will come via
AsyncReadCallbackHandler.onIOException()
readFromAsyncQueue
in interface AsyncQueueReadable
buffer
- ByteBuffer
callbackHandler
- AsyncReadCallbackHandler
,
which will get notified, when
ByteBuffer
will get fullcondition
- AsyncReadCondition
, which will be called to
check if read data is complete, and callbackHandler could
be called
ByteBuffer
was read completely,
false if read operation was put to queue
IOException
public Future<AsyncQueueReadUnit> readFromAsyncQueue(ByteBuffer buffer, AsyncReadCallbackHandler callbackHandler, AsyncReadCondition condition, AsyncQueueDataProcessor readPostProcessor) throws IOException
ByteBuffer
using async read queue.
First, if read queue is empty - it tries to read to the
ByteBuffer
directly (without putting to the queue).
If associated read queue is not empty or after direct reading
ByteBuffer
still has remaining place for next read -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct reading - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a reading queue - exception notification will come via
AsyncReadCallbackHandler.onIOException()
readFromAsyncQueue
in interface AsyncQueueReadable
buffer
- ByteBuffer
callbackHandler
- AsyncReadCallbackHandler
,
which will get notified, when
ByteBuffer
will get fullcondition
- AsyncReadCondition
, which will be called to
check if read data is complete, and callbackHandler could
be calledreadPostProcessor
- post processor, to be called to process read data
ByteBuffer
was read completely,
false if read operation was put to queue
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(ByteBuffer buffer) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to write ByteBuffer
directly (without putting to the queue).
If associated write queue is not empty or after direct writing
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise it will be just logged by
Grizzly framework.
writeToAsyncQueue
in interface AsyncQueueWritable
buffer
- ByteBuffer
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to write ByteBuffer
directly (without putting to the queue).
If associated write queue is not empty or after direct writing
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a writing queue - exception notification will come via
AsyncWriteCallbackHandler.onIOException()
writeToAsyncQueue
in interface AsyncQueueWritable
buffer
- ByteBuffer
callbackHandler
- AsyncWriteCallbackHandler
,
which will get notified, when
ByteBuffer
will be completely written
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to write ByteBuffer
directly (without putting to the queue).
If associated write queue is not empty or after direct writing
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a writing queue - exception notification will come via
AsyncWriteCallbackHandler.onIOException()
Before data will be written on SelectableChannel
, first it
will be passed for preprocessing to AsyncQueueDataProcessor
,
and then preprocessor result data
(AsyncQueueDataProcessor.getResultByteBuffer()
) will be
written on the SelectableChannel
.
writeToAsyncQueue
in interface AsyncQueueWritable
buffer
- ByteBuffer
callbackHandler
- AsyncWriteCallbackHandler
,
which will get notified, when
ByteBuffer
will be completely writtenwritePreProcessor
- AsyncQueueDataProcessor
, which
will perform data processing, before it will be
written on SelectableChannel
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor, ByteBufferCloner cloner) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to write ByteBuffer
directly (without putting to the queue).
If associated write queue is not empty or after direct writing
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a writing queue - exception notification will come via
AsyncWriteCallbackHandler.onIOException()
Before data will be written on SelectableChannel
, first it
will be passed for preprocessing to AsyncQueueDataProcessor
,
and then preprocessor result data
(AsyncQueueDataProcessor.getResultByteBuffer()
) will be
written on the SelectableChannel
.
writeToAsyncQueue
in interface AsyncQueueWritable
buffer
- ByteBuffer
callbackHandler
- AsyncWriteCallbackHandler
,
which will get notified, when
ByteBuffer
will be completely writtenwritePreProcessor
- AsyncQueueDataProcessor
, which
will perform data processing, before it will be
written on SelectableChannel
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to send ByteBuffer
to the given SocketAddress
directly
(without putting to the queue).
If associated write queue is not empty or after direct sending
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise it will be just logged by
Grizzly framework.
writeToAsyncQueue
in interface AsyncQueueWritable
dstAddress
- destination SocketAddress
data will
be sent tobuffer
- ByteBuffer
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to send ByteBuffer
to the given SocketAddress
directly
(without putting to the queue).
If associated write queue is not empty or after direct sending
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a writing queue - exception notification will come via
AsyncWriteCallbackHandler.onIOException()
writeToAsyncQueue
in interface AsyncQueueWritable
dstAddress
- destination SocketAddress
data will
be sent tobuffer
- ByteBuffer
callbackHandler
- AsyncWriteCallbackHandler
,
which will get notified, when
ByteBuffer
will be completely written
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to send ByteBuffer
to the given SocketAddress
directly
(without putting to the queue).
If associated write queue is not empty or after direct sending
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a writing queue - exception notification will come via
AsyncWriteCallbackHandler.onIOException()
Before data will be written on SelectableChannel
, first it
will be passed for preprocessing to AsyncQueueDataProcessor
,
and then preprocessor result data
(AsyncQueueDataProcessor.getResultByteBuffer()
) will be
written on the SelectableChannel
.
writeToAsyncQueue
in interface AsyncQueueWritable
dstAddress
- destination SocketAddress
data will
be sent tobuffer
- ByteBuffer
callbackHandler
- AsyncWriteCallbackHandler
,
which will get notified, when
ByteBuffer
will be completely writtenwritePreProcessor
- AsyncQueueDataProcessor
, which
will perform data processing, before it will be
written on SelectableChannel
IOException
public Future<AsyncQueueWriteUnit> writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor, ByteBufferCloner cloner) throws IOException
ByteBuffer
using async write queue.
First, if write queue is empty - it tries to send ByteBuffer
to the given SocketAddress
directly
(without putting to the queue).
If associated write queue is not empty or after direct sending
ByteBuffer
still has ready data to be written -
ByteBuffer
will be added to AsyncQueue
.
If an exception occurs, during direct writing - it will be propagated
to the caller directly, otherwise, if the ByteBuffer
is
added to a writing queue - exception notification will come via
AsyncWriteCallbackHandler.onIOException()
Before data will be written on SelectableChannel
, first it
will be passed for preprocessing to AsyncQueueDataProcessor
,
and then preprocessor result data
(AsyncQueueDataProcessor.getResultByteBuffer()
) will be
written on the SelectableChannel
.
writeToAsyncQueue
in interface AsyncQueueWritable
dstAddress
- destination SocketAddress
data will
be sent tobuffer
- ByteBuffer
callbackHandler
- AsyncWriteCallbackHandler
,
which will get notified, when
ByteBuffer
will be completely writtenwritePreProcessor
- AsyncQueueDataProcessor
, which
will perform data processing, before it will be
written on SelectableChannel
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |