Search in sources :

Example 1 with UndertowOptions

use of io.undertow.UndertowOptions in project adeptj-runtime by AdeptJ.

the class BaseOptions method getOption.

/**
 * Search the given {@link Option} first in UndertowOptions class and if not found then Options class.
 *
 * @param name the option name
 * @param <T>  the option type
 * @return Option of correct resolved type as per the field type.
 */
@SuppressWarnings("unchecked")
<T> Option<T> getOption(String name) {
    Option<T> option = null;
    try {
        Field field = FieldUtils.getDeclaredField(UndertowOptions.class, name);
        if (field == null) {
            field = FieldUtils.getDeclaredField(Options.class, name);
        }
        if (field == null) {
            this.logger.error("[{}] field is not found either in class UndertowOptions or Options", name);
        }
        option = (field == null ? null : (Option<T>) field.get(null));
    } catch (IllegalArgumentException | IllegalAccessException ex) {
        this.logger.error("Exception while accessing field: [{}]", name, ex);
    }
    return option;
}
Also used : Field(java.lang.reflect.Field) Options(org.xnio.Options) UndertowOptions(io.undertow.UndertowOptions)

Aggregations

UndertowOptions (io.undertow.UndertowOptions)1 Field (java.lang.reflect.Field)1 Options (org.xnio.Options)1