publicclassSessionMessageSourceextendsResourceBundleMessageSource{staticfinalLoggerlogger=LoggerFactory.getLogger(SessionMessageSource.class);privateString[]basenames=newString[0];@OverrideprotectedStringresolveCodeWithoutArguments(Stringcode,Localelocale){ServletRequestAttributesattr=(ServletRequestAttributes)RequestContextHolder.currentRequestAttributes();finalStringbrand=(String)attr.getAttribute("brand",RequestAttributes.SCOPE_SESSION);logger.debug(brand);ArrayList<String>basenameList=Lists.newArrayList(basenames);for(Stringbasename:basenameList){if(StringUtils.endsWithIgnoreCase(basename,brand)){ResourceBundlebundle=getResourceBundle(basename,locale);if(bundle!=null){returngetStringOrNull(bundle,code);}}}returnnull;}@OverridepublicvoidsetBasenames(String...basenames){if(basenames!=null){this.basenames=newString[basenames.length];for(inti=0;i<basenames.length;i++){Stringbasename=basenames[i];Assert.hasText(basename,"Basename must not be empty");this.basenames[i]=basename.trim();}}else{this.basenames=newString[0];}super.setBasenames(basenames);}privateStringgetStringOrNull(ResourceBundlebundle,Stringkey){try{returnbundle.getString(key);}catch(MissingResourceExceptionex){// Assume key not found// -> do NOT throw the exception to allow for checking parent message source.returnnull;}}}