Top Description Inners Fields Constructors Methods
org.eclipse.jetty.websocket.core.util

public abstract Class TransformingFlusher

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jetty.websocket.core.internal.PerMessageDeflateExtension.OutgoingFlusher, org.eclipse.jetty.websocket.core.util.FragmentingFlusher
Imports
java.util.ArrayDeque, .Queue, org.eclipse.jetty.util.Callback, .IteratingCallback, .StaticException, org.eclipse.jetty.util.thread.AutoLock, org.eclipse.jetty.websocket.core.Frame, org.eclipse.jetty.websocket.core.internal.FrameEntry, org.slf4j.Logger, .LoggerFactory

This is used to iteratively transform or process a frame into one or more other frames. When a frame is ready to be processed onFrame(Frame, Callback, boolean) is called. Subsequent calls to transform(Callback) are made on each callback success until one of these calls returns true to indicate they are done processing the frame and are ready to receive a new one. The Callback passed in to both these method must be succeeded in order to continue processing.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Queue<FrameEntry>
private Throwable
private boolean
private final IteratingCallback
private final AutoLock
private final Logger
private static final Throwable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
closeFlusher()

Used to close this flusher when there is no explicit failure.

public void
failFlusher(Throwable
the failure.
t
)

Used to fail this flusher possibly from an external event such as a callback.

private void
private void
private void
protected abstract boolean

Returns:

true to indicate that you have finished transforming this frame.
onFrame
(Frame
the frame to transform.
frame
,
Callback
used to signal to start processing again.
callback
,
boolean
whether this frame can be batched.
batch
)

Called when a frame is ready to be transformed.

private FrameEntry
public final void
sendFrame(Frame frame, Callback callback, boolean batch)

protected abstract boolean

Returns:

true to indicate that you have finished transforming this frame.
transform
(Callback
used to signal to start processing again.
callback
)

Called to transform the frame given in TransformingFlusher#onFrame(Frame, Callback, boolean).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final Queue<FrameEntry> entries
failureback to summary
private Throwable failure
finishedback to summary
private boolean finished
flusherback to summary
private final IteratingCallback flusher
lockback to summary
private final AutoLock lock
logback to summary
private final Logger log
SENTINEL_CLOSE_EXCEPTIONback to summary
private static final Throwable SENTINEL_CLOSE_EXCEPTION

Constructor Detail

TransformingFlusherback to summary
public TransformingFlusher()

Method Detail

closeFlusherback to summary
public void closeFlusher()

Used to close this flusher when there is no explicit failure.

failFlusherback to summary
public void failFlusher(Throwable t)

Used to fail this flusher possibly from an external event such as a callback.

Parameters
t:Throwable

the failure.

notifyCallbackFailureback to summary
private void notifyCallbackFailure(Callback callback, Throwable failure)
notifyCallbackSuccessback to summary
private void notifyCallbackSuccess(Callback callback)
onFailureback to summary
private void onFailure(Throwable t)
onFrameback to summary
protected abstract boolean onFrame(Frame frame, Callback callback, boolean batch)

Called when a frame is ready to be transformed.

Parameters
frame:Frame

the frame to transform.

callback:Callback

used to signal to start processing again.

batch:boolean

whether this frame can be batched.

Returns:boolean

true to indicate that you have finished transforming this frame.

pollEntryback to summary
private FrameEntry pollEntry()
sendFrameback to summary
public final void sendFrame(Frame frame, Callback callback, boolean batch)
transformback to summary
protected abstract boolean transform(Callback callback)

Called to transform the frame given in TransformingFlusher#onFrame(Frame, Callback, boolean). This method is called on each callback success until it returns true. If the call to onFrame(Frame, Callback, boolean) returns true then this method will not be called.

Parameters
callback:Callback

used to signal to start processing again.

Returns:boolean

true to indicate that you have finished transforming this frame.

org.eclipse.jetty.websocket.core.util back to summary

private Class TransformingFlusher.Flusher

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

Field Summary

Modifier and TypeField and Description
private FrameEntry

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
onCompleteFailure(Throwable
the throwable to indicate cause of failure
t
)

Overrides org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Invoked when the overall task has completed with a failure.

protected IteratingCallback.Action
process()

Implements abstract org.eclipse.jetty.util.IteratingCallback.process.

Method called by iterate() to process the asynchronous sub-task.

Inherited from org.eclipse.jetty.util.IteratingCallback:
abortclosefailedisAbortedisClosedisFailedisSucceedediterateonCompleteSuccessresetsucceededtoString

Field Detail

currentback to summary
private FrameEntry current

Constructor Detail

Flusherback to summary
private Flusher()

Method Detail

onCompleteFailureback to summary
protected void onCompleteFailure(Throwable t)

Overrides org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Doc from org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Invoked when the overall task has completed with a failure.

Parameters
t:Throwable

the throwable to indicate cause of failure

Annotations
@Override
processback to summary
protected IteratingCallback.Action process() throws Throwable

Implements abstract org.eclipse.jetty.util.IteratingCallback.process.

Doc from org.eclipse.jetty.util.IteratingCallback.process.

Method called by iterate() to process the asynchronous sub-task.

Implementations must initiate the asynchronous execution of the sub-task (if any) and return an appropriate action:

  • Action#IDLE when no sub tasks are available for execution but the overall job is not completed yet
  • Action#SCHEDULED when the sub task asynchronous execution has been started
  • Action#SUCCEEDED when the overall job is completed
Returns:IteratingCallback.Action

the appropriate Action

Annotations
@Override
Exceptions
Throwable:
if the sub-task processing throws