Examples of BeanWrapper


Examples of org.springframework.beans.BeanWrapper

    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);
    } catch (BeansException ex) {
      String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': "
          + ex.getMessage();
      logger.error(msg, ex);
      throw new NestedServletException(msg, ex);
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

                        @Override
                        public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item,
                                final String componentId, final IModel<AbstractSchemaTO> model) {

                            BeanWrapper bwi = new BeanWrapperImpl(model.getObject());
                            Object obj = bwi.getPropertyValue(field);

                            item.add(new Label(componentId, ""));
                            item.add(new AttributeModifier("class", new Model<String>(obj.toString())));
                        }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

                jobInstanceLoader.registerJob(report);
            }
        }

        final Object job = ctx.getBean(bundle.getJobDetail().getKey().getName());
        final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(job);
        if (isEligibleForPropertyPopulation(wrapper.getWrappedInstance())) {
            final MutablePropertyValues pvs = new MutablePropertyValues();
            if (this.schedulerContext != null) {
                pvs.addPropertyValues(this.schedulerContext);
            }
            pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap());
            pvs.addPropertyValues(bundle.getTrigger().getJobDataMap());
            if (this.ignoredUnknownProperties == null) {
                wrapper.setPropertyValues(pvs, true);
            } else {
                for (String propName : this.ignoredUnknownProperties) {
                    if (pvs.contains(propName) && !wrapper.isWritableProperty(propName)) {

                        pvs.removePropertyValue(propName);
                    }
                }
                wrapper.setPropertyValues(pvs);
            }
        }
        return job;
    }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

    return memberCollection.containsKey(id);
  }

  // alternative way of copying values
  public void copyValues(Member source, Member target, Iterable<String> properties) {
    BeanWrapper src = new BeanWrapperImpl(source);
    BeanWrapper trg = new BeanWrapperImpl(target);

    for(String propertyName : properties){
      trg.setPropertyValue(propertyName,src.getPropertyValue(propertyName)
      );
    }

  }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

    List<T> results = new ArrayList<T>();
    if (reader != null) {
      try {
        for (GenericRecord r : reader) {
          T data = targetClass.newInstance();
          BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(data);
          for (Schema.Field f : r.getSchema().getFields()) {
            if (beanWrapper.isWritableProperty(f.name())) {
              beanWrapper.setPropertyValue(f.name(), r.get(f.name()));
            }
          }
          results.add(data);
        }
      } catch (InstantiationException e) {
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

        fs.exists(new Path(path + "/test/" + DatasetUtils.getDatasetName(recordClass) + "/.metadata")));
    Collection<T> results = datasetOperations.read(recordClass);
    assertEquals(2, results.size());
    List<T> sorted = new ArrayList<T>(results);
    Collections.sort(sorted);
    BeanWrapper result = new BeanWrapperImpl(sorted.get(0));
    assertTrue(result.isReadableProperty("name"));
    assertTrue(result.getPropertyValue("name").equals("Sven"));
    assertTrue(result.isReadableProperty("id"));
    assertTrue(result.getPropertyValue("id").equals(22L));
    result = new BeanWrapperImpl(sorted.get(1));
    assertTrue(result.isReadableProperty("name"));
    assertTrue(result.getPropertyValue("name").equals("Nisse"));
    assertTrue(result.isReadableProperty("id"));
    assertTrue(result.getPropertyValue("id").equals(48L));
  }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

  public void usesFieldAccessForReadIfNoAccessorCanBeFound() {

    Sample sample = new Sample();
    sample.firstname = "Dave";

    BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(sample);

    assertThat(wrapper.getPropertyValue("firstname"), is((Object) "Dave"));
  }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

  @Test
  public void usesFieldAccessForWriteIfNoAccessorCanBeFound() {

    Sample sample = new Sample();

    BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(sample);
    wrapper.setPropertyValue("firstname", "Dave");

    assertThat(sample.firstname, is("Dave"));
  }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

   * @see DATACMNS-452
   */
  @Test(expected = NotReadablePropertyException.class)
  public void throwsAppropriateExceptionIfNoFieldFoundForRead() {

    BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(new Sample());
    wrapper.getPropertyValue("lastname");
  }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

   * @see DATACMNS-452
   */
  @Test(expected = NotWritablePropertyException.class)
  public void throwsAppropriateExceptionIfNoFieldFoundForWrite() {

    BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(new Sample());
    wrapper.setPropertyValue("lastname", "Matthews");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.