use of org.springframework.beans.BeanWrapper in project syncope by apache.
the class BooleanPropertyColumn method populateItem.
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel) {
BeanWrapper bwi = new BeanWrapperImpl(rowModel.getObject());
Object obj = bwi.getPropertyValue(getPropertyExpression());
item.add(new Label(componentId, StringUtils.EMPTY));
if (Boolean.valueOf(obj.toString())) {
item.add(new AttributeModifier("class", "glyphicon glyphicon-ok"));
item.add(new AttributeModifier("style", "display: table-cell; text-align: center;"));
}
}
use of org.springframework.beans.BeanWrapper in project syncope by apache.
the class AutowiringSpringBeanJobFactory method createJobInstance.
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
Object job = beanFactory.getBean(bundle.getJobDetail().getKey().getName());
if (isEligibleForPropertyPopulation(job)) {
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
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) {
for (String propName : this.ignoredUnknownProperties) {
if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
pvs.removePropertyValue(propName);
}
}
bw.setPropertyValues(pvs);
} else {
bw.setPropertyValues(pvs, true);
}
}
return job;
}
use of org.springframework.beans.BeanWrapper in project walkmod-core by walkmod.
the class ConfigurationImpl method getBean.
@Override
public Object getBean(String name, Map<?, ?> parameters) {
Object result = null;
if (name == null || "".equals(name)) {
return result;
}
if (name.equals("script")) {
name = "walkmod:commons:scripting";
} else if (name.equals("template")) {
name = "walkmod:commons:template";
}
if (beanFactory != null && beanFactory.containsBean(name)) {
result = beanFactory.getBean(name);
}
if (result == null) {
String fullName = "org.walkmod:walkmod-" + name + "-plugin:" + name;
if (!name.contains(":") && beanFactory.containsBean(fullName)) {
result = beanFactory.getBean(fullName);
} else {
String[] parts = name.split(":");
if (parts.length == 2) {
String pluginId = parts[0].trim();
String beanId = parts[1].trim();
String compositeName = "org.walkmod:walkmod-" + pluginId + "-plugin:" + beanId;
if (pluginId.length() > 0 && beanId.length() > 0 && beanFactory.containsBean(compositeName)) {
result = beanFactory.getBean(compositeName);
}
}
}
}
if (result == null) {
try {
Class<?> clazz = getClassLoader().loadClass(name);
result = clazz.newInstance();
} catch (Exception e) {
throw new WalkModException("Sorry, it is impossible to load the bean " + name + ". Please, assure that it is a valid class name and the library which contains it is in the classpath", e);
}
}
if (result != null) {
BeanWrapper bw = new BeanWrapperImpl(result);
if (this.parameters != null) {
MutablePropertyValues pvs = new MutablePropertyValues(this.parameters);
bw.setPropertyValues(pvs, true, true);
}
if (parameters != null) {
MutablePropertyValues pvs = new MutablePropertyValues(parameters);
bw.setPropertyValues(pvs, true, true);
}
}
return result;
}
use of org.springframework.beans.BeanWrapper in project spring-data-commons by spring-projects.
the class DirectFieldAccessFallbackBeanWrapperUnitTests method throwsAppropriateExceptionIfNoFieldFoundForWrite.
// DATACMNS-452
@Test(expected = NotWritablePropertyException.class)
public void throwsAppropriateExceptionIfNoFieldFoundForWrite() {
BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(new Sample());
wrapper.setPropertyValue("lastname", "Matthews");
}
use of org.springframework.beans.BeanWrapper in project spring-data-commons by spring-projects.
the class DirectFieldAccessFallbackBeanWrapperUnitTests method usesFieldAccessForReadIfNoAccessorCanBeFound.
// DATACMNS-452
@Test
public void usesFieldAccessForReadIfNoAccessorCanBeFound() {
Sample sample = new Sample();
sample.firstname = "Dave";
BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(sample);
assertThat(wrapper.getPropertyValue("firstname")).isEqualTo("Dave");
}
Aggregations