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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(EventListener listener) Adds a listener of connection events.void
close()
Performs a logical close of this connection.protected void
failedCallback
(Callback callback, Throwable x) void
Utility method to be called to register read interest.long
long
long
protected Executor
int
long
long
boolean
void
Callback method invoked when this connection is closed.abstract void
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.boolean
Callback method invoked upon an idle timeout event.void
onOpen()
Callback method invoked when this connection is opened.protected boolean
onReadTimeout
(Throwable timeout) Callback method invoked when the endpoint failed to be ready to be read after a timeoutvoid
removeEventListener
(EventListener listener) Removes a listener of connection events.void
setInputBufferSize
(int inputBufferSize) final String
toString()
void
tryFillInterested
(Callback callback)
-
Constructor Details
-
AbstractConnection
-
-
Method Details
-
addEventListener
Description copied from interface:Connection
Adds a listener of connection events.
- Specified by:
addEventListener
in interfaceConnection
- Parameters:
listener
- the listener to add
-
removeEventListener
Description copied from interface:Connection
Removes a listener of connection events.
- Specified by:
removeEventListener
in 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:Connection
Callback method invoked when this connection is opened.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
onOpen
in interfaceConnection
-
onClose
Description copied from interface:Connection
Callback method invoked when this connection is closed.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
onClose
in interfaceConnection
- Parameters:
cause
- The cause of the close or null for a normal close
-
getEndPoint
- Specified by:
getEndPoint
in interfaceConnection
- Returns:
- the
EndPoint
associated with this Connection.
-
close
public void close()Description copied from interface:Connection
Performs 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 associatedEndPoint
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceConnection
-
onIdleExpired
public boolean onIdleExpired()Description copied from interface:Connection
Callback 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:
onIdleExpired
in 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:
getMessagesIn
in interfaceConnection
-
getMessagesOut
public long getMessagesOut()- Specified by:
getMessagesOut
in interfaceConnection
-
getBytesIn
public long getBytesIn()- Specified by:
getBytesIn
in interfaceConnection
-
getBytesOut
public long getBytesOut()- Specified by:
getBytesOut
in interfaceConnection
-
getCreatedTimeStamp
public long getCreatedTimeStamp()- Specified by:
getCreatedTimeStamp
in interfaceConnection
-
toString
-
toConnectionString
-