org.springframework.context.ApplicationContextAware Java Examples

The following examples show how to use org.springframework.context.ApplicationContextAware. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationContextAwareProcessor.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
@Nullable
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
	AccessControlContext acc = null;

	if (System.getSecurityManager() != null &&
			(bean instanceof EnvironmentAware || bean instanceof EmbeddedValueResolverAware ||
					bean instanceof ResourceLoaderAware || bean instanceof ApplicationEventPublisherAware ||
					bean instanceof MessageSourceAware || bean instanceof ApplicationContextAware)) {
		acc = this.applicationContext.getBeanFactory().getAccessControlContext();
	}

	if (acc != null) {
		AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
			invokeAwareInterfaces(bean);
			return null;
		}, acc);
	}
	else {
		invokeAwareInterfaces(bean);
	}

	return bean;
}
 
Example #2
Source File: ShibcasAuthServlet.java    From shib-cas-authn3 with Apache License 2.0 6 votes vote down vote up
private void buildParameterBuilders(final ApplicationContext applicationContext) {
    final Environment environment = applicationContext.getEnvironment();
    final String builders = StringUtils.defaultString(environment.getProperty("shibcas.parameterBuilders", ""));
    for (final String parameterBuilder : StringUtils.split(builders, ";")) {
        try {
            logger.debug("Loading parameter builder class {}", parameterBuilder);
            final Class clazz = Class.forName(parameterBuilder);
            final IParameterBuilder builder = IParameterBuilder.class.cast(clazz.newInstance());
            if (builder instanceof ApplicationContextAware) {
                ((ApplicationContextAware) builder).setApplicationContext(applicationContext);
            }
            this.parameterBuilders.add(builder);
            logger.debug("Added parameter builder {}", parameterBuilder);
        } catch (final Throwable e) {
            logger.error("Error building parameter builder with name: " + parameterBuilder, e);
        }
    }
}
 
Example #3
Source File: ShibcasAuthServlet.java    From shib-cas-authn3 with Apache License 2.0 6 votes vote down vote up
private void buildParameterBuilders(final ApplicationContext applicationContext) {
    final Environment environment = applicationContext.getEnvironment();
    final String builders = StringUtils.defaultString(environment.getProperty("shibcas.parameterBuilders", ""));
    for (final String parameterBuilder : StringUtils.split(builders, ";")) {
        try {
            logger.debug("Loading parameter builder class {}", parameterBuilder);
            final Class clazz = Class.forName(parameterBuilder);
            final IParameterBuilder builder = IParameterBuilder.class.cast(clazz.newInstance());
            if (builder instanceof ApplicationContextAware) {
                ((ApplicationContextAware) builder).setApplicationContext(applicationContext);
            }
            this.parameterBuilders.add(builder);
            logger.debug("Added parameter builder {}", parameterBuilder);
        } catch (final Throwable e) {
            logger.error("Error building parameter builder with name: " + parameterBuilder, e);
        }
    }
}
 
Example #4
Source File: ActionsImpl.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Action instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize UI Component - calling afterPropertiesSet for " +
                            instance.getClass(), e);
        }
    }
}
 
Example #5
Source File: DesktopComponentsFactory.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Component instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize Component - calling afterPropertiesSet for " +
                            instance.getClass());
        }
    }
}
 
Example #6
Source File: WebAbstractDataGrid.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Renderer instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException("Unable to initialize Renderer - calling afterPropertiesSet for " +
                    instance.getClass(), e);
        }
    }
}
 
Example #7
Source File: WebUiComponents.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Component instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize UI Component - calling afterPropertiesSet for " +
                            instance.getClass(), e);
        }
    }
}
 
Example #8
Source File: WebFacets.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Facet instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize UI Component - calling afterPropertiesSet for " +
                            instance.getClass(), e);
        }
    }
}
 
Example #9
Source File: AppUI.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Object instance, ApplicationContext applicationContext) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize UI Component - calling afterPropertiesSet for " +
                            instance.getClass(), e);
        }
    }
}
 
Example #10
Source File: StandaloneMockMvcBuilder.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			((ApplicationContextAware) resolver).setApplicationContext(getApplicationContext());
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
Example #11
Source File: ApplicationContextAwareProcessor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**��beanʵ�ֵ�aware�������лص�
 * @param bean
 */
private void invokeAwareInterfaces(Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof EnvironmentAware) {
			((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment());
		}
		if (bean instanceof EmbeddedValueResolverAware) {
			((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(
					new EmbeddedValueResolver(this.applicationContext.getBeanFactory()));
		}
		if (bean instanceof ResourceLoaderAware) {
			((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext);
		}
		if (bean instanceof ApplicationEventPublisherAware) {
			((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext);
		}
		if (bean instanceof MessageSourceAware) {
			((MessageSourceAware) bean).setMessageSource(this.applicationContext);
		}
		if (bean instanceof ApplicationContextAware) {
			((ApplicationContextAware) bean).setApplicationContext(this.applicationContext);
		}
	}
}
 
Example #12
Source File: ApplicationContextAwareProcessor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void invokeAwareInterfaces(Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof EnvironmentAware) {
			((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment());
		}
		if (bean instanceof EmbeddedValueResolverAware) {
			((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver);
		}
		if (bean instanceof ResourceLoaderAware) {
			((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext);
		}
		if (bean instanceof ApplicationEventPublisherAware) {
			((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext);
		}
		if (bean instanceof MessageSourceAware) {
			((MessageSourceAware) bean).setMessageSource(this.applicationContext);
		}
		if (bean instanceof ApplicationContextAware) {
			((ApplicationContextAware) bean).setApplicationContext(this.applicationContext);
		}
	}
}
 
Example #13
Source File: ApplicationContextAwareProcessor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
	AccessControlContext acc = null;

	if (System.getSecurityManager() != null &&
			(bean instanceof EnvironmentAware || bean instanceof EmbeddedValueResolverAware ||
					bean instanceof ResourceLoaderAware || bean instanceof ApplicationEventPublisherAware ||
					bean instanceof MessageSourceAware || bean instanceof ApplicationContextAware)) {
		acc = this.applicationContext.getBeanFactory().getAccessControlContext();
	}

	if (acc != null) {
		AccessController.doPrivileged(new PrivilegedAction<Object>() {
			@Override
			public Object run() {
				invokeAwareInterfaces(bean);
				return null;
			}
		}, acc);
	}
	else {
		invokeAwareInterfaces(bean);
	}

	return bean;
}
 
Example #14
Source File: StandaloneMockMvcBuilder.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			ApplicationContext applicationContext  = getApplicationContext();
			if (applicationContext != null) {
				((ApplicationContextAware) resolver).setApplicationContext(applicationContext);
			}
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
Example #15
Source File: ApplicationContextAwareProcessor.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void invokeAwareInterfaces(Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof EnvironmentAware) {
			((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment());
		}
		if (bean instanceof EmbeddedValueResolverAware) {
			((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver);
		}
		if (bean instanceof ResourceLoaderAware) {
			((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext);
		}
		if (bean instanceof ApplicationEventPublisherAware) {
			((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext);
		}
		if (bean instanceof MessageSourceAware) {
			((MessageSourceAware) bean).setMessageSource(this.applicationContext);
		}
		if (bean instanceof ApplicationContextAware) {
			((ApplicationContextAware) bean).setApplicationContext(this.applicationContext);
		}
	}
}
 
Example #16
Source File: StandaloneMockMvcBuilder.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			ApplicationContext applicationContext = getApplicationContext();
			if (applicationContext != null) {
				((ApplicationContextAware) resolver).setApplicationContext(applicationContext);
			}
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
Example #17
Source File: ApplicationContextAwareProcessor.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void invokeAwareInterfaces(Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof EnvironmentAware) {
			((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment());
		}
		if (bean instanceof EmbeddedValueResolverAware) {
			((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver);
		}
		if (bean instanceof ResourceLoaderAware) {
			((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext);
		}
		if (bean instanceof ApplicationEventPublisherAware) {
			((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext);
		}
		if (bean instanceof MessageSourceAware) {
			((MessageSourceAware) bean).setMessageSource(this.applicationContext);
		}
		if (bean instanceof ApplicationContextAware) {
			((ApplicationContextAware) bean).setApplicationContext(this.applicationContext);
		}
	}
}
 
Example #18
Source File: ApplicationContextAwareProcessor.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
@Nullable
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
	AccessControlContext acc = null;

	if (System.getSecurityManager() != null &&
			(bean instanceof EnvironmentAware || bean instanceof EmbeddedValueResolverAware ||
					bean instanceof ResourceLoaderAware || bean instanceof ApplicationEventPublisherAware ||
					bean instanceof MessageSourceAware || bean instanceof ApplicationContextAware)) {
		acc = this.applicationContext.getBeanFactory().getAccessControlContext();
	}

	if (acc != null) {
		AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
			invokeAwareInterfaces(bean);
			return null;
		}, acc);
	}
	else {
		invokeAwareInterfaces(bean);
	}

	return bean;
}
 
Example #19
Source File: StubWebApplicationContext.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public Object initializeBean(Object existingBean, String beanName) throws BeansException {
	if (existingBean instanceof ApplicationContextAware) {
		((ApplicationContextAware) existingBean).setApplicationContext(StubWebApplicationContext.this);
	}
	return existingBean;
}
 
Example #20
Source File: PolygeneApplicationFactoryBean.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
@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 );
    }
}
 
Example #21
Source File: ViewResolverComposite.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	for (ViewResolver viewResolver : this.viewResolvers) {
		if (viewResolver instanceof ApplicationContextAware) {
			((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext);
		}
	}
}
 
Example #22
Source File: StubWebApplicationContext.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public Object initializeBean(Object existingBean, String beanName) throws BeansException {
	if (existingBean instanceof ApplicationContextAware) {
		((ApplicationContextAware) existingBean).setApplicationContext(StubWebApplicationContext.this);
	}
	return existingBean;
}
 
Example #23
Source File: StubWebApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Object initializeBean(Object existingBean, String beanName) throws BeansException {
	if (existingBean instanceof ApplicationContextAware) {
		((ApplicationContextAware) existingBean).setApplicationContext(StubWebApplicationContext.this);
	}
	return existingBean;
}
 
Example #24
Source File: ViewResolverComposite.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	for (ViewResolver viewResolver : this.viewResolvers) {
		if (viewResolver instanceof ApplicationContextAware) {
			((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext);
		}
	}
}
 
Example #25
Source File: ApplicationContextAwareProcessor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
	AccessControlContext acc = null;

	if (System.getSecurityManager() != null &&
			(bean instanceof EnvironmentAware || bean instanceof EmbeddedValueResolverAware ||
					bean instanceof ResourceLoaderAware || bean instanceof ApplicationEventPublisherAware ||
					bean instanceof MessageSourceAware || bean instanceof ApplicationContextAware)) {
		
		acc = this.applicationContext.getBeanFactory().getAccessControlContext();
	}

	if (acc != null) {
		AccessController.doPrivileged(new PrivilegedAction<Object>() {
			@Override
			public Object run() {
				invokeAwareInterfaces(bean);
				return null;
			}
		}, acc);
	}
	else {
		invokeAwareInterfaces(bean);
	}

	return bean;
}
 
Example #26
Source File: AbstractApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Configure the factory's standard context characteristics,
 * such as the context's ClassLoader and post-processors.
 * @param beanFactory the BeanFactory to configure
 */
protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
	// Tell the internal bean factory to use the context's class loader etc.
	beanFactory.setBeanClassLoader(getClassLoader());
	beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver(beanFactory.getBeanClassLoader()));
	beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar(this, getEnvironment()));

	// Configure the bean factory with context callbacks.
	beanFactory.addBeanPostProcessor(new ApplicationContextAwareProcessor(this));
	beanFactory.ignoreDependencyInterface(ResourceLoaderAware.class);
	beanFactory.ignoreDependencyInterface(ApplicationEventPublisherAware.class);
	beanFactory.ignoreDependencyInterface(MessageSourceAware.class);
	beanFactory.ignoreDependencyInterface(ApplicationContextAware.class);
	beanFactory.ignoreDependencyInterface(EnvironmentAware.class);

	// BeanFactory interface not registered as resolvable type in a plain factory.
	// MessageSource registered (and found for autowiring) as a bean.
	beanFactory.registerResolvableDependency(BeanFactory.class, beanFactory);
	beanFactory.registerResolvableDependency(ResourceLoader.class, this);
	beanFactory.registerResolvableDependency(ApplicationEventPublisher.class, this);
	beanFactory.registerResolvableDependency(ApplicationContext.class, this);

	// Detect a LoadTimeWeaver and prepare for weaving, if found.
	if (beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
		beanFactory.addBeanPostProcessor(new LoadTimeWeaverAwareProcessor(beanFactory));
		// Set a temporary ClassLoader for type matching.
		beanFactory.setTempClassLoader(new ContextTypeMatchClassLoader(beanFactory.getBeanClassLoader()));
	}

	// Register default environment beans.
	if (!beanFactory.containsLocalBean(ENVIRONMENT_BEAN_NAME)) {
		beanFactory.registerSingleton(ENVIRONMENT_BEAN_NAME, getEnvironment());
	}
	if (!beanFactory.containsLocalBean(SYSTEM_PROPERTIES_BEAN_NAME)) {
		beanFactory.registerSingleton(SYSTEM_PROPERTIES_BEAN_NAME, getEnvironment().getSystemProperties());
	}
	if (!beanFactory.containsLocalBean(SYSTEM_ENVIRONMENT_BEAN_NAME)) {
		beanFactory.registerSingleton(SYSTEM_ENVIRONMENT_BEAN_NAME, getEnvironment().getSystemEnvironment());
	}
}
 
Example #27
Source File: LifecycleAwareCacheDataImporterExporter.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
/**
 * Configures a reference to the Spring {@link ApplicationContext}.
 *
 * @param applicationContext Spring {@link ApplicationContext} in which this component operates.
 * @see org.springframework.context.ApplicationContext
 */
@Override
public void setApplicationContext(ApplicationContext applicationContext) {

	CacheDataImporterExporter importerExporter = getCacheDataImporterExporter();

	if (applicationContext != null && importerExporter instanceof ApplicationContextAware) {
		((ApplicationContextAware) importerExporter).setApplicationContext(applicationContext);
	}
}
 
Example #28
Source File: SpringConfigProvider.java    From jetcache with Apache License 2.0 5 votes vote down vote up
@Override
public void doInit() {
    if (encoderParser instanceof ApplicationContextAware) {
        ((ApplicationContextAware) encoderParser).setApplicationContext(applicationContext);
    }
    if (keyConvertorParser instanceof ApplicationContextAware) {
        ((ApplicationContextAware) keyConvertorParser).setApplicationContext(applicationContext);
    }
    super.doInit();
}
 
Example #29
Source File: ViewResolverComposite.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	for (ViewResolver viewResolver : this.viewResolvers) {
		if (viewResolver instanceof ApplicationContextAware) {
			((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext);
		}
	}
}
 
Example #30
Source File: ViewResolverComposite.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	for (ViewResolver viewResolver : this.viewResolvers) {
		if (viewResolver instanceof ApplicationContextAware) {
			((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext);
		}
	}
}