本文整理汇总了Java中org.springframework.beans.factory.config.RuntimeBeanReference类的典型用法代码示例。如果您正苦于以下问题:Java RuntimeBeanReference类的具体用法?Java RuntimeBeanReference怎么用?Java RuntimeBeanReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeBeanReference类属于org.springframework.beans.factory.config包,在下文中一共展示了RuntimeBeanReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConfigBeanFactoryMethod
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
/**
* 修改配置Bean定义,使用静态方法{@link ConfigBeanFactory#FACTORY_METHOD}来实例化。
*
* @param registry
* @param beanName
* @param beanDefinition
* @param propertyName
* @param converterType
*/
public static void setConfigBeanFactoryMethod(BeanDefinitionRegistry registry,
String beanName, BeanDefinition beanDefinition,
String propertyName, Class<?> converterType) {
// 注册ConfigBeanPropertyResolver
registerConfigBeanPropertyResolver(registry);
// 注册ConfigBeanConversionService
registerConfigBeanConversionService(registry);
String beanClassName = beanDefinition.getBeanClassName();
beanDefinition.setBeanClassName(ConfigBeanFactory.class.getName());
beanDefinition.setFactoryMethodName(ConfigBeanFactory.FACTORY_METHOD);
ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
constructorArgumentValues.addGenericArgumentValue(propertyName, String.class.getName());
constructorArgumentValues.addGenericArgumentValue(beanClassName, Class.class.getName());
constructorArgumentValues.addGenericArgumentValue(converterType);
constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(CONFIG_BEAN_PROPERTY_RESOLVER_BEAN_NAME));
constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(CONFIG_BEAN_CONVERSION_SERVICE_BEAN_NAME));
beanDefinition.getConstructorArgumentValues().addArgumentValues(constructorArgumentValues);
}
示例2: parseNested
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
Class<?> apiClass;
try {
apiClass = Class.forName(helper.getAttribute(element,
RedissonNamespaceParserSupport.CLASS_ATTRIBUTE));
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException(
"The class [" + helper.getAttribute(element,
RedissonNamespaceParserSupport.CLASS_ATTRIBUTE)
+ "] specified in \"api-class\" attribute has not "
+ "found. Please check the class path.", ex);
}
builder.addPropertyValue("targetObject", new RuntimeBeanReference(
helper.getAttribute(element,
RedissonNamespaceParserSupport.LIVE_OBJECT_SERVICE_REF_ATTRIBUTE)));
builder.addPropertyValue("targetMethod", "registerClass");
builder.addPropertyValue("arguments", new Object[] {apiClass});
}
示例3: parseNested
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
Class<?> apiClass;
try {
apiClass = Class.forName(helper.getAttribute(element,
RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE));
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException(
"The class [" + helper.getAttribute(element,
RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE)
+ "] specified in \""
+ RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE
+ "\" attribute has not "
+ "found. Please check the class path.", ex);
}
builder.addPropertyValue("targetObject", new RuntimeBeanReference(
helper.getAttribute(element,
RedissonNamespaceParserSupport.REMOTE_SERVICE_REF_ATTRIBUTE)));
builder.addPropertyValue("targetMethod", "get");
builder.addPropertyValue("arguments", new Object[] {apiClass});
}
示例4: parseNested
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
NodeList nodeList = element.getChildNodes();
if (nodeList != null && nodeList.getLength() > 0) {
boolean first = true;
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
if (tag.equals(node.getNodeName())
|| tag.equals(node.getLocalName())) {
if (first) {
first = false;
String isDefault = element.getAttribute("default");
if (isDefault == null || isDefault.length() == 0) {
beanDefinition.getPropertyValues().addPropertyValue("default", "false");
}
}
BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
if (subDefinition != null && ref != null && ref.length() > 0) {
subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
}
}
}
}
}
}
示例5: parseProperties
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
if (nodeList != null && nodeList.getLength() > 0) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
if ("property".equals(node.getNodeName())
|| "property".equals(node.getLocalName())) {
String name = ((Element) node).getAttribute("name");
if (name != null && name.length() > 0) {
String value = ((Element) node).getAttribute("value");
String ref = ((Element) node).getAttribute("ref");
if (value != null && value.length() > 0) {
beanDefinition.getPropertyValues().addPropertyValue(name, value);
} else if (ref != null && ref.length() > 0) {
beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
} else {
throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
}
}
}
}
}
}
}
示例6: addRefIfNeeded
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private void addRefIfNeeded(Object v, List<String> refs) {
if(v == null) return;
if(v instanceof RuntimeBeanReference) {
RuntimeBeanReference r = (RuntimeBeanReference)v;
String name = r.getBeanName();
addRefIfNeeded(name, refs);
if(name == null || name.length() == 0) {
System.err.println("Warning - empty reference " + r);
}
} else if(v instanceof BeanDefinitionHolder) {
// Nested bean definition
BeanDefinitionHolder bdh = (BeanDefinitionHolder)v;
processBeanDefinition(bdh.getBeanName(), bdh.getBeanDefinition());
} else if(v instanceof ManagedList<?>) {
ManagedList<?> ml = (ManagedList<?>)v;
for(Object le : ml) {
addRefIfNeeded(le, refs);
}
// } else {
// System.err.println(v.getClass());
}
}
示例7: resolveId
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
@Override
protected String resolveId(Element el, AbstractBeanDefinition def, ParserContext ctx) {
String id = super.resolveId(el, def, ctx);
deferredBaseBeans.forEach((baseBeanBuilder, baseBeanName) -> {
baseBeanBuilder.addPropertyValue("source", new RuntimeBeanReference(id));
AbstractBeanDefinition baseBean = baseBeanBuilder.getBeanDefinition();
if (baseBeanName == null) {
ctx.getRegistry().registerBeanDefinition(ctx.getReaderContext().generateBeanName(baseBean), baseBean);
} else {
ctx.getRegistry().registerBeanDefinition(baseBeanName, baseBean);
}
});
return id;
}
示例8: parseMessagingBackPressure
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private Optional<RuntimeBeanReference> parseMessagingBackPressure(Element el, ParserContext ctx) {
Element backPressureEl = getChildElementByTagName(el, "back-pressure");
if (backPressureEl != null) {
BeanDefinitionBuilder backPressure = newBean(MessagingBackPressureConfig.class, backPressureEl);
Element outboundEl = getChildElementByTagName(backPressureEl, "outbound");
Element inboundEl = getChildElementByTagName(backPressureEl, "inbound");
if (outboundEl != null) {
setProperty(backPressure, outboundEl, "outLowWatermark", "low-watermark");
setProperty(backPressure, outboundEl, "outHighWatermark", "high-watermark");
setProperty(backPressure, outboundEl, "outOverflowPolicy", "overflow");
}
if (inboundEl != null) {
setProperty(backPressure, inboundEl, "inLowWatermark", "low-watermark");
setProperty(backPressure, inboundEl, "inHighWatermark", "high-watermark");
}
return Optional.of(registerInnerBean(backPressure, ctx));
} else {
return Optional.empty();
}
}
示例9: parseClusterMetricsService
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private Optional<RuntimeBeanReference> parseClusterMetricsService(Element rootEl, ParserContext ctx) {
Element metricsEl = getChildElementByTagName(rootEl, "cluster-metrics");
if (metricsEl != null) {
BeanDefinitionBuilder metrics = newBean(ClusterMetricsServiceFactory.class, metricsEl);
setProperty(metrics, metricsEl, "enabled", "enabled");
setProperty(metrics, metricsEl, "replicationInterval", "replication-interval-ms");
setBeanOrRef(metrics, metricsEl, "replicationFilter", "filter", ctx);
String id = metricsEl.getAttribute("id");
if (!id.isEmpty()) {
deferredBaseBeans.put(newLazyBean(ClusterMetricsServiceBean.class, metricsEl), id);
}
return Optional.of(registerInnerBean(metrics, ctx));
} else {
return Optional.empty();
}
}
示例10: parseRefOrBean
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private Optional<RuntimeBeanReference> parseRefOrBean(Element elem, ParserContext ctx) {
if (elem != null) {
String ref = elem.getAttribute("ref").trim();
Element beanEl = getChildElementByTagName(elem, "bean");
if (!ref.isEmpty() && beanEl != null) {
String name = elem.getLocalName();
ctx.getReaderContext().error('<' + name + ">'s 'ref' attribute can't be mixed with nested <bean> element.", elem);
} else if (!ref.isEmpty()) {
return Optional.of(new RuntimeBeanReference(ref));
} else if (beanEl != null) {
BeanDefinitionHolder holder = ctx.getDelegate().parseBeanDefinitionElement(beanEl);
ctx.registerBeanComponent(new BeanComponentDefinition(holder.getBeanDefinition(), holder.getBeanName()));
return Optional.of(new RuntimeBeanReference(holder.getBeanName()));
}
}
return Optional.empty();
}
示例11: getDefaultKeyValueTemplateBeanDefinition
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
RepositoryConfigurationSource configurationSource) {
RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(TarantoolKeyValueTemplate.class);
ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
new RuntimeBeanReference(TARANTOOL_OPS_IMPL_BEAN_NAME));
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(2,
new RuntimeBeanReference(TARANTOOL_CONVERTER_BEAN_NAME));
keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);
return keyValueTemplateDefinition;
}
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:18,代码来源:TarantoolRepositoryConfigurationExtension.java
示例12: buildExporter
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private AbstractBeanDefinition buildExporter(ServiceMetadata metadata) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(EXPORTER_CLASS);
// add properties
builder.addPropertyValue(EXPORTER_RANKING_PROP, metadata.getRanking());
builder.addPropertyValue(EXPORTER_INTFS_PROP, metadata.getInterfaces());
builder.addPropertyValue(EXPORTER_PROPS_PROP, metadata.getServiceProperties());
builder.addPropertyValue(EXPORTER_AUTO_EXPORT_PROP,
DefaultInterfaceDetector.values()[metadata.getAutoExport() - 1]);
BeanMetadataElement beanMetadata = BeanMetadataElementFactory.buildBeanMetadata(metadata.getServiceComponent());
if (beanMetadata instanceof RuntimeBeanReference) {
builder.addPropertyValue(EXPORTER_TARGET_BEAN_NAME_PROP, beanMetadata);
} else {
builder.addPropertyValue(EXPORTER_TARGET_BEAN_PROP, beanMetadata);
}
// FIXME: add registration listeners
return builder.getBeanDefinition();
}
示例13: parseRefElement
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private Object parseRefElement(Element ele) {
// A generic reference to any name of any component.
String refName = ele.getAttribute(COMPONENT_ID_ATTR);
if (!StringUtils.hasLength(refName)) {
error("'" + COMPONENT_ID_ATTR + "' is required for <ref> element", ele);
return null;
}
if (!StringUtils.hasText(refName)) {
error("<ref> element contains empty target attribute", ele);
return null;
}
RuntimeBeanReference ref = new InstanceEqualityRuntimeBeanReference(refName);
ref.setSource(parserContext.extractSource(ele));
return ref;
}
示例14: tag
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
private void tag(Collection<ValueHolder> values, String name, BeanDefinition definition) {
boolean trace = log.isTraceEnabled();
for (ValueHolder value : values) {
Object val = value.getValue();
if (val instanceof BeanMetadataElement) {
if (val instanceof RuntimeBeanReference) {
String beanName = ((RuntimeBeanReference) val).getBeanName();
if (trace) {
log.trace("Adding (cycle breaking) depends-on on " + name + " to " + beanName);
}
addSyntheticDependsOn(definition, beanName);
}
}
}
}
示例15: resolveReference
import org.springframework.beans.factory.config.RuntimeBeanReference; //导入依赖的package包/类
/**
* Resolve a reference to another bean in the factory.
*/
private Object resolveReference(Object argName, RuntimeBeanReference ref) {
try {
String refName = ref.getBeanName();
refName = String.valueOf(evaluate(refName));
if (ref.isToParent()) {
if (this.beanFactory.getParentBeanFactory() == null) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Can't resolve reference to bean '" + refName +
"' in parent factory: no parent factory available");
}
return this.beanFactory.getParentBeanFactory().getBean(refName);
}
else {
Object bean = this.beanFactory.getBean(refName);
this.beanFactory.registerDependentBean(refName, this.beanName);
return bean;
}
}
catch (BeansException ex) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
}
}