Search in sources :

Example 1 with AnnotationParser

use of jodd.util.AnnotationParser in project jodd by oblac.

the class ActionConfigManager method bindAnnotationConfig.

/**
 * Binds action annotation and the action config. This can overwrite the default annotation
 * configuration of an annotation.
 */
public void bindAnnotationConfig(final Class<? extends Annotation> annotationType, final Class<? extends ActionConfig> actionConfigClass) {
    final ActionConfig actionConfig = registerNewActionConfiguration(actionConfigClass);
    actionConfigs.put(annotationType, actionConfig);
    for (final AnnotationParser annotationParser : annotationParsers) {
        if (annotationType.equals(annotationParser.getAnnotationType())) {
            // parser already exists
            return;
        }
    }
    annotationParsers = ArraysUtil.append(annotationParsers, new AnnotationParser(annotationType, Action.class));
}
Also used : ActionConfig(jodd.madvoc.ActionConfig) AnnotationParser(jodd.util.AnnotationParser)

Example 2 with AnnotationParser

use of jodd.util.AnnotationParser in project jodd by oblac.

the class ActionAnnotationTest method testMiscActionAnnotation.

@Test
void testMiscActionAnnotation() throws NoSuchMethodException {
    final AnnotationParser annotationParser = parserFor(MiscAnnotation.class);
    Method method = this.getClass().getMethod("hello5");
    ActionAnnotationValues annotationValues = ActionAnnotationValues.of(annotationParser, method);
    assertNull(annotationValues.alias());
    assertEquals("VAL", annotationValues.value());
    method = this.getClass().getMethod("hello6");
    annotationValues = ActionAnnotationValues.of(annotationParser, method);
    assertNull(annotationValues.alias());
    assertEquals("VAL", annotationValues.value());
}
Also used : AnnotationParser(jodd.util.AnnotationParser) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Example 3 with AnnotationParser

use of jodd.util.AnnotationParser in project jodd by oblac.

the class ActionAnnotationTest method testCustomActionAnnotation.

@Test
void testCustomActionAnnotation() throws NoSuchMethodException {
    final AnnotationParser annotationParser = parserFor(CustomAction.class);
    Method method = this.getClass().getMethod("hello3");
    ActionAnnotationValues annotationValues = ActionAnnotationValues.of(annotationParser, method);
    assertEquals("ALIAS", annotationValues.alias());
    assertNull(annotationValues.value());
    method = this.getClass().getMethod("hello4");
    annotationValues = ActionAnnotationValues.of(annotationParser, method);
    assertEquals("ALIAS", annotationValues.alias());
    assertNull(annotationValues.value());
}
Also used : AnnotationParser(jodd.util.AnnotationParser) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotationParser (jodd.util.AnnotationParser)3 Method (java.lang.reflect.Method)2 Test (org.junit.jupiter.api.Test)2 ActionConfig (jodd.madvoc.ActionConfig)1