org.springframework.beans.factory.BeanClassLoaderAware Java Examples
The following examples show how to use
org.springframework.beans.factory.BeanClassLoaderAware.
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: ConfigurationClassProcessingTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void configWithFactoryBeanReturnType() { ListableBeanFactory factory = initBeanFactory(ConfigWithNonSpecificReturnTypes.class); assertEquals(List.class, factory.getType("factoryBean")); assertTrue(factory.isTypeMatch("factoryBean", List.class)); assertEquals(FactoryBean.class, factory.getType("&factoryBean")); assertTrue(factory.isTypeMatch("&factoryBean", FactoryBean.class)); assertFalse(factory.isTypeMatch("&factoryBean", BeanClassLoaderAware.class)); assertFalse(factory.isTypeMatch("&factoryBean", ListFactoryBean.class)); assertTrue(factory.getBean("factoryBean") instanceof List); String[] beanNames = factory.getBeanNamesForType(FactoryBean.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(BeanClassLoaderAware.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(ListFactoryBean.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(List.class); assertEquals("factoryBean", beanNames[0]); }
Example #2
Source File: ConfigurationClassProcessingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void configWithFactoryBeanReturnType() { ListableBeanFactory factory = initBeanFactory(ConfigWithNonSpecificReturnTypes.class); assertEquals(List.class, factory.getType("factoryBean")); assertTrue(factory.isTypeMatch("factoryBean", List.class)); assertEquals(FactoryBean.class, factory.getType("&factoryBean")); assertTrue(factory.isTypeMatch("&factoryBean", FactoryBean.class)); assertFalse(factory.isTypeMatch("&factoryBean", BeanClassLoaderAware.class)); assertFalse(factory.isTypeMatch("&factoryBean", ListFactoryBean.class)); assertTrue(factory.getBean("factoryBean") instanceof List); String[] beanNames = factory.getBeanNamesForType(FactoryBean.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(BeanClassLoaderAware.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(ListFactoryBean.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(List.class); assertEquals("factoryBean", beanNames[0]); }
Example #3
Source File: ConfigurationClassParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Invoke {@link ResourceLoaderAware}, {@link BeanClassLoaderAware} and * {@link BeanFactoryAware} contracts if implemented by the given {@code bean}. */ private void invokeAwareMethods(Object importStrategyBean) { if (importStrategyBean instanceof Aware) { if (importStrategyBean instanceof EnvironmentAware) { ((EnvironmentAware) importStrategyBean).setEnvironment(this.environment); } if (importStrategyBean instanceof ResourceLoaderAware) { ((ResourceLoaderAware) importStrategyBean).setResourceLoader(this.resourceLoader); } if (importStrategyBean instanceof BeanClassLoaderAware) { ClassLoader classLoader = (this.registry instanceof ConfigurableBeanFactory ? ((ConfigurableBeanFactory) this.registry).getBeanClassLoader() : this.resourceLoader.getClassLoader()); ((BeanClassLoaderAware) importStrategyBean).setBeanClassLoader(classLoader); } if (importStrategyBean instanceof BeanFactoryAware && this.registry instanceof BeanFactory) { ((BeanFactoryAware) importStrategyBean).setBeanFactory((BeanFactory) this.registry); } } }
Example #4
Source File: ParserStrategyUtils.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Invoke {@link BeanClassLoaderAware}, {@link BeanFactoryAware}, * {@link EnvironmentAware}, and {@link ResourceLoaderAware} contracts * if implemented by the given object. */ public static void invokeAwareMethods(Object parserStrategyBean, Environment environment, ResourceLoader resourceLoader, BeanDefinitionRegistry registry) { if (parserStrategyBean instanceof Aware) { if (parserStrategyBean instanceof BeanClassLoaderAware) { ClassLoader classLoader = (registry instanceof ConfigurableBeanFactory ? ((ConfigurableBeanFactory) registry).getBeanClassLoader() : resourceLoader.getClassLoader()); ((BeanClassLoaderAware) parserStrategyBean).setBeanClassLoader(classLoader); } if (parserStrategyBean instanceof BeanFactoryAware && registry instanceof BeanFactory) { ((BeanFactoryAware) parserStrategyBean).setBeanFactory((BeanFactory) registry); } if (parserStrategyBean instanceof EnvironmentAware) { ((EnvironmentAware) parserStrategyBean).setEnvironment(environment); } if (parserStrategyBean instanceof ResourceLoaderAware) { ((ResourceLoaderAware) parserStrategyBean).setResourceLoader(resourceLoader); } } }
Example #5
Source File: FunctionalInstallerListener.java From spring-init with Apache License 2.0 | 6 votes |
public static void invokeAwareMethods(Object target, Environment environment, ResourceLoader resourceLoader, BeanDefinitionRegistry registry) { if (target instanceof Aware) { if (target instanceof BeanClassLoaderAware) { ClassLoader classLoader = (registry instanceof ConfigurableBeanFactory ? ((ConfigurableBeanFactory) registry).getBeanClassLoader() : resourceLoader.getClassLoader()); if (classLoader != null) { ((BeanClassLoaderAware) target).setBeanClassLoader(classLoader); } } if (target instanceof BeanFactoryAware && registry instanceof BeanFactory) { ((BeanFactoryAware) target).setBeanFactory((BeanFactory) registry); } if (target instanceof EnvironmentAware) { ((EnvironmentAware) target).setEnvironment(environment); } if (target instanceof ResourceLoaderAware) { ((ResourceLoaderAware) target).setResourceLoader(resourceLoader); } } }
Example #6
Source File: AbstractAutowireCapableBeanFactory.java From java-technology-stack with MIT License | 6 votes |
private void invokeAwareMethods(final String beanName, final Object bean) { if (bean instanceof Aware) { if (bean instanceof BeanNameAware) { ((BeanNameAware) bean).setBeanName(beanName); } if (bean instanceof BeanClassLoaderAware) { ClassLoader bcl = getBeanClassLoader(); if (bcl != null) { ((BeanClassLoaderAware) bean).setBeanClassLoader(bcl); } } if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this); } } }
Example #7
Source File: ConfigurationClassProcessingTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void configWithFactoryBeanReturnType() { ListableBeanFactory factory = initBeanFactory(ConfigWithNonSpecificReturnTypes.class); assertEquals(List.class, factory.getType("factoryBean")); assertTrue(factory.isTypeMatch("factoryBean", List.class)); assertEquals(FactoryBean.class, factory.getType("&factoryBean")); assertTrue(factory.isTypeMatch("&factoryBean", FactoryBean.class)); assertFalse(factory.isTypeMatch("&factoryBean", BeanClassLoaderAware.class)); assertFalse(factory.isTypeMatch("&factoryBean", ListFactoryBean.class)); assertTrue(factory.getBean("factoryBean") instanceof List); String[] beanNames = factory.getBeanNamesForType(FactoryBean.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(BeanClassLoaderAware.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(ListFactoryBean.class); assertEquals(1, beanNames.length); assertEquals("&factoryBean", beanNames[0]); beanNames = factory.getBeanNamesForType(List.class); assertEquals("factoryBean", beanNames[0]); }
Example #8
Source File: ParserStrategyUtils.java From java-technology-stack with MIT License | 6 votes |
/** * Invoke {@link BeanClassLoaderAware}, {@link BeanFactoryAware}, * {@link EnvironmentAware}, and {@link ResourceLoaderAware} contracts * if implemented by the given object. */ public static void invokeAwareMethods(Object parserStrategyBean, Environment environment, ResourceLoader resourceLoader, BeanDefinitionRegistry registry) { if (parserStrategyBean instanceof Aware) { if (parserStrategyBean instanceof BeanClassLoaderAware) { ClassLoader classLoader = (registry instanceof ConfigurableBeanFactory ? ((ConfigurableBeanFactory) registry).getBeanClassLoader() : resourceLoader.getClassLoader()); if (classLoader != null) { ((BeanClassLoaderAware) parserStrategyBean).setBeanClassLoader(classLoader); } } if (parserStrategyBean instanceof BeanFactoryAware && registry instanceof BeanFactory) { ((BeanFactoryAware) parserStrategyBean).setBeanFactory((BeanFactory) registry); } if (parserStrategyBean instanceof EnvironmentAware) { ((EnvironmentAware) parserStrategyBean).setEnvironment(environment); } if (parserStrategyBean instanceof ResourceLoaderAware) { ((ResourceLoaderAware) parserStrategyBean).setResourceLoader(resourceLoader); } } }
Example #9
Source File: AbstractAutowireCapableBeanFactory.java From spring-analysis-note with MIT License | 6 votes |
private void invokeAwareMethods(final String beanName, final Object bean) { if (bean instanceof Aware) { if (bean instanceof BeanNameAware) { ((BeanNameAware) bean).setBeanName(beanName); } if (bean instanceof BeanClassLoaderAware) { ClassLoader bcl = getBeanClassLoader(); if (bcl != null) { ((BeanClassLoaderAware) bean).setBeanClassLoader(bcl); } } if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this); } } }
Example #10
Source File: ParserStrategyUtils.java From spring-analysis-note with MIT License | 6 votes |
/** * Invoke {@link BeanClassLoaderAware}, {@link BeanFactoryAware}, * {@link EnvironmentAware}, and {@link ResourceLoaderAware} contracts * if implemented by the given object. */ public static void invokeAwareMethods(Object parserStrategyBean, Environment environment, ResourceLoader resourceLoader, BeanDefinitionRegistry registry) { if (parserStrategyBean instanceof Aware) { if (parserStrategyBean instanceof BeanClassLoaderAware) { ClassLoader classLoader = (registry instanceof ConfigurableBeanFactory ? ((ConfigurableBeanFactory) registry).getBeanClassLoader() : resourceLoader.getClassLoader()); if (classLoader != null) { ((BeanClassLoaderAware) parserStrategyBean).setBeanClassLoader(classLoader); } } if (parserStrategyBean instanceof BeanFactoryAware && registry instanceof BeanFactory) { ((BeanFactoryAware) parserStrategyBean).setBeanFactory((BeanFactory) registry); } if (parserStrategyBean instanceof EnvironmentAware) { ((EnvironmentAware) parserStrategyBean).setEnvironment(environment); } if (parserStrategyBean instanceof ResourceLoaderAware) { ((ResourceLoaderAware) parserStrategyBean).setResourceLoader(resourceLoader); } } }
Example #11
Source File: AbstractAutowireCapableBeanFactory.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new AbstractAutowireCapableBeanFactory. */ public AbstractAutowireCapableBeanFactory() { super(); ignoreDependencyInterface(BeanNameAware.class); ignoreDependencyInterface(BeanFactoryAware.class); ignoreDependencyInterface(BeanClassLoaderAware.class); }
Example #12
Source File: AbstractAutowireCapableBeanFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new AbstractAutowireCapableBeanFactory. */ public AbstractAutowireCapableBeanFactory() { super(); ignoreDependencyInterface(BeanNameAware.class); ignoreDependencyInterface(BeanFactoryAware.class); ignoreDependencyInterface(BeanClassLoaderAware.class); }
Example #13
Source File: AbstractAutowireCapableBeanFactory.java From lams with GNU General Public License v2.0 | 5 votes |
private void invokeAwareMethods(final String beanName, final Object bean) { if (bean instanceof Aware) { if (bean instanceof BeanNameAware) { ((BeanNameAware) bean).setBeanName(beanName); } if (bean instanceof BeanClassLoaderAware) { ((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader()); } if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this); } } }
Example #14
Source File: AbstractAutowireCapableBeanFactory.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Create a new AbstractAutowireCapableBeanFactory. */ public AbstractAutowireCapableBeanFactory() { super(); ignoreDependencyInterface(BeanNameAware.class); ignoreDependencyInterface(BeanFactoryAware.class); ignoreDependencyInterface(BeanClassLoaderAware.class); }
Example #15
Source File: AbstractAutowireCapableBeanFactory.java From blog_demos with Apache License 2.0 | 5 votes |
private void invokeAwareMethods(final String beanName, final Object bean) { if (bean instanceof Aware) { if (bean instanceof BeanNameAware) { ((BeanNameAware) bean).setBeanName(beanName); } if (bean instanceof BeanClassLoaderAware) { ((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader()); } if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this); } } }
Example #16
Source File: AbstractAutowireCapableBeanFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new AbstractAutowireCapableBeanFactory. */ public AbstractAutowireCapableBeanFactory() { super(); ignoreDependencyInterface(BeanNameAware.class); ignoreDependencyInterface(BeanFactoryAware.class); ignoreDependencyInterface(BeanClassLoaderAware.class); }
Example #17
Source File: AbstractAutowireCapableBeanFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new AbstractAutowireCapableBeanFactory. */ public AbstractAutowireCapableBeanFactory() { super(); ignoreDependencyInterface(BeanNameAware.class); ignoreDependencyInterface(BeanFactoryAware.class); ignoreDependencyInterface(BeanClassLoaderAware.class); }
Example #18
Source File: AbstractAutowireCapableBeanFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void invokeAwareMethods(final String beanName, final Object bean) { if (bean instanceof Aware) { if (bean instanceof BeanNameAware) { ((BeanNameAware) bean).setBeanName(beanName); } if (bean instanceof BeanClassLoaderAware) { ((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader()); } if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this); } } }