Class AbstractConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Connection
,Invocable
- Direct Known Subclasses:
AbstractMetaDataConnection
,ConnectHandler.DownstreamConnection
,ConnectHandler.UpstreamConnection
,HTTP2Connection
,HTTP3StreamConnection
,HttpConnectionOverFCGI
,HttpConnectionOverHTTP
,InstructionStreamConnection
,NegotiatingClientConnection
,NegotiatingServerConnection
,ProxyProtocolClientConnectionFactory.ProxyProtocolConnection
,QuicConnection
,SslConnection
,UnidirectionalStreamConnection
,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
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
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
Deprecated.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
onIdleExpired
(TimeoutException timeoutException) Callback method invoked upon an idle timeout event.void
onOpen()
Callback method invoked when this connection is opened.protected boolean
onReadTimeout
(TimeoutException timeout) Callback method invoked when the endpoint failed to be ready to be read after a timeoutvoid
removeEventListener
(EventListener eventListener) Removes a listener of connection events.void
setInputBufferSize
(int inputBufferSize) final String
toString()
void
tryFillInterested
(Callback callback)
-
Constructor Details
-
AbstractConnection
-
-
Method Details
-
getInvocationType
Deprecated.- Specified by:
getInvocationType
in interfaceInvocable
- Returns:
- The InvocationType of this object
-
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:
eventListener
- 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
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
-