Top Description Inners Fields Constructors Methods
org.eclipse.jetty.io

public abstract Class AbstractConnection

extends Object
implements Connection, Invocable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.thread.Invocable, org.eclipse.jetty.io.Connection, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.eclipse.jetty.io.NegotiatingClientConnection, org.eclipse.jetty.io.ssl.SslConnection
Imports
java.util.EventListener, .List, java.util.concurrent.CopyOnWriteArrayList, .Executor, .RejectedExecutionException, .TimeoutException, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.thread.Invocable, org.slf4j.Logger, .LoggerFactory

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 and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final long
private final EndPoint
private final Executor
private int
private final List<Connection.Listener>
private final Callback
private static final Logger

Constructor Summary

AccessConstructor and Description
protected
AbstractConnection(EndPoint endPoint, Executor executor)

Method Summary

Modifier and TypeMethod and Description
public void
addEventListener(EventListener
the listener to add
listener
)

Implements org.eclipse.jetty.io.Connection.addEventListener.

Adds a listener of connection events.

public void
close()

Implements org.eclipse.jetty.io.Connection.close.

Performs a logical close of this connection.

protected void
failedCallback(final Callback callback, final Throwable x)

public void
fillInterested()

Utility method to be called to register read interest.

public long
public long
public long
public EndPoint
protected Executor
public int
public Invocable.InvocationType
public long
public long
public boolean
public void
onClose(Throwable
The cause of the close or null for a normal close
cause
)

Implements org.eclipse.jetty.io.Connection.onClose.

Callback method invoked when this connection is closed.

private void
public abstract void
onFillable()

Callback method invoked when the endpoint is ready to be read.

protected void
onFillInterestedFailed(Throwable
the exception that caused the failure
cause
)

Callback method invoked when the endpoint failed to be ready to be read.

public boolean
onIdleExpired(TimeoutException timeoutException)

Implements org.eclipse.jetty.io.Connection.onIdleExpired.

Callback method invoked upon an idle timeout event.

public void
onOpen()

Implements org.eclipse.jetty.io.Connection.onOpen.

Callback method invoked when this connection is opened.

private void
protected boolean

Returns:

true to signal that the endpoint must be closed, false to keep the endpoint open
onReadTimeout
(TimeoutException
the cause of the read timeout
timeout
)

Callback method invoked when the endpoint failed to be ready to be read after a timeout

public void
removeEventListener(EventListener
the listener to remove
eventListener
)

Implements org.eclipse.jetty.io.Connection.removeEventListener.

Removes a listener of connection events.

public void
setInputBufferSize(int inputBufferSize)

public String
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_createdback to summary
private final long _created
_endPointback to summary
private final EndPoint _endPoint
_executorback to summary
private final Executor _executor
_inputBufferSizeback to summary
private int _inputBufferSize
_listenersback to summary
private final List<Connection.Listener> _listeners
_readCallbackback to summary
private final Callback _readCallback
LOGback to summary
private static final Logger LOG

Constructor Detail

AbstractConnectionback to summary
protected AbstractConnection(EndPoint endPoint, Executor executor)

Method Detail

addEventListenerback to summary
public void addEventListener(EventListener listener)

Implements org.eclipse.jetty.io.Connection.addEventListener.

Doc from org.eclipse.jetty.io.Connection.addEventListener.

Adds a listener of connection events.

Parameters
listener:EventListener

the listener to add

Annotations
@Override
closeback to summary
public void close()

Implements org.eclipse.jetty.io.Connection.close.

Doc from org.eclipse.jetty.io.Connection.close.

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 associated EndPoint.

Annotations
@Override
failedCallbackback to summary
protected void failedCallback(final Callback callback, final Throwable x)
fillInterestedback to summary
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.

See Also
onFillable()
getBytesInback to summary
public long getBytesIn()

Implements org.eclipse.jetty.io.Connection.getBytesIn.

Annotations
@Override
getBytesOutback to summary
public long getBytesOut()

Implements org.eclipse.jetty.io.Connection.getBytesOut.

Annotations
@Override
getCreatedTimeStampback to summary
public long getCreatedTimeStamp()

Implements org.eclipse.jetty.io.Connection.getCreatedTimeStamp.

Annotations
@Override
getEndPointback to summary
public EndPoint getEndPoint()

Implements org.eclipse.jetty.io.Connection.getEndPoint.

Returns:EndPoint

Doc from org.eclipse.jetty.io.Connection.getEndPoint.

the EndPoint associated with this Connection.

Annotations
@Override
getExecutorback to summary
protected Executor getExecutor()
getInputBufferSizeback to summary
public int getInputBufferSize()
getInvocationTypeback to summary
public Invocable.InvocationType getInvocationType()

Overrides default org.eclipse.jetty.util.thread.Invocable.getInvocationType.

Deprecated

Returns:Invocable.InvocationType

Doc from org.eclipse.jetty.util.thread.Invocable.getInvocationType.

The InvocationType of this object

Annotations
@Deprecated
@Override
getMessagesInback to summary
public long getMessagesIn()

Implements org.eclipse.jetty.io.Connection.getMessagesIn.

Annotations
@Override
getMessagesOutback to summary
public long getMessagesOut()

Implements org.eclipse.jetty.io.Connection.getMessagesOut.

Annotations
@Override
isFillInterestedback to summary
public boolean isFillInterested()
onCloseback to summary
public void onClose(Throwable cause)

Implements org.eclipse.jetty.io.Connection.onClose.

Doc from org.eclipse.jetty.io.Connection.onClose.

Callback method invoked when this connection is closed.

Creators of the connection implementation are responsible for calling this method.

Parameters
cause:Throwable

The cause of the close or null for a normal close

Annotations
@Override
onClosedback to summary
private void onClosed(Connection.Listener listener)
onFillableback to summary
public abstract void onFillable()

Callback method invoked when the endpoint is ready to be read.

See Also
fillInterested()
onFillInterestedFailedback to summary
protected void onFillInterestedFailed(Throwable cause)

Callback method invoked when the endpoint failed to be ready to be read.

Parameters
cause:Throwable

the exception that caused the failure

onIdleExpiredback to summary
public boolean onIdleExpired(TimeoutException timeoutException)

Implements org.eclipse.jetty.io.Connection.onIdleExpired.

Doc from org.eclipse.jetty.io.Connection.onIdleExpired.

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.

Returns:boolean

true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.

Annotations
@Override
onOpenback to summary
public void onOpen()

Implements org.eclipse.jetty.io.Connection.onOpen.

Doc from org.eclipse.jetty.io.Connection.onOpen.

Callback method invoked when this connection is opened.

Creators of the connection implementation are responsible for calling this method.

Annotations
@Override
onOpenedback to summary
private void onOpened(Connection.Listener listener)
onReadTimeoutback to summary
protected boolean onReadTimeout(TimeoutException timeout)

Callback method invoked when the endpoint failed to be ready to be read after a timeout

Parameters
timeout:TimeoutException

the cause of the read timeout

Returns:boolean

true to signal that the endpoint must be closed, false to keep the endpoint open

removeEventListenerback to summary
public void removeEventListener(EventListener eventListener)

Implements org.eclipse.jetty.io.Connection.removeEventListener.

Doc from org.eclipse.jetty.io.Connection.removeEventListener.

Removes a listener of connection events.

Parameters
eventListener:EventListener

the listener to remove

Annotations
@Override
setInputBufferSizeback to summary
public void setInputBufferSize(int inputBufferSize)
toConnectionStringback to summary
public String toConnectionString()
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryFillInterestedback to summary
public void tryFillInterested(Callback callback)
org.eclipse.jetty.io back to summary

private Class AbstractConnection.ReadCallback

extends Object
implements Callback, Invocable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.thread.Invocable, org.eclipse.jetty.util.Callback

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
failed(Throwable
the reason for the operation failure
x
)

Overrides default org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

public Invocable.InvocationType
public void
succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

ReadCallbackback to summary
private ReadCallback()

Method Detail

failedback to summary
public void failed(Throwable x)

Overrides default org.eclipse.jetty.util.Callback.failed.

Doc from org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

Parameters
x:Throwable

the reason for the operation failure

Annotations
@Override
getInvocationTypeback to summary
public Invocable.InvocationType getInvocationType()

Overrides default org.eclipse.jetty.util.thread.Invocable.getInvocationType.

Returns:Invocable.InvocationType

Doc from org.eclipse.jetty.util.thread.Invocable.getInvocationType.

The InvocationType of this object

Annotations
@Override
succeededback to summary
public void succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Doc from org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override