本文整理汇总了Java中javax.management.modelmbean.ModelMBeanAttributeInfo类的典型用法代码示例。如果您正苦于以下问题:Java ModelMBeanAttributeInfo类的具体用法?Java ModelMBeanAttributeInfo怎么用?Java ModelMBeanAttributeInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelMBeanAttributeInfo类属于javax.management.modelmbean包,在下文中一共展示了ModelMBeanAttributeInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAttributeInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName,
"descriptorType=attribute", "currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName, "getMethod=getJmxValue", "setMethod=setJmxValue"});
Assert.assertTrue(this.config != null, "Config target object is null!");
desc.setField("targetObject", this.config);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例2: addAttributeChangeNotificationListener
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
public void addAttributeChangeNotificationListener(NotificationListener listener,
String attributeName, Object handback)
throws MBeanException, RuntimeOperationsException, IllegalArgumentException {
if (listener == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
if (attributeName != null) {
filter.enableAttribute(attributeName);
} else {
MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
for (int i = 0; i < ai.length; i++) {
Descriptor d = ((ModelMBeanAttributeInfo) ai[i]).getDescriptor();
filter.enableAttribute((String) d.getFieldValue("name"));
}
}
getAttributeChangeBroadcaster().addNotificationListener(listener, filter, handback);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Listener " + listener + " for attribute " + attributeName
+ " added successfully, handback is " + handback);
}
示例3: removeAttributeChangeNotificationListener
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
private void removeAttributeChangeNotificationListener(NotificationListener listener,
String attributeName, Object handback)
throws MBeanException, RuntimeOperationsException, ListenerNotFoundException {
if (listener == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
if (attributeName != null) {
filter.enableAttribute(attributeName);
} else {
MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
for (int i = 0; i < ai.length; i++) {
Descriptor d = ((ModelMBeanAttributeInfo) ai[i]).getDescriptor();
filter.enableAttribute((String) d.getFieldValue("name"));
}
}
getAttributeChangeBroadcaster().removeNotificationListener(listener, filter, handback);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Listener " + listener + " for attribute " + attributeName
+ " removed successfully, handback is " + handback);
}
示例4: createAttributeInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName,
"descriptorType=attribute", "currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName, "getMethod=getValue"});
Assert.assertTrue(this.stat != null, "Stat target object is null!");
desc.setField("targetObject", this.stat);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例5: createAttributeInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(
new String[] {
"name=" + this.displayName,
"descriptorType=attribute",
"currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName,
"getMethod=getJmxValue",
"setMethod=setJmxValue"
});
Assert.assertTrue(this.config != null, "Config target object is null!");
desc.setField("targetObject", this.config);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例6: addAttributeChangeNotificationListener
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
public void addAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
{
if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
if (attributeName != null)
{
filter.enableAttribute(attributeName);
}
else
{
MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
for (int i = 0; i < ai.length; i++)
{
Descriptor d = ((ModelMBeanAttributeInfo)ai[i]).getDescriptor();
filter.enableAttribute((String)d.getFieldValue("name"));
}
}
getAttributeChangeBroadcaster().addNotificationListener(listener, filter, handback);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " added successfully, handback is " + handback);
}
示例7: removeAttributeChangeNotificationListener
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
private void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
{
if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
if (attributeName != null)
{
filter.enableAttribute(attributeName);
}
else
{
MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
for (int i = 0; i < ai.length; i++)
{
Descriptor d = ((ModelMBeanAttributeInfo)ai[i]).getDescriptor();
filter.enableAttribute((String)d.getFieldValue("name"));
}
}
getAttributeChangeBroadcaster().removeNotificationListener(listener, filter, handback);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " removed successfully, handback is " + handback);
}
示例8: createAttributeInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(
new String[] {
"name=" + this.displayName,
"descriptorType=attribute",
"currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName,
"getMethod=getValue" });
Assert.assertTrue(this.stat != null, "Stat target object is null!");
desc.setField("targetObject", this.stat);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例9: getMBeanInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Override
public MBeanInfo getMBeanInfo() {
try {
ModelMBeanAttributeInfo[] attributes = new ModelMBeanAttributeInfo[0];
ModelMBeanConstructorInfo[] constructors = new ModelMBeanConstructorInfo[] {
new ModelMBeanConstructorInfo("-", this.getClass().getConstructor())
};
ModelMBeanOperationInfo[] operations = new ModelMBeanOperationInfo[] {
new ModelMBeanOperationInfo("info", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.INFO),
new ModelMBeanOperationInfo("action", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.ACTION),
new ModelMBeanOperationInfo("actionInfo", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.ACTION_INFO),
new ModelMBeanOperationInfo("unknown", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.UNKNOWN)
};
ModelMBeanNotificationInfo[] notifications = new ModelMBeanNotificationInfo[0];
return new ModelMBeanInfoSupport(this.getClass().getName(), "-", attributes, constructors, operations, notifications);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例10: verifyNotifivation
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
/**
* Verify that notification which RequiredModelMBean is emitted is correct.
*/
private void verifyNotifivation(
AttributeChangeNotification attributeChangeNotification,
ModelMBeanAttributeInfo attributeInfo) {
assertEquals(attributeChangeNotification.getAttributeName(),
attributeInfo.getName());
assertEquals(attributeChangeNotification.getAttributeType(),
attributeInfo.getType());
assertEquals(attributeChangeNotification.getNewValue(), "new value");
assertNull(attributeChangeNotification.getOldValue());
assertEquals(attributeChangeNotification.getType(),
"jmx.attribute.change");
assertEquals(attributeChangeNotification.getMessage(),
"AttributeChangeDetected");
assertEquals(attributeChangeNotification.getSequenceNumber(), 1);
}
示例11: testModelMBeanAttributeInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
/**
* Verify default fields of descriptor from ModelMBeanAttributeInfo:
* name=nameUsedInConstructor, displayName=nameUsedInConstructor and
* descriptorType=attribute.
*/
public Result testModelMBeanAttributeInfo() throws Exception {
Method getter = sampleClass.getMethod("getH", null);
Method setter = sampleClass.getMethod("setH",
new Class[] { String.class });
final String name = "attribute name";
ModelMBeanAttributeInfo attributeInfo = new ModelMBeanAttributeInfo(
name, "description", getter, setter);
descriptor = attributeInfo.getDescriptor();
//descriptor.getFieldNames();
assertEquals(descriptor.getFieldValue("name"), name);
assertEquals(descriptor.getFieldValue("displayName"), name);
assertEquals(descriptor.getFieldValue("descriptorType"), "attribute");
assertEquals(descriptor.getFields().length, 3);
commonCheck();
return result();
}
示例12: buildAttributeInfo
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
/**
* Builds an AttributeInfo in a default way
* @param name
* @param displayName
* @param description
* @param deflt
* @param operName
* @param signature
* @return the default modelMBeanAttributeInfo object
*/
public static ModelMBeanAttributeInfo buildAttributeInfo(String name, String displayName, String description, String deflt, String operName, String signature){
Descriptor attrDesc = new DescriptorSupport();
attrDesc.setField("name", name);
attrDesc.setField("descriptorType", "attribute");
attrDesc.setField("default", deflt);
attrDesc.setField("displayName", displayName);
attrDesc.setField(
"getMethod",
operName);
ModelMBeanAttributeInfo result=new ModelMBeanAttributeInfo(name,
signature,
description,
true,
false,
false,
attrDesc);
return result;
}
示例13: testAttributeFromInterface
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@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());
}
示例14: testAttributeDescriptionOnSetter
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Test
public void testAttributeDescriptionOnSetter() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute(AGE_ATTRIBUTE);
assertEquals("The description for the age attribute is incorrect",
"The Age Attribute", attr.getDescription());
}
示例15: testAttributeDescriptionOnGetter
import javax.management.modelmbean.ModelMBeanAttributeInfo; //导入依赖的package包/类
@Test
public void testAttributeDescriptionOnGetter() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE);
assertEquals("The description for the name attribute is incorrect",
"The Name Attribute", attr.getDescription());
}