3.2.1: 2012-12-13

net.sf.basedb.util.overview.extensions
Class ReflectValidationRuleActionFactory

java.lang.Object
  extended by net.sf.basedb.util.overview.extensions.ReflectValidationRuleActionFactory
All Implemented Interfaces:
ActionFactory<ValidationRuleAction>

public class ReflectValidationRuleActionFactory
extends Object
implements ActionFactory<ValidationRuleAction>

Factory implementation for validation rule actions that uses reflection to access the value of a public static field and return that as the validation rule. The public static field must be a ValidationRuleAction object.

This factory has one configuration parameter field which is the fully qualified name for the field. Failure to access or use the class and/or field disabled the action and is reported to the log only.

Since:
3.2
Author:
nicklas

Field Summary
private  String fullFieldName
           
private  ValidationRuleAction rule
           
 
Constructor Summary
ReflectValidationRuleActionFactory()
           
 
Method Summary
 ValidationRuleAction[] getActions(InvokationContext<? super ValidationRuleAction> context)
          This method may be called one or several times for each request.
private  ValidationRuleAction getValidationRule(InvokationContext context)
           
 boolean prepareContext(InvokationContext<? super ValidationRuleAction> context)
          This method is called once for each request/use of an extension and have two purposes: The factory should decide if the extension should be enabled or not.
 void setField(String fullFieldName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fullFieldName

private String fullFieldName

rule

private ValidationRuleAction rule
Constructor Detail

ReflectValidationRuleActionFactory

public ReflectValidationRuleActionFactory()
Method Detail

prepareContext

public boolean prepareContext(InvokationContext<? super ValidationRuleAction> context)
Description copied from interface: ActionFactory
This method is called once for each request/use of an extension and have two purposes:

Specified by:
prepareContext in interface ActionFactory<ValidationRuleAction>
Parameters:
context - The current invokation context
Returns:
TRUE if the extension should be enabled, FALSE if the extension should be disabled

getActions

public ValidationRuleAction[] getActions(InvokationContext<? super ValidationRuleAction> context)
Description copied from interface: ActionFactory
This method may be called one or several times for each request. This is decided by the extension point. If, for example, the extension point is a pure single-item extension point then this method is probably only called once. If the extension point is a per-item extension point in a list context, then this method may be called once for every item in the list. The context parameter contains all information about the context of the extension point, including the current item, if any.

Specified by:
getActions in interface ActionFactory<ValidationRuleAction>
Parameters:
context - The current invokation context
Returns:
An array of actions that should be added to the extension point. Returns null or an empty array if there are no actions in the current context.

setField

public void setField(String fullFieldName)

getValidationRule

private ValidationRuleAction getValidationRule(InvokationContext context)

3.2.1: 2012-12-13