@ Override public void setApplicationContext ( ApplicationContext appContext ) throws BeansException { try ( InputStream is = originalResource . getInputStream ( ) ; ) { ConfigurableListableBeanFactory beanFactory = ( ( AbstractRefreshableApplicationContext ) appContext ) . getBeanFactory ( ) ; StringBuilder sb = new StringBuilder ( ) ; Iterator < String > iter = IOUtils . lineIterator ( is , "UTF-8" ) ; boolean transformed = false ; while ( iter . hasNext ( ) ) { String line = iter . next ( ) ; if ( line . contains ( "${" ) ) { transformed = true ; line = beanFactory . resolveEmbeddedValue ( line ) ; } sb . append ( line ) ; } transformedResource = ! transformed ? originalResource : new ByteArrayResource ( sb . toString ( ) . getBytes ( ) ) ; } catch ( IOException e ) { throw MiscUtil . toUnchecked ( e ) ; } }
Use the application context to resolve any embedded property values within the original resource .