Package org.springframework.beans

Examples of org.springframework.beans.PropertyValues


    this.filterConfig = filterConfig;

    // Set bean properties from init parameters.
    try {
      PropertyValues pvs = new FilterConfigPropertyValues(filterConfig,
          this.requiredProperties);
      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      ResourceLoader resourceLoader = new ServletContextResourceLoader(
          filterConfig.getServletContext());
      bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader));
View Full Code Here


    this.filterConfig = filterConfig;

    // Set bean properties from init parameters.
    try {
      PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties);
      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext());
      bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader));
      initBeanWrapper(bw);
      bw.setPropertyValues(pvs, true);
View Full Code Here

    return !ClassUtils.hasMethod(superclass, wm.getName(), wm.getParameterTypes());
  }

  protected Map<String, PropertyDescriptor> unsatisfiedNonSimpleProperties(BeanDefinition mbd) {
    Map<String, PropertyDescriptor> properties = CollectUtils.newHashMap();
    PropertyValues pvs = mbd.getPropertyValues();
    Class<?> clazz = null;
    try {
      clazz = Class.forName(mbd.getBeanClassName());
    } catch (ClassNotFoundException e) {
      logger.error("Class " + mbd.getBeanClassName() + "not found", e);
      return properties;
    }
    PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(clazz);
    for (PropertyDescriptor pd : pds) {
      if (pd.getWriteMethod() != null && !isExcludedFromDependencyCheck(pd)
          && !pvs.contains(pd.getName()) && !BeanUtils.isSimpleProperty(pd.getPropertyType())) {
        properties.put(pd.getName(), pd);
      }
    }
    return properties;
  }
View Full Code Here


  private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefinition) {
    List innerBeans = new ArrayList();
    List references = new ArrayList();
    PropertyValues propertyValues = beanDefinition.getPropertyValues();
    for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
      PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
      Object value = propertyValue.getValue();
      if (value instanceof BeanDefinitionHolder) {
        innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());
      }
      else if (value instanceof BeanDefinition) {
View Full Code Here

   * @param beanName the name of the bean
   * @param mbd the bean definition for the bean
   * @param bw BeanWrapper with bean instance
   */
  protected void populateBean(String beanName, AbstractBeanDefinition mbd, BeanWrapper bw) {
    PropertyValues pvs = mbd.getPropertyValues();

    if (bw == null) {
      if (!pvs.isEmpty()) {
        throw new BeanCreationException(
            mbd.getResourceDescription(), beanName, "Cannot apply property values to null instance");
      }
      else {
        // Skip property population phase for null instance.
View Full Code Here

   * @return an array of bean property names
   * @see org.springframework.beans.BeanUtils#isSimpleProperty
   */
  protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, BeanWrapper bw) {
    Set result = new TreeSet();
    PropertyValues pvs = mbd.getPropertyValues();
    PropertyDescriptor[] pds = bw.getPropertyDescriptors();
    for (int i = 0; i < pds.length; i++) {
      if (pds[i].getWriteMethod() != null && !isExcludedFromDependencyCheck(pds[i]) &&
          !pvs.contains(pds[i].getName()) && !BeanUtils.isSimpleProperty(pds[i].getPropertyType())) {
        result.add(pds[i].getName());
      }
    }
    return StringUtils.toStringArray(result);
  }
View Full Code Here

        @Override
        public void insertBeanInTarget(String oldName)
        {
            assertTargetPresent();
            PropertyValues sourceProperties = bean.getRawBeanDefinition().getPropertyValues();
            String newName = bestGuessName(targetConfig, oldName, target.getBeanClassName());
            MutablePropertyValues targetProperties = target.getPropertyValues();
            PropertyValue pv = targetProperties.getPropertyValue(newName);
            @SuppressWarnings("unchecked")
            ManagedMap<String, String> oldValue = (ManagedMap<String, String>) (null == pv
                                                                                          ? null
                                                                                          : pv.getValue());

            if (null == oldValue)
            {
                oldValue = new ManagedMap<String, String>();
                pv = new PropertyValue(newName, oldValue);
                targetProperties.addPropertyValue(pv);
            }

            String importName = null;
            String importClassName = (String) sourceProperties.getPropertyValue(
                ChildMapEntryDefinitionParser.VALUE).getValue();

            PropertyValue namePropertyValue = sourceProperties.getPropertyValue(ChildMapEntryDefinitionParser.KEY);
            if (namePropertyValue != null)
            {
                importName = (String) namePropertyValue.getValue();
            }
            else
View Full Code Here

    public void insertBeanInTarget(String oldName)
    {
        logger.debug("insert " + bean.getBeanDefinition().getBeanClassName() + " -> " + target.getBeanClassName());
        assertTargetPresent();
        String beanClass = bean.getBeanDefinition().getBeanClassName();
        PropertyValues sourceProperties = bean.getRawBeanDefinition().getPropertyValues();
        String newName = bestGuessName(targetConfig, oldName, target.getBeanClassName());
        MutablePropertyValues targetProperties = target.getPropertyValues();
        PropertyValue pv = targetProperties.getPropertyValue(newName);
        Object oldValue = null == pv ? null : pv.getValue();

        if (! targetConfig.isIgnored(oldName))
        {
            if (targetConfig.isCollection(oldName) ||
                    beanClass.equals(ChildListEntryDefinitionParser.ListEntry.class.getName()))
            {
                if (null == oldValue)
                {
                    if (beanClass.equals(ChildMapEntryDefinitionParser.KeyValuePair.class.getName()) ||
                            beanClass.equals(MapEntryCombiner.class.getName()) ||
                            beanClass.equals(MapFactoryBean.class.getName()))
                    {
                        // a collection of maps requires an extra intermediate object that does the
                        // lazy combination/caching of maps when first used
                        BeanDefinitionBuilder combiner = BeanDefinitionBuilder.rootBeanDefinition(MapCombiner.class);
                        targetProperties.addPropertyValue(newName, combiner.getBeanDefinition());
                        MutablePropertyValues combinerProperties = combiner.getBeanDefinition().getPropertyValues();
                        oldValue = new ManagedList();
                        pv = new PropertyValue(MapCombiner.LIST, oldValue);
                        combinerProperties.addPropertyValue(pv);
                    }
                    else
                    {
                        oldValue = new ManagedList();
                        pv = new PropertyValue(newName, oldValue);
                        targetProperties.addPropertyValue(pv);
                    }
                }

                List list = retrieveList(oldValue);
                if (ChildMapEntryDefinitionParser.KeyValuePair.class.getName().equals(beanClass))
                {
                    list.add(new ManagedMap());
                    retrieveMap(list.get(list.size() - 1)).put(
                            sourceProperties.getPropertyValue(ChildMapEntryDefinitionParser.KEY).getValue(),
                            sourceProperties.getPropertyValue(ChildMapEntryDefinitionParser.VALUE).getValue());
                }
                else if (beanClass.equals(ChildListEntryDefinitionParser.ListEntry.class.getName()))
                {
                    list.add(sourceProperties.getPropertyValue(ChildListEntryDefinitionParser.VALUE).getValue());
                }
                else
                {
                    list.add(bean.getBeanDefinition());
                }
            }
            else
            {
                // not a collection

                if (ChildMapEntryDefinitionParser.KeyValuePair.class.getName().equals(beanClass))
                {
                    if (null == pv || null == oldValue)
                    {
                        pv = new PropertyValue(newName, new ManagedMap());
                        targetProperties.addPropertyValue(pv);
                    }
                    retrieveMap(pv.getValue()).put(
                            sourceProperties.getPropertyValue(ChildMapEntryDefinitionParser.KEY).getValue(),
                            sourceProperties.getPropertyValue(ChildMapEntryDefinitionParser.VALUE).getValue());
                }
                else
                {
                    targetProperties.addPropertyValue(newName, bean.getBeanDefinition());
                }
View Full Code Here

    private String getLoginFormUrl(BeanDefinition entryPoint) {
        if (entryPoint == null) {
            return null;
        }

        PropertyValues pvs = entryPoint.getPropertyValues();
        PropertyValue pv = pvs.getPropertyValue("loginFormUrl");
        if (pv == null) {
             return null;
        }

        // If the login URL is the default one, then it is assumed not to have been set explicitly
View Full Code Here

        this.filterConfig = filterConfig;

        logInBothServletAndLoggingSystem("Initializing filter: " + getFilterName());

        try {
            PropertyValues pvs = new FilterConfigPropertyValues(getFilterConfig(), requiredProperties);
            BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
            ResourceLoader resourceLoader = new ServletContextResourceLoader(getServletContext());
            bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader));
            initBeanWrapper(bw);
            bw.setPropertyValues(pvs, true);
View Full Code Here

TOP

Related Classes of org.springframework.beans.PropertyValues

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.