当前位置: 首页>>代码示例>>Java>>正文


Java BeanClassLoaderAware类代码示例

本文整理汇总了Java中org.springframework.beans.factory.BeanClassLoaderAware的典型用法代码示例。如果您正苦于以下问题:Java BeanClassLoaderAware类的具体用法?Java BeanClassLoaderAware怎么用?Java BeanClassLoaderAware使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanClassLoaderAware类属于org.springframework.beans.factory包,在下文中一共展示了BeanClassLoaderAware类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postProcessBeanFactory

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
public void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory)
		throws BeansException, OsgiException {

	Bundle bundle = bundleContext.getBundle();
	try {
		// Try and load the annotation code using the bundle classloader
		Class<?> annotationBppClass = bundle.loadClass(ANNOTATION_BPP_CLASS);
		// instantiate the class
		final BeanPostProcessor annotationBeanPostProcessor = (BeanPostProcessor) BeanUtils.instantiateClass(annotationBppClass);

		// everything went okay so configure the BPP and add it to the BF
		((BeanFactoryAware) annotationBeanPostProcessor).setBeanFactory(beanFactory);
		((BeanClassLoaderAware) annotationBeanPostProcessor).setBeanClassLoader(beanFactory.getBeanClassLoader());
		((BundleContextAware) annotationBeanPostProcessor).setBundleContext(bundleContext);
		beanFactory.addBeanPostProcessor(annotationBeanPostProcessor);
	}
	catch (ClassNotFoundException exception) {
		log.info("Spring-DM annotation package could not be loaded from bundle ["
				+ OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]; annotation processing disabled...");
		if (log.isDebugEnabled())
			log.debug("Cannot load annotation injection processor", exception);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:OsgiAnnotationPostProcessor.java

示例2: invokeAwareMethods

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ConfigurationClassParser.java

示例3: configWithFactoryBeanReturnType

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
@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]);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:ConfigurationClassProcessingTests.java

示例4: invokeAwareMethods

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:txazo,项目名称:spring,代码行数:24,代码来源:ComponentScanAnnotationParser.java

示例5: invokeAwareMethods

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:lindzh,项目名称:mybatis-spring-1.2.2,代码行数:24,代码来源:ConfigurationClassParser.java

示例6: postProcessBeanFactory

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
public void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory)
		throws BeansException, OsgiException {

	Bundle bundle = bundleContext.getBundle();
	try {
		// Try and load the annotation code using the bundle classloader
		Class annotationBppClass = bundle.loadClass(ANNOTATION_BPP_CLASS);
		// instantiate the class
		final BeanPostProcessor annotationBeanPostProcessor = (BeanPostProcessor) BeanUtils.instantiateClass(annotationBppClass);

		// everything went okay so configure the BPP and add it to the BF
		((BeanFactoryAware) annotationBeanPostProcessor).setBeanFactory(beanFactory);
		((BeanClassLoaderAware) annotationBeanPostProcessor).setBeanClassLoader(beanFactory.getBeanClassLoader());
		((BundleContextAware) annotationBeanPostProcessor).setBundleContext(bundleContext);
		beanFactory.addBeanPostProcessor(annotationBeanPostProcessor);
	}
	catch (ClassNotFoundException exception) {
		log.info("Spring-DM annotation package could not be loaded from bundle ["
				+ OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]; annotation processing disabled...");
		if (log.isDebugEnabled())
			log.debug("Cannot load annotation injection processor", exception);
	}
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:24,代码来源:OsgiAnnotationPostProcessor.java

示例7: AbstractAutowireCapableBeanFactory

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
/**
 * Create a new AbstractAutowireCapableBeanFactory.
 */
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractAutowireCapableBeanFactory.java

示例8: invokeAwareMethods

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
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);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AbstractAutowireCapableBeanFactory.java

示例9: setBeanClassLoader

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
static void setBeanClassLoader(Object importer, ClassLoader cl) {
	((BeanClassLoaderAware) importer).setBeanClassLoader(cl);
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:4,代码来源:ServiceReferenceInjectionBeanPostProcessor.java

示例10: setBeanClassLoader

import org.springframework.beans.factory.BeanClassLoaderAware; //导入依赖的package包/类
static void setBeanClassLoader(Object importer, ClassLoader cl) {
    ((BeanClassLoaderAware) importer).setBeanClassLoader(cl);
}
 
开发者ID:twachan,项目名称:James,代码行数:4,代码来源:AbstractOSGIAnnotationBeanPostProcessor.java


注:本文中的org.springframework.beans.factory.BeanClassLoaderAware类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。