Class AbstractConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,Connection
- Direct Known Subclasses:
HTTP2Connection,HttpConnection,HttpConnectionOverFCGI,HttpConnectionOverHTTP,NegotiatingClientConnection,NegotiatingServerConnection,ProxyConnection,ProxyProtocolClientConnectionFactory.ProxyProtocolConnection,QuicConnection,ServerFCGIConnection,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 classes/interfaces inherited from interface org.eclipse.jetty.io.Connection
Connection.Listener, 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.protected voidfailedCallback(Callback callback, Throwable x) voidUtility method to be called to register read interest.longlonglongprotected ExecutorintlonglongbooleanvoidCallback method invoked when this connection is closed.abstract voidCallback method invoked when the endpoint is ready to be read.protected voidonFillInterestedFailed(Throwable cause) Callback method invoked when the endpoint failed to be ready to be read.booleanCallback method invoked upon an idle timeout event.voidonOpen()Callback method invoked when this connection is opened.protected booleanonReadTimeout(Throwable timeout) Callback method invoked when the endpoint failed to be ready to be read after a timeoutvoidremoveEventListener(EventListener listener) 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:
listener- the listener to remove
-
getInputBufferSize
public int getInputBufferSize() -
setInputBufferSize
public void setInputBufferSize(int inputBufferSize) -
getExecutor
-
failedCallback
-
fillInterested
public void fillInterested()Utility method to be called to register read interest.
After a call to this method,
onFillable()oronFillInterestedFailed(Throwable)will be called back as appropriate.- See Also:
-
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
public boolean 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
-