|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.DefaultProtocolChain
public class DefaultProtocolChain
Default ProtocolChain implementation.
Nested Class Summary | |
---|---|
static interface |
DefaultProtocolChain.EventHandler
Interface, which introduces handler, which will be notified about event, happened on ProtocolChain |
static class |
DefaultProtocolChain.Phase
|
Field Summary | |
---|---|
protected boolean |
continousExecution
true if a pipelined execution is required. |
protected List<DefaultProtocolChain.EventHandler> |
eventHandlers
The list of DefaultProtocolChain.EventHandler s, which will be notified about this
ProtocolChain events |
protected List<ProtocolFilter> |
protocolFilters
The list of ProtocolFilter this chain will invoke. |
Fields inherited from interface com.sun.grizzly.ProtocolChain |
---|
PROTOCOL_CHAIN_POST_INSTRUCTION |
Constructor Summary | |
---|---|
DefaultProtocolChain()
|
Method Summary | |
---|---|
boolean |
addEventHandler(DefaultProtocolChain.EventHandler eventHandler)
Add the DefaultProtocolChain.EventHandler |
void |
addFilter(int pos,
ProtocolFilter protocolFilter)
Insert a ProtocolFilter at position pos. |
boolean |
addFilter(ProtocolFilter protocolFilter)
Add the ProtocolFilter to this ProtocolChain |
void |
execute(Context ctx)
Execute this ProtocolChain. |
void |
execute(Context ctx,
int firstFilter)
Execute this ProtocolChain. |
protected int |
executeProtocolFilter(Context ctx)
Execute the ProtocolFilter.execute method. |
protected int |
executeProtocolFilter(Context ctx,
int firstFilter)
Execute the ProtocolFilter.execute method. |
boolean |
isContinuousExecution()
Return true if the current ExecutorService can
re-execute its ProtocolFilter after a successful execution. |
protected void |
notifyException(DefaultProtocolChain.Phase phase,
ProtocolFilter filter,
Throwable throwable)
Notifies all DefaultProtocolChain.EventHandler s about exception, which occured |
protected boolean |
postExecuteProtocolFilter(int currentPosition,
Context ctx)
Execute the ProtocolFilter.postExcute. |
boolean |
removeEventHandler(DefaultProtocolChain.EventHandler eventHandler)
Remove the DefaultProtocolChain.EventHandler . |
boolean |
removeFilter(ProtocolFilter theFilter)
Remove a ProtocolFilter. |
void |
setContinuousExecution(boolean continousExecution)
Set to true if the current ExecutorService can
re-execute its ProtocolFilter(s) after a successful execution. |
ProtocolFilter |
setProtocolFilter(int pos,
ProtocolFilter protocolFilter)
Insert a ProtocolFilter at position pos. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final List<ProtocolFilter> protocolFilters
protected final List<DefaultProtocolChain.EventHandler> eventHandlers
DefaultProtocolChain.EventHandler
s, which will be notified about this
ProtocolChain
events
protected boolean continousExecution
Constructor Detail |
---|
public DefaultProtocolChain()
Method Detail |
---|
public void execute(Context ctx) throws Exception
execute
in interface ProtocolChain
ctx
- Context
Exception
public void execute(Context ctx, int firstFilter) throws Exception
ctx
- Context
firstFilter
- The first filter to be invoked.
Exception
protected int executeProtocolFilter(Context ctx)
ctx
- Context
ProtocolFilter
to exexuteprotected int executeProtocolFilter(Context ctx, int firstFilter)
ctx
- Context
firstFilter
- The first filter position to be invoked.
ProtocolFilter
to exexuteprotected boolean postExecuteProtocolFilter(int currentPosition, Context ctx)
currentPosition
- position in list of ProtocolFilter
sctx
- Context
public boolean removeFilter(ProtocolFilter theFilter)
removeFilter
in interface ProtocolChain
theFilter
- the ProtocolFilter to remove
public boolean addFilter(ProtocolFilter protocolFilter)
ProtocolFilter
to this ProtocolChain
addFilter
in interface ProtocolChain
protocolFilter
- to add
public void addFilter(int pos, ProtocolFilter protocolFilter)
addFilter
in interface ProtocolChain
pos
- protocolFilter
- public ProtocolFilter setProtocolFilter(int pos, ProtocolFilter protocolFilter)
pos
- - position in this ProtocolChainprotocolFilter
- - ProtocolFilter
to insert
ProtocolFilter
that was setpublic void setContinuousExecution(boolean continousExecution)
ExecutorService
can
re-execute its ProtocolFilter(s) after a successful execution. Enabling
this property is useful for protocol that needs to support pipelined
message requests as the ProtocolFilter are automatically re-executed,
avoiding the overhead of releasing the current Thread, registering
back the SelectionKey to the SelectorHandler and waiting for a new
NIO event.
Some protocols (like http) can get the http headers in one
SocketChannel.read, parse the message and then get the next http message
on the second SocketChannel.read(). Not having to release the Thread
and re-execute the ProtocolFilter greatly improve performance.
setContinuousExecution
in interface ReinvokeAware
continousExecution
- true to enable continuous execution.
(default is false).public boolean isContinuousExecution()
ExecutorService
can
re-execute its ProtocolFilter after a successful execution.
isContinuousExecution
in interface ReinvokeAware
public boolean addEventHandler(DefaultProtocolChain.EventHandler eventHandler)
DefaultProtocolChain.EventHandler
eventHandler
-
DefaultProtocolChain.EventHandler
was added, false otherwisepublic boolean removeEventHandler(DefaultProtocolChain.EventHandler eventHandler)
DefaultProtocolChain.EventHandler
.
eventHandler
- the ProtocolFilter to remove
- Returns:
- true, if
DefaultProtocolChain.EventHandler
was removed, false otherwise
protected void notifyException(DefaultProtocolChain.Phase phase, ProtocolFilter filter, Throwable throwable)
DefaultProtocolChain.EventHandler
s about exception, which occured
phase
- execution Phase
, where exception occuredfilter
- ProtocolFilter
, where exception occuredthrowable
- actual exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |