public final class FilterChainContext extends Object implements AttributeStorage
FilterChain
Context
implementation.Context
,
FilterChain
Modifier and Type | Class and Description |
---|---|
static interface |
FilterChainContext.CompletionListener
The interface, which represents a listener, which will be notified,
once
FilterChainContext processing is complete. |
static interface |
FilterChainContext.CopyListener
The interface, which represents a listener, which will be notified,
after
copy() is called. |
static class |
FilterChainContext.Operation |
static class |
FilterChainContext.State |
static class |
FilterChainContext.TransportContext |
Modifier and Type | Field and Description |
---|---|
protected FilterChainEvent |
event
Context associated event, if EVENT operation
|
static int |
NO_FILTER_INDEX |
protected CompletionHandler<FilterChainContext> |
operationCompletionHandler
CompletionHandler , which will be notified, when operation will be
complete. |
Constructor and Description |
---|
FilterChainContext() |
Modifier and Type | Method and Description |
---|---|
void |
addCompletionListener(FilterChainContext.CompletionListener listener)
Add the
FilterChainContext.CompletionListener , which will be notified, when
this FilterChainContext processing will be completed. |
void |
addCopyListener(FilterChainContext.CopyListener listener)
Add the
FilterChainContext.CopyListener , which will be notified, right after
this copy() is called. |
void |
completeAndRecycle() |
FilterChainContext |
copy() |
static FilterChainContext |
create(Connection connection) |
void |
fail(Throwable error) |
void |
flush(CompletionHandler completionHandler) |
void |
fork()
This method invocation suggests the
FilterChain to create a
copy of this FilterChainContext and resume/fork its execution
starting from the current Filter . |
void |
fork(NextAction nextAction)
This method invocation suggests the
FilterChain to create a
copy of this FilterChainContext and resume/fork its execution
starting from the current Filter . |
Object |
getAddress()
Get address, associated with the current
IOEvent processing. |
Holder<?> |
getAddressHolder()
|
AttributeHolder |
getAttributes()
Get associated
AttributeHolder . |
Connection |
getConnection()
Get the
Connection , associated with the current processing. |
int |
getEndIdx() |
FilterChain |
getFilterChain()
Get
FilterChain , which runs the Filter . |
int |
getFilterIdx() |
NextAction |
getForkAction() |
NextAction |
getForkAction(NextAction nextAction) |
Context |
getInternalContext()
Get the general Grizzly
Context this filter context wraps. |
NextAction |
getInvokeAction()
|
<E> NextAction |
getInvokeAction(E incompleteChunk,
Appender<E> appender)
|
NextAction |
getInvokeAction(Object unparsedChunk)
|
MemoryManager |
getMemoryManager()
A simple alias for
FilterChainContext.getConnection().getTransport().getMemoryManager() . |
<T> T |
getMessage()
Get message object, associated with the current processing.
|
NextAction |
getRerunFilterAction()
Get
NextAction , which instructs FilterChain to rerun the
filter. |
protected Runnable |
getRunnable() |
int |
getStartIdx() |
NextAction |
getStopAction()
Get
NextAction implementation, which instructs FilterChain
to stop executing phase. |
<E> NextAction |
getStopAction(E incompleteChunk,
Appender<E> appender)
Get
NextAction implementation, which instructs FilterChain
stop executing phase. |
NextAction |
getStopAction(Object incompleteChunk)
Get
NextAction implementation, which instructs FilterChain
stop executing phase. |
NextAction |
getSuspendAction()
Get
NextAction , which instructs FilterChain to suspend filter
chain execution. |
NextAction |
getSuspendingStopAction()
Deprecated.
use
getForkAction() |
FilterChainContext.TransportContext |
getTransportContext()
Get the
TransportFilter related context. |
int |
nextFilterIdx() |
void |
notifyDownstream(FilterChainEvent event) |
void |
notifyDownstream(FilterChainEvent event,
CompletionHandler<FilterChainContext> completionHandler) |
void |
notifyUpstream(FilterChainEvent event) |
void |
notifyUpstream(FilterChainEvent event,
CompletionHandler<FilterChainContext> completionHandler) |
int |
previousFilterIdx() |
ReadResult |
read()
Performs a blocking read.
|
boolean |
removeCompletionListener(FilterChainContext.CompletionListener listener)
Remove the
FilterChainContext.CompletionListener . |
boolean |
removeCopyListener(FilterChainContext.CopyListener listener)
Remove the
FilterChainContext.CopyListener . |
void |
reset()
Release the context associated resources.
|
void |
resume()
Resume processing of the current task
|
void |
resume(NextAction nextAction)
Resume the current FilterChain task processing by completing the current
Filter (the Filter, which suspended the processing) with the
passed NextAction . |
void |
resumeNext()
Resume processing of the current task starting from the Filter, which
follows the Filter, which suspend the processing.
|
void |
setAddress(Object address)
Set address, associated with the current
IOEvent processing. |
void |
setAddressHolder(Holder<?> addressHolder)
Set address, associated with the current
IOEvent processing. |
void |
setEndIdx(int endIdx) |
void |
setFilterIdx(int index) |
void |
setMessage(Object message)
Set message object, associated with the current processing.
|
void |
setStartIdx(int startIdx) |
FilterChainContext.State |
state()
Get the current processing task state.
|
Runnable |
suspend()
Suspend processing of the current task
|
String |
toString() |
void |
write(Object message) |
void |
write(Object message,
boolean blocking) |
void |
write(Object message,
CompletionHandler<WriteResult> completionHandler) |
void |
write(Object message,
CompletionHandler<WriteResult> completionHandler,
boolean blocking) |
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler) |
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
boolean blocking) |
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
MessageCloner cloner) |
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
MessageCloner cloner,
boolean blocking) |
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
PushBackHandler pushBackHandler)
Deprecated.
|
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
PushBackHandler pushBackHandler,
boolean blocking)
Deprecated.
|
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
PushBackHandler pushBackHandler,
MessageCloner cloner)
Deprecated.
|
void |
write(Object address,
Object message,
CompletionHandler<WriteResult> completionHandler,
PushBackHandler pushBackHandler,
MessageCloner cloner,
boolean blocking)
Deprecated.
|
public static final int NO_FILTER_INDEX
protected CompletionHandler<FilterChainContext> operationCompletionHandler
CompletionHandler
, which will be notified, when operation will be
complete. For WRITE it means the data will be written on wire, for other
operations - the last Filter has finished the processing.protected FilterChainEvent event
public static FilterChainContext create(Connection connection)
public Runnable suspend()
public void resume()
public void resumeNext()
public void resume(NextAction nextAction)
Filter
(the Filter, which suspended the processing) with the
passed NextAction
.nextAction
- the NextAction
, based on which FilterChain
will continue processing.public void fork()
FilterChain
to create a
copy of this FilterChainContext
and resume/fork its execution
starting from the current Filter
.public void fork(NextAction nextAction)
FilterChain
to create a
copy of this FilterChainContext
and resume/fork its execution
starting from the current Filter
.
If nextAction
parameter is not null - then its value is treated
as a result of the current Filter
execution on the forked
FilterChain
processing. So during the forked FilterChain
processing the current Filter
will not be invoked, but
the processing will be continued as if the current Filter
returned nextAction
as a result.
For example if we call fork(ctx.getInvokeAction());
the forked
FilterChain
processing will start with the next Filter
in
chain.public FilterChainContext.State state()
public int nextFilterIdx()
public int previousFilterIdx()
public int getFilterIdx()
public void setFilterIdx(int index)
public int getStartIdx()
public void setStartIdx(int startIdx)
public int getEndIdx()
public void setEndIdx(int endIdx)
public FilterChain getFilterChain()
FilterChain
, which runs the Filter
.FilterChain
, which runs the Filter
.public Connection getConnection()
Connection
, associated with the current processing.Connection
object, associated with the current processing.public <T> T getMessage()
FilterChain
represents sequence of parser and process
Filter
s. Each parser can change the message representation until
it will come to processor Filter
.public void setMessage(Object message)
FilterChain
represents sequence of parser and process
Filter
s. Each parser can change the message representation until
it will come to processor Filter
.message
- message object, associated with the current processing.public Holder<?> getAddressHolder()
Holder
, which contains address, associated with the
current IOEvent
processing.
When we process IOEvent.READ
event - it represents sender address,
or when process IOEvent.WRITE
- address of receiver.public void setAddressHolder(Holder<?> addressHolder)
IOEvent
processing.
When we process IOEvent.READ
event - it represents sender address,
or when process IOEvent.WRITE
- address of receiver.public Object getAddress()
IOEvent
processing.
When we process IOEvent.READ
event - it represents sender address,
or when process IOEvent.WRITE
- address of receiver.IOEvent
processing.public void setAddress(Object address)
IOEvent
processing.
When we process IOEvent.READ
event - it represents sender address,
or when process IOEvent.WRITE
- address of receiver.address
- address, associated with the current IOEvent
processing.protected final Runnable getRunnable()
public FilterChainContext.TransportContext getTransportContext()
TransportFilter
related context.TransportFilter
.public final Context getInternalContext()
Context
this filter context wraps.Context
this filter context wraps.public NextAction getInvokeAction()
NextAction
implementation, which instructs FilterChain
to
process next Filter
in chain.
Normally, after receiving this instruction from Filter
,
FilterChain
executes next filter.NextAction
implementation, which instructs FilterChain
to
process next Filter
in chain.public NextAction getInvokeAction(Object unparsedChunk)
NextAction
implementation, which instructs FilterChain
to
process next Filter
in chain.
Normally, after receiving this instruction from Filter
,
FilterChain
executes next filter.unparsedChunk
- signals, that there is some unparsed data remaining
in the source message, so FilterChain
could be rerun.NextAction
implementation, which instructs FilterChain
to
process next Filter
in chain.public <E> NextAction getInvokeAction(E incompleteChunk, Appender<E> appender)
NextAction
implementation, which instructs FilterChain
to
process next Filter
in chain.
Normally, after receiving this instruction from Filter
,
FilterChain
executes next filter.incompleteChunk
- signals, that there is a data chunk remaining,
which doesn't represent complete message. As more data becomes available
but before FilterChain
calls the current Filter
,
it will check if the Filter
has any data stored after the
last invocation. If a remainder is present it will append the new data
to the stored one and pass the result as the FilterChainContext message.appender
- the Appender
, which knows
how to append chunks of type <E>
.NextAction
implementation, which instructs FilterChain
to
process next Filter
in chain.IllegalArgumentException
- if appender is null
and
remainder's type is not Buffer
or Appendable
.public NextAction getStopAction()
NextAction
implementation, which instructs FilterChain
to stop executing phase.NextAction
implementation, which instructs FilterChain
to stop executing phase.public NextAction getStopAction(Object incompleteChunk)
NextAction
implementation, which instructs FilterChain
stop executing phase.incompleteChunk
- signals, that there is a data chunk remaining,
which doesn't represent complete message. As more data becomes available
but before FilterChain
calls the current Filter
,
it will check if the Filter
has any data stored after the
last invocation. If a remainder is present it will append the new data
to the stored one and pass the result as the FilterChainContext message.NextAction
implementation, which instructs FilterChain
to stop executing phase.IllegalArgumentException
- if remainder's type is not Buffer
or
Appendable
.public <E> NextAction getStopAction(E incompleteChunk, Appender<E> appender)
NextAction
implementation, which instructs FilterChain
stop executing phase.incompleteChunk
- signals, that there is a data chunk remaining,
which doesn't represent complete message. As more data becomes available
but before FilterChain
calls the current Filter
,
it will check if the Filter
has any data stored after the
last invocation. If a remainder is present it will append the new data
to the stored one and pass the result as the FilterChainContext message.appender
- the Appender
, which knows
how to append chunks of type <E>
.NextAction
implementation, which instructs FilterChain
to stop executing phase.IllegalArgumentException
- if appender is null
and
remainder's type is not Buffer
or Appendable
.public NextAction getForkAction()
NextAction
implementation, which suggests the FilterChain
to forget about the current FilterChainContext
, create a copy of it
and continue/fork FilterChain
processing using the copied
FilterChainContext
starting from the current Filter
.public NextAction getForkAction(NextAction nextAction)
NextAction
implementation, which suggests the FilterChain
to forget about the current FilterChainContext
, create a copy of it
and continue/fork FilterChain
processing using the copied
FilterChainContext
starting from the current Filter
.
If nextAction
parameter is not null - then its value is treated
as a result of the current Filter
execution on the forked
FilterChain
processing. So during the forked FilterChain
processing the current Filter
will not be invoked, but
the processing will be continued as if the current Filter
returned nextAction
as a result.
For example if we call fork(ctx.getInvokeAction());
the forked
FilterChain
processing will start with the next Filter
in
chain.public NextAction getSuspendingStopAction()
getForkAction()
NextAction
implementation, which instructs the FilterChain
to suspend the current FilterChainContext
and invoke similar logic
as instructed by StopAction
with a clean FilterChainContext
.public NextAction getSuspendAction()
NextAction
, which instructs FilterChain
to suspend filter
chain execution.NextAction
, which instructs FilterChain
to suspend
filter chain execution.public NextAction getRerunFilterAction()
NextAction
, which instructs FilterChain
to rerun the
filter.NextAction
, which instructs FilterChain
to rerun the
filter.public ReadResult read() throws IOException
Performs a blocking read.
IOException
- if an I/O error occurs.public void write(Object message)
public void write(Object message, boolean blocking)
public void write(Object message, CompletionHandler<WriteResult> completionHandler)
public void write(Object message, CompletionHandler<WriteResult> completionHandler, boolean blocking)
public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler)
public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, boolean blocking)
@Deprecated public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, PushBackHandler pushBackHandler)
@Deprecated public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, PushBackHandler pushBackHandler, boolean blocking)
public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, MessageCloner cloner)
@Deprecated public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, PushBackHandler pushBackHandler, MessageCloner cloner)
public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, MessageCloner cloner, boolean blocking)
@Deprecated public void write(Object address, Object message, CompletionHandler<WriteResult> completionHandler, PushBackHandler pushBackHandler, MessageCloner cloner, boolean blocking)
public void flush(CompletionHandler completionHandler)
public void notifyUpstream(FilterChainEvent event)
public void notifyUpstream(FilterChainEvent event, CompletionHandler<FilterChainContext> completionHandler)
public void notifyDownstream(FilterChainEvent event)
public void notifyDownstream(FilterChainEvent event, CompletionHandler<FilterChainContext> completionHandler)
public void fail(Throwable error)
public AttributeHolder getAttributes()
AttributeHolder
.
Implementation may return null if AttributeHolder
wasn't
initialized yet.getAttributes
in interface AttributeStorage
AttributeHolder
.
Implementation may return null if AttributeHolder
wasn't
initialized yet.public final void addCompletionListener(FilterChainContext.CompletionListener listener)
FilterChainContext.CompletionListener
, which will be notified, when
this FilterChainContext
processing will be completed.listener
- the FilterChainContext.CompletionListener
, which will be notified, when
this FilterChainContext
processing will be completed.public final boolean removeCompletionListener(FilterChainContext.CompletionListener listener)
FilterChainContext.CompletionListener
.listener
- the FilterChainContext.CompletionListener
to be removed.public final void addCopyListener(FilterChainContext.CopyListener listener)
FilterChainContext.CopyListener
, which will be notified, right after
this copy()
is called.listener
- the FilterChainContext.CopyListener
, which will be notified, right
after this copy()
is called.public final boolean removeCopyListener(FilterChainContext.CopyListener listener)
FilterChainContext.CopyListener
.listener
- the FilterChainContext.CopyListener
to be removed.public final MemoryManager getMemoryManager()
A simple alias for FilterChainContext.getConnection().getTransport().getMemoryManager()
.
MemoryManager
associated with the Connection
of this FilterChainContext
.public FilterChainContext copy()
public void reset()
public void completeAndRecycle()
Copyright © 2014 Oracle Corporation. All rights reserved.