org.apache.jmeter.control

Class GenericController

Implemented Interfaces:
Cloneable, Controller, Serializable, TestElement
Known Direct Subclasses:
ForeachController, IfController, IncludeController, InterleaveControl, LoopController, ModuleController, OnceOnlyController, ProxyControl, RandomOrderController, RecordingController, RunTime, SwitchController, ThroughputController, TransactionController, WhileController

public class GenericController
extends AbstractTestElement
implements Controller, Serializable

This class is the basis for all the controllers. It also implements SimpleController.

The main entry point is next(), which is called by by JMeterThread as follows:

while (running && (sampler = controller.next()) != null)

Field Summary

protected int
current
protected List
subControllersAndSamplers

Fields inherited from interface org.apache.jmeter.testelement.TestElement

COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS

Constructor Summary

GenericController()
Creates a Generic Controller

Method Summary

void
addIterationListener(LoopIterationListener lis)
void
addTestElement(TestElement child)
protected void
currentReturnedNull(Controller c)
If the controller is done, remove it from the list, otherwise increment to next entry in list.
protected void
fireIterEvents()
protected void
fireIterationStart()
protected TestElement
getCurrentElement()
Gets the element indicated by the current index, if one exists, from the subControllersAndSamplers list.
protected int
getIterCount()
protected List
getSubControllers()
Gets the SubControllers attribute of the GenericController object
protected void
incrementCurrent()
Increments the current pointer; called by currentReturnedNull to move the controller on to its next child.
protected void
incrementIterCount()
void
initialize()
boolean
isDone()
protected boolean
isFirst()
Sampler
next()
Determines the next sampler to be processed.
protected Sampler
nextIsAController(Controller controller)
Called by next() if the element is a Controller, and returns the next sampler from the controller.
protected Sampler
nextIsASampler(Sampler element)
Increment the current pointer and return the element.
protected Sampler
nextIsNull()
Called by next() when getCurrentElement() returns null.
protected void
reInitialize()
Resets the controller:
  • resetCurrent() (i.e. current=0)
  • increment iteration count
  • sets first=true
  • recoverRunningVersion() to set the controller back to the initial state
protected void
removeCurrentElement()
protected void
resetCurrent()
protected void
resetIterCount()
protected void
setCurrentElement(TestElement currentElement)
Empty implementation - does nothing.
protected void
setDone(boolean done)
void
setFirst(boolean b)

Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

addProperty, addTestElement, canRemove, clear, clearTemporary, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty

Field Details

current

protected int current

subControllersAndSamplers

protected List subControllersAndSamplers

Constructor Details

GenericController

public GenericController()
Creates a Generic Controller

Method Details

addIterationListener

public void addIterationListener(LoopIterationListener lis)
Specified by:
addIterationListener in interface Controller

addTestElement

public void addTestElement(TestElement child)
Specified by:
addTestElement in interface TestElement
Overrides:
addTestElement in interface AbstractTestElement

currentReturnedNull

protected void currentReturnedNull(Controller c)
If the controller is done, remove it from the list, otherwise increment to next entry in list.
Parameters:
c - controller

fireIterEvents

protected void fireIterEvents()

fireIterationStart

protected void fireIterationStart()

getCurrentElement

protected TestElement getCurrentElement()
            throws NextIsNullException
Gets the element indicated by the current index, if one exists, from the subControllersAndSamplers list.

If the subControllersAndSamplers list is empty, then set done = true, and throw NextIsNullException.

Returns:
the current element - or null if current index too large
Throws:
NextIsNullException - if list is empty

getIterCount

protected int getIterCount()

getSubControllers

protected List getSubControllers()
Gets the SubControllers attribute of the GenericController object
Returns:
the SubControllers value

incrementCurrent

protected void incrementCurrent()
Increments the current pointer; called by currentReturnedNull to move the controller on to its next child.

incrementIterCount

protected void incrementIterCount()

initialize

public void initialize()
Specified by:
initialize in interface Controller

isDone

public boolean isDone()
Specified by:
isDone in interface Controller

isFirst

protected boolean isFirst()

next

public Sampler next()
Determines the next sampler to be processed.

If isDone, returns null.

Gets the list element using current pointer. If this is null, calls nextIsNull().

If the list element is a sampler, calls nextIsASampler(Sampler), otherwise calls nextIsAController(Controller)

If any of the called methods throws NextIsNullException, returns null, otherwise the value obtained above is returned.

Specified by:
next in interface Controller
Returns:
the next sampler or null

nextIsAController

protected Sampler nextIsAController(Controller controller)
            throws NextIsNullException
Called by next() if the element is a Controller, and returns the next sampler from the controller. If this is null, then updates the current pointer and makes recursive call to next().
Parameters:
controller -
Returns:
the next sampler

nextIsASampler

protected Sampler nextIsASampler(Sampler element)
            throws NextIsNullException
Increment the current pointer and return the element. Called by next() if the element is a sampler. (May be overriden by sub-classes).
Parameters:
element -
Returns:
input element

nextIsNull

protected Sampler nextIsNull()
            throws NextIsNullException
Called by next() when getCurrentElement() returns null. Reinitialises the controller.
Returns:
null (always, for this class)

reInitialize

protected void reInitialize()
Resets the controller:
  • resetCurrent() (i.e. current=0)
  • increment iteration count
  • sets first=true
  • recoverRunningVersion() to set the controller back to the initial state

removeCurrentElement

protected void removeCurrentElement()

resetCurrent

protected void resetCurrent()

resetIterCount

protected void resetIterCount()

setCurrentElement

protected void setCurrentElement(TestElement currentElement)
            throws NextIsNullException
Empty implementation - does nothing.
Parameters:
currentElement -

setDone

protected void setDone(boolean done)

setFirst

public void setFirst(boolean b)

Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.