WebFilterInstaller.java 文件源码

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

项目:dropwizard-guicey 作者:
@Override
public void install(final Environment environment, final Filter instance) {
    final Class<? extends Filter> extType = FeatureUtils.getInstanceClass(instance);
    final WebFilter annotation = FeatureUtils.getAnnotation(extType, WebFilter.class);
    final String[] servlets = annotation.servletNames();
    final String[] patterns = annotation.urlPatterns().length > 0 ? annotation.urlPatterns() : annotation.value();
    Preconditions.checkArgument(servlets.length > 0 || patterns.length > 0,
            "Filter %s not specified servlet or pattern for mapping", extType.getName());
    Preconditions.checkArgument(servlets.length == 0 || patterns.length == 0,
            "Filter %s specifies both servlets and patters, when only one allowed",
            extType.getName());
    final boolean servletMapping = servlets.length > 0;
    final AdminContext context = FeatureUtils.getAnnotation(extType, AdminContext.class);
    final String name = WebUtils.getFilterName(annotation, extType);
    reporter.line("%-15s %-5s %-2s (%s)   %s", Joiner.on(",").join(servletMapping ? servlets : patterns),
            WebUtils.getAsyncMarker(annotation), WebUtils.getContextMarkers(context), extType.getName(), name);

    if (WebUtils.isForMain(context)) {
        configure(environment.servlets(), instance, name, annotation);
    }
    if (WebUtils.isForAdmin(context)) {
        configure(environment.admin(), instance, name, annotation);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号