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


Java RuntimeBeanReference類代碼示例

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

示例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});
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:20,代碼來源:RedissonLiveObjectRegistrationDefinitionParser.java

示例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});
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:22,代碼來源:RedissonRPCClientDefinitionParser.java

示例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));
                    }
                }
            }
        }
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:26,代碼來源:DubboBeanDefinitionParser.java

示例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=\"...\" />");
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:25,代碼來源:DubboBeanDefinitionParser.java

示例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());
         }
      }
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:26,代碼來源:ContextDependencyLister.java

示例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;
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:19,代碼來源:HekateBeanDefinitionParser.java

示例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();
    }
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:26,代碼來源:HekateBeanDefinitionParser.java

示例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();
    }
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:23,代碼來源:HekateBeanDefinitionParser.java

示例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();
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:24,代碼來源:HekateBeanDefinitionParser.java

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

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

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

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


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