OnWebApplicationCondition.java 文件源码

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

项目:contestparser 作者:
private ConditionOutcome isWebApplication(ConditionContext context,
        AnnotatedTypeMetadata metadata) {

    if (!ClassUtils.isPresent(WEB_CONTEXT_CLASS, context.getClassLoader())) {
        return ConditionOutcome.noMatch("web application classes not found");
    }

    if (context.getBeanFactory() != null) {
        String[] scopes = context.getBeanFactory().getRegisteredScopeNames();
        if (ObjectUtils.containsElement(scopes, "session")) {
            return ConditionOutcome.match("found web application 'session' scope");
        }
    }

    if (context.getEnvironment() instanceof StandardServletEnvironment) {
        return ConditionOutcome
                .match("found web application StandardServletEnvironment");
    }

    if (context.getResourceLoader() instanceof WebApplicationContext) {
        return ConditionOutcome.match("found web application WebApplicationContext");
    }

    return ConditionOutcome.noMatch("not a web application");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号