Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

recoin.system.session
Class RetrievalCycle  view RetrievalCycle download RetrievalCycle.java

java.lang.Object
  extended byrecoin.system.session.RetrievalCycle
All Implemented Interfaces:
java.lang.Runnable

public class RetrievalCycle
extends java.lang.Object
implements java.lang.Runnable

The RetrievalCycle represents the execution of a client order inside a RetrievalSession.

This class passes a RetrievalContainer to the appropriate ModuleGroups in order to be processed. The state of a RetrievalCycle changes during execution.

Version:
0.2.9

Field Summary
private  recoin.container.RetrievalContainer container
          The RetrievalContainer.
private  int currentState
          The current state.
private  int cycleID
          The ID of this RetrievalCycle that is passed by the RetrievalSession.
private  boolean finished
          A boolean flag signaling the end of this RetrievalCycle.
static int FINISHING
          Static variable representing the finishing phase.
static int HALTED
          Static variable representing the state HALTED.
private  int lastState
          The last state.
(package private) static org.apache.log4j.Logger logger
          The logger for this class.
static int POSTRESULT
          Static variable representing the post-result phase.
static int PREQUERY
          Static variable representing the pre-query phase.
static int RETRIEVING
          Static variable representing the matching phase.
private  RetrievalSession session
          The RetrievalSession that forms the context for this RetrievalCycle.
static int STARTING
          Static variable representing the initializing phase.
 
Constructor Summary
RetrievalCycle(RetrievalSession session, recoin.container.Query query, ComponentChain chain, int id)
          Creates a new RetrievalCycle for the specified RetrievalSession, with the specified Query and ID.
RetrievalCycle(RetrievalSession session, recoin.container.Query query, int id)
          Creates a new RetrievalCycle for the specified RetrievalSession and with the specified Query and ID.
 
Method Summary
private  void distributeContainer(recoin.container.RetrievalContainer con, java.lang.String group)
          Distributes the specified RetrievalContainer to the ModuleGroup with the specified groupname.
 recoin.container.RetrievalContainer getContainer()
          Returns the ResultContainer that is used or was created in this RetrievalCycle.
 int getCurrentState()
          Returns the current state of this RetrievalCycle.
(package private)  void nextPhase(int newState)
          Switches to the next phase of this RetrievalCycle by adjusting the necessary attributes.
 void run()
          The run-method of this RetrievalCycle.
 void setFinished(boolean fin)
          Sets the finished field of this RetrievalCycle to the specified value.
 void start()
          Starts this RetrievalCycle by creating a named Thread with this RetrievalCycle and starting it.
 void waitForResults()
          Adds the calling Thread to the wait set of this RetrievalCycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
The logger for this class.


HALTED

public static final int HALTED
Static variable representing the state HALTED.

See Also:
Constant Field Values

PREQUERY

public static final int PREQUERY
Static variable representing the pre-query phase.

See Also:
Constant Field Values

RETRIEVING

public static final int RETRIEVING
Static variable representing the matching phase.

See Also:
Constant Field Values

POSTRESULT

public static final int POSTRESULT
Static variable representing the post-result phase.

See Also:
Constant Field Values

STARTING

public static final int STARTING
Static variable representing the initializing phase.

See Also:
Constant Field Values

FINISHING

public static final int FINISHING
Static variable representing the finishing phase.

See Also:
Constant Field Values

currentState

private int currentState
The current state.


lastState

private int lastState
The last state.


finished

private boolean finished
A boolean flag signaling the end of this RetrievalCycle.


container

private recoin.container.RetrievalContainer container
The RetrievalContainer.


session

private RetrievalSession session
The RetrievalSession that forms the context for this RetrievalCycle.


cycleID

private int cycleID
The ID of this RetrievalCycle that is passed by the RetrievalSession.

Constructor Detail

RetrievalCycle

public RetrievalCycle(RetrievalSession session,
                      recoin.container.Query query,
                      int id)
Creates a new RetrievalCycle for the specified RetrievalSession and with the specified Query and ID. The Query is put into a new RetrievalContainer.


RetrievalCycle

public RetrievalCycle(RetrievalSession session,
                      recoin.container.Query query,
                      ComponentChain chain,
                      int id)
Creates a new RetrievalCycle for the specified RetrievalSession, with the specified Query and ID. The ComponentChain and the Query are put into a new RetrievalContainer.

Method Detail

nextPhase

void nextPhase(int newState)
Switches to the next phase of this RetrievalCycle by adjusting the necessary attributes.


getCurrentState

public int getCurrentState()
Returns the current state of this RetrievalCycle.


waitForResults

public void waitForResults()
                    throws java.lang.InterruptedException
Adds the calling Thread to the wait set of this RetrievalCycle. This should generally be the RetrievalSession that is waiting for this RetrievalCycle to finish.


setFinished

public void setFinished(boolean fin)
Sets the finished field of this RetrievalCycle to the specified value. If true a Thread waiting for this RetrievalCycle to finish is notified.


start

public void start()
Starts this RetrievalCycle by creating a named Thread with this RetrievalCycle and starting it.


getContainer

public recoin.container.RetrievalContainer getContainer()
Returns the ResultContainer that is used or was created in this RetrievalCycle.


run

public void run()
The run-method of this RetrievalCycle. It steps through the phases of a RetrievalCycle in the following order:

STARTING -> PREQUERY -> RETRIEVING -> POSTRESULT -> FINISHING

At the end of the run-method setFinished(true) is called.

Specified by:
run in interface java.lang.Runnable

distributeContainer

private void distributeContainer(recoin.container.RetrievalContainer con,
                                 java.lang.String group)
Distributes the specified RetrievalContainer to the ModuleGroup with the specified groupname.