Java 类org.springframework.beans.factory.Aware 实例源码

项目:lams    文件:ConfigurationClassParser.java   
/**
 * 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);
        }
    }
}
项目:lams    文件:ApplicationContextAwareProcessor.java   
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);
        }
    }
}
项目:spring4-understanding    文件:ConfigurationClassParser.java   
/**
 * 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);
        }
    }
}
项目:spring4-understanding    文件:ApplicationContextAwareProcessor.java   
/**��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);
        }
    }
}
项目:my-spring-cache-redis    文件:ConfigurationClassParser.java   
/**
 * 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);
        }
    }
}
项目:my-spring-cache-redis    文件:ApplicationContextAwareProcessor.java   
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);
        }
    }
}
项目:spring    文件:ConfigurationClassParser.java   
/**
 * 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);
        }
    }
}
项目:spring    文件:ComponentScanAnnotationParser.java   
/**
 * Invoke {@link ResourceLoaderAware}, {@link BeanClassLoaderAware} and
 * {@link BeanFactoryAware} contracts if implemented by the given {@code filter}.
 */
private void invokeAwareMethods(TypeFilter filter) {
    if (filter instanceof Aware) {
        if (filter instanceof EnvironmentAware) {
            ((EnvironmentAware) filter).setEnvironment(this.environment);
        }
        if (filter instanceof ResourceLoaderAware) {
            ((ResourceLoaderAware) filter).setResourceLoader(this.resourceLoader);
        }
        if (filter instanceof BeanClassLoaderAware) {
            ClassLoader classLoader = (this.registry instanceof ConfigurableBeanFactory ?
                    ((ConfigurableBeanFactory) this.registry).getBeanClassLoader() :
                    this.resourceLoader.getClassLoader());
            ((BeanClassLoaderAware) filter).setBeanClassLoader(classLoader);
        }
        if (filter instanceof BeanFactoryAware && this.registry instanceof BeanFactory) {
            ((BeanFactoryAware) filter).setBeanFactory((BeanFactory) this.registry);
        }
    }
}
项目:spring    文件:ApplicationContextAwareProcessor.java   
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);
        }
    }
}
项目:mybatis-spring-1.2.2    文件:ConfigurationClassParser.java   
/**
 * Invoke {@link EnvironmentAware}, {@link ResourceLoaderAware}, {@link BeanClassLoaderAware}
 * and {@link BeanFactoryAware} contracts if implemented by the given {@code registrar}.
 */
private void invokeAwareMethods(ImportBeanDefinitionRegistrar registrar) {
    if (registrar instanceof Aware) {
        if (registrar instanceof EnvironmentAware) {
            ((EnvironmentAware) registrar).setEnvironment(this.environment);
        }
        if (registrar instanceof ResourceLoaderAware) {
            ((ResourceLoaderAware) registrar).setResourceLoader(this.resourceLoader);
        }
        if (registrar instanceof BeanClassLoaderAware) {
            ClassLoader classLoader = (this.registry instanceof ConfigurableBeanFactory ?
                    ((ConfigurableBeanFactory) this.registry).getBeanClassLoader() :
                    this.resourceLoader.getClassLoader());
            ((BeanClassLoaderAware) registrar).setBeanClassLoader(classLoader);
        }
        if (registrar instanceof BeanFactoryAware && this.registry instanceof BeanFactory) {
            ((BeanFactoryAware) registrar).setBeanFactory((BeanFactory) this.registry);
        }
    }
}
项目:class-guard    文件:ConfigurationClassParser.java   
/**
 * Invoke {@link EnvironmentAware}, {@link ResourceLoaderAware}, {@link BeanClassLoaderAware}
 * and {@link BeanFactoryAware} contracts if implemented by the given {@code registrar}.
 */
private void invokeAwareMethods(ImportBeanDefinitionRegistrar registrar) {
    if (registrar instanceof Aware) {
        if (registrar instanceof EnvironmentAware) {
            ((EnvironmentAware) registrar).setEnvironment(this.environment);
        }
        if (registrar instanceof ResourceLoaderAware) {
            ((ResourceLoaderAware) registrar).setResourceLoader(this.resourceLoader);
        }
        if (registrar instanceof BeanClassLoaderAware) {
            ClassLoader classLoader = (this.registry instanceof ConfigurableBeanFactory ?
                    ((ConfigurableBeanFactory) this.registry).getBeanClassLoader() :
                    this.resourceLoader.getClassLoader());
            ((BeanClassLoaderAware) registrar).setBeanClassLoader(classLoader);
        }
        if (registrar instanceof BeanFactoryAware && this.registry instanceof BeanFactory) {
            ((BeanFactoryAware) registrar).setBeanFactory((BeanFactory) this.registry);
        }
    }
}
项目:class-guard    文件:ApplicationContextAwareProcessor.java   
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);
        }
    }
}
项目:lams    文件:AbstractAutowireCapableBeanFactory.java   
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);
        }
    }
}
项目:spring-boot-starter-disruptor    文件:DisruptorEventAwareProcessor.java   
protected void invokeAwareInterfaces(Object bean) {
    if (bean instanceof Aware) {
        //扩展 DisruptorEventPublisherAware
        if (bean instanceof DisruptorEventPublisherAware) {
            DisruptorEventPublisherAware awareBean = (DisruptorEventPublisherAware) bean;  
            awareBean.setDisruptorEventPublisher( this.disruptorContext );
        }
    }
}
项目:spring4-understanding    文件:AbstractAutowireCapableBeanFactory.java   
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);
        }
    }
}
项目:puzzle    文件:PluginServletManager.java   
private void injectComponentAware(Object instance){
    if(instance instanceof Aware){
        if(instance instanceof PluginContextAware){
            ((PluginContextAware)instance).setPluginContext(pluginContext);
        }
        if(instance instanceof ApplicationContextAware){
            ((ApplicationContextAware)instance).setApplicationContext(pluginContext.getApplicationContext());
        }
    }
}
项目:spring    文件:AbstractAutowireCapableBeanFactory.java   
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);
        }
    }
}
项目:class-guard    文件:AbstractAutowireCapableBeanFactory.java   
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);
        }
    }
}
项目:vaadin4spring    文件:VaadinSecurityAwareProcessor.java   
private void invokeAwareInterfaces(Object bean) {

        if ( bean instanceof Aware ) {

            if ( bean instanceof VaadinSecurityAware ) {
                ((VaadinSecurityAware) bean).setVaadinSecurity(this.applicationContext.getBean(VaadinSecurity.class));
            }

            if ( bean instanceof VaadinSecurityContextAware ) {
                ((VaadinSecurityContextAware) bean).setVaadinSecurityContext(this.applicationContext.getBean(VaadinSecurityContext.class));
            }
        }

    }
项目:lams    文件:AbstractAutoProxyCreator.java   
/**
 * Determine whether the given interface is just a container callback and
 * therefore not to be considered as a reasonable proxy interface.
 * <p>If no reasonable proxy interface is found for a given bean, it will get
 * proxied with its full target class, assuming that as the user's intention.
 * @param ifc the interface to check
 * @return whether the given interface is just a container callback
 */
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
    return (ifc.equals(InitializingBean.class) || ifc.equals(DisposableBean.class) ||
            ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}
项目:spring4-understanding    文件:ProxyProcessorSupport.java   
/**
 * Determine whether the given interface is just a container callback and
 * therefore not to be considered as a reasonable proxy interface.
 * <p>If no reasonable proxy interface is found for a given bean, it will get
 * proxied with its full target class, assuming that as the user's intention.
 * @param ifc the interface to check
 * @return whether the given interface is just a container callback
 */
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
    return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
            ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}
项目:spring    文件:ProxyProcessorSupport.java   
/**
 * Determine whether the given interface is just a container callback and
 * therefore not to be considered as a reasonable proxy interface.
 * <p>If no reasonable proxy interface is found for a given bean, it will get
 * proxied with its full target class, assuming that as the user's intention.
 * @param ifc the interface to check
 * @return whether the given interface is just a container callback
 */
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
    return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
            ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}