BrpApplicatieStartListener.java 文件源码

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

项目:OperatieBRP 作者:
@Override
public final void onApplicationEvent(final ApplicationContextEvent event) {
    try {
        final ApplicationContext context = event.getApplicationContext();
        if (context instanceof XmlWebApplicationContext) {
            final XmlWebApplicationContext ctx = (XmlWebApplicationContext) context;
            String webContextName = ctx.getServletContext().getServletContextName();
            if (webContextName.contains("/")) {
                webContextName = webContextName.substring(webContextName.indexOf('/'));
            }
            ctx.setDisplayName(webContextName);
            MDC.put(LeveringVeld.MDC_APPLICATIE_NAAM, webContextName).close();
        }
        LOGGER.debug("Context event '{}'; id='{}', displayName='{}'", event.getClass().getSimpleName(), event
                .getApplicationContext().getId(), event.getApplicationContext().getDisplayName());

        if (event instanceof ContextClosedEvent) {
            LOGGER.info("==> Context voor applicatie '{}' is gestopt", event.getApplicationContext().getId());
        }
        /* Wanneer een applicatie is gestart, dan wordt een ContextRefreshedEvent gestuurt **/
        if (event instanceof ContextRefreshedEvent) {
            LOGGER.info("==> Context voor applicatie '{}' is gestart/herstart", event.getApplicationContext()
                    .getId());
            logJvmSettings();
        }
    } catch (final ApplicationContextException ex) {
        LOGGER.error("Fout bij het opstarten van de applicatiecontext bij event {}", event.toString(), ex);
    }


}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号