Class DigesterLoader
- java.lang.Object
-
- org.apache.commons.digester.annotations.DigesterLoader
-
public final class DigesterLoader extends java.lang.ObjectThis class manages the creation of Digester instances analyzing target classes annotated with digester annotations.- Since:
- 2.1
-
-
Field Summary
Fields Modifier and Type Field Description private AnnotationRuleProviderFactoryannotationRuleProviderFactoryprivate RuleSetCachecachedRuleSetIn-memory LRU cache that stores already analyzed classes and relativeRuleSet.private DigesterLoaderHandlerFactorydigesterLoaderHandlerFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedDigesterLoader(AnnotationRuleProviderFactory annotationRuleProviderFactory, DigesterLoaderHandlerFactory digesterLoaderHandlerFactory)Creates a newDigesterLoaderinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRules(java.lang.Class<?> target, Digester digester)Add rules to an already created Digester instance, analyzing the digester annotations in the target class.voidaddRulesTo(java.lang.Class<?> target, FromAnnotationsRuleSet ruleSet)Analyzes the target class and adds theAnnotationRuleProviders to the existingFromAnnotationsRuleSet.DigestercreateDigester(java.lang.Class<?> target)Creates a new digester which rules are defined by analyzing the digester annotations in the target class.protected AnnotationRuleProviderFactorygetAnnotationRuleProviderFactory()protected DigesterLoaderHandlerFactorygetDigesterLoaderHandlerFactory()RuleSetgetRuleSet(java.lang.Class<?> target)Builds a newRuleSetanalyzing the digester annotations in the target class.private <A extends java.lang.annotation.Annotation,E extends java.lang.reflect.AnnotatedElement,R extends Rule>
voidhandle(A annotation, E element, FromAnnotationsRuleSet ruleSet)Handles the current visited element and related annotation, invoking the right handler putting the rule provider in the rule set.private voidhandle(java.lang.reflect.AnnotatedElement element, FromAnnotationsRuleSet ruleSet)Executes an analysis for each annotation present in the element.
-
-
-
Field Detail
-
cachedRuleSet
private final RuleSetCache cachedRuleSet
In-memory LRU cache that stores already analyzed classes and relativeRuleSet.
-
annotationRuleProviderFactory
private final AnnotationRuleProviderFactory annotationRuleProviderFactory
-
digesterLoaderHandlerFactory
private final DigesterLoaderHandlerFactory digesterLoaderHandlerFactory
-
-
Constructor Detail
-
DigesterLoader
protected DigesterLoader(AnnotationRuleProviderFactory annotationRuleProviderFactory, DigesterLoaderHandlerFactory digesterLoaderHandlerFactory)
Creates a newDigesterLoaderinstance.- Parameters:
annotationRuleProviderFactory-digesterLoaderHandlerFactory-
-
-
Method Detail
-
getAnnotationRuleProviderFactory
protected AnnotationRuleProviderFactory getAnnotationRuleProviderFactory()
-
getDigesterLoaderHandlerFactory
protected DigesterLoaderHandlerFactory getDigesterLoaderHandlerFactory()
-
createDigester
public Digester createDigester(java.lang.Class<?> target)
Creates a new digester which rules are defined by analyzing the digester annotations in the target class.- Parameters:
target- the class has to be analyzed.- Returns:
- a new Digester instance.
-
addRules
public void addRules(java.lang.Class<?> target, Digester digester)Add rules to an already created Digester instance, analyzing the digester annotations in the target class.- Parameters:
target- the class has to be analyzed.digester- the Digester instance reference.
-
getRuleSet
public RuleSet getRuleSet(java.lang.Class<?> target)
Builds a newRuleSetanalyzing the digester annotations in the target class. It avoids iterate the annotations analysis for already analyzed classes, using an in-memory LRU cache.- Parameters:
target- the class has to be analyzed.- Returns:
- a new
RuleSet.
-
addRulesTo
public void addRulesTo(java.lang.Class<?> target, FromAnnotationsRuleSet ruleSet)Analyzes the target class and adds theAnnotationRuleProviders to the existingFromAnnotationsRuleSet.- Parameters:
target- the class has to be analyzed.ruleSet- the RuleSet where adding the providers.
-
handle
private void handle(java.lang.reflect.AnnotatedElement element, FromAnnotationsRuleSet ruleSet)Executes an analysis for each annotation present in the element.- Parameters:
element- the current element under analysis.ruleSet- the ruleSet where add providers.
-
handle
private <A extends java.lang.annotation.Annotation,E extends java.lang.reflect.AnnotatedElement,R extends Rule> void handle(A annotation, E element, FromAnnotationsRuleSet ruleSet)
Handles the current visited element and related annotation, invoking the right handler putting the rule provider in the rule set.- Parameters:
annotation- the current visited annotation.element- the current visited element.
-
-