private Object[] getValues(OpenMBeanAttributeInfo pOpenTypeInfo, Object pCurrentValue, JmxWriteRequest pRequest) { // TODO: What to do when path is not null ? Simplest: Throw exception. Advanced: Extract other values and create // a new CompositeData with old values and the new value. // However, since this is probably out of scope, we will simply throw an exception if the path is not empty. List<String> pathParts = pRequest.getPathParts(); if (pathParts != null && pathParts.size() > 0) { throw new IllegalArgumentException("Cannot set value for OpenType " + pOpenTypeInfo.getOpenType() + " with inner path " + pRequest.getPath() + " since OpenTypes are immutable"); } return new Object[] { converters.getToOpenTypeConverter().convertToObject(pOpenTypeInfo.getOpenType(), pRequest.getValue()), pCurrentValue }; } }
public Object perform(Object[] args) throws Throwable { Object result = mbeanServerConnection.getAttribute(objectName, attribute.getName()); return MXBeanUtils.reconstruct(attribute.getOpenType(), type, result, "Get attribute: " + attribute.getName()); } }
buf.append(idt).append(nvp("OpenType", open.getOpenType().toString())).append(NL); buf.append(idt).append(nvp("hasLegalValues", open.hasLegalValues())).append(NL); buf.append(idt).append(nvp("hasDefaultValue", open.hasDefaultValue())).append(NL); buf.append(idt).append(nvp("hasMinValue", open.hasMinValue())).append(NL); buf.append(idt).append(nvp("hasMaxValue", open.hasMaxValue())).append(NL); if (open.hasDefaultValue()) buf.append(idt).append(nvp("DefaultValue", open.getDefaultValue())).append(NL);
attributeMapping.put(attribute.getName(), attribute);
buf.append(idt + nvp("OpenType", open.getOpenType().toString()) + NL); buf.append(idt + nvp("hasLegalValues", open.hasLegalValues()) + NL); buf.append(idt + nvp("hasDefaultValue", open.hasDefaultValue()) + NL); buf.append(idt + nvp("hasMinValue", open.hasMinValue()) + NL); buf.append(idt + nvp("hasMaxValue", open.hasMaxValue()) + NL); if (open.hasDefaultValue()) buf.append(idt + nvp("DefaultValue", open.getDefaultValue()) + NL);
attributeMapping.put(attribute.getName(), attribute);
/** {@inheritDoc} */ public void setAttribute(Attribute pAttribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { try { if (!attributeInfoMap.containsKey(pAttribute.getName())) { jolokiaMBeanServer.setAttribute(objectName, pAttribute); } else { String name = pAttribute.getName(); MBeanAttributeInfo info = attributeInfoMap.get(name); Object value; if (info instanceof OpenMBeanAttributeInfo) { value = fromJson(((OpenMBeanAttributeInfo) info).getOpenType(), (String) pAttribute.getValue()); } else { value = fromJson(info.getType(), (String) pAttribute.getValue()); } Attribute attr = new Attribute(name, value); jolokiaMBeanServer.setAttribute(objectName, attr); } } catch (InstanceNotFoundException e) { AttributeNotFoundException exp = new AttributeNotFoundException("MBean " + objectName + " not found for attribute " + pAttribute); exp.initCause(e); throw exp; } }
public Object perform(Object[] args) throws Throwable { Object result = mbeanServerConnection.getAttribute(objectName, attribute.getName()); return MXBeanUtils.reconstruct(attribute.getOpenType(), type, result, "Get attribute: " + attribute.getName()); } }
attributesMap.put(openAttribute.getName(), openAttribute);
openType = ((OpenMBeanAttributeInfo) attributeInfo).getOpenType(); } else {
public Object perform(Object[] args) throws Throwable { Object value = MXBeanUtils.construct(attribute.getOpenType(), args[0], "Set attribute: " + attribute.getName()); Attribute attr = new Attribute(attribute.getName(), value); mbeanServerConnection.setAttribute(objectName, attr); return null; } }
attributesMap.put(openAttribute.getName(), openAttribute);
public MAttribute(MBeanAttributeInfo info, ReflectValued value) { this.info = info; this.valued = value; this.openType = info instanceof OpenMBeanAttributeInfo ? ((OpenMBeanAttributeInfo) info).getOpenType() : null; }
public Object perform(Object[] args) throws Throwable { Object value = MXBeanUtils.construct(attribute.getOpenType(), args[0], "Set attribute: " + attribute.getName()); Attribute attr = new Attribute(attribute.getName(), value); mbeanServerConnection.setAttribute(objectName, attr); return null; } }
private Object[] getValues(OpenMBeanAttributeInfo pOpenTypeInfo, Object pCurrentValue, JmxWriteRequest pRequest) { // TODO: What to do when path is not null ? Simplest: Throw exception. Advanced: Extract other values and create // a new CompositeData with old values and the new value. // However, since this is probably out of scope, we will simply throw an exception if the path is not empty. List<String> pathParts = pRequest.getPathParts(); if (pathParts != null && pathParts.size() > 0) { throw new IllegalArgumentException("Cannot set value for OpenType " + pOpenTypeInfo.getOpenType() + " with inner path " + pRequest.getPath() + " since OpenTypes are immutable"); } return new Object[] { converters.getToOpenTypeConverter().convertToObject(pOpenTypeInfo.getOpenType(), pRequest.getValue()), pCurrentValue }; } }
private Object[] getValues(OpenMBeanAttributeInfo pOpenTypeInfo, Object pCurrentValue, JmxWriteRequest pRequest) { // TODO: What to do when path is not null ? Simplest: Throw exception. Advanced: Extract other values and create // a new CompositeData with old values and the new value. // However, since this is probably out of scope, we will simply throw an exception if the path is not empty. List<String> pathParts = pRequest.getPathParts(); if (pathParts != null && pathParts.size() > 0) { throw new IllegalArgumentException("Cannot set value for OpenType " + pOpenTypeInfo.getOpenType() + " with inner path " + pRequest.getPath() + " since OpenTypes are immutable"); } return new Object[] { converters.getToOpenTypeConverter().convertToObject(pOpenTypeInfo.getOpenType(), pRequest.getValue()), pCurrentValue }; } }
return MXBeanUtils.construct(attributeInfo.getOpenType(), result, "Get attribute: " + attribute);
return MXBeanUtils.construct(attributeInfo.getOpenType(), result, "Get attribute: " + attribute);
/** {@inheritDoc} */ public void setAttribute(Attribute pAttribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { try { if (!attributeInfoMap.containsKey(pAttribute.getName())) { jolokiaMBeanServer.setAttribute(objectName, pAttribute); } else { String name = pAttribute.getName(); MBeanAttributeInfo info = attributeInfoMap.get(name); Object value; if (info instanceof OpenMBeanAttributeInfo) { value = fromJson(((OpenMBeanAttributeInfo) info).getOpenType(), (String) pAttribute.getValue()); } else { value = fromJson(info.getType(), (String) pAttribute.getValue()); } Attribute attr = new Attribute(name, value); jolokiaMBeanServer.setAttribute(objectName, attr); } } catch (InstanceNotFoundException e) { AttributeNotFoundException exp = new AttributeNotFoundException("MBean " + objectName + " not found for attribute " + pAttribute); exp.initCause(e); throw exp; } }
openType = ((OpenMBeanAttributeInfo) attributeInfo).getOpenType(); } else {