Search in sources :

Example 1 with ApplicationFilters

use of ninja.application.ApplicationFilters in project ninja by ninjaframework.

the class RouteBuilderImpl method calculateGlobalFilters.

private List<Class<? extends Filter>> calculateGlobalFilters(Optional<List<Class<? extends Filter>>> globalFiltersList, Injector injector) {
    List<Class<? extends Filter>> allFilters = Lists.newArrayList();
    // by conf.Filters
    if (globalFiltersList.isPresent()) {
        allFilters.addAll(globalFiltersList.get());
    } else {
        String globalFiltersWithPrefixMaybe = ninjaBaseDirectoryResolver.resolveApplicationClassName(GLOBAL_FILTERS_DEFAULT_LOCATION);
        if (SwissKnife.doesClassExist(globalFiltersWithPrefixMaybe, this)) {
            try {
                Class<?> globalFiltersClass = Class.forName(globalFiltersWithPrefixMaybe);
                ApplicationFilters globalFilters = (ApplicationFilters) injector.getInstance(globalFiltersClass);
                globalFilters.addFilters(allFilters);
            } catch (Exception exception) {
            // That simply means the user did not configure conf.Filters.
            }
        }
    }
    return allFilters;
}
Also used : ApplicationFilters(ninja.application.ApplicationFilters)

Aggregations

ApplicationFilters (ninja.application.ApplicationFilters)1