Class AbstractConnection
- All Implemented Interfaces:
 Closeable, AutoCloseable, Connection
- Direct Known Subclasses:
 AbstractConnection.NonBlocking, AbstractMetaDataConnection, HTTP2Connection, HTTP3StreamConnection, QuicheConnection, SslConnection, WebSocketConnection
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.
- 
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface Connection
Connection.Listener, Connection.Tunnel, Connection.UpgradeFrom, Connection.UpgradeTo - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(EventListener listener) Adds a listener of connection events.voidclose()Performs a logical close of this connection.voidRegisters read interest using the defaultCallbackwithInvocable.InvocationType.BLOCKING.voidfillInterested(Callback callback) Registers read interest with the given callback.longlonglongprotected ExecutorintlonglongbooleanvoidCallback method invoked when this connection is closed.abstract voidCallback method invoked when the endpoint is ready to be read.voidonFillInterestedFailed(Throwable cause) Callback method invoked when the endpoint failed to be ready to be read.booleanonIdleExpired(TimeoutException timeoutException) Callback method invoked upon an idle timeout event.voidonOpen()Callback method invoked when this connection is opened.protected booleanonReadTimeout(TimeoutException timeout) Callback method invoked when the endpoint failed to be ready to be read after a timeoutvoidremoveEventListener(EventListener eventListener) Removes a listener of connection events.voidsetInputBufferSize(int inputBufferSize) final StringtoString()voidtryFillInterested(Callback callback)  
- 
Constructor Details
- 
AbstractConnection
 
 - 
 - 
Method Details
- 
addEventListener
Description copied from interface:ConnectionAdds a listener of connection events.
- Specified by:
 addEventListenerin interfaceConnection- Parameters:
 listener- the listener to add
 - 
removeEventListener
Description copied from interface:ConnectionRemoves a listener of connection events.
- Specified by:
 removeEventListenerin interfaceConnection- Parameters:
 eventListener- the listener to remove
 - 
getInputBufferSize
public int getInputBufferSize() - 
setInputBufferSize
public void setInputBufferSize(int inputBufferSize)  - 
getExecutor
 - 
fillInterested
public void fillInterested()Registers read interest using the default
CallbackwithInvocable.InvocationType.BLOCKING.When read readiness is signaled,
onFillable()oronFillInterestedFailed(Throwable)will be invoked.This method should be used sparingly, mainly from
onOpen(), andfillInterested(Callback)should be preferred instead, passing aCallbackthat specifies theInvocable.InvocationTypefor each specific case where read interest needs to be registered.- See Also:
 
 - 
fillInterested
Registers read interest with the given callback.
When read readiness is signaled, the callback will be completed.
- Parameters:
 callback- the callback to complete when read readiness is signaled
 - 
tryFillInterested
 - 
isFillInterested
public boolean isFillInterested() - 
onFillable
public abstract void onFillable()Callback method invoked when the endpoint is ready to be read.
- See Also:
 
 - 
onFillInterestedFailed
Callback method invoked when the endpoint failed to be ready to be read.
- Parameters:
 cause- the exception that caused the failure
 - 
onReadTimeout
Callback method invoked when the endpoint failed to be ready to be read after a timeout
- Parameters:
 timeout- the cause of the read timeout- Returns:
 - true to signal that the endpoint must be closed, false to keep the endpoint open
 
 - 
onOpen
public void onOpen()Description copied from interface:ConnectionCallback method invoked when this connection is opened.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
 onOpenin interfaceConnection
 - 
onClose
Description copied from interface:ConnectionCallback method invoked when this connection is closed.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
 onClosein interfaceConnection- Parameters:
 cause- The cause of the close or null for a normal close
 - 
getEndPoint
- Specified by:
 getEndPointin interfaceConnection- Returns:
 - the 
EndPointassociated with this Connection. 
 - 
close
public void close()Description copied from interface:ConnectionPerforms a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPointbut, for example, SSL connections should write the SSL close message before closing the associatedEndPoint.- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Specified by:
 closein interfaceConnection
 - 
onIdleExpired
Description copied from interface: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.
- Specified by:
 onIdleExpiredin interfaceConnection- Returns:
 - true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
 
 - 
getMessagesIn
public long getMessagesIn()- Specified by:
 getMessagesInin interfaceConnection
 - 
getMessagesOut
public long getMessagesOut()- Specified by:
 getMessagesOutin interfaceConnection
 - 
getBytesIn
public long getBytesIn()- Specified by:
 getBytesInin interfaceConnection
 - 
getBytesOut
public long getBytesOut()- Specified by:
 getBytesOutin interfaceConnection
 - 
getCreatedTimeStamp
public long getCreatedTimeStamp()- Specified by:
 getCreatedTimeStampin interfaceConnection
 - 
toString
 - 
toConnectionString
 
 -