H
- the parameterization lower bounded by AbstractFilteredHandler
itself.C
- the Connection
type.T
- the Filter
inbound type.public abstract class AbstractFilteredHandler<H extends AbstractFilteredHandler<H,C,T>,C extends Connection,T> extends Object implements FilteredHandler<H,C,T>, OobHandler<C>, Closeable
FilteredHandler
.ConnectionHandler.ClosingType
Modifier and Type | Field and Description |
---|---|
protected static Future<?> |
dummyFuture
A trivial
Future that returns immediately with null . |
Constructor and Description |
---|
AbstractFilteredHandler(String name)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
C |
getConnection()
Gets the
Connection associated with this handler. |
void |
onBind()
On binding.
|
void |
onClosing(ConnectionHandler.ClosingType type,
ByteBuffer bb)
On closure.
|
Future<?> |
onOob(OobEvent evt)
On receipt of a user-defined
OobEvent . |
protected void |
onOob(OobEvent evt,
ByteBuffer bb)
|
void |
onReceive(ByteBuffer bb)
On receipt of data.
|
int |
send(T output)
Sends the given output value to the remote host.
|
void |
setConnection(C connection)
Sets the
Connection associated with this handler. |
H |
setFilterFactory(FilterFactory<? extends Filter<T,ByteBuffer>,T,ByteBuffer,? super H> filterFactory)
Sets the
FilterFactory from which appropriate Filter s will be derived. |
String |
toString()
Creates a human-readable representation of this handler.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
onBind, onClosing, onReceive
onClose
public AbstractFilteredHandler(String name)
public H setFilterFactory(FilterFactory<? extends Filter<T,ByteBuffer>,T,ByteBuffer,? super H> filterFactory)
FilteredHandler
FilterFactory
from which appropriate Filter
s will be derived.setFilterFactory
in interface FilteredHandler<H extends AbstractFilteredHandler<H,C,T>,C extends Connection,T>
filterFactory
- the FilterFactory
.public int send(T output)
FilteredHandler
send
in interface FilteredHandler<H extends AbstractFilteredHandler<H,C,T>,C extends Connection,T>
output
- the output value.public void onBind()
ConnectionHandler
onBind
in interface ConnectionHandler<C extends Connection>
public void onReceive(ByteBuffer bb)
ConnectionHandler
onReceive
in interface ConnectionHandler<C extends Connection>
bb
- the ByteBuffer
containing data.public void onClosing(ConnectionHandler.ClosingType type, ByteBuffer bb)
ConnectionHandler
onClosing
in interface ConnectionHandler<C extends Connection>
type
- the ConnectionHandler.ClosingType
.bb
- the ByteBuffer
containing data. It must be completely drained, as this is the final callback.ConnectionHandler.ClosingType
public Future<?> onOob(OobEvent evt)
OobHandler
OobEvent
.onOob
in interface OobHandler<C extends Connection>
evt
- the OobEvent
.Future
for waiting on completion of out-of-band processing, which may occur asynchronously on
another thread.public C getConnection()
ConnectionHandler
Connection
associated with this handler.getConnection
in interface ConnectionHandler<C extends Connection>
public void setConnection(C connection)
ConnectionHandler
Connection
associated with this handler.setConnection
in interface ConnectionHandler<C extends Connection>
connection
- the Connection
.public void close()
close
in interface Closeable
close
in interface AutoCloseable
public String toString()
ConnectionHandler
toString
in interface ConnectionHandler<C extends Connection>
toString
in class Object
protected void onOob(OobEvent evt, ByteBuffer bb)