CcmNG: Fix
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5664 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: e99ce7ec82
pull/2/head
parent
31f8bec007
commit
7fe5930e7e
|
|
@ -296,11 +296,12 @@ public class Components {
|
|||
final ComponentModel componentModel) {
|
||||
|
||||
final Class<? extends ComponentModel> clazz = Objects
|
||||
.requireNonNull(componentModel.getClass());
|
||||
.requireNonNull(componentModel)
|
||||
.getClass();
|
||||
|
||||
final ComponentModelJsonConverter jsonConverter
|
||||
= findJsonConverter(clazz)
|
||||
.orElseThrow(() -> new WebApplicationException(String.format(
|
||||
= findJsonConverter(clazz)
|
||||
.orElseThrow(() -> new WebApplicationException(String.format(
|
||||
"No JSON converter available for component model \"%s\".",
|
||||
clazz.getName())));
|
||||
|
||||
|
|
@ -394,9 +395,9 @@ public class Components {
|
|||
try {
|
||||
componentModel = clazz.getConstructor().newInstance();
|
||||
} catch (IllegalAccessException
|
||||
| InstantiationException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException ex) {
|
||||
| InstantiationException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException ex) {
|
||||
throw new WebApplicationException(ex);
|
||||
}
|
||||
|
||||
|
|
@ -453,19 +454,31 @@ public class Components {
|
|||
final JsonObject data,
|
||||
final ComponentModel componentModel) {
|
||||
|
||||
final BeanInfo beanInfo;
|
||||
try {
|
||||
beanInfo = Introspector.getBeanInfo(componentModel.getClass());
|
||||
} catch (IntrospectionException ex) {
|
||||
throw new WebApplicationException(ex);
|
||||
}
|
||||
final Class<? extends ComponentModel> clazz = Objects
|
||||
.requireNonNull(componentModel)
|
||||
.getClass();
|
||||
|
||||
Arrays
|
||||
.stream(beanInfo.getPropertyDescriptors())
|
||||
.forEach(
|
||||
propertyDesc -> setComponentPropertyFromJson(componentModel,
|
||||
propertyDesc,
|
||||
data));
|
||||
final ComponentModelJsonConverter jsonConverter
|
||||
= findJsonConverter(clazz)
|
||||
.orElseThrow(() -> new WebApplicationException(String.format(
|
||||
"No JSON converter available for component model \"%s\".",
|
||||
clazz.getName())));
|
||||
|
||||
jsonConverter.fromJson(data, componentModel);
|
||||
|
||||
// final BeanInfo beanInfo;
|
||||
// try {
|
||||
// beanInfo = Introspector.getBeanInfo(componentModel.getClass());
|
||||
// } catch (IntrospectionException ex) {
|
||||
// throw new WebApplicationException(ex);
|
||||
// }
|
||||
//
|
||||
// Arrays
|
||||
// .stream(beanInfo.getPropertyDescriptors())
|
||||
// .forEach(
|
||||
// propertyDesc -> setComponentPropertyFromJson(componentModel,
|
||||
// propertyDesc,
|
||||
// data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -561,7 +574,7 @@ public class Components {
|
|||
}
|
||||
|
||||
} catch (IllegalAccessException
|
||||
| InvocationTargetException ex) {
|
||||
| InvocationTargetException ex) {
|
||||
throw new WebApplicationException(ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue