Search in sources :

Example 1 with ApplicationContextAware

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);
    }
}
Also used : ConverterException(org.grails.web.converters.exceptions.ConverterException) ApplicationContextAware(org.springframework.context.ApplicationContextAware) ConverterException(org.grails.web.converters.exceptions.ConverterException)

Example 2 with ApplicationContextAware

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);
    }
}
Also used : ApplicationContextAware(org.springframework.context.ApplicationContextAware)

Aggregations

ApplicationContextAware (org.springframework.context.ApplicationContextAware)2 ConverterException (org.grails.web.converters.exceptions.ConverterException)1