Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.RuntimeBeanReference


      if (Object.class.equals(pd.getPropertyType())) continue;
      MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd);
      List<String> beanNames = bindRegistry.getBeanNames(methodParam.getParameterType());
      boolean binded = false;
      if (beanNames.size() == 1) {
        mbd.getPropertyValues().add(propertyName, new RuntimeBeanReference(beanNames.get(0)));
        binded = true;
      } else if (beanNames.size() > 1) {
        for (String name : beanNames) {
          if (name.equals(propertyName)) {
            mbd.getPropertyValues().add(propertyName, new RuntimeBeanReference(propertyName));
            binded = true;
            break;
          }
        }
      }
View Full Code Here


    if (hasRefAttribute) {
      String refName = ele.getAttribute(REF_ATTRIBUTE);
      if (!StringUtils.hasText(refName)) {
        error(elementName + " contains empty 'ref' attribute", ele);
      }
      RuntimeBeanReference ref = new RuntimeBeanReference(refName);
      ref.setSource(extractSource(ele));
      return ref;
    } else if (hasValueAttribute) {
      TypedStringValue valueHolder = new TypedStringValue(ele.getAttribute(VALUE_ATTRIBUTE));
      valueHolder.setSource(extractSource(ele));
      return valueHolder;
View Full Code Here

      }
      if (!StringUtils.hasText(refName)) {
        error("<ref> element contains empty target attribute", ele);
        return null;
      }
      RuntimeBeanReference ref = new RuntimeBeanReference(refName, toParent);
      ref.setSource(extractSource(ele));
      return ref;
    } else if (nodeNameEquals(ele, IDREF_ELEMENT)) {
      return parseIdRefElement(ele);
    } else if (nodeNameEquals(ele, VALUE_ELEMENT)) {
      return parseValueElement(ele, defaultValueType);
View Full Code Here

      } else if (hasKeyRefAttribute) {
        String refName = entryEle.getAttribute(KEY_REF_ATTRIBUTE);
        if (!StringUtils.hasText(refName)) {
          error("<entry> element contains empty 'key-ref' attribute", entryEle);
        }
        RuntimeBeanReference ref = new RuntimeBeanReference(refName);
        ref.setSource(extractSource(entryEle));
        key = ref;
      } else if (keyEle != null) {
        key = parseKeyElement(keyEle, bd, defaultKeyType);
      } else {
        error("<entry> element must specify a key", entryEle);
      }

      // Extract value from attribute or sub-element.
      Object value = null;
      boolean hasValueAttribute = entryEle.hasAttribute(VALUE_ATTRIBUTE);
      boolean hasValueRefAttribute = entryEle.hasAttribute(VALUE_REF_ATTRIBUTE);
      if ((hasValueAttribute && hasValueRefAttribute) || ((hasValueAttribute || hasValueRefAttribute))
          && valueEle != null) {
        error("<entry> element is only allowed to contain either "
            + "'value' attribute OR 'value-ref' attribute OR <value> sub-element", entryEle);
      }
      if (hasValueAttribute) {
        value = buildTypedStringValueForMap(entryEle.getAttribute(VALUE_ATTRIBUTE), defaultValueType,
            entryEle);
      } else if (hasValueRefAttribute) {
        String refName = entryEle.getAttribute(VALUE_REF_ATTRIBUTE);
        if (!StringUtils.hasText(refName)) {
          error("<entry> element contains empty 'value-ref' attribute", entryEle);
        }
        RuntimeBeanReference ref = new RuntimeBeanReference(refName);
        ref.setSource(extractSource(entryEle));
        value = ref;
      } else if (valueEle != null) {
        value = parsePropertySubElement(valueEle, bd, defaultValueType);
      } else {
        error("<entry> element must specify a value", entryEle);
View Full Code Here

        argumentResolvers.add(createBeanDefinition(MessageContextMethodArgumentResolver.class, source));
        argumentResolvers.add(createBeanDefinition(XPathParamMethodArgumentResolver.class, source));
        argumentResolvers.add(createBeanDefinition(SoapMethodArgumentResolver.class, source));
        argumentResolvers.add(createBeanDefinition(SoapHeaderElementMethodArgumentResolver.class, source));

        RuntimeBeanReference domProcessor = createBeanReference(DomPayloadMethodProcessor.class, source, parserContext);
        argumentResolvers.add(domProcessor);
        returnValueHandlers.add(domProcessor);

        RuntimeBeanReference sourceProcessor =
                createBeanReference(SourcePayloadMethodProcessor.class, source, parserContext);
        argumentResolvers.add(sourceProcessor);
        returnValueHandlers.add(sourceProcessor);

        if (dom4jPresent) {
            RuntimeBeanReference dom4jProcessor =
                    createBeanReference(Dom4jPayloadMethodProcessor.class, source, parserContext);
            argumentResolvers.add(dom4jProcessor);
            returnValueHandlers.add(dom4jProcessor);
        }
        if (jaxb2Present) {
            RuntimeBeanReference xmlRootElementProcessor =
                    createBeanReference(XmlRootElementPayloadMethodProcessor.class, source, parserContext);
            argumentResolvers.add(xmlRootElementProcessor);
            returnValueHandlers.add(xmlRootElementProcessor);

            RuntimeBeanReference jaxbElementProcessor =
                    createBeanReference(JaxbElementPayloadMethodProcessor.class, source, parserContext);
            argumentResolvers.add(jaxbElementProcessor);
            returnValueHandlers.add(jaxbElementProcessor);
        }
        if (jdomPresent) {
            RuntimeBeanReference jdomProcessor =
                    createBeanReference(JDomPayloadMethodProcessor.class, source, parserContext);
            argumentResolvers.add(jdomProcessor);
            returnValueHandlers.add(jdomProcessor);
        }
        if (staxPresent) {
            argumentResolvers.add(createBeanDefinition(StaxPayloadMethodArgumentResolver.class, source));
        }
        if (xomPresent) {
            RuntimeBeanReference xomProcessor =
                    createBeanReference(XomPayloadMethodProcessor.class, source, parserContext);
            argumentResolvers.add(xomProcessor);
            returnValueHandlers.add(xomProcessor);
        }
        if (element.hasAttribute("marshaller")) {
            RuntimeBeanReference marshallerReference = new RuntimeBeanReference(element.getAttribute("marshaller"));
            RuntimeBeanReference unmarshallerReference;
            if (element.hasAttribute("unmarshaller")) {
                unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller"));
            }
            else {
                unmarshallerReference = marshallerReference;
            }
View Full Code Here

    private RuntimeBeanReference createBeanReference(Class<?> beanClass, Object source, ParserContext parserContext) {
        RootBeanDefinition beanDefinition = createBeanDefinition(beanClass, source);
        String beanName = parserContext.getReaderContext().registerWithGeneratedName(beanDefinition);
        parserContext.registerComponent(new BeanComponentDefinition(beanDefinition, beanName));
        return new RuntimeBeanReference(beanName);
    }
View Full Code Here

        }
        if (!StringUtils.hasText(refName)) {
            error(parserContext, "<ref> element contains empty target attribute", element);
            return null;
        }
        RuntimeBeanReference ref = new RuntimeBeanReference(refName);
        ref.setSource(parserContext.extractSource(element));
        return ref;
    }
View Full Code Here

    String attr = element.getAttribute(attrName);
    if (StringUtils.hasText(attr)) {
      String[] strs = StringUtils.commaDelimitedListToStringArray(attr);
      ManagedList<RuntimeBeanReference> list = new ManagedList<RuntimeBeanReference>(strs.length);
      for (int i = 0; i < strs.length; i++) {
        list.add(new RuntimeBeanReference(strs[i].trim()));
      }
      builder.addPropertyValue(propertyName, list);
      return true;
    }
    return false;
View Full Code Here

        nested.setScope(scope);
      }
      script = nested;
    }
    else {
      script = new RuntimeBeanReference(attribute);
    }

    builder.addPropertyValue("scriptCallback", script);
  }
View Full Code Here

    b.addPropertyValue("propertiesArray", propsArray);
   
    String attr = element.getAttribute("properties-ref");
    if (StringUtils.hasText(attr)) {
      hasProperties = true;
      propsArray.add(new RuntimeBeanReference(attr));
    }

    hasProperties |= NamespaceUtils.setCSVProperty(element, b, "properties-location", "locations");

    // parse nested properties
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.RuntimeBeanReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.