2.17.2: 2011-06-17

net.sf.basedb.util.extensions
Class ExtensionContext<A extends Action>

java.lang.Object
  extended by net.sf.basedb.util.extensions.InvokationContext<A>
      extended by net.sf.basedb.util.extensions.ExtensionContext<A>

 class ExtensionContext<A extends Action>
extends InvokationContext<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: 2010-11-15 13:32:35 +0100 (Mon, 15 Nov 2010) $

Field Summary
private  Registry.RegisteredExtension<A> extension
           
private  boolean hasCreatedRenderer
           
private  ExtensionPointContext<A> mainContext
           
private  Renderer<? super A> renderer
           
 
Constructor Summary
ExtensionContext(ExtensionPointContext<A> mainContext, Registry.RegisteredExtension<A> extension)
           
 
Method Summary
protected  void clearError()
          Clear the registered error for the current extension or extension point.
protected  A[] getActions()
          Call Extension.getActionFactory() and then ActionFactory.getActions(InvokationContext) on the returned factory.
 Object getAttribute(String name)
          Get the value of an attribute that has been registered for the extension.
 ClientContext getClientContext()
          Get the client context that was passed to the Registry.useExtensions(ClientContext, ExtensionsFilter, String...)
protected  ErrorHandler<? super A> getErrorHandler()
          Get the error handler used in this context.
 Extension<A> getExtension()
          Get information about the extension.
 ExtensionPoint<? super A> getExtensionPoint()
          Get information about the extension point.
protected  Registry getRegistry()
          Get the registry where this invokation originated from.
protected  Renderer<? super A> getRenderer()
          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 prepareActionFactory()
           
protected  void prepareRendererFactory()
          Prepare the renderer factory if the extension or extension point has one.
protected  void setError(A action, Throwable t)
          Register an error for the current extension or extension point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainContext

private final ExtensionPointContext<A extends Action> mainContext

extension

private final Registry.RegisteredExtension<A extends Action> extension

renderer

private Renderer<? super A extends Action> renderer

hasCreatedRenderer

private boolean hasCreatedRenderer
Constructor Detail

ExtensionContext

ExtensionContext(ExtensionPointContext<A> mainContext,
                 Registry.RegisteredExtension<A> extension)
Method Detail

getClientContext

public ClientContext getClientContext()
Description copied from class: InvokationContext
Get the client context that was passed to the Registry.useExtensions(ClientContext, ExtensionsFilter, String...) method.

Specified by:
getClientContext in class InvokationContext<A extends Action>
Returns:
The client context, or null if the client didn't pass any context object

getExtensionPoint

public ExtensionPoint<? super A> getExtensionPoint()
Description copied from class: InvokationContext
Get information about the extension point.

Specified by:
getExtensionPoint in class InvokationContext<A extends Action>
Returns:
An extension point object

getExtension

public Extension<A> 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 the RendererFactory methods are called for a renderer factory attached to an extension point and for the ErrorHandlerFactory methods.

Specified by:
getExtension in class InvokationContext<A extends Action>
Returns:
An extension object, or null if there is no current extension

getAttribute

public Object getAttribute(String name)
Description copied from class: InvokationContext
Get the value of an attribute that has been registered for the extension.

Specified by:
getAttribute in class InvokationContext<A extends Action>
Parameters:
name - The name of the attribute
Returns:
The attribute value, or null if no attribute has been registered
See Also:
Registry.getAttribute(String, String)

getRegistry

protected Registry getRegistry()
Description copied from class: InvokationContext
Get the registry where this invokation originated from.

Specified by:
getRegistry in class InvokationContext<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 class InvokationContext<A extends Action>

getRenderer

protected Renderer<? super A> 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 class InvokationContext<A extends Action>

getActions

protected A[] getActions()
Call Extension.getActionFactory() and then ActionFactory.getActions(InvokationContext) on the returned factory.

Specified by:
getActions in class InvokationContext<A extends Action>

setError

protected void setError(A action,
                        Throwable t)
Description copied from class: InvokationContext
Register an error for the current extension or extension point. Registered errors can be retrieved by Registry.getLastExtensionError(String) and Registry.getLastExtensionPointError(String)

Specified by:
setError in class InvokationContext<A extends Action>
Parameters:
action - The action that caused the error
t - 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 class InvokationContext<A extends Action>

getErrorHandler

protected ErrorHandler<? super A> 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 class InvokationContext<A extends Action>

prepareActionFactory

boolean prepareActionFactory()

handleError

private void handleError(String message,
                         Throwable t)

handleError

void handleError(A action,
                 String message,
                 Throwable t)

2.17.2: 2011-06-17