本文整理匯總了Java中org.springframework.beans.factory.support.AbstractBeanDefinition.addQualifier方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractBeanDefinition.addQualifier方法的具體用法?Java AbstractBeanDefinition.addQualifier怎麽用?Java AbstractBeanDefinition.addQualifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.beans.factory.support.AbstractBeanDefinition
的用法示例。
在下文中一共展示了AbstractBeanDefinition.addQualifier方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerBeans
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
@Override
protected void registerBeans(InjectRpcClient annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
String tag = annotation.tag().isEmpty() ? "" : '#' + annotation.tag();
String name = RpcClientBean.class.getName() + tag + "-" + targetType.toString();
if (!registry.containsBeanDefinition(name)) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(RpcClientBean.class)
.setLazyInit(true)
.addPropertyValue("rpcInterface", targetType.getType().getTypeName());
if (!annotation.tag().isEmpty()) {
builder.addPropertyValue("tag", annotation.tag());
}
AbstractBeanDefinition def = builder.getBeanDefinition();
AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(annotation.annotationType());
if (!annotation.tag().isEmpty()) {
qualifier.setAttribute("tag", annotation.tag());
}
def.addQualifier(qualifier);
registry.registerBeanDefinition(name, def);
}
}
示例2: registerBeans
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
@Override
protected void registerBeans(InjectLock annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
String name = LockBean.class.getName() + "-" + annotation.name() + "--" + annotation.name();
if (!registry.containsBeanDefinition(name)) {
AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(LockBean.class)
.setLazyInit(true)
.addPropertyValue("region", annotation.region())
.addPropertyValue("name", annotation.name())
.getBeanDefinition();
AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(annotation.annotationType());
qualifier.addMetadataAttribute(new BeanMetadataAttribute("region", annotation.region()));
qualifier.addMetadataAttribute(new BeanMetadataAttribute("name", annotation.name()));
def.addQualifier(qualifier);
registry.registerBeanDefinition(name, def);
}
}
示例3: registerBeans
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
@Override
protected void registerBeans(InjectConnector annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
String name = NetworkConnectorBean.class.getName() + "-" + annotation.value();
if (!registry.containsBeanDefinition(name)) {
AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(NetworkConnectorBean.class)
.setLazyInit(true)
.addPropertyValue("protocol", annotation.value())
.getBeanDefinition();
def.addQualifier(new AutowireCandidateQualifier(annotation.annotationType(), annotation.value()));
registry.registerBeanDefinition(name, def);
}
}
示例4: registerBeans
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
@Override
protected void registerBeans(InjectCounter annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
String name = CounterMetricBean.class.getName() + "-" + annotation.value();
if (!registry.containsBeanDefinition(name)) {
AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(CounterMetricBean.class)
.setLazyInit(true)
.addPropertyValue("name", annotation.value())
.getBeanDefinition();
def.addQualifier(new AutowireCandidateQualifier(annotation.annotationType(), annotation.value()));
registry.registerBeanDefinition(name, def);
}
}
示例5: registerBeans
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
@Override
protected void registerBeans(InjectChannel annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
String name = MessagingChannelBean.class.getName() + "-" + annotation.value();
if (!registry.containsBeanDefinition(name)) {
AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(MessagingChannelBean.class)
.setLazyInit(true)
.addPropertyValue("channel", annotation.value())
.getBeanDefinition();
def.addQualifier(new AutowireCandidateQualifier(annotation.annotationType(), annotation.value()));
registry.registerBeanDefinition(name, def);
}
}
示例6: parseQualifierElement
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
/**
* Parse a qualifier element.
*/
public void parseQualifierElement(Element ele, AbstractBeanDefinition bd) {
String typeName = ele.getAttribute(TYPE_ATTRIBUTE);
if (!StringUtils.hasLength(typeName)) {
error("Tag 'qualifier' must have a 'type' attribute", ele);
return;
}
this.parseState.push(new QualifierEntry(typeName));
try {
AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(typeName);
qualifier.setSource(extractSource(ele));
String value = ele.getAttribute(VALUE_ATTRIBUTE);
if (StringUtils.hasLength(value)) {
qualifier.setAttribute(AutowireCandidateQualifier.VALUE_KEY, value);
}
NodeList nl = ele.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (isCandidateElement(node) && nodeNameEquals(node, QUALIFIER_ATTRIBUTE_ELEMENT)) {
Element attributeEle = (Element) node;
String attributeName = attributeEle.getAttribute(KEY_ATTRIBUTE);
String attributeValue = attributeEle.getAttribute(VALUE_ATTRIBUTE);
if (StringUtils.hasLength(attributeName) && StringUtils.hasLength(attributeValue)) {
BeanMetadataAttribute attribute = new BeanMetadataAttribute(attributeName, attributeValue);
attribute.setSource(extractSource(attributeEle));
qualifier.addMetadataAttribute(attribute);
}
else {
error("Qualifier 'attribute' tag must have a 'name' and 'value'", attributeEle);
return;
}
}
}
bd.addQualifier(qualifier);
}
finally {
this.parseState.pop();
}
}