@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue(attr.isReadable()); assertFalse(attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertTrue("Age is not writable", attr.isWritable()); }
@Test public void testAttributeFromInterface() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute("Colour"); assertTrue("The name attribute should be writable", attr.isWritable()); assertTrue("The name attribute should be readable", attr.isReadable()); }
@Test public void testReadWriteAttribute() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE); assertTrue("The name attribute should be writable", attr.isWritable()); assertTrue("The name attribute should be readable", attr.isReadable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue(attr.isReadable()); assertFalse(attr.isWritable()); }
@Test public void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertTrue("Age is not readable", attr.isReadable()); assertFalse("Age is not writable", attr.isWritable()); }
@Test public void testSupermanIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute("Superman"); assertTrue(attr.isReadable()); assertFalse(attr.isWritable()); }
if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Attribute info is: " + attrInfo); if (!attrInfo.isReadable()) throw new AttributeNotFoundException( String.format("Attribute %s is not readable", attribute));
@Override public Object get(Object managedResource) throws ReflectionException { if (!getMetadata().isReadable()) throw new ReflectionException(new IllegalAccessException("Attribute not readable: " + this), "Attribute not readable: " + this); if (!field.isAccessible()) field.setAccessible(true); try { return field.get(managedResource); } catch (Exception e) { throw JmxUtils.rethrow(e); } }
@Override public Object get(Object managedResource) throws ReflectionException { if (!getMetadata().isReadable()) throw new ReflectionException(new IllegalAccessException("Property not readable: " + this), "Property not readable: " + this); try { return beanProperty.get(managedResource); } catch (Throwable e) { throw JmxUtils.rethrow(e); } }
Method setter=null; if (attrInfo.isReadable()) getter=oClass.getMethod((attrInfo.isIs()?"is":"get")+uName,(java.lang.Class[])null);
Method setter=null; if (attrInfo.isReadable()) getter=oClass.getMethod((attrInfo.isIs()?"is":"get")+uName,(java.lang.Class[])null);
protected void initAttributeContexts(MBeanAttributeInfo[] attributes) { super.initAttributeContexts(attributes); for (int i = 0; i < attributes.length; ++i) { ModelMBeanAttributeInfo info = (ModelMBeanAttributeInfo) attributes[i]; String name = info.getName(); InvocationContext ctx = (InvocationContext) attributeContextMap.get(name); ctx.setDescriptor(info.getDescriptor()); ctx.setReadable(info.isReadable()); ctx.setWritable(info.isWritable()); } }
protected void initAttributeContexts(MBeanAttributeInfo[] attributes) { super.initAttributeContexts(attributes); for (int i = 0; i < attributes.length; ++i) { ModelMBeanAttributeInfo info = (ModelMBeanAttributeInfo) attributes[i]; String name = info.getName(); InvocationContext ctx = (InvocationContext) attributeContextMap.get(name); ctx.setDescriptor(info.getDescriptor()); ctx.setReadable(info.isReadable()); ctx.setWritable(info.isWritable()); } }
if (attributes[i].isReadable() && (attributes[i].getDescriptor().getFieldValue("getMethod") != null))
if (attributes[i].isReadable() && (attributes[i].getDescriptor().getFieldValue("getMethod") != null))
if (attrInfo == null) throw new AttributeNotFoundException(LocalizedStrings.MX4JModelMBean_CANNOT_FIND_MODELMBEANATTRIBUTEINFO_FOR_ATTRIBUTE_0.toLocalizedString(attribute)); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Attribute info is: " + attrInfo); if (!attrInfo.isReadable()) throw new AttributeNotFoundException(LocalizedStrings.MX4JModelMBean_ATTRIBUTE_0_IS_NOT_READABLE.toLocalizedString(attribute));