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


Java BeanDefinitionBuilder.setLazyInit方法代码示例

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


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

示例1: process

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();
	String value = attribute.getValue();

	if (ACTIVATION_ATTR.equals(name) && StringUtils.hasText(value)) {
		if (LAZY_ACTIVATION.equalsIgnoreCase(value)) {
		builder.setLazyInit(true);
		}
		else {
			builder.setLazyInit(false);
		}
		return false;
	}

	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:BlueprintAttributeCallback.java

示例2: process

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();

	if (BeanDefinitionParserDelegate.ID_ATTRIBUTE.equals(name)) {
		return false;
	}

	if (BeanDefinitionParserDelegate.DEPENDS_ON_ATTRIBUTE.equals(name)) {
		builder.getBeanDefinition().setDependsOn(
			(StringUtils.tokenizeToStringArray(attribute.getValue(),
				BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS)));
		return false;
	}
	if (BeanDefinitionParserDelegate.LAZY_INIT_ATTRIBUTE.equals(name)) {
		builder.setLazyInit(Boolean.valueOf(attribute.getValue()));
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:20,代码来源:StandardAttributeCallback.java

示例3: postProcess

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) {
	Object envValue = DomUtils.getChildElementValueByTagName(element, ENVIRONMENT);
	if (envValue != null) {
		// Specific environment settings defined, overriding any shared properties.
		definitionBuilder.addPropertyValue(JNDI_ENVIRONMENT, envValue);
	}
	else {
		// Check whether there is a reference to shared environment properties...
		String envRef = element.getAttribute(ENVIRONMENT_REF);
		if (StringUtils.hasLength(envRef)) {
			definitionBuilder.addPropertyValue(JNDI_ENVIRONMENT, new RuntimeBeanReference(envRef));
		}
	}

	String lazyInit = element.getAttribute(LAZY_INIT_ATTRIBUTE);
	if (StringUtils.hasText(lazyInit) && !DEFAULT_VALUE.equals(lazyInit)) {
		definitionBuilder.setLazyInit(TRUE_VALUE.equals(lazyInit));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractJndiLocatingBeanDefinitionParser.java

示例4: createBeanDefinitionBuilder

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, ParserContext parserContext, Class<?> cls) {
    BeanDefinitionBuilder builder
            = BeanDefinitionBuilder.genericBeanDefinition();
    builder.getRawBeanDefinition().setBeanClass(cls);
    builder.getRawBeanDefinition()
            .setSource(parserContext.extractSource(element));
    if (parserContext.isNested()) {
        builder.setScope(parserContext.getContainingBeanDefinition()
                .getScope());
    }
    if (parserContext.isDefaultLazyInit()) {
        builder.setLazyInit(true);
    }
    return builder;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:16,代码来源:RedissonNamespaceParserSupport.java

示例5: applyDefaults

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected void applyDefaults(ParserContext parserContext, OsgiDefaultsDefinition defaults,
		BeanDefinitionBuilder builder) {
	if (parserContext.isNested()) {
		// Inner bean definition must receive same scope as containing bean.
		builder.setScope(parserContext.getContainingBeanDefinition().getScope());
	}
	if (parserContext.isDefaultLazyInit()) {
		// Default-lazy-init applies to custom bean definitions as well.
		builder.setLazyInit(true);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:12,代码来源:AbstractReferenceDefinitionParser.java

示例6: applyDefaults

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected void applyDefaults(ParserContext parserContext, OsgiDefaultsDefinition defaults,
		BeanDefinitionBuilder builder) {
	if (parserContext.isDefaultLazyInit()) {
		// Default-lazy-init applies to custom bean definitions as well.
		builder.setLazyInit(true);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:8,代码来源:ServiceBeanDefinitionParser.java

示例7: applyDefaults

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void applyDefaults(ParserContext parserContext, OsgiDefaultsDefinition defaults,
		BeanDefinitionBuilder builder) {
	super.applyDefaults(parserContext, defaults, builder);
	if (defaults instanceof BlueprintDefaultsDefinition) {
		BlueprintDefaultsDefinition defs = (BlueprintDefaultsDefinition) defaults;
		if (defs.getDefaultInitialization()) {
			builder.setLazyInit(defs.getDefaultInitialization());
		}
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:12,代码来源:BlueprintCollectionBeanDefinitionParser.java

示例8: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * Creates a {@link BeanDefinitionBuilder} instance for the
 * {@link #getBeanClass bean Class} and passes it to the
 * {@link #doParse} strategy method.
 * @param element the element that is to be parsed into a single BeanDefinition
 * @param parserContext the object encapsulating the current state of the parsing process
 * @return the BeanDefinition resulting from the parsing of the supplied {@link Element}
 * @throws IllegalStateException if the bean {@link Class} returned from
 * {@link #getBeanClass(org.w3c.dom.Element)} is {@code null}
 * @see #doParse
 */
@Override
protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
	String parentName = getParentName(element);
	if (parentName != null) {
		builder.getRawBeanDefinition().setParentName(parentName);
	}
	Class<?> beanClass = getBeanClass(element);
	if (beanClass != null) {
		builder.getRawBeanDefinition().setBeanClass(beanClass);
	}
	else {
		String beanClassName = getBeanClassName(element);
		if (beanClassName != null) {
			builder.getRawBeanDefinition().setBeanClassName(beanClassName);
		}
	}
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
	if (parserContext.isNested()) {
		// Inner bean definition must receive same scope as containing bean.
		builder.setScope(parserContext.getContainingBeanDefinition().getScope());
	}
	if (parserContext.isDefaultLazyInit()) {
		// Default-lazy-init applies to custom bean definitions as well.
		builder.setLazyInit(true);
	}
	doParse(element, parserContext, builder);
	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:AbstractSingleBeanDefinitionParser.java

示例9: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.setLazyInit(false); // lazy scheduled tasks are a contradiction in terms -> force to false
	ManagedList<RuntimeBeanReference> cronTaskList = new ManagedList<RuntimeBeanReference>();
	ManagedList<RuntimeBeanReference> fixedDelayTaskList = new ManagedList<RuntimeBeanReference>();
	ManagedList<RuntimeBeanReference> fixedRateTaskList = new ManagedList<RuntimeBeanReference>();
	ManagedList<RuntimeBeanReference> triggerTaskList = new ManagedList<RuntimeBeanReference>();
	NodeList childNodes = element.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		Node child = childNodes.item(i);
		if (!isScheduledElement(child, parserContext)) {
			continue;
		}
		Element taskElement = (Element) child;
		String ref = taskElement.getAttribute("ref");
		String method = taskElement.getAttribute("method");

		// Check that 'ref' and 'method' are specified
		if (!StringUtils.hasText(ref) || !StringUtils.hasText(method)) {
			parserContext.getReaderContext().error("Both 'ref' and 'method' are required", taskElement);
			// Continue with the possible next task element
			continue;
		}

		String cronAttribute = taskElement.getAttribute("cron");
		String fixedDelayAttribute = taskElement.getAttribute("fixed-delay");
		String fixedRateAttribute = taskElement.getAttribute("fixed-rate");
		String triggerAttribute = taskElement.getAttribute("trigger");
		String initialDelayAttribute = taskElement.getAttribute("initial-delay");

		boolean hasCronAttribute = StringUtils.hasText(cronAttribute);
		boolean hasFixedDelayAttribute = StringUtils.hasText(fixedDelayAttribute);
		boolean hasFixedRateAttribute = StringUtils.hasText(fixedRateAttribute);
		boolean hasTriggerAttribute = StringUtils.hasText(triggerAttribute);
		boolean hasInitialDelayAttribute = StringUtils.hasText(initialDelayAttribute);

		if (!(hasCronAttribute || hasFixedDelayAttribute || hasFixedRateAttribute || hasTriggerAttribute)) {
			parserContext.getReaderContext().error(
					"one of the 'cron', 'fixed-delay', 'fixed-rate', or 'trigger' attributes is required", taskElement);
			continue; // with the possible next task element
		}

		if (hasInitialDelayAttribute && (hasCronAttribute || hasTriggerAttribute)) {
			parserContext.getReaderContext().error(
					"the 'initial-delay' attribute may not be used with cron and trigger tasks", taskElement);
			continue; // with the possible next task element
		}

		String runnableName =
				runnableReference(ref, method, taskElement, parserContext).getBeanName();

		if (hasFixedDelayAttribute) {
			fixedDelayTaskList.add(intervalTaskReference(runnableName,
					initialDelayAttribute, fixedDelayAttribute, taskElement, parserContext));
		}
		if (hasFixedRateAttribute) {
			fixedRateTaskList.add(intervalTaskReference(runnableName,
					initialDelayAttribute, fixedRateAttribute, taskElement, parserContext));
		}
		if (hasCronAttribute) {
			cronTaskList.add(cronTaskReference(runnableName, cronAttribute,
					taskElement, parserContext));
		}
		if (hasTriggerAttribute) {
			String triggerName = new RuntimeBeanReference(triggerAttribute).getBeanName();
			triggerTaskList.add(triggerTaskReference(runnableName, triggerName,
					taskElement, parserContext));
		}
	}
	String schedulerRef = element.getAttribute("scheduler");
	if (StringUtils.hasText(schedulerRef)) {
		builder.addPropertyReference("taskScheduler", schedulerRef);
	}
	builder.addPropertyValue("cronTasksList", cronTaskList);
	builder.addPropertyValue("fixedDelayTasksList", fixedDelayTaskList);
	builder.addPropertyValue("fixedRateTasksList", fixedRateTaskList);
	builder.addPropertyValue("triggerTasksList", triggerTaskList);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:79,代码来源:ScheduledTasksBeanDefinitionParser.java


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