private static MBeanParameterInfo customize(MBeanParameterInfo pi, String name, String description) { if (equal(name, pi.getName()) && equal(description, pi.getDescription())) return pi; else if (pi instanceof OpenMBeanParameterInfo) { OpenMBeanParameterInfo opi = (OpenMBeanParameterInfo) pi; return new OpenMBeanParameterInfoSupport(name, description, opi.getOpenType(), pi.getDescriptor()); } else { return new MBeanParameterInfo(name, pi.getType(), description, pi.getDescriptor()); } }
private static MBeanConstructorInfo customize(MBeanConstructorInfo ci, String description, MBeanParameterInfo[] signature) { if (equal(description, ci.getDescription()) && identicalArrays(signature, ci.getSignature())) return ci; if (ci instanceof OpenMBeanConstructorInfo) { OpenMBeanParameterInfo[] oparams = paramsToOpenParams(signature); return new OpenMBeanConstructorInfoSupport(ci.getName(), description, oparams, ci.getDescriptor()); } else { return new MBeanConstructorInfo(ci.getName(), description, signature, ci.getDescriptor()); } }
@Override public MBeanInfo getMBeanInfo() { ArrayList<OpenMBeanAttributeInfoSupport> attributes = new ArrayList<>(); attributes.add(new OpenMBeanAttributeInfoSupport("enabled", "enabled", SimpleType.BOOLEAN, true, true, true)); for (String type : registry.getTypes()) { attributes.add(new OpenMBeanAttributeInfoSupport(type, type, getCompositeType(type), true, false, false)); } OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0]; OpenMBeanOperationInfoSupport reset = new OpenMBeanOperationInfoSupport("reset", "Reset all Metrics", params, SimpleType.VOID, MBeanOperationInfo.ACTION); OpenMBeanInfoSupport PSOMBInfo = new OpenMBeanInfoSupport(this.getClass().getName(), description, attributes.toArray(new OpenMBeanAttributeInfoSupport[0]), new OpenMBeanConstructorInfoSupport[0], new OpenMBeanOperationInfoSupport[] { reset }, new MBeanNotificationInfo[0]); return PSOMBInfo; }
private OpenMBeanOperationInfo getOperation(String name, OpenMBeanParameterInfo addWildcardChildName, OperationEntry entry) { ModelNode opNode = entry.getDescriptionProvider().getModelDescription(null); OpenMBeanParameterInfo[] params = getParameterInfos(opNode); if (addWildcardChildName != null) { OpenMBeanParameterInfo[] newParams = new OpenMBeanParameterInfo[params.length + 1]; newParams[0] = addWildcardChildName; System.arraycopy(params, 0, newParams, 1, params.length); params = newParams; } return new OpenMBeanOperationInfoSupport( name, getDescription(opNode), params, getReturnType(opNode), entry.getFlags().contains(Flag.READ_ONLY) ? MBeanOperationInfo.INFO : MBeanOperationInfo.UNKNOWN, createOperationDescriptor()); }
private static MBeanOperationInfo customize(MBeanOperationInfo oi, String description, MBeanParameterInfo[] signature, int impact) { if (equal(description, oi.getDescription()) && identicalArrays(signature, oi.getSignature()) && impact == oi.getImpact()) return oi; if (oi instanceof OpenMBeanOperationInfo) { OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi; OpenMBeanParameterInfo[] oparams = paramsToOpenParams(signature); return new OpenMBeanOperationInfoSupport(oi.getName(), description, oparams, ooi.getReturnOpenType(), impact, oi.getDescriptor()); } else { return new MBeanOperationInfo(oi.getName(), description, signature, oi.getReturnType(), impact, oi.getDescriptor()); } }
private static OpenMBeanParameterInfo[] paramsToOpenParams(MBeanParameterInfo[] params) { if (params instanceof OpenMBeanParameterInfo[]) return (OpenMBeanParameterInfo[]) params; OpenMBeanParameterInfo[] oparams = new OpenMBeanParameterInfoSupport[params.length]; System.arraycopy(params, 0, oparams, 0, params.length); return oparams; }