java.io.Closeable, java.lang.AutoCloseable, ConnectionNegotiatingClientConnection, SslConnectionpublic abstract class AbstractConnection extends java.lang.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.
Connection.Listener, Connection.UpgradeFrom, Connection.UpgradeTo| Modifier | Constructor | Description |
|---|---|---|
protected |
AbstractConnection(EndPoint endp,
java.util.concurrent.Executor executor) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addListener(Connection.Listener listener) |
Adds a listener of connection events.
|
void |
close() |
Performs a logical close of this connection.
|
protected void |
failedCallback(Callback callback,
java.lang.Throwable x) |
|
void |
fillInterested() |
Utility method to be called to register read interest.
|
long |
getBytesIn() |
|
long |
getBytesOut() |
|
long |
getCreatedTimeStamp() |
|
EndPoint |
getEndPoint() |
|
protected java.util.concurrent.Executor |
getExecutor() |
|
int |
getInputBufferSize() |
|
long |
getMessagesIn() |
|
long |
getMessagesOut() |
|
boolean |
isFillInterested() |
|
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(java.lang.Throwable cause) |
Callback method invoked when the endpoint failed to be ready to be read.
|
boolean |
onIdleExpired() |
Callback method invoked upon an idle timeout event.
|
void |
onOpen() |
Callback method invoked when this connection is opened.
|
protected boolean |
onReadTimeout(java.lang.Throwable timeout) |
Callback method invoked when the endpoint failed to be ready to be read after a timeout
|
void |
removeListener(Connection.Listener listener) |
Removes a listener of connection events.
|
void |
setInputBufferSize(int inputBufferSize) |
|
java.lang.String |
toConnectionString() |
|
java.lang.String |
toString() |
|
void |
tryFillInterested() |
|
void |
tryFillInterested(Callback callback) |
protected AbstractConnection(EndPoint endp, java.util.concurrent.Executor executor)
public void addListener(Connection.Listener listener)
ConnectionAdds a listener of connection events.
addListener in interface Connectionlistener - the listener to addpublic void removeListener(Connection.Listener listener)
ConnectionRemoves a listener of connection events.
removeListener in interface Connectionlistener - the listener to removepublic int getInputBufferSize()
public void setInputBufferSize(int inputBufferSize)
protected java.util.concurrent.Executor getExecutor()
protected void failedCallback(Callback callback, java.lang.Throwable x)
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 tryFillInterested()
public void tryFillInterested(Callback callback)
public boolean isFillInterested()
public abstract void onFillable()
Callback method invoked when the endpoint is ready to be read.
fillInterested()protected void onFillInterestedFailed(java.lang.Throwable cause)
Callback method invoked when the endpoint failed to be ready to be read.
cause - the exception that caused the failureprotected boolean onReadTimeout(java.lang.Throwable timeout)
Callback method invoked when the endpoint failed to be ready to be read after a timeout
timeout - the cause of the read timeoutpublic 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 Connection.public 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 java.lang.AutoCloseableclose in interface java.io.Closeableclose in interface Connectionpublic boolean onIdleExpired()
ConnectionCallback method invoked upon an idle timeout event.
Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.
When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.
onIdleExpired in interface Connectionpublic long getMessagesIn()
getMessagesIn in interface Connectionpublic long getMessagesOut()
getMessagesOut in interface Connectionpublic long getBytesIn()
getBytesIn in interface Connectionpublic long getBytesOut()
getBytesOut in interface Connectionpublic long getCreatedTimeStamp()
getCreatedTimeStamp in interface Connectionpublic final java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toConnectionString()
Copyright © 1995–2018 Webtide. All rights reserved.