@PostConstruct public void init() { synchronized (LOCK_OBJECT) { Object obj = context.getBean(DEFAULT_MESSAGE_SOURCE); if (obj instanceof DefaultResourceBundleMessageSource) { bundleMessageSource = (DefaultResourceBundleMessageSource) obj; } else if (obj instanceof DelegatingMessageSource) { DelegatingMessageSource delegatingMessageSource = (DelegatingMessageSource) obj; Object obj2 = delegatingMessageSource.getParentMessageSource(); if (obj2 instanceof DefaultResourceBundleMessageSource) { bundleMessageSource = (DefaultResourceBundleMessageSource) obj2; } else { throw new RuntimeException("can not find any messageSource what is DefaultResourceBundleMessageSource!"); } } } }