DefaultLifecycleProcessor.java 文件源码

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

项目:class-guard 作者:
public void stop() {
    if (this.members.isEmpty()) {
        return;
    }
    if (logger.isInfoEnabled()) {
        logger.info("Stopping beans in phase " + this.phase);
    }
    Collections.sort(this.members, Collections.reverseOrder());
    CountDownLatch latch = new CountDownLatch(this.smartMemberCount);
    Set<String> countDownBeanNames = Collections.synchronizedSet(new LinkedHashSet<String>());
    for (LifecycleGroupMember member : this.members) {
        if (this.lifecycleBeans.containsKey(member.name)) {
            doStop(this.lifecycleBeans, member.name, latch, countDownBeanNames);
        }
        else if (member.bean instanceof SmartLifecycle) {
            // already removed, must have been a dependent
            latch.countDown();
        }
    }
    try {
        latch.await(this.timeout, TimeUnit.MILLISECONDS);
        if (latch.getCount() > 0 && !countDownBeanNames.isEmpty() && logger.isWarnEnabled()) {
            logger.warn("Failed to shut down " + countDownBeanNames.size() + " bean" +
                    (countDownBeanNames.size() > 1 ? "s" : "") + " with phase value " +
                    this.phase + " within timeout of " + this.timeout + ": " + countDownBeanNames);
        }
    }
    catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号