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


Java AbstractBeanDefinitionParser類代碼示例

本文整理匯總了Java中org.springframework.beans.factory.xml.AbstractBeanDefinitionParser的典型用法代碼示例。如果您正苦於以下問題:Java AbstractBeanDefinitionParser類的具體用法?Java AbstractBeanDefinitionParser怎麽用?Java AbstractBeanDefinitionParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbstractBeanDefinitionParser類屬於org.springframework.beans.factory.xml包,在下文中一共展示了AbstractBeanDefinitionParser類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doParse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String path = element.getAttribute("path");
    builder.addPropertyValue("path", path);
    // set bean alias
    element.setAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE, BeanIdGenerator.getMemcachedBeanId(path));

    String cacheName = element.getAttribute("cache-name");
    builder.addPropertyValue("cacheName", cacheName);

    String resolverBeanName = element.getAttribute("resolver-ref");
    if(StringUtils.hasLength(resolverBeanName) && parserContext.getRegistry().containsBeanDefinition(resolverBeanName)) {
        builder.addPropertyReference("resolver", resolverBeanName);
    }

    String validatorBeanName = element.getAttribute("validator-ref");
    if(StringUtils.hasLength(validatorBeanName) && parserContext.getRegistry().containsBeanDefinition(validatorBeanName)) {
        builder.addPropertyReference("validator", validatorBeanName);
    }
}
 
開發者ID:hekailiang,項目名稱:cloud-config,代碼行數:21,代碼來源:ZkCacheResourceBeanDefinitionParser.java

示例2: doParse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) {
	String listClass = element.getAttribute("list-class");
	List<?> currentParsedList = parserContext.getDelegate().parseListElement(element, builder.getRawBeanDefinition());

	String id = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
	if (parserContext.getRegistry().isBeanNameInUse(id)) {
		PropertyValue propValue = parserContext.getRegistry().getBeanDefinition(id).getPropertyValues()
				.getPropertyValue("sourceList");
		ManagedList oldList = (ManagedList) propValue.getValue();

		currentParsedList.addAll(oldList);
	}

	builder.addPropertyValue("sourceList", currentParsedList);
	if (StringUtils.hasText(listClass)) {
		builder.addPropertyValue("targetListClass", listClass);
	}
	String scope = element.getAttribute(NamespaceHandler.SCOPE_ATTRIBUTE);
	if (StringUtils.hasLength(scope)) {
		builder.setScope(scope);
	}
}
 
開發者ID:8090boy,項目名稱:gomall.la,代碼行數:24,代碼來源:NamespaceHandler.java

示例3: parse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(LdapTemplate.class);

    String contextSourceRef = getString(element, ATT_CONTEXT_SOURCE_REF, ContextSourceParser.DEFAULT_ID);
    builder.addPropertyReference("contextSource", contextSourceRef);
    builder.addPropertyValue("defaultCountLimit", getInt(element, ATT_COUNT_LIMIT, DEFAULT_COUNT_LIMIT));
    builder.addPropertyValue("defaultTimeLimit", getInt(element, ATT_TIME_LIMIT, DEFAULT_TIME_LIMIT));

    String searchScope = getString(element, ATT_SEARCH_SCOPE, SearchScope.SUBTREE.toString());
    builder.addPropertyValue("defaultSearchScope", SearchScope.valueOf(searchScope).getId());
    builder.addPropertyValue("ignorePartialResultException", getBoolean(element, ATT_IGNORE_PARTIAL_RESULT, false));
    builder.addPropertyValue("ignoreNameNotFoundException", getBoolean(element, ATT_IGNORE_NAME_NOT_FOUND, false));

    String odmRef = element.getAttribute(ATT_ODM_REF);
    if(StringUtils.hasText(odmRef)) {
        builder.addPropertyReference("objectDirectoryMapper", odmRef);
    }

    String id = getString(element, AbstractBeanDefinitionParser.ID_ATTRIBUTE, DEFAULT_ID);

    BeanDefinition beanDefinition = builder.getBeanDefinition();
    parserContext.registerBeanComponent(new BeanComponentDefinition(beanDefinition, id));

    return beanDefinition;
}
 
開發者ID:spring-projects,項目名稱:spring-ldap,代碼行數:27,代碼來源:LdapTemplateParser.java

示例4: parseInternal

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();

	Class<?> beanClass = getBeanClass(element);
	Assert.notNull(beanClass);

	if (beanClass != null) {
		builder.getRawBeanDefinition().setBeanClass(beanClass);
	}

	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));

	OsgiDefaultsDefinition defaults = resolveDefaults(element.getOwnerDocument(), parserContext);
	applyDefaults(parserContext, defaults, builder);

	doParse(element, parserContext, builder);

	AbstractBeanDefinition def = builder.getBeanDefinition();

	// check whether the bean is mandatory (and if it is, make it top-level
	// bean)
	if (parserContext.isNested()) {
		String value = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
		value = (StringUtils.hasText(value) ? value + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR : "");
		String generatedName = generateBeanName(value, def, parserContext);
		// make the bean lazy (since it is an inner bean initiallly)
		def.setLazyInit(true);
		// disable autowiring for promoted bean
		def.setAutowireCandidate(false);
		def.setAttribute(PROMOTED_REF, Boolean.TRUE);

		BeanDefinitionHolder holder = new BeanDefinitionHolder(def, generatedName);
		BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
		return createBeanReferenceDefinition(generatedName, def);
	}

	return def;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:40,代碼來源:AbstractReferenceDefinitionParser.java

示例5: doParse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String path = element.getAttribute("path");
    // add alias for data source bean
    element.setAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE, BeanIdGenerator.getDataSourceBeanId(path));
    String resourceType = element.getAttribute("resource-type");
    boolean autoReload = getSafeBoolean(element.getAttribute("auto-reload"));
    boolean routingSupport = getSafeBoolean(element.getAttribute("routing-support"));
    String validatorBeanName = element.getAttribute("validator-ref");
    if (routingSupport) {
        String fallbackDsPath = element.getAttribute("fallback");
        String resolverBeanName = element.getAttribute("resolver-ref");
        if(!parserContext.getRegistry().containsBeanDefinition(resolverBeanName)) {
            throw new IllegalArgumentException("Undefined routing key resolver");
        }
        if ("BoneCP".equals(resourceType)) {
            builder.addPropertyValue("resourceFactoryBeanClass", BoneCPDataSourceFactoryBean.class.getName());
        } else if ("C3P0".equals(resourceType)) {
            builder.addPropertyValue("resourceFactoryBeanClass", C3P0DataSourceFactoryBean.class.getName());
        } else if ("Druid".equals(resourceType)) {
            builder.addPropertyValue("resourceFactoryBeanClass", DruidDataSourceFactoryBean.class.getName());
        } else {
            throw new UnsupportedOperationException("Unsupported resource type "+resourceType);
        }

        builder.addPropertyReference("resolver", resolverBeanName);
        builder.addPropertyValue("path", path);
        builder.addPropertyReference("client", CloudConfigCommon.ZK_CLIENT_BEAN_NAME);
        if(StringUtils.hasLength(fallbackDsPath)) {
            builder.addPropertyValue("fallbackDataSourcePath", fallbackDsPath);
        }
    } else {
        builder.addPropertyValue("configPath", path);
    }
    if(StringUtils.hasText(validatorBeanName) && parserContext.getRegistry().containsBeanDefinition(validatorBeanName)) {
        builder.addPropertyReference("validator", validatorBeanName);
    }
    builder.addPropertyValue("autoReload", autoReload);
}
 
開發者ID:hekailiang,項目名稱:cloud-config,代碼行數:40,代碼來源:ZkJdbcDataSourceBeanDefinitionParser.java

示例6: doParse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String path = element.getAttribute("path");
    String resourceType = element.getAttribute("resource-type");
    element.setAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE, getBeanAliasByType(resourceType, path));

    boolean autoReload = getSafeBoolean(element.getAttribute("auto-reload"));
    boolean routingSupport = getSafeBoolean(element.getAttribute("routing-support"));
    String validatorBeanName = element.getAttribute("validator-ref");
    if(routingSupport) {
        String fallbackRsPath = element.getAttribute("fallback");
        String resolverBeanName = element.getAttribute("resolver-ref");
        if(!parserContext.getRegistry().containsBeanDefinition(resolverBeanName)) {
            throw new IllegalArgumentException("Undefined routing key resolver");
        }
        builder.addPropertyValue("path", path);
        builder.addPropertyReference("client", CloudConfigCommon.ZK_CLIENT_BEAN_NAME);
        builder.addPropertyReference("resolver", resolverBeanName);
        builder.addPropertyValue("resourceFactoryBeanClass", getFactoryBeanClassByType(resourceType, false));
        if(StringUtils.hasLength(fallbackRsPath)) {
            builder.addPropertyValue("fallbackResourcePath", fallbackRsPath);
        }
    } else {
        builder.addPropertyValue("configPath", path);
    }
    if(StringUtils.hasLength(validatorBeanName) && parserContext.getRegistry().containsBeanDefinition(validatorBeanName)) {
        builder.addPropertyReference("validator", validatorBeanName);
    }
    builder.addPropertyValue("autoReload", autoReload);
}
 
開發者ID:hekailiang,項目名稱:cloud-config,代碼行數:31,代碼來源:ZkResourceBeanDefinitionParser.java

示例7: parseInternal

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
	
	Class beanClass = getBeanClass(element);
	Assert.notNull(beanClass);

	if (beanClass != null) {
		builder.getRawBeanDefinition().setBeanClass(beanClass);
	}
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

	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);

	// check whether the bean is mandatory (and if it is, make it top-level
	// bean)

	AbstractBeanDefinition def = builder.getBeanDefinition();

	if (parserContext.isNested()) {
		StringBuffer id = new StringBuffer();
		String value = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
		if (StringUtils.hasText(value)) {
			id.append(value);
			id.append(BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR);
		}
		// disable autowiring for promoted bean
		def.setAutowireCandidate(false);

		id.append(parserContext.getReaderContext().generateBeanName(def));
		BeanDefinitionHolder holder = new BeanDefinitionHolder(def, id.toString());
		BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
		return createBeanReferenceDefinition(id.toString());
	}

	return def;
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:46,代碼來源:AbstractReferenceDefinitionParser.java

示例8: parse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {

    String contextSourceRef = getString(element, ATT_CONTEXT_SOURCE_REF, ContextSourceParser.DEFAULT_ID);
    String dataSourceRef = element.getAttribute(ATT_DATA_SOURCE_REF);
    String sessionFactoryRef = element.getAttribute(ATT_SESSION_FACTORY_REF);

    if(StringUtils.hasText(dataSourceRef) && StringUtils.hasText(sessionFactoryRef)) {
        throw new IllegalArgumentException(
                String.format("Only one of %s and %s can be specified",
                        ATT_DATA_SOURCE_REF, ATT_SESSION_FACTORY_REF));
    }

    BeanDefinitionBuilder builder;
    if(StringUtils.hasText(dataSourceRef)) {
        builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceAndDataSourceTransactionManager.class);
        builder.addPropertyReference("dataSource", dataSourceRef);
    } else if(StringUtils.hasText(sessionFactoryRef)) {
        builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceAndHibernateTransactionManager.class);
        builder.addPropertyReference("sessionFactory", sessionFactoryRef);
    } else {
        // Standard transaction manager
        builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceTransactionManager.class);
    }

    builder.addPropertyReference("contextSource", contextSourceRef);

    Element defaultStrategyChild = DomUtils.getChildElementByTagName(element, Elements.DEFAULT_RENAMING_STRATEGY);
    Element differentSubtreeChild = DomUtils.getChildElementByTagName(element, Elements.DIFFERENT_SUBTREE_RENAMING_STRATEGY);

    if(defaultStrategyChild != null) {
        builder.addPropertyValue("renamingStrategy", parseDefaultRenamingStrategy(defaultStrategyChild));
    }

    if(differentSubtreeChild != null) {
        builder.addPropertyValue("renamingStrategy", parseDifferentSubtreeRenamingStrategy(differentSubtreeChild));
    }

    String id = getString(element, AbstractBeanDefinitionParser.ID_ATTRIBUTE, DEFAULT_ID);

    BeanDefinition beanDefinition = builder.getBeanDefinition();
    parserContext.registerBeanComponent(new BeanComponentDefinition(beanDefinition, id));

    return beanDefinition;
}
 
開發者ID:spring-projects,項目名稱:spring-ldap,代碼行數:46,代碼來源:TransactionManagerParser.java

示例9: parse

import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; //導入依賴的package包/類
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(LdapContextSource.class);

    String username = element.getAttribute(ATT_USERNAME);
    String password = element.getAttribute(ATT_PASSWORD);
    String url = element.getAttribute(ATT_URL);
    Assert.hasText(url, "url attribute must be specified");

    builder.addPropertyValue("userDn", username);
    builder.addPropertyValue("password", password);

    BeanDefinitionBuilder urlsBuilder = BeanDefinitionBuilder
            .rootBeanDefinition(UrlsFactory.class)
            .setFactoryMethod("urls")
            .addConstructorArgValue(url);

    builder.addPropertyValue("urls", urlsBuilder.getBeanDefinition());
    builder.addPropertyValue("base", getString(element, ATT_BASE, ""));
    builder.addPropertyValue("referral", getString(element, ATT_REFERRAL, null));

    boolean anonymousReadOnly = getBoolean(element, ATT_ANONYMOUS_READ_ONLY, false);
    builder.addPropertyValue("anonymousReadOnly", anonymousReadOnly);
    boolean nativePooling = getBoolean(element, ATT_NATIVE_POOLING, false);
    builder.addPropertyValue("pooled", nativePooling);

    String authStrategyRef = element.getAttribute(ATT_AUTHENTICATION_STRATEGY_REF);
    if(StringUtils.hasText(authStrategyRef)) {
        builder.addPropertyReference("authenticationStrategy", authStrategyRef);
    }

    String authSourceRef = element.getAttribute(ATT_AUTHENTICATION_SOURCE_REF);
    if(StringUtils.hasText(authSourceRef)) {
        builder.addPropertyReference("authenticationSource", authSourceRef);
    } else {
        Assert.hasText(username, "username attribute must be specified unless an authentication-source-ref explicitly configured");
        Assert.hasText(password, "password attribute must be specified unless an authentication-source-ref explicitly configured");
    }

    String baseEnvPropsRef = element.getAttribute(ATT_BASE_ENV_PROPS_REF);
    if(StringUtils.hasText(baseEnvPropsRef)) {
        builder.addPropertyReference("baseEnvironmentProperties", baseEnvPropsRef);
    }

    BeanDefinition targetContextSourceDefinition = builder.getBeanDefinition();
    targetContextSourceDefinition = applyPoolingIfApplicable(targetContextSourceDefinition, element, nativePooling);

    BeanDefinition actualContextSourceDefinition = targetContextSourceDefinition;
    if (!anonymousReadOnly) {
        BeanDefinitionBuilder proxyBuilder = BeanDefinitionBuilder.rootBeanDefinition(TransactionAwareContextSourceProxy.class);
        proxyBuilder.addConstructorArgValue(targetContextSourceDefinition);
        actualContextSourceDefinition = proxyBuilder.getBeanDefinition();
    }

    String id = getString(element, AbstractBeanDefinitionParser.ID_ATTRIBUTE, DEFAULT_ID);
    parserContext.registerBeanComponent(new BeanComponentDefinition(actualContextSourceDefinition, id));

    return actualContextSourceDefinition;
}
 
開發者ID:spring-projects,項目名稱:spring-ldap,代碼行數:60,代碼來源:ContextSourceParser.java


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