use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class AttributeEditWindow method postInit.
@Override
protected void postInit() {
ManagedBeanAttribute mba = getItem();
final String type = mba.getType();
valueHolder = new AttributeEditor(this, type, mba.getValue(), true, true);
valueContainer.add(valueHolder.getComponent(), 1, 0);
if (mba.getName() != null) {
setCaption(formatMessage("editAttribute.title.format", mba.getName()));
}
}
use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class AttributeEditWindow method assignValue.
private boolean assignValue() {
ManagedBeanAttribute mba = getItem();
Object oldValue = mba.getValue();
try {
Object newValue = valueHolder != null ? valueHolder.getAttributeValue(false) : null;
if (newValue != null) {
if (!Objects.equals(mba.getValue(), newValue)) {
mba.setValue(newValue);
jmxControlAPI.saveAttributeValue(mba);
}
return true;
}
} catch (Exception e) {
String width = themeConstants.get("cuba.web.AttributeEditWindow.messageDialog.width");
showMessageDialog(String.format(getMessage("editAttribute.exception"), mba.getName()), e.getClass().getCanonicalName() + " " + e.getMessage() + "\n", MessageType.WARNING.setWidth(width));
mba.setValue(oldValue);
return false;
}
showNotification(getMessage("editAttribute.conversionError"), NotificationType.HUMANIZED);
return false;
}
use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class StatisticsDatasource method setParameters.
protected void setParameters(String objectName, String[] beanProps, String[] paramNames) throws ReflectionException, InstanceNotFoundException {
for (int i = 0; i < beanProps.length; i++) {
String beanProp = beanProps[i];
ManagedBeanAttribute attr = findAttribute(objectName, beanProp);
if (attr != null) {
String paramName = paramNames[i];
PerformanceParameter param = getParameter(paramName);
Object value = attr.getValue();
if (value instanceof Long) {
param.setCurrent(((Long) value).doubleValue());
} else if (value instanceof Integer) {
param.setCurrent(((Integer) value).doubleValue());
} else if (value instanceof Double) {
param.setCurrent((Double) value);
}
}
}
}
use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class StatisticsDatasource method findAttribute.
@Nullable
protected ManagedBeanAttribute findAttribute(String beanObjectName, String attrName) {
ManagedBeanAttribute res = name2attr.get(attrName);
if (res == NOT_FOUND_ATTR)
return null;
if (res == null) {
ManagedBeanInfo bean = jmxControlAPI.getManagedBean(node, beanObjectName);
if (bean != null) {
res = jmxControlAPI.loadAttribute(bean, attrName);
}
name2attr.put(attrName, res == null ? NOT_FOUND_ATTR : res);
}
if (res != null)
jmxControlAPI.loadAttributeValue(res);
return res;
}
use of com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute in project cuba by cuba-platform.
the class ThreadsDatasource method getAttributeValue.
protected Object getAttributeValue(JmxInstance node, String beanObjectName, String attrName) {
ManagedBeanInfo bean = jmxControlAPI.getManagedBean(node, beanObjectName);
Object res = null;
if (bean != null) {
ManagedBeanAttribute attr = jmxControlAPI.loadAttribute(bean, attrName);
jmxControlAPI.loadAttributeValue(attr);
res = attr.getValue();
}
return res;
}
Aggregations