Class ExtensionsInvoker<A extends Action>
- java.lang.Object
-
- net.sf.basedb.util.extensions.ExtensionsInvoker<A>
-
- All Implemented Interfaces:
Iterable<A>
public class ExtensionsInvoker<A extends Action> extends Object implements Iterable<A>
Object of this class handles a single invokation of the extensions for one or several extension points. CallRegistry.useExtensions(ClientContext, ExtensionsFilter, String...)
to create an invoker object. With this object you caniterate()
over all actions created by the extensions, or use one of the render methods to render all actions automatically.The
renderDefault()
method uses the default render objects registered with the extension points and/or extensions (seeExtensionPoint.getRendererFactory()
andExtension.getRendererFactory()
). Since the registration of rendering factories are optional, therenderDefault()
method only works with extensions that have done so. If an action can't be associated with a renderer, an exception is thrown.If there is no default rendering factory or if you want to override the default renderer, you can use the
render(Renderer)
method. This will force the use of the specified renderer for all extensions, ignoring all renderers set by extension points or extensions.- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
clearErrors
private Collection<ExtensionContext<A>>
contexts
-
Constructor Summary
Constructors Constructor Description ExtensionsInvoker(Collection<ExtensionContext<A>> contexts)
Creates a new invoker object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getNumExtensions()
Get the number of enabled extensions in this invokation.ActionIterator<A>
iterate()
Create an iterator that iterates over allAction
:s created by the extensions.Iterator<A>
iterator()
void
render(Renderer<A> renderer)
Render all actions using a specific renderer.void
renderDefault()
Render all actions using the renderers created by the default renderer factories as specified by the registered extension points and/or extensions.void
renderDefault(WrappingRenderer<A> wrapper)
Render all actions by wrapping the default renderers by the given wrapping renderer.void
renderWithEvent(Renderer<A> renderer, EventType event)
Render all actions using a specific renderer and send the specified event to event handlers.void
setClearErrors(boolean clearErrors)
Set a flag to indicate if existing errors should be cleared before an action is rendered.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
contexts
private final Collection<ExtensionContext<A extends Action>> contexts
-
clearErrors
private boolean clearErrors
-
-
Constructor Detail
-
ExtensionsInvoker
ExtensionsInvoker(Collection<ExtensionContext<A>> contexts)
Creates a new invoker object.
-
-
Method Detail
-
setClearErrors
public void setClearErrors(boolean clearErrors)
Set a flag to indicate if existing errors should be cleared before an action is rendered. If this setting is not enabled (default) old errors are never cleared.- Parameters:
clearErrors
- TRUE to clear old errors, FALSE to keep them- Since:
- 2.9
-
getNumExtensions
public int getNumExtensions()
Get the number of enabled extensions in this invokation. Note that this number doesn't have to correspond to the actual number of actions since an extension may choose to create 0, 1 or more actions.- Returns:
- The number of enabled extensions
- Since:
- 2.12
-
iterate
public ActionIterator<A> iterate()
Create an iterator that iterates over allAction
:s created by the extensions. The iterator may return zero actions if none has been created.- Returns:
- An iterator
-
renderDefault
public void renderDefault()
Render all actions using the renderers created by the default renderer factories as specified by the registered extension points and/or extensions.
-
renderDefault
public void renderDefault(WrappingRenderer<A> wrapper)
Render all actions by wrapping the default renderers by the given wrapping renderer.- Parameters:
wrapper
- A wrapping renderer, or null to not wrap the default renderers- Since:
- 2.12
-
render
public void render(Renderer<A> renderer)
Render all actions using a specific renderer. The given renderer will be used even if an extension point has provided a renderer factory and disallowed overriding it.
-
renderWithEvent
public void renderWithEvent(Renderer<A> renderer, EventType event)
Render all actions using a specific renderer and send the specified event to event handlers.- Parameters:
event
- The event to send or null to not send any event- Since:
- 3.10
-
-