@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { for (ViewResolver viewResolver : this.viewResolvers) { if (viewResolver instanceof ApplicationContextAware) { ((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext); } } }
@Override public Object initializeBean(Object existingBean, String beanName) throws BeansException { if (existingBean instanceof ApplicationContextAware) { ((ApplicationContextAware) existingBean).setApplicationContext(StubWebApplicationContext.this); } return existingBean; }
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { for (ViewResolver viewResolver : this.viewResolvers) { if (viewResolver instanceof ApplicationContextAware) { ((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext); } } }
@Override public void setApplicationContext(ApplicationContext context) throws BeansException { if (elasticsearchConverter instanceof ApplicationContextAware) { ((ApplicationContextAware) elasticsearchConverter).setApplicationContext(context); } }
@Override public void setApplicationContext(ApplicationContext context) throws BeansException { if (factory instanceof ApplicationContextAware) { ((ApplicationContextAware) factory).setApplicationContext(context); } }
/** * Add some factories to the set that will be used to load contexts and jobs. * * @param applicationContextFactory the {@link ApplicationContextFactory} values to use */ public void addApplicationContextFactory(ApplicationContextFactory applicationContextFactory) { if (applicationContextFactory instanceof ApplicationContextAware) { ((ApplicationContextAware) applicationContextFactory).setApplicationContext(applicationContext); } this.applicationContextFactories.add(applicationContextFactory); }
@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); } } }
((ApplicationContextAware) this.jobFactory).setApplicationContext(this.applicationContext);
((ApplicationContextAware) this.jobFactory).setApplicationContext(this.applicationContext);
@Override public void contextLoaded(ConfigurableApplicationContext context) { for (ApplicationListener<?> listener : this.application.getListeners()) { if (listener instanceof ApplicationContextAware) { ((ApplicationContextAware) listener).setApplicationContext(context); } context.addApplicationListener(listener); } this.initialMulticaster.multicastEvent( new ApplicationPreparedEvent(this.application, this.args, context)); }
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); } } }
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); } } }
@Test public void postProcessWhenApplicationContextAwareThenAwareInvoked() { this.spring.register(Config.class).autowire(); ApplicationContextAware toPostProcess = mock(ApplicationContextAware.class); this.objectObjectPostProcessor.postProcess(toPostProcess); verify(toPostProcess).setApplicationContext(isNotNull()); }
protected void initBeanPostProcessor(SpringCamelContext context) { if (beanPostProcessor != null) { if (beanPostProcessor instanceof ApplicationContextAware) { ((ApplicationContextAware) beanPostProcessor).setApplicationContext(applicationContext); } if (beanPostProcessor instanceof CamelBeanPostProcessor) { ((CamelBeanPostProcessor) beanPostProcessor).setCamelContext(getContext()); } } }
((ApplicationContextAware) resourceInstance).setApplicationContext(applicationContext);
@Override public Object initializeBean(Object existingBean, String beanName) throws BeansException { if (existingBean instanceof ApplicationContextAware) { ((ApplicationContextAware) existingBean).setApplicationContext(StubWebApplicationContext.this); } return existingBean; }
/** * Add some factories to the set that will be used to load contexts and jobs. * * @param applicationContextFactory the {@link ApplicationContextFactory} values to use */ public void addApplicationContextFactory(ApplicationContextFactory applicationContextFactory) { if (applicationContextFactory instanceof ApplicationContextAware) { ((ApplicationContextAware) applicationContextFactory).setApplicationContext(applicationContext); } this.applicationContextFactories.add(applicationContextFactory); }
((ApplicationContextAware) this.handler).setApplicationContext(this.applicationContext);
((ApplicationContextAware) bean).setApplicationContext(this.applicationContext);
private void wireAwareObjects(Object bean) { if (bean instanceof EnvironmentAware) { ((EnvironmentAware) bean).setEnvironment(environmentProvider.get()); } if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(beanFactoryProvider.get()); } if (bean instanceof ApplicationContextAware) { ((ApplicationContextAware) bean).setApplicationContext(applicationContextProvider.get()); } }