use of org.jowidgets.cap.service.api.plugin.IBeanInitializerPlugin in project jo-client-platform by jo-source.
the class BeanInitializerImpl method initialize.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize(final BEAN_TYPE bean, final IBeanData beanData) {
Assert.paramNotNull(bean, "bean");
Assert.paramNotNull(beanData, "beanData");
// plugin before invocation
final List<IBeanInitializerPlugin<?>> plugins;
plugins = PluginProvider.getPlugins(IBeanInitializerPlugin.ID, pluginProperties);
for (final IBeanInitializerPlugin plugin : plugins) {
plugin.beforeInitialize(bean, beanData);
}
// set the values
for (final String propertyName : propertyNames) {
final Method method = methods.get(propertyName);
if (method != null) {
try {
method.invoke(bean, beanData.getValue(propertyName));
} catch (final Exception e) {
throw new RuntimeException("Error while setting property '" + propertyName + "' on bean '" + bean + "'.", e);
}
} else if (bean instanceof IPropertyMap) {
((IPropertyMap) bean).setValue(propertyName, beanData.getValue(propertyName));
}
}
// plugin after invocation
for (final IBeanInitializerPlugin plugin : plugins) {
plugin.afterInitialize(bean, beanData);
}
}
use of org.jowidgets.cap.service.api.plugin.IBeanInitializerPlugin in project jo-client-platform by jo-source.
the class BeanPropertyMapInitializer method initialize.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize(final IBeanPropertyMap bean, final IBeanData beanData) {
// plugin before invocation
final List<IBeanInitializerPlugin<?>> plugins;
plugins = PluginProvider.getPlugins(IBeanInitializerPlugin.ID, pluginProperties);
for (final IBeanInitializerPlugin plugin : plugins) {
plugin.beforeInitialize(bean, beanData);
}
// set the values
for (final String propertyName : propertyNames) {
if (!IBean.ID_PROPERTY.equals(propertyName) && !IBean.VERSION_PROPERTY.equals(propertyName)) {
bean.setValue(propertyName, beanData.getValue(propertyName));
}
}
// plugin after invocation
for (final IBeanInitializerPlugin plugin : plugins) {
plugin.afterInitialize(bean, beanData);
}
}
Aggregations