Apache JMeter

## org.apache.jmeter.control
Class GenericController

    java.lang.Object
      org.apache.jmeter.testelement.AbstractTestElement
          org.apache.jmeter.control.GenericController

All Implemented Interfaces:
  Serializable, Cloneable, Controller, TestElement

Direct Known Subclasses:
  ForeachController, IfController, IncludeController, InterleaveControl, LoopController, ModuleController, OnceOnlyController, ProxyControl, RandomOrderController, RecordingController, RunTime, SwitchController, TestFragmentController, 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)`

See Also:
  Serialized Form

Field Summary
`protected int` `current`
`protected List<TestElement>` `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)` Controllers have to notify listeners of when they begin an iteration through their sub-elements.
`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` `fireIterationStart()`
`protected void` `fireIterEvents()`
`protected TestElement` `getCurrentElement()` Gets the element indicated by the `current` index, if one exists, from the `subControllersAndSamplers` list.
`protected int` `getIterCount()`
`protected List<TestElement>` `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()` Called to initialize a controller at the beginning of a test iteration.
`boolean` `isDone()` Indicates whether the Controller is done delivering Samplers for the rest of the test.
`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` `reInitializeSubController()` Called to re-initialize a index of controller's elements (Bug 50032)
`protected void` `removeCurrentElement()`
`void` `removeIterationListener(LoopIterationListener iterationListener)` Remove listener
`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, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, 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`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

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

`canRemove, clear, clearTestElementChildren, clone, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse`

Field Detail

### subControllersAndSamplers

    protected transient List<TestElement> subControllersAndSamplers

### current

    protected transient int current

Constructor Detail

### GenericController

    public GenericController()

  Creates a Generic Controller

Method Detail

### initialize

    public void initialize()

  Description copied from interface: `Controller`
  Called to initialize a controller at the beginning of a test iteration.

  Specified by:
    `initialize` in interface `Controller`

### 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

### 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

### isDone

    public boolean isDone()

  Description copied from interface: `Controller`
  Indicates whether the Controller is done delivering Samplers for the rest of the test. When the top-level controller returns true to JMeterThread, the thread is complete.

  Specified by:
    `isDone` in interface `Controller`
  Returns:
    boolean
  See Also:
    `Controller.isDone()`

### setDone

    protected void setDone(boolean done)

### isFirst

    protected boolean isFirst()

### setFirst

    public void setFirst(boolean b)

### 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
  Throws:
    `NextIsNullException`

### 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
  Throws:
    `NextIsNullException`

### nextIsNull

    protected Sampler nextIsNull()
                          throws NextIsNullException

  Called by next() when getCurrentElement() returns null. Reinitialises the controller.

  Returns:
    null (always, for this class)
  Throws:
    `NextIsNullException`

### reInitializeSubController

    protected void reInitializeSubController()

  Called to re-initialize a index of controller's elements (Bug 50032)

### 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

### getSubControllers

    protected List<TestElement> getSubControllers()

  Gets the SubControllers attribute of the GenericController object

  Returns:
    the SubControllers value

### setCurrentElement

    protected void setCurrentElement(TestElement currentElement)
                              throws NextIsNullException

  Empty implementation - does nothing.

  Parameters:
    `currentElement` -
  Throws:
    `NextIsNullException`

### 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

### removeCurrentElement

    protected void removeCurrentElement()

### incrementCurrent

    protected void incrementCurrent()

  Increments the current pointer; called by currentReturnedNull to move the controller on to its next child.

### resetCurrent

    protected void resetCurrent()

### addTestElement

    public void addTestElement(TestElement child)

  Description copied from class: `AbstractTestElement`

  Specified by:
    `addTestElement` in interface `TestElement`
  Overrides:
    `addTestElement` in class `AbstractTestElement`

### addIterationListener

    public void addIterationListener(LoopIterationListener lis)

  Description copied from interface: `Controller`
  Controllers have to notify listeners of when they begin an iteration through their sub-elements.

  Specified by:
    `addIterationListener` in interface `Controller`

### removeIterationListener

    public void removeIterationListener(LoopIterationListener iterationListener)

  Remove listener

  Specified by:
    `removeIterationListener` in interface `Controller`
  Parameters:
    `iterationListener` - `LoopIterationListener`

### fireIterEvents

    protected void fireIterEvents()

### fireIterationStart

    protected void fireIterationStart()

### getIterCount

    protected int getIterCount()

### incrementIterCount

    protected void incrementIterCount()

### resetIterCount

    protected void resetIterCount()

Apache JMeter

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