com.sun.grizzly.strategies
Class SameThreadStrategy

java.lang.Object
  extended by com.sun.grizzly.strategies.SameThreadStrategy
All Implemented Interfaces:
Strategy

public class SameThreadStrategy
extends Object
implements Strategy

Strategy, which executes Processors in a current thread.

Author:
Alexey Stashok

Constructor Summary
SameThreadStrategy()
           
 
Method Summary
 void executeProcessor(Object strategyContext, ProcessorRunnable processorRunnable)
          Execute ProcessorRunnable task.
 boolean isTerminateThread(Object strategyContext)
          This method may be called by runner Thread after task will be executed.
 Object prepare(Connection connection, IOEvent ioEvent)
          Prepare Strategy for processing IOEvent, occured on the Connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SameThreadStrategy

public SameThreadStrategy()
Method Detail

prepare

public Object prepare(Connection connection,
                      IOEvent ioEvent)
Prepare Strategy for processing IOEvent, occured on the Connection. At this phase Strategy may initialize and return context data, which will be passed further into executeProcessor and isTerminateThread methods.

Specified by:
prepare in interface Strategy
Parameters:
connection - Connection, on which IOEvent occured.
ioEvent - IOEvent.
Returns:
context/state, associated with the IOEvent processing.

executeProcessor

public void executeProcessor(Object strategyContext,
                             ProcessorRunnable processorRunnable)
                      throws IOException
Execute ProcessorRunnable task.

Specified by:
executeProcessor in interface Strategy
Parameters:
strategyContext - context object, initialized on "prepare" phase.
processorRunnable - the ProcessorRunnable task to be executed.
Throws:
IOException

isTerminateThread

public boolean isTerminateThread(Object strategyContext)
This method may be called by runner Thread after task will be executed. Strategy may instruct the caller to release current thread, after task execution will be completed.

Specified by:
isTerminateThread in interface Strategy
Parameters:
strategyContext - Strategy context, initialized on "prepare" phase.
Returns:
true, to instruct caller to release the current Thread, or false otherwise.
See Also:
LeaderFollowerStrategy


Copyright © 2009 SUN Microsystems. All Rights Reserved.