use of org.springframework.context.ApplicationContextAware in project grails-core by grails.
the class ConverterUtil method createConverter.
public static <T> T createConverter(Class<T> converterClass, Object target, ApplicationContext applicationContext) throws ConverterException {
try {
T converter = converterClass.newInstance();
if (converter instanceof ApplicationContextAware && applicationContext != null) {
((ApplicationContextAware) converter).setApplicationContext(applicationContext);
}
((AbstractConverter) converter).setTarget(target);
return converter;
} catch (Exception e) {
throw new ConverterException("Initialization of Converter Object " + converterClass.getName() + " failed for target " + target.getClass().getName(), e);
}
}
use of org.springframework.context.ApplicationContextAware in project qi4j-sdk by Qi4j.
the class Qi4jApplicationFactoryBean method setApplicationContext.
@Override
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
if (this.applicationBootstrap instanceof ApplicationContextAware) {
// propagate application context to the application bootstrap
ApplicationContextAware aware = (ApplicationContextAware) this.applicationBootstrap;
aware.setApplicationContext(applicationContext);
}
}
Aggregations