本文整理汇总了Java中org.springframework.beans.factory.support.DefaultListableBeanFactory.setBeanClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListableBeanFactory.setBeanClassLoader方法的具体用法?Java DefaultListableBeanFactory.setBeanClassLoader怎么用?Java DefaultListableBeanFactory.setBeanClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.DefaultListableBeanFactory
的用法示例。
在下文中一共展示了DefaultListableBeanFactory.setBeanClassLoader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEmbeddedBeanFactory
import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
private void createEmbeddedBeanFactory() {
synchronized (monitor) {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(owningBeanFactory);
if (owningBeanFactory instanceof ConfigurableBeanFactory) {
bf.copyConfigurationFrom((ConfigurableBeanFactory) owningBeanFactory);
}
// just to be on the safe side
bf.setBeanClassLoader(classLoader);
// add autowiring processor
bf.addBeanPostProcessor(new InitialInjectionProcessor());
beanFactory = bf;
}
}
示例2: SQLErrorCodesFactory
import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
/**
* Create a new instance of the {@link SQLErrorCodesFactory} class.
* <p>Not public to enforce Singleton design pattern. Would be private
* except to allow testing via overriding the
* {@link #loadResource(String)} method.
* <p><b>Do not subclass in application code.</b>
* @see #loadResource(String)
*/
protected SQLErrorCodesFactory() {
Map<String, SQLErrorCodes> errorCodes;
try {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
lbf.setBeanClassLoader(getClass().getClassLoader());
XmlBeanDefinitionReader bdr = new XmlBeanDefinitionReader(lbf);
// Load default SQL error codes.
Resource resource = loadResource(SQL_ERROR_CODE_DEFAULT_PATH);
if (resource != null && resource.exists()) {
bdr.loadBeanDefinitions(resource);
}
else {
logger.warn("Default sql-error-codes.xml not found (should be included in spring.jar)");
}
// Load custom SQL error codes, overriding defaults.
resource = loadResource(SQL_ERROR_CODE_OVERRIDE_PATH);
if (resource != null && resource.exists()) {
bdr.loadBeanDefinitions(resource);
logger.info("Found custom sql-error-codes.xml file at the root of the classpath");
}
// Check all beans of type SQLErrorCodes.
errorCodes = lbf.getBeansOfType(SQLErrorCodes.class, true, false);
if (logger.isInfoEnabled()) {
logger.info("SQLErrorCodes loaded: " + errorCodes.keySet());
}
}
catch (BeansException ex) {
logger.warn("Error loading SQL error codes from config file", ex);
errorCodes = Collections.emptyMap();
}
this.errorCodesMap = errorCodes;
}