AbstractJoynrServletModule.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:joynr 作者:
/**
 * Sets up filters that are annotated with the {@link WebFilter} annotation.
 * Every class in the classpath is searched for the annotation.
 */
@SuppressWarnings("unchecked")
private void bindAnnotatedFilters() {

    String appsPackages = null;
    if (System.getProperties().containsKey(IO_JOYNR_APPS_PACKAGES)) {
        logger.info("Using property {} from system properties", IO_JOYNR_APPS_PACKAGES);
        appsPackages = System.getProperty(IO_JOYNR_APPS_PACKAGES);
    } else {
        Properties servletProperties = PropertyLoader.loadProperties("servlet.properties");
        if (servletProperties.containsKey(IO_JOYNR_APPS_PACKAGES)) {
            appsPackages = servletProperties.getProperty(IO_JOYNR_APPS_PACKAGES);
        }
    }

    if (appsPackages != null) {
        String[] packageNames = appsPackages.split(";");
        logger.info("Searching packages for @WebFilter annotation: {}", Arrays.toString(packageNames));

        PackageNamesScanner scanner = new PackageNamesScanner(packageNames);
        AnnotationScannerListener sl = new AnnotationScannerListener(WebFilter.class);
        scanner.scan(sl);

        for (Class<?> webFilterAnnotatedClass : sl.getAnnotatedClasses()) {

            if (Filter.class.isAssignableFrom(webFilterAnnotatedClass)) {
                bind(webFilterAnnotatedClass).in(Singleton.class);
                filter("/*").through((Class<? extends Filter>) webFilterAnnotatedClass);
                logger.info("Adding filter {} for '/*'", webFilterAnnotatedClass.getName());
            }

        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号