本文整理汇总了Java中org.springframework.beans.factory.config.BeanDefinition.isLazyInit方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinition.isLazyInit方法的具体用法?Java BeanDefinition.isLazyInit怎么用?Java BeanDefinition.isLazyInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.config.BeanDefinition
的用法示例。
在下文中一共展示了BeanDefinition.isLazyInit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
public void start(ContextRefreshedEvent event) {
if (event.getApplicationContext() == this.context) {
if (this.eager && this.registry != null) {
for (String name : this.context.getBeanDefinitionNames()) {
BeanDefinition definition = this.registry.getBeanDefinition(name);
if (this.getName().equals(definition.getScope())
&& !definition.isLazyInit()) {
this.context.getBean(name);
}
}
}
}
}
示例2: createBeanFactoryBasedTargetSource
import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
Class<?> beanClass, String beanName) {
if (getBeanFactory() instanceof ConfigurableListableBeanFactory) {
BeanDefinition definition =
((ConfigurableListableBeanFactory) getBeanFactory()).getBeanDefinition(beanName);
if (definition.isLazyInit()) {
return new LazyInitTargetSource();
}
}
return null;
}
示例3: afterPropertiesSet
import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
public void afterPropertiesSet() throws Exception {
Assert.notNull(bundleContext, "required property 'bundleContext' has not been set");
hasNamedBean = StringUtils.hasText(targetBeanName);
Assert.isTrue(hasNamedBean || target != null, "Either 'targetBeanName' or 'target' properties have to be set.");
// if we have a name, we need a bean factory
if (hasNamedBean) {
Assert.notNull(beanFactory, "Required property 'beanFactory' has not been set.");
}
// initialize bean only when dealing with singletons and named beans
if (hasNamedBean) {
Assert.isTrue(beanFactory.containsBean(targetBeanName), "Cannot locate bean named '" + targetBeanName
+ "' inside the running bean factory.");
if (beanFactory.isSingleton(targetBeanName)) {
if (beanFactory instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory clbf = (ConfigurableListableBeanFactory) beanFactory;
BeanDefinition definition = clbf.getBeanDefinition(targetBeanName);
if (!definition.isLazyInit()) {
target = beanFactory.getBean(targetBeanName);
targetClass = target.getClass();
}
}
}
if (targetClass == null) {
// lazily get the target class
targetClass = beanFactory.getType(targetBeanName);
}
// when running inside a container, add the dependency between this bean and the target one
addBeanFactoryDependency();
} else {
targetClass = target.getClass();
}
if (propertiesResolver == null) {
propertiesResolver = new BeanNameServicePropertiesResolver();
((BeanNameServicePropertiesResolver) propertiesResolver).setBundleContext(bundleContext);
}
// sanity check
if (interfaces == null) {
if (DefaultInterfaceDetector.DISABLED.equals(interfaceDetector))
throw new IllegalArgumentException(
"No service interface(s) specified and auto-export discovery disabled; change at least one of these properties.");
interfaces = new Class[0];
}
// check visibility type
else {
if (!ServiceFactory.class.isAssignableFrom(targetClass)) {
for (int interfaceIndex = 0; interfaceIndex < interfaces.length; interfaceIndex++) {
Class<?> intf = interfaces[interfaceIndex];
Assert.isAssignable(intf, targetClass,
"Exported service object does not implement the given interface: ");
}
}
}
// check service properties listener
if (serviceProperties instanceof ServicePropertiesListenerManager) {
propertiesListener = new PropertiesMonitor();
((ServicePropertiesListenerManager) serviceProperties).addListener(propertiesListener);
}
boolean shouldRegisterAtStartup;
synchronized (lock) {
shouldRegisterAtStartup = registerAtStartup;
}
resolver =
new LazyTargetResolver(target, beanFactory, targetBeanName, cacheTarget, getNotifier(),
getLazyListeners());
if (shouldRegisterAtStartup) {
registerService();
}
}
示例4: isBeanEligible
import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
* Determine whether the specified bean is eligible for inclusion in the
* LiveBeansView JSON snapshot.
* @param beanName the name of the bean
* @param bd the corresponding bean definition
* @param bf the containing bean factory
* @return {@code true} if the bean is to be included; {@code false} otherwise
*/
protected boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) {
return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
(!bd.isLazyInit() || bf.containsSingleton(beanName)));
}