下面列出了怎么用javax.management.modelmbean.ModelMBeanConstructorInfo的API类实例代码及写法,或者点击链接到github查看源代码。
@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);
}
}
public ModelMBeanInfo buildModelMBeanInfo(Descriptor desc) {
ModelMBeanOperationInfo[] ops =
operations.values().toArray(new ModelMBeanOperationInfo[operations.values().size()]);
ModelMBeanAttributeInfo[] atts =
attributes.values().toArray(new ModelMBeanAttributeInfo[attributes.values().size()]);
ModelMBeanConstructorInfo[] cons =
constructors.values().toArray(new ModelMBeanConstructorInfo[constructors.values().size()]);
ModelMBeanNotificationInfo[] notifs =
notifications.values().toArray(new ModelMBeanNotificationInfo[notifications.values().size()]);
return new ModelMBeanInfoSupport("javax.management.modelmbean.ModelMBeanInfo",
"description",
atts,
cons,
ops,
notifs, desc);
}
public void addModelMBeanConstructor(Constructor<?> c,
String description,
Descriptor desc) {
this.constructors.put(c,
new ModelMBeanConstructorInfo(description,
c,
desc));
}
/**
* Get the constructor metadata for the MBean resource. Subclasses should implement
* this method to return the appropriate metadata for all constructors that should
* be exposed in the management interface for the managed resource.
* <p>Default implementation returns an empty array of {@code ModelMBeanConstructorInfo}.
* @param managedBean the bean instance (might be an AOP proxy)
* @param beanKey the key associated with the MBean in the beans map
* of the {@code MBeanExporter}
* @return the constructor metadata
* @throws JMException in case of errors
*/
protected ModelMBeanConstructorInfo[] getConstructorInfo(Object managedBean, String beanKey)
throws JMException {
return new ModelMBeanConstructorInfo[0];
}
/**
* Get the constructor metadata for the MBean resource. Subclasses should implement
* this method to return the appropriate metadata for all constructors that should
* be exposed in the management interface for the managed resource.
* <p>Default implementation returns an empty array of {@code ModelMBeanConstructorInfo}.
* @param managedBean the bean instance (might be an AOP proxy)
* @param beanKey the key associated with the MBean in the beans map
* of the {@code MBeanExporter}
* @return the constructor metadata
* @throws JMException in case of errors
*/
protected ModelMBeanConstructorInfo[] getConstructorInfo(Object managedBean, String beanKey)
throws JMException {
return new ModelMBeanConstructorInfo[0];
}
/**
* Get the constructor metadata for the MBean resource. Subclasses should implement
* this method to return the appropriate metadata for all constructors that should
* be exposed in the management interface for the managed resource.
* <p>Default implementation returns an empty array of {@code ModelMBeanConstructorInfo}.
* @param managedBean the bean instance (might be an AOP proxy)
* @param beanKey the key associated with the MBean in the beans map
* of the {@code MBeanExporter}
* @return the constructor metadata
* @throws JMException in case of errors
*/
protected ModelMBeanConstructorInfo[] getConstructorInfo(Object managedBean, String beanKey)
throws JMException {
return new ModelMBeanConstructorInfo[0];
}
/**
* Get the constructor metadata for the MBean resource. Subclasses should implement
* this method to return the appropriate metadata for all constructors that should
* be exposed in the management interface for the managed resource.
* <p>Default implementation returns an empty array of {@code ModelMBeanConstructorInfo}.
* @param managedBean the bean instance (might be an AOP proxy)
* @param beanKey the key associated with the MBean in the beans map
* of the {@code MBeanExporter}
* @return the constructor metadata
* @throws JMException in case of errors
*/
protected ModelMBeanConstructorInfo[] getConstructorInfo(Object managedBean, String beanKey)
throws JMException {
return new ModelMBeanConstructorInfo[0];
}