private static MBeanAttributeInfo customize(MBeanAttributeInfo ai, String description) { if (equal(description, ai.getDescription())) return ai; if (ai instanceof OpenMBeanAttributeInfo) { OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai; return new OpenMBeanAttributeInfoSupport(ai.getName(), description, oai.getOpenType(), ai.isReadable(), ai.isWritable(), ai.isIs(), ai.getDescriptor()); } else { return new MBeanAttributeInfo(ai.getName(), ai.getType(), description, ai.isReadable(), ai.isWritable(), ai.isIs(), ai.getDescriptor()); } }
private void registerOpenInfos(String csName, String csDescription) { OpenMBeanAttributeInfo[] arrAttributes = null; if(m_arrOpenMBeanAttributeInfosWrapper != null) { int nNbItems = m_arrOpenMBeanAttributeInfosWrapper.size(); arrAttributes = new OpenMBeanAttributeInfo[nNbItems]; for(int n=0; n<nNbItems; n++) { OpenMBeanAttributeInfoWrapper wrapper = m_arrOpenMBeanAttributeInfosWrapper.get(n); arrAttributes[n] = wrapper.getAttribute(); } } m_OpenMBeanInfo = new OpenMBeanInfoSupport(csName, csDescription, arrAttributes, null, null, null); }
private OpenMBeanAttributeInfo getAttribute(String name) { final String escapedName = NameConverter.convertToCamelCase(name); ModelNode attribute = providedDescription.require(ATTRIBUTES).require(name); AttributeAccess access = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name); if (access == null) { // Check for a bogus attribute in the description that's really a child Set<String> childTypes = resourceRegistration.getChildNames(PathAddress.EMPTY_ADDRESS); if (childTypes.contains(name)) { return null; } } final boolean writable = mutabilityChecker.mutable(pathAddress) && (access != null && access.getAccessType() == AccessType.READ_WRITE); return new OpenMBeanAttributeInfoSupport( escapedName, getDescription(attribute), converters.convertToMBeanType(attribute), true, writable, false, createAttributeDescriptor(attribute)); }
/** * * @param cache * @throws OpenDataException */ private OpenMBeanAttributeInfo[] createMBeanAttributeInfo() throws OpenDataException { List<OpenMBeanAttributeInfo> attributes = new ArrayList<OpenMBeanAttributeInfo>(); attributes.add( new OpenMBeanAttributeInfoSupport("knownCacheNames", "A comma seperated list of known cache names", SimpleType.STRING, true, false, false) ); return attributes.toArray(new OpenMBeanAttributeInfo[attributes.size()]); }
private OpenMBeanAttributeInfo[] getAttributes() { List<OpenMBeanAttributeInfo> infos = new LinkedList<OpenMBeanAttributeInfo>(); if (providedDescription.hasDefined(ATTRIBUTES)) { for (final String name : providedDescription.require(ATTRIBUTES).keys()) { OpenMBeanAttributeInfo attributeInfo = getAttribute(name); if (attributeInfo != null) { infos.add(getAttribute(name)); } } } return infos.toArray(new OpenMBeanAttributeInfo[infos.size()]); }
private void checkMBeanInfoAttributes(MBeanInfo info, boolean writable, boolean expressions) { //All attributes should be read-only MBeanAttributeInfo[] attributes = info.getAttributes(); Assert.assertEquals(14, attributes.length); Arrays.sort(attributes, new Comparator<MBeanAttributeInfo>() { @Override public int compare(MBeanAttributeInfo o1, MBeanAttributeInfo o2) { return o1.getName().compareTo(o2.getName()); } }); assertAttributeDescription(attributes[0], "bigdec", expressions ? String.class.getName() : BigDecimal.class.getName(), "bigdec", true, writable); assertAttributeDescription(attributes[1], "bigint", expressions ? String.class.getName() : BigInteger.class.getName(), "bigint", true, writable); assertAttributeDescription(attributes[2], "boolean", expressions ? String.class.getName() : Boolean.class.getName(), "boolean", true, writable); assertAttributeDescription(attributes[3], "bytes", byte[].class.getName(), "bytes", true, writable); checkComplexTypeInfo(assertCast(CompositeType.class, assertCast(OpenMBeanAttributeInfo.class, attributes[4]).getOpenType()), expressions, "complex."); assertAttributeDescription(attributes[5], "double", expressions ? String.class.getName() : Double.class.getName(), "double", true, writable); assertAttributeDescription(attributes[6], "int", expressions ? String.class.getName() : Integer.class.getName(), "int", true, writable); assertAttributeDescription(attributes[7], "list", expressions ? String[].class.getName() : Integer[].class.getName(), "list", true, writable); assertAttributeDescription(attributes[8], "long", expressions ? String.class.getName() : Long.class.getName(), "long", true, writable); //type=OBJECT, value-type=a simple type -> a map assertAttributeDescription(attributes[9], "map", TabularData.class.getName(), "map", true, writable); assertMapType(assertCast(OpenMBeanAttributeInfo.class, attributes[9]).getOpenType(), SimpleType.STRING, expressions ? SimpleType.STRING : SimpleType.INTEGER); assertAttributeDescription(attributes[10], "roInt", expressions ? String.class.getName() : Integer.class.getName(), "ro-int", true, false); assertAttributeDescription(attributes[11], "string", expressions ? String.class.getName() : String.class.getName(), "string", true, writable); assertAttributeDescription(attributes[12], "type", String.class.getName(), "type", true, writable); assertAttributeDescription(attributes[13], "undefinedInt", expressions ? String.class.getName() : Integer.class.getName(), "undefined-int", true, writable); }
private OpenMBeanAttributeInfo findAttribute(MBeanAttributeInfo[] attrs, String name) { for (MBeanAttributeInfo attr : attrs) { Assert.assertNotNull(attr.getName()); if (attr.getName().equals(name)) { return assertCast(OpenMBeanAttributeInfo.class, attr); } } Assert.fail("No attr called " + name); return null; }
public MBeanInfo getMBeanInfo() { OpenMBeanParameterInfoSupport parameterInfoSupport = new OpenMBeanParameterInfoSupport( "par name", "descripttiosdf", SimpleType.STRING); OpenMBeanOperationInfo infoSupport = new OpenMBeanOperationInfoSupport( operationName, "desciption", new OpenMBeanParameterInfo[] { parameterInfoSupport }, SimpleType.STRING, MBeanOperationInfo.ACTION); OpenMBeanAttributeInfoSupport attributeInfo = new OpenMBeanAttributeInfoSupport( attrName, "description", SimpleType.STRING, true, true, false); OpenMBeanInfoSupport beanInfoSupport = new OpenMBeanInfoSupport(this .getClass().getName(), "descriptor", new OpenMBeanAttributeInfo[] { attributeInfo }, null, new OpenMBeanOperationInfo[] { infoSupport }, null); return beanInfoSupport; }
OpenMBeanAttributeInfo getAttribute() { return m_openType; }
protected void cacheMBeanInfo(MBeanInfo info) { if (info == null) return; try { MBeanAttributeInfo[] oldA = info.getAttributes(); OpenMBeanAttributeInfo[] attribs = new OpenMBeanAttributeInfoSupport[oldA.length]; for (int a = 0; a < oldA.length; ++a) { OpenMBeanParameterInfo param = Translator.translate(oldA[a].getType()); if (param.getMinValue() == null) { Object[] lv; if (param.getLegalValues() == null) lv = null; else lv = param.getLegalValues().toArray(); attribs[a] = new OpenMBeanAttributeInfoSupport(oldA[a].getName(), oldA[a].getDescription(), ((OpenType<Object>) param.getOpenType()), oldA[a].isReadable(), oldA[a].isWritable(), oldA[a].isIs(), param.getDefaultValue(), lv); } else attribs[a] = new OpenMBeanAttributeInfoSupport(oldA[a].getName(), oldA[a].getDescription(), ((OpenType<Object>) param.getOpenType()), oldA[a].isReadable(), oldA[a].isWritable(), oldA[a].isIs(), param.getDefaultValue(), ((Comparable<Object>) param.getMinValue()), ((Comparable<Object>) param.getMaxValue())); } MBeanConstructorInfo[] oldC = info.getConstructors(); OpenMBeanConstructorInfo[] cons = new OpenMBeanConstructorInfoSupport[oldC.length]; for (int a = 0; a < oldC.length; ++a) cons[a] = new OpenMBeanConstructorInfoSupport(oldC[a].getName(), oldC[a].getDescription(), translateSignature(oldC[a].getSignature())); MBeanOperationInfo[] oldO = info.getOperations(); OpenMBeanOperationInfo[] ops = new OpenMBeanOperationInfoSupport[oldO.length]; for (int a = 0; a < oldO.length; ++a) ops[a] = new OpenMBeanOperationInfoSupport(oldO[a].getName(), oldO[a].getDescription(), translateSignature(oldO[a].getSignature()), Translator.translate(oldO[a].getReturnType()).getOpenType(), oldO[a].getImpact()); openInfo = new OpenMBeanInfoSupport(info.getClassName(), info.getDescription(), attribs, cons, ops, info.getNotifications()); } catch (OpenDataException e) { throw (InternalError) (new InternalError("A problem occurred creating the open type " + "descriptors.").initCause(e)); } }