Package net.sf.basedb.util.extensions
Class ExtensionContext<A extends Action>
java.lang.Object
net.sf.basedb.util.extensions.InvokationContext<A>
net.sf.basedb.util.extensions.ExtensionContext<A>
Invokation context for an extension. Most
calls are forwarded to the invokation context for the
extension point this extension belongs to.
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date: 2012-03-28 12:38:04 +0200 (on, 28 mar 2012) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Registry.RegisteredExtension<A>
private boolean
private final ExtensionPointContext<A>
-
Constructor Summary
ConstructorDescriptionExtensionContext
(ExtensionPointContext<A> mainContext, Registry.RegisteredExtension<A> extension) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Clear the registered error for the current extension or extension point.protected A[]
CallExtension.getActionFactory()
and thenActionFactory.getActions(InvokationContext)
on the returned factory.getAttribute
(String name) Get the value of an attribute that has been registered for the extension.The class loader is the class loader that loaded the action factory of the extension.Get the client context that was passed to theRegistry.useExtensions(ClientContext, ExtensionsFilter, String...)
method.protected ErrorHandler<? super A>
Get the error handler used in this context.Get information about the extension.ExtensionPoint<? super A>
Get information about the extension point.protected Registry
Get the registry where this invokation originated from.If the extension point allows it and this extension specifies a renderer factory, create a new renderer from it.(package private) void
handleError
(A action, String message, Throwable t) private void
handleError
(String message, Throwable t) (package private) boolean
protected void
Prepare the renderer factory if the extension or extension point has one.protected void
Register an error for the current extension or extension point.
-
Field Details
-
mainContext
-
extension
-
renderer
-
hasCreatedRenderer
private boolean hasCreatedRenderer
-
-
Constructor Details
-
ExtensionContext
ExtensionContext(ExtensionPointContext<A> mainContext, Registry.RegisteredExtension<A> extension)
-
-
Method Details
-
getClientContext
Description copied from class:InvokationContext
Get the client context that was passed to theRegistry.useExtensions(ClientContext, ExtensionsFilter, String...)
method.- Specified by:
getClientContext
in classInvokationContext<A extends Action>
- Returns:
- The client context, or null if the client didn't pass any context object
-
getExtensionPoint
Description copied from class:InvokationContext
Get information about the extension point.- Specified by:
getExtensionPoint
in classInvokationContext<A extends Action>
- Returns:
- An extension point object
-
getExtension
Description copied from class:InvokationContext
Get information about the extension. This method may return null if there is no current extension, which happens when any of theRendererFactory
methods are called for a renderer factory attached to an extension point and for theErrorHandlerFactory
methods.- Specified by:
getExtension
in classInvokationContext<A extends Action>
- Returns:
- An extension object, or null if there is no current extension
-
getClassLoader
The class loader is the class loader that loaded the action factory of the extension.- Specified by:
getClassLoader
in classInvokationContext<A extends Action>
-
getAttribute
Description copied from class:InvokationContext
Get the value of an attribute that has been registered for the extension.- Specified by:
getAttribute
in classInvokationContext<A extends Action>
- Parameters:
name
- The name of the attribute- Returns:
- The attribute value, or null if no attribute has been registered
- See Also:
-
getRegistry
Description copied from class:InvokationContext
Get the registry where this invokation originated from.- Specified by:
getRegistry
in classInvokationContext<A extends Action>
-
prepareRendererFactory
protected void prepareRendererFactory()Description copied from class:InvokationContext
Prepare the renderer factory if the extension or extension point has one.- Specified by:
prepareRendererFactory
in classInvokationContext<A extends Action>
-
getRenderer
If the extension point allows it and this extension specifies a renderer factory, create a new renderer from it. Otherwise, get the renderer from the extension point.- Specified by:
getRenderer
in classInvokationContext<A extends Action>
-
getActions
CallExtension.getActionFactory()
and thenActionFactory.getActions(InvokationContext)
on the returned factory.- Specified by:
getActions
in classInvokationContext<A extends Action>
-
setError
Description copied from class:InvokationContext
Register an error for the current extension or extension point. Registered errors can be retrieved byRegistry.getLastExtensionError(String)
andRegistry.getLastExtensionPointError(String)
- Specified by:
setError
in classInvokationContext<A extends Action>
- Parameters:
action
- The action that caused the errort
- The error
-
clearError
protected void clearError()Description copied from class:InvokationContext
Clear the registered error for the current extension or extension point.- Specified by:
clearError
in classInvokationContext<A extends Action>
-
getErrorHandler
Description copied from class:InvokationContext
Get the error handler used in this context. Should never be null, since if not the extension point provides one, the system should.- Specified by:
getErrorHandler
in classInvokationContext<A extends Action>
-
prepareActionFactory
boolean prepareActionFactory() -
handleError
-
handleError
-