Class ActionIterator<A extends Action>

java.lang.Object
net.sf.basedb.util.extensions.ActionIterator<A>
All Implemented Interfaces:
Iterator<A>

public class ActionIterator<A extends Action> extends Object implements Iterator<A>
Iterator for iterating over all actions that will be created by extensions after a call to Registry.useExtensions(ClientContext, ExtensionsFilter, String...). That method returns an ExtensionsInvoker object which in it's turn uses this iterator.

Note the phrase "will be created" above. The actions are created on demand as this iterator moves on the next item. This happens in the hasNext() method, which, for each extension, calls Extension.getActionFactory() and then ActionFactory.getActions(InvokationContext).

The actions returned from the extensions are piled up in an internal buffer that the next() method pick items from. When the buffer is empty the iterator moves on to the actions from next extension until there are no more extensions and the action buffer is empty.

Version:
2.7
Author:
nicklas
Last modified
$Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
  • Field Details

    • currentContext

      private ExtensionContext<A extends Action> currentContext
    • currentAction

      private A extends Action currentAction
    • iterator

      private final Iterator<ExtensionContext<A extends Action>> iterator
    • actions

      private A extends Action[] actions
    • offset

      private int offset
    • checkNext

      private boolean checkNext
    • hasNext

      private boolean hasNext
  • Constructor Details

  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<A extends Action>
    • next

      public A next()
      Specified by:
      next in interface Iterator<A extends Action>
    • remove

      public void remove()
      Not supported.
      Specified by:
      remove in interface Iterator<A extends Action>
      Throws:
      UnsupportedOperationException - Always
    • getExtensionPoint

      public ExtensionPoint<? super A> getExtensionPoint()
      Get the extension point that the current action belongs to.
    • getExtension

      public Extension<? extends A> getExtension()
      Get the extension that created the current action.
    • getRenderer

      public Renderer<? super A> getRenderer()
      Gets the renderer for the current action.
      Since:
      2.9
    • handleEvent

      public void handleEvent(EventType event)
      Send the event to event handlers registered in the registry.
      Since:
      3.10
      See Also:
    • clearError

      public void clearError()
      Clear any error that has been registered for the current action.
      Since:
      2.9
      See Also:
    • setError

      public void setError(Throwable t)
      Register an error for the current action. The error is handled by the error handler for the extension point.
      Parameters:
      t - The error to register
      Since:
      2.9
    • setError

      public void setError(String message, Throwable t)
      Register an error with a message for the current action. The error is handled by the error handler for the extension point.
      Parameters:
      t - The error to register
      message - An optional message
      Since:
      2.17
    • validActions

      private boolean validActions(A[] actions)
      Check that the actions array is a not-null, non-empty array and contains actions of a type that is compatible with the ExtensionPoint.getActionClass() class.

      NOTE! If the array contains at least one invalid action, all actions, including the valid ones, will be ignored. No exception will be thrown. An error-level log message is written to the log file.

      Parameters:
      actions - The actions to check
      Returns:
      TRUE if the actions are valid, FALSE otherwise