本文整理汇总了Java中javax.management.modelmbean.ModelMBeanNotificationInfo类的典型用法代码示例。如果您正苦于以下问题:Java ModelMBeanNotificationInfo类的具体用法?Java ModelMBeanNotificationInfo怎么用?Java ModelMBeanNotificationInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelMBeanNotificationInfo类属于javax.management.modelmbean包,在下文中一共展示了ModelMBeanNotificationInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNotificationInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* Reads the {@link ManagedNotification} metadata from the {@code Class} of the managed resource
* and generates and returns the corresponding {@link javax.management.modelmbean.ModelMBeanNotificationInfo} metadata.
*/
@Override
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey) {
Class intf = findJmxInterface(beanKey, AopUtils.getTargetClass(managedBean));
ManagedNotification[] notificationAttributes =
this.attributeSource.getManagedNotifications(intf);
ModelMBeanNotificationInfo[] notificationInfos =
new ModelMBeanNotificationInfo[notificationAttributes.length];
for (int i = 0; i < notificationAttributes.length; i++) {
ManagedNotification attribute = notificationAttributes[i];
notificationInfos[i] = JmxMetadataUtils.convertToModelMBeanNotificationInfo(attribute);
}
return notificationInfos;
}
示例2: MBean
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
public MBean(String className, String description, Collection<MBeanAttribute> attributes, Collection<MBeanOperation> operations)
{
List<MBeanAttributeInfo> attributeInfos = new ArrayList<MBeanAttributeInfo>();
Map<String, MBeanAttribute> attributesBuilder = new TreeMap<String, MBeanAttribute>();
for (MBeanAttribute attribute : attributes) {
attributesBuilder.put(attribute.getName(), attribute);
attributeInfos.add(attribute.getInfo());
}
this.attributes = Collections.unmodifiableMap(attributesBuilder);
Map<Signature, MBeanOperation> operationsBuilder = new HashMap<Signature, MBeanOperation>();
List<MBeanOperationInfo> operationsInfos = new ArrayList<MBeanOperationInfo>();
for (MBeanOperation operation : operations) {
operationsBuilder.put(operation.getSignature(), operation);
operationsInfos.add(operation.getInfo());
}
this.operations = Collections.unmodifiableMap(operationsBuilder);
mbeanInfo = new MBeanInfo(className,
description,
attributeInfos.toArray(new MBeanAttributeInfo[attributeInfos.size()]),
new ModelMBeanConstructorInfo[0],
operationsInfos.toArray(new MBeanOperationInfo[operationsInfos.size()]),
new ModelMBeanNotificationInfo[0]);
}
示例3: getMBeanInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的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);
}
}
示例4: convertToModelMBeanNotificationInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* Convert the supplied {@link ManagedNotification} into the corresponding
* {@link javax.management.modelmbean.ModelMBeanNotificationInfo}.
*/
public static ModelMBeanNotificationInfo convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) {
String name = notificationInfo.getName();
if (!StringUtils.hasText(name)) {
throw new IllegalArgumentException("Must specify notification name");
}
String[] notifTypes = notificationInfo.getNotificationTypes();
if (notifTypes == null || notifTypes.length == 0) {
throw new IllegalArgumentException("Must specify at least one notification type");
}
String description = notificationInfo.getDescription();
return new ModelMBeanNotificationInfo(notifTypes, name, description);
}
示例5: getNotificationInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* Reads the {@link ManagedNotification} metadata from the {@code Class} of the managed resource
* and generates and returns the corresponding {@link ModelMBeanNotificationInfo} metadata.
*/
@Override
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey) {
ManagedNotification[] notificationAttributes =
this.attributeSource.getManagedNotifications(getClassToExpose(managedBean));
ModelMBeanNotificationInfo[] notificationInfos =
new ModelMBeanNotificationInfo[notificationAttributes.length];
for (int i = 0; i < notificationAttributes.length; i++) {
ManagedNotification attribute = notificationAttributes[i];
notificationInfos[i] = JmxMetadataUtils.convertToModelMBeanNotificationInfo(attribute);
}
return notificationInfos;
}
示例6: setNotificationInfos
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
public void setNotificationInfos(ManagedNotification[] notificationInfos) {
ModelMBeanNotificationInfo[] infos = new ModelMBeanNotificationInfo[notificationInfos.length];
for (int i = 0; i < notificationInfos.length; i++) {
ManagedNotification notificationInfo = notificationInfos[i];
infos[i] = JmxMetadataUtils.convertToModelMBeanNotificationInfo(notificationInfo);
}
this.notificationInfos = infos;
}
示例7: getNotificationInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
@Override
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey) {
ModelMBeanNotificationInfo[] result = null;
if (StringUtils.hasText(beanKey)) {
result = this.notificationInfoMappings.get(beanKey);
}
if (result == null) {
result = this.notificationInfos;
}
return (result != null ? result : new ModelMBeanNotificationInfo[0]);
}
示例8: extractMbeanNotifications
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
private void extractMbeanNotifications(Object managedBean, Set<ModelMBeanNotificationInfo> mBeanNotifications) {
ManagedNotifications notifications = managedBean.getClass().getAnnotation(ManagedNotifications.class);
if (notifications != null) {
for (ManagedNotification notification : notifications.value()) {
ModelMBeanNotificationInfo info = new ModelMBeanNotificationInfo(notification.notificationTypes(), notification.name(), notification.description());
mBeanNotifications.add(info);
LOGGER.trace("Assembled notification: {}", info);
}
}
}
示例9: extractMbeanNotifications
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
private void extractMbeanNotifications(Object managedBean, Set<ModelMBeanNotificationInfo> mBeanNotifications) {
ManagedNotifications notifications = managedBean.getClass().getAnnotation(ManagedNotifications.class);
if (notifications != null) {
for (ManagedNotification notification : notifications.value()) {
ModelMBeanNotificationInfo info = new ModelMBeanNotificationInfo(notification.notificationTypes(), notification.name(), notification.description());
mBeanNotifications.add(info);
LOG.trace("Assembled notification: {}", info);
}
}
}
示例10: constractModelMBeanInfoSupport
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* Do 1-6 steps.
*/
private ModelMBeanInfoSupport constractModelMBeanInfoSupport()
throws Exception {
ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo(
"description", class1.getMethod("simpleOperartion", null));
setDescriptor(operationInfo);
ModelMBeanConstructorInfo constructorInfo = new ModelMBeanConstructorInfo(
"description", class1.getConstructor(null));
setDescriptor(constructorInfo);
ModelMBeanAttributeInfo attributeInfo = new ModelMBeanAttributeInfo(
"name", "description", class1.getMethod("getH", null), class1
.getMethod("setH", new Class[] { int.class }));
setDescriptor(attributeInfo);
ModelMBeanNotificationInfo notificationInfo = new ModelMBeanNotificationInfo(
new String[] { "specific notification tepes" }, "name",
"description");
setDescriptor(notificationInfo);
ModelMBeanInfoSupport beanInfoSupport = new ModelMBeanInfoSupport(
class1.getName(), "description",
new ModelMBeanAttributeInfo[] { attributeInfo },
new ModelMBeanConstructorInfo[] { constructorInfo },
new ModelMBeanOperationInfo[] { operationInfo },
new ModelMBeanNotificationInfo[] { notificationInfo });
Descriptor descriptor = beanInfoSupport.getMBeanDescriptor();
String[] strings = getSpesific(beanInfoSupport.getClass());
descriptor.setField(strings[0], strings[1]);
map.put(beanInfoSupport.getClass().getName(), descriptor);
beanInfoSupport.setMBeanDescriptor(descriptor);
return beanInfoSupport;
}
示例11: testLogging
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* <ul>
* Verify that logs of new notifications, when sendNotification is invoked,
* write to file. File name is value of descriptor of
* ModelMBeanNotificationInfo.
* <li>Create java class, which is not MBean. MBean has 1 getter and 1
* setter methods.
* <li>Create ModelMBeanNotificationInfo object for my type with descriptor
* with logging.
* <li>Create ModelMBeanInfoSupport object. All ModelMBeanXXXInfo except
* ModelMBeanNotificationInfo are default.
* <li>Create RequiredModelMBean object.
* <li>Instance of java class in 1st step sets managed resource for
* RequiredModelMBean using setManagedResource method.
* <li>Send my notification using sendNotification method.
* <li>Verify that logfile was created and size of file > 0.
* </ul>
*/
public Result testLogging() throws Exception {
ModelMBeanAttributeInfo attributeInfoForG = new ModelMBeanAttributeInfo(
"g", "descr", class1.getMethod("getG", null), class1.getMethod(
"setG", new Class[] { String.class }));
ModelMBeanAttributeInfo[] attributeInfos = new ModelMBeanAttributeInfo[] { attributeInfoForG };
ModelMBeanNotificationInfo notificationInfo = new ModelMBeanNotificationInfo(
new String[] { SimpleNotification.notificationType },
SimpleNotification.notificationType, "description");
File file = File.createTempFile("log", ".txt");
file.deleteOnExit();
Descriptor descriptor = notificationInfo.getDescriptor();
descriptor.setField("log", "true");
descriptor.setField("logfile", file.getAbsolutePath());
log.info("file name: " + file.getAbsolutePath());
notificationInfo.setDescriptor(descriptor);
ModelMBeanInfoSupport beanInfoSupport = new ModelMBeanInfoSupport(
class1.getName(), "description", attributeInfos, null, null,
new ModelMBeanNotificationInfo[] { notificationInfo });
beanInfoSupport.getNotification(new SimpleNotification("src", 1)
.getType());
RequiredModelMBean requiredModelMBean = new RequiredModelMBean(
beanInfoSupport);
beanInfoSupport.getDescriptor(new SimpleNotification("src", 1)
.getType(), "notification");
requiredModelMBean.sendNotification(new SimpleNotification("src", 1));
assertTrue(file.length() > 0);
file.delete();
return result();
}
示例12: testModelMBeanNotificationInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* Verify default fields of descriptor from ModelMBeanNotificationInfo:
* name=nameUsedInConstructor, displayName=nameUsedInConstructor, severity=6
* and descriptorType=notification.
*/
public Result testModelMBeanNotificationInfo() throws Exception {
final String name = "notification name";
ModelMBeanNotificationInfo notificationInfo = new ModelMBeanNotificationInfo(
null, name, "description");
descriptor = notificationInfo.getDescriptor();
assertEquals(descriptor.getFieldValue("name"), name);
assertEquals(descriptor.getFieldValue("displayName"), name);
assertEquals(descriptor.getFieldValue("severity"), "6");
assertEquals(descriptor.getFieldValue("descriptorType"), "notification");
assertEquals(descriptor.getFields().length, 4);
commonCheck();
return result();
}
示例13: getMBeanInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean, String objectName) throws JMException {
if ((defaultManagedBean == null && customManagedBean == null) || objectName == null)
return null;
// skip proxy classes
if (defaultManagedBean != null && Proxy.isProxyClass(defaultManagedBean.getClass())) {
LOGGER.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
return null;
}
// maps and lists to contain information about attributes and operations
Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<>();
Set<ManagedOperationInfo> operations = new LinkedHashSet<>();
Set<ModelMBeanAttributeInfo> mBeanAttributes = new LinkedHashSet<>();
Set<ModelMBeanOperationInfo> mBeanOperations = new LinkedHashSet<>();
Set<ModelMBeanNotificationInfo> mBeanNotifications = new LinkedHashSet<>();
// extract details from default managed bean
if (defaultManagedBean != null) {
extractAttributesAndOperations(defaultManagedBean.getClass(), attributes, operations);
extractMbeanAttributes(defaultManagedBean, attributes, mBeanAttributes, mBeanOperations);
extractMbeanOperations(defaultManagedBean, operations, mBeanOperations);
extractMbeanNotifications(defaultManagedBean, mBeanNotifications);
}
// extract details from custom managed bean
if (customManagedBean != null) {
extractAttributesAndOperations(customManagedBean.getClass(), attributes, operations);
extractMbeanAttributes(customManagedBean, attributes, mBeanAttributes, mBeanOperations);
extractMbeanOperations(customManagedBean, operations, mBeanOperations);
extractMbeanNotifications(customManagedBean, mBeanNotifications);
}
// create the ModelMBeanInfo
String name = getName(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
String description = getDescription(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
ModelMBeanAttributeInfo[] arrayAttributes = mBeanAttributes.toArray(new ModelMBeanAttributeInfo[mBeanAttributes.size()]);
ModelMBeanOperationInfo[] arrayOperations = mBeanOperations.toArray(new ModelMBeanOperationInfo[mBeanOperations.size()]);
ModelMBeanNotificationInfo[] arrayNotifications = mBeanNotifications.toArray(new ModelMBeanNotificationInfo[mBeanNotifications.size()]);
ModelMBeanInfo info = new ModelMBeanInfoSupport(name, description, arrayAttributes, null, arrayOperations, arrayNotifications);
LOGGER.trace("Created ModelMBeanInfo {}", info);
return info;
}
示例14: getMBeanInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
/**
* Gets the {@link ModelMBeanInfo} for the given managed bean
*
* @param defaultManagedBean the default managed bean
* @param customManagedBean an optional custom managed bean
* @param objectName the object name
* @return the model info, or <tt>null</tt> if not possible to create, for example due the managed bean is a proxy class
* @throws JMException is thrown if error creating the model info
*/
public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean, String objectName) throws JMException {
// skip proxy classes
if (defaultManagedBean != null && Proxy.isProxyClass(defaultManagedBean.getClass())) {
LOG.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
return null;
}
// maps and lists to contain information about attributes and operations
Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<String, ManagedAttributeInfo>();
Set<ManagedOperationInfo> operations = new LinkedHashSet<ManagedOperationInfo>();
Set<ModelMBeanAttributeInfo> mBeanAttributes = new LinkedHashSet<ModelMBeanAttributeInfo>();
Set<ModelMBeanOperationInfo> mBeanOperations = new LinkedHashSet<ModelMBeanOperationInfo>();
Set<ModelMBeanNotificationInfo> mBeanNotifications = new LinkedHashSet<ModelMBeanNotificationInfo>();
// extract details from default managed bean
if (defaultManagedBean != null) {
extractAttributesAndOperations(defaultManagedBean.getClass(), attributes, operations);
extractMbeanAttributes(defaultManagedBean, attributes, mBeanAttributes, mBeanOperations);
extractMbeanOperations(defaultManagedBean, operations, mBeanOperations);
extractMbeanNotifications(defaultManagedBean, mBeanNotifications);
}
// extract details from custom managed bean
if (customManagedBean != null) {
extractAttributesAndOperations(customManagedBean.getClass(), attributes, operations);
extractMbeanAttributes(customManagedBean, attributes, mBeanAttributes, mBeanOperations);
extractMbeanOperations(customManagedBean, operations, mBeanOperations);
extractMbeanNotifications(customManagedBean, mBeanNotifications);
}
// create the ModelMBeanInfo
String name = getName(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
String description = getDescription(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
ModelMBeanAttributeInfo[] arrayAttributes = mBeanAttributes.toArray(new ModelMBeanAttributeInfo[mBeanAttributes.size()]);
ModelMBeanOperationInfo[] arrayOperations = mBeanOperations.toArray(new ModelMBeanOperationInfo[mBeanOperations.size()]);
ModelMBeanNotificationInfo[] arrayNotifications = mBeanNotifications.toArray(new ModelMBeanNotificationInfo[mBeanNotifications.size()]);
ModelMBeanInfo info = new ModelMBeanInfoSupport(name, description, arrayAttributes, null, arrayOperations, arrayNotifications);
LOG.trace("Created ModelMBeanInfo {}", info);
return info;
}
示例15: getNotificationInfo
import javax.management.modelmbean.ModelMBeanNotificationInfo; //导入依赖的package包/类
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey) {
managedBean = AspectUtil.exposeRootBean(managedBean);
return super.getNotificationInfo(managedBean, beanKey);
}