當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanDefinition.isLazyInit方法代碼示例

本文整理匯總了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);
                }
            }
        }
    }
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:14,代碼來源:VersionRefreshScope.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:LazyInitTargetSourceCreator.java

示例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();
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:81,代碼來源:OsgiServiceFactoryBean.java

示例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)));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:LiveBeansView.java


注:本文中的org.springframework.beans.factory.config.BeanDefinition.isLazyInit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。