@Override protected void initInfoSectionFromModel() { Table table = getInfoTable(); table.removeAll(); MBeanFeatureInfo featureInfo = getFeatureInfo(); TableItem nameItem = new TableItem(table, SWT.NONE); nameItem.setText(0, FEATURE_INFO_PROPERTY_NAME_NAME); nameItem.setText(1, featureInfo.getName()); TableItem descriptionItem = new TableItem(table, SWT.NONE); descriptionItem.setText(0, FEATURE_INFO_PROPERTY_NAME_DESCRIPTION); descriptionItem.setText(1, featureInfo.getDescription()); }
public void setAttributesFilter(String exclude, String include) { if (include == null) { include = ""; } if (exclude == null) { exclude = ""; } includes = Pattern.compile(include); excludes = Pattern.compile(exclude); try { // Set the current value as the description final Field field = MBeanFeatureInfo.class.getDeclaredField("description"); field.setAccessible(true); field.set(includeInfo, "\"" + includes.pattern() + "\""); field.set(excludeInfo, "\"" + excludes.pattern() + "\""); } catch (final Exception e) { // Oh well, we tried } }
private ResourcePermission getOperationContext(ObjectName objectName, String featureName, boolean isOp) throws InstanceNotFoundException, ReflectionException { MBeanInfo beanInfo = null; try { beanInfo = mbs.getMBeanInfo(objectName); } catch (IntrospectionException e) { throw new GemFireSecurityException("error getting beanInfo of " + objectName, e); } // If there is no annotation defined either in the class level or method level, we should // consider this operation/attribute freely accessible ResourcePermission result = null; // find the context in the beanInfo if defined in the class level result = getOperationContext(beanInfo.getDescriptor(), result); MBeanFeatureInfo[] featureInfos = null; if (isOp) { featureInfos = beanInfo.getOperations(); } else { featureInfos = beanInfo.getAttributes(); } // still look into the attributes/operations to see if it's defined in the method level for (MBeanFeatureInfo info : featureInfos) { if (info.getName().equals(featureName)) { // found the featureInfo of this method on the bean result = getOperationContext(info.getDescriptor(), result); break; } } return result; }
private List<String> getNamesList(MBeanFeatureInfo[] features) { List<String> names = new ArrayList<String>(); for (MBeanFeatureInfo feature : features) { names.add(feature.getName()); } return names; }
private void verifyDescriptor(MBeanFeatureInfo featureInfo) throws Exception { Method getDescriptorMethod = featureInfo.getClass().getMethod( "getDescriptor", null); Descriptor descriptor = (Descriptor)getDescriptorMethod.invoke( featureInfo, null); Descriptor descriptor2 = (Descriptor)map.get(featureInfo.getClass() .getName()); assertTrue(DefaultDescriptorTest.compareDescriptors(descriptor, descriptor2)); }
private void setDescriptor(MBeanFeatureInfo featureInfo) throws Exception { Method getDescriptorMethod = featureInfo.getClass().getMethod( "getDescriptor", null); Descriptor descriptor = (Descriptor)getDescriptorMethod.invoke( featureInfo, null); String[] strings = getSpesific(featureInfo.getClass()); descriptor.setField(strings[0], strings[1]); map.put(featureInfo.getClass().getName(), descriptor); Method setDescriptorMethod = featureInfo.getClass().getMethod( "setDescriptor", new Class[] { Descriptor.class }); setDescriptorMethod.invoke(featureInfo, new Object[] { descriptor }); }
/** * Test for the method hashCode() * * @see javax.management.MBeanFeatureInfo#hashCode(); */ public final void testHashCode() { MBeanFeatureInfo inf1 = new MBeanFeatureInfo("name", "description"); MBeanFeatureInfo inf2 = new MBeanFeatureInfo("name", "description"); assertEquals("The hashCode() method must return the same integer " + "when it is invoked on the same object more than once!", inf1 .hashCode(), inf1.hashCode()); assertEquals("If two objects are equal according to the equals(Object)" + " method, then hashCode method on each of them must" + " produce the same integer. ", inf1.hashCode(), inf2.hashCode()); }
protected MBeanFeatureInfo getFeatureInfo() { return getModel().getData().getInfo(); }
private static String getDescription(MBeanFeatureInfo element) { String desc = element.getDescription(); return desc != null && desc.equals(element.getName()) ? null : desc; // Remove silly descriptions }
private void verifyDescriptor(MBeanFeatureInfo[] featureInfos) throws Exception { assertEquals(featureInfos.length, 1); verifyDescriptor(featureInfos[0]); }
@Override public int compare(final MBeanFeatureInfo o1, final MBeanFeatureInfo o2) { return o1.getName().compareTo(o2.getName()); }
/** * Retrieves and deserializes the object stored at the given key. * @return The deserialized object. * @throws IOException if the object cannot be deserialized. * @throws ClassNotFoundException if the class of the serialized object * cannot be loaded. **/ public static MBeanFeatureInfo get(String name) throws IOException, ClassNotFoundException { final byte[] bytes = map.get(name); final Object obj = deserialize(bytes); return (MBeanFeatureInfo)obj; }
/** * Feature information. */ MBeanFeatureInfo getInfo();
/** * Test for the constructor MBeanFeatureInfo(java.lang.String, * java.lang.String) * * @see javax.management.MBeanFeatureInfo#MBeanFeatureInfo(java.lang.String, * java.lang.String) */ public final void testMBeanFeatureInfo() { new MBeanFeatureInfo("name", "description"); new MBeanFeatureInfo("name", null); }
/** * Test for the method getDescription() * * @see javax.management.MBeanFeatureInfo#getDescription() */ public final void testGetDescription() { MBeanFeatureInfo inf = new MBeanFeatureInfo("name", "description"); assertEquals("description", inf.getDescription()); }
/** * Test for the method getName() * * @see javax.management.MBeanFeatureInfo#getName() */ public final void testGetName() { MBeanFeatureInfo inf = new MBeanFeatureInfo("name", "description"); assertEquals("name", inf.getName()); }
public abstract MBeanFeatureDoc<? extends MBeanFeatureInfo> getDoc();
public MBeanFeatureInfo getInfo();