public abstract class AbstractConnection extends Object implements Connection
A convenience base implementation of Connection.
This class uses the capabilities of the EndPoint API to provide a
more traditional style of async reading. A call to fillInterested()
will schedule a callback to onFillable() or onFillInterestedFailed(Throwable)
as appropriate.
| Modifier and Type | Class and Description |
|---|---|
class |
AbstractConnection.FillingInterestedCallback |
class |
AbstractConnection.NestedState |
static class |
AbstractConnection.State |
Connection.Listener| Modifier and Type | Field and Description |
|---|---|
static boolean |
EXECUTE_ONFILLABLE |
static AbstractConnection.State |
FILL_INTERESTED |
static AbstractConnection.State |
FILLING |
static AbstractConnection.State |
FILLING_FILL_INTERESTED |
static AbstractConnection.State |
IDLE |
static AbstractConnection.State |
REFILLING |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConnection(EndPoint endp,
Executor executor) |
protected |
AbstractConnection(EndPoint endp,
Executor executor,
boolean executeOnfillable) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Connection.Listener listener) |
void |
close()
Performs a logical close of this connection.
|
protected void |
failedCallback(Callback callback,
Throwable x) |
void |
fillInterested()
Utility method to be called to register read interest.
|
void |
fillInterested(Callback callback) |
long |
getBytesIn() |
long |
getBytesOut() |
long |
getCreatedTimeStamp() |
EndPoint |
getEndPoint() |
protected Executor |
getExecutor() |
int |
getInputBufferSize() |
int |
getMessagesIn() |
int |
getMessagesOut() |
boolean |
next(AbstractConnection.State state,
AbstractConnection.State next) |
void |
onClose()
Callback method invoked when this
Connection is closed. |
abstract void |
onFillable()
Callback method invoked when the endpoint is ready to be read.
|
protected void |
onFillInterestedFailed(Throwable cause)
Callback method invoked when the endpoint failed to be ready to be read.
|
void |
onOpen()
Callback method invoked when this
Connection is opened. |
protected boolean |
onReadTimeout()
Callback method invoked when the endpoint failed to be ready to be read after a timeout
|
void |
setInputBufferSize(int inputBufferSize) |
String |
toString() |
public static final boolean EXECUTE_ONFILLABLE
public static final AbstractConnection.State IDLE
public static final AbstractConnection.State FILL_INTERESTED
public static final AbstractConnection.State FILLING
public static final AbstractConnection.State REFILLING
public static final AbstractConnection.State FILLING_FILL_INTERESTED
public void addListener(Connection.Listener listener)
addListener in interface Connectionpublic int getInputBufferSize()
public void setInputBufferSize(int inputBufferSize)
protected Executor getExecutor()
public void fillInterested()
Utility method to be called to register read interest.
After a call to this method, onFillable() or onFillInterestedFailed(Throwable)
will be called back as appropriate.
onFillable()public void fillInterested(Callback callback)
public abstract void onFillable()
Callback method invoked when the endpoint is ready to be read.
fillInterested()protected void onFillInterestedFailed(Throwable cause)
Callback method invoked when the endpoint failed to be ready to be read.
cause - the exception that caused the failureprotected boolean onReadTimeout()
Callback method invoked when the endpoint failed to be ready to be read after a timeout
public void onOpen()
ConnectionCallback method invoked when this Connection is opened.
Creators of the connection implementation are responsible for calling this method.
onOpen in interface Connectionpublic void onClose()
ConnectionCallback method invoked when this Connection is closed.
Creators of the connection implementation are responsible for calling this method.
onClose in interface Connectionpublic EndPoint getEndPoint()
getEndPoint in interface ConnectionEndPoint associated with this Connectionpublic void close()
ConnectionPerforms a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPoint but, for example, SSL connections should write the SSL close message
before closing the associated EndPoint.
close in interface Closeableclose in interface AutoCloseableclose in interface Connectionpublic int getMessagesIn()
getMessagesIn in interface Connectionpublic int getMessagesOut()
getMessagesOut in interface Connectionpublic long getBytesIn()
getBytesIn in interface Connectionpublic long getBytesOut()
getBytesOut in interface Connectionpublic long getCreatedTimeStamp()
getCreatedTimeStamp in interface Connectionpublic boolean next(AbstractConnection.State state, AbstractConnection.State next)
Copyright © 1995-2015 Webtide. All Rights Reserved.