Search in sources :

Example 1 with ManagedBeanAttribute

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()));
    }
}
Also used : ManagedBeanAttribute(com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute) AttributeEditor(com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor)

Example 2 with ManagedBeanAttribute

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;
}
Also used : ManagedBeanAttribute(com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute)

Example 3 with ManagedBeanAttribute

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);
            }
        }
    }
}
Also used : ManagedBeanAttribute(com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute)

Example 4 with ManagedBeanAttribute

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;
}
Also used : ManagedBeanAttribute(com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) Nullable(javax.annotation.Nullable)

Example 5 with ManagedBeanAttribute

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;
}
Also used : ManagedBeanAttribute(com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo)

Aggregations

ManagedBeanAttribute (com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute)7 ManagedBeanInfo (com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo)3 JmxControlException (com.haulmont.cuba.web.jmx.JmxControlException)2 Datasource (com.haulmont.cuba.gui.data.Datasource)1 AttributeEditor (com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor)1 Nullable (javax.annotation.Nullable)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 ReflectionException (javax.management.ReflectionException)1 CompositeData (javax.management.openmbean.CompositeData)1