use of org.jowidgets.cap.service.api.plugin.IBeanModifierPlugin in project jo-client-platform by jo-source.
the class BeanModifierImpl method modify.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void modify(final BEAN_TYPE bean, final IBeanModification modification) {
final Method writeMethod = writeMethods.get(modification.getPropertyName());
if (writeMethod != null || bean instanceof IPropertyMap) {
// plugin before invocation
final List<IBeanModifierPlugin<?>> plugins;
plugins = PluginProvider.getPlugins(IBeanModifierPlugin.ID, pluginProperties);
for (final IBeanModifierPlugin plugin : plugins) {
plugin.beforeModification(bean, modification);
}
// do modification
if (writeMethod != null) {
try {
writeMethod.invoke(bean, modification.getNewValue());
} catch (final Exception e) {
throw new RuntimeException(e);
}
} else if (bean instanceof IPropertyMap) {
((IPropertyMap) bean).setValue(modification.getPropertyName(), modification.getNewValue());
}
// plugin after invocation
for (final IBeanModifierPlugin plugin : plugins) {
plugin.afterModification(bean, modification);
}
} else {
throw new BeanException(modification.getId(), "Tryed to set the property '" + modification.getPropertyName() + "', but the property is not defined / allowed for this bean.");
}
}
use of org.jowidgets.cap.service.api.plugin.IBeanModifierPlugin in project jo-client-platform by jo-source.
the class BeanPropertyMapModifier method modify.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void modify(final IBeanPropertyMap bean, final IBeanModification modification) {
// plugin before invocation
final List<IBeanModifierPlugin<?>> plugins;
plugins = PluginProvider.getPlugins(IBeanModifierPlugin.ID, pluginProperties);
for (final IBeanModifierPlugin plugin : plugins) {
plugin.beforeModification(bean, modification);
}
// do modification
bean.setValue(modification.getPropertyName(), modification.getNewValue());
// plugin after invocation
for (final IBeanModifierPlugin plugin : plugins) {
plugin.afterModification(bean, modification);
}
}
Aggregations