當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。