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


Java SmartFactoryBean类代码示例

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


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

示例1: isPrototype

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
@Override
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
	Object bean = getBean(name);
	// In case of FactoryBean, return prototype status of created object.
	return ((bean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) bean).isPrototype()) ||
			(bean instanceof FactoryBean && !((FactoryBean<?>) bean).isSingleton()));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:StaticListableBeanFactory.java

示例2: preInstantiateSingletons

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
@Override
public void preInstantiateSingletons() throws BeansException {
	if (this.logger.isDebugEnabled()) {
		this.logger.debug("Pre-instantiating singletons in " + this);
	}
	List<String> beanNames;
	synchronized (this.beanDefinitionMap) {
		// Iterate over a copy to allow for init methods which in turn register new bean definitions.
		// While this may not be part of the regular factory bootstrap, it does otherwise work fine.
		beanNames = new ArrayList<String>(this.beanDefinitionNames);
	}
	for (String beanName : beanNames) {
		RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
		if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
			if (isFactoryBean(beanName)) {
				final FactoryBean<?> factory = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
				boolean isEagerInit;
				if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
					isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
						@Override
						public Boolean run() {
							return ((SmartFactoryBean<?>) factory).isEagerInit();
						}
					}, getAccessControlContext());
				}
				else {
					isEagerInit = (factory instanceof SmartFactoryBean &&
							((SmartFactoryBean<?>) factory).isEagerInit());
				}
				if (isEagerInit) {
					getBean(beanName);
				}
			}
			else {
				getBean(beanName);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:DefaultListableBeanFactory.java

示例3: preInstantiateSingletons

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
public void preInstantiateSingletons() throws BeansException {
	if (this.logger.isTraceEnabled()) {
		this.logger.info("Pre-instantiating singletons in " + this);
	} else if (this.logger.isInfoEnabled()) {
           this.logger.info("Pre-instantiating singletons");
       }
	List<String> beanNames;
	synchronized (this.beanDefinitionMap) {
		// Iterate over a copy to allow for init methods which in turn register new bean definitions.
		// While this may not be part of the regular factory bootstrap, it does otherwise work fine.
		beanNames = new ArrayList<String>(this.beanDefinitionNames);
	}
	for (String beanName : beanNames) {
		RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
		if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
			if (isFactoryBean(beanName)) {
				final FactoryBean<?> factory = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
				boolean isEagerInit;
				if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
					isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
						public Boolean run() {
							return ((SmartFactoryBean<?>) factory).isEagerInit();
						}
					}, getAccessControlContext());
				}
				else {
					isEagerInit = (factory instanceof SmartFactoryBean &&
							((SmartFactoryBean<?>) factory).isEagerInit());
				}
				if (isEagerInit) {
					getBean(beanName);
				}
			}
			else {
				getBean(beanName);
			}
		}
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:40,代码来源:DefaultListableBeanFactory.java

示例4: isPrototype

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
	String beanName = transformedBeanName(name);

	BeanFactory parentBeanFactory = getParentBeanFactory();
	if (parentBeanFactory != null && !containsBeanDefinition(beanName)) {
		// No bean definition found in this factory -> delegate to parent.
		return parentBeanFactory.isPrototype(originalBeanName(name));
	}

	RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
	if (mbd.isPrototype()) {
		// In case of FactoryBean, return singleton status of created object if not a dereference.
		return (!BeanFactoryUtils.isFactoryDereference(name) || isFactoryBean(beanName, mbd));
	}
	else {
		// Singleton or scoped - not a prototype.
		// However, FactoryBean may still produce a prototype object...
		if (BeanFactoryUtils.isFactoryDereference(name)) {
			return false;
		}
		if (isFactoryBean(beanName, mbd)) {
			final FactoryBean<?> factoryBean = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
			if (System.getSecurityManager() != null) {
				return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
					public Boolean run() {
						return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) factoryBean).isPrototype()) ||
								!factoryBean.isSingleton());
					}
				}, getAccessControlContext());
			}
			else {
				return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) factoryBean).isPrototype()) ||
						!factoryBean.isSingleton());
			}
		}
		else {
			return false;
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:41,代码来源:AbstractBeanFactory.java

示例5: preInstantiateSingletons

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
public void preInstantiateSingletons() throws BeansException {
	if (this.logger.isInfoEnabled()) {
		this.logger.info("Pre-instantiating singletons in " + this);
	}
	List<String> beanNames;
	synchronized (this.beanDefinitionMap) {
		// Iterate over a copy to allow for init methods which in turn register new bean definitions.
		// While this may not be part of the regular factory bootstrap, it does otherwise work fine.
		beanNames = new ArrayList<String>(this.beanDefinitionNames);
	}
	for (String beanName : beanNames) {
		RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
		if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
			if (isFactoryBean(beanName)) {
				final FactoryBean<?> factory = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
				boolean isEagerInit;
				if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
					isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
						public Boolean run() {
							return ((SmartFactoryBean<?>) factory).isEagerInit();
						}
					}, getAccessControlContext());
				}
				else {
					isEagerInit = (factory instanceof SmartFactoryBean &&
							((SmartFactoryBean<?>) factory).isEagerInit());
				}
				if (isEagerInit) {
					getBean(beanName);
				}
			}
			else {
				getBean(beanName);
			}
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:38,代码来源:DefaultListableBeanFactory.java

示例6: preInstantiateSingletons

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
@Override
   public void preInstantiateSingletons() throws BeansException {
	if (this.logger.isInfoEnabled()) {
		this.logger.info("Pre-instantiating singletons in " + this);
	}
	synchronized (this.beanDefinitionMap) {
		// Iterate over a copy to allow for init methods which in turn register new bean definitions.
		// While this may not be part of the regular factory bootstrap, it does otherwise work fine.
		List<String> beanNames = new ArrayList<String>(this.beanDefinitionNames);
		for (String beanName : beanNames) {
			RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
			if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
				if (isFactoryBean(beanName)) {
					final FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
					boolean isEagerInit;
					if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
						isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
							@Override
                               public Boolean run() {
								return ((SmartFactoryBean) factory).isEagerInit();
							}
						}, getAccessControlContext());
					}
					else {
						isEagerInit = (factory instanceof SmartFactoryBean &&
								((SmartFactoryBean) factory).isEagerInit());
					}
					if (isEagerInit) {
						getBean(beanName);
					}
				}
				else {
					getBean(beanName);
				}
			}
		}
	}
}
 
开发者ID:kuali,项目名称:kfs,代码行数:39,代码来源:DefaultListableBeanFactory.java

示例7: preInstantiateSingletons

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
public void preInstantiateSingletons() throws BeansException {
	if (this.logger.isInfoEnabled()) {
		this.logger.info("Pre-instantiating singletons in " + this);
	}
	synchronized (this.beanDefinitionMap) {
		// Iterate over a copy to allow for init methods which in turn register new bean definitions.
		// While this may not be part of the regular factory bootstrap, it does otherwise work fine.
		List<String> beanNames = new ArrayList<String>(this.beanDefinitionNames);
		for (String beanName : beanNames) {
			RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
			if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
				if (isFactoryBean(beanName)) {
					final FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
					boolean isEagerInit;
					if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
						isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
							public Boolean run() {
								return ((SmartFactoryBean) factory).isEagerInit();
							}
						}, getAccessControlContext());
					}
					else {
						isEagerInit = (factory instanceof SmartFactoryBean &&
								((SmartFactoryBean) factory).isEagerInit());
					}
					if (isEagerInit) {
						getBean(beanName);
					}
				}
				else {
					getBean(beanName);
				}
			}
		}
	}
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:37,代码来源:KualiDefaultListableBeanFactory.java

示例8: isPrototype

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
@Override
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
	String beanName = transformedBeanName(name);

	BeanFactory parentBeanFactory = getParentBeanFactory();
	if (parentBeanFactory != null && !containsBeanDefinition(beanName)) {
		// No bean definition found in this factory -> delegate to parent.
		return parentBeanFactory.isPrototype(originalBeanName(name));
	}

	RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
	if (mbd.isPrototype()) {
		// In case of FactoryBean, return singleton status of created object if not a dereference.
		return (!BeanFactoryUtils.isFactoryDereference(name) || isFactoryBean(beanName, mbd));
	}
	else {
		// Singleton or scoped - not a prototype.
		// However, FactoryBean may still produce a prototype object...
		if (BeanFactoryUtils.isFactoryDereference(name)) {
			return false;
		}
		if (isFactoryBean(beanName, mbd)) {
			final FactoryBean<?> factoryBean = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
			if (System.getSecurityManager() != null) {
				return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
					@Override
					public Boolean run() {
						return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) factoryBean).isPrototype()) ||
								!factoryBean.isSingleton());
					}
				}, getAccessControlContext());
			}
			else {
				return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) factoryBean).isPrototype()) ||
						!factoryBean.isSingleton());
			}
		}
		else {
			return false;
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:AbstractBeanFactory.java

示例9: isPrototype

import org.springframework.beans.factory.SmartFactoryBean; //导入依赖的package包/类
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
	Object bean = getBean(name);
	// In case of FactoryBean, return prototype status of created object.
	return ((bean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) bean).isPrototype()) ||
			(bean instanceof FactoryBean && !((FactoryBean<?>) bean).isSingleton()));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:StaticListableBeanFactory.java


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