类javax.management.modelmbean.ModelMBeanNotificationInfo源码实例Demo

下面列出了怎么用javax.management.modelmbean.ModelMBeanNotificationInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: cuba   文件: AnnotationMBeanInfoAssembler.java
/**
 * 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
@Nonnull
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 项目: wildfly-core   文件: TestModelMBean.java
@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);
    }
}
 
源代码3 项目: cxf   文件: ModelMBeanInfoSupporter.java
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);
    }
 
源代码4 项目: spring-analysis-note   文件: JmxMetadataUtils.java
/**
 * Convert the supplied {@link ManagedNotification} into the corresponding
 * {@link javax.management.modelmbean.ModelMBeanNotificationInfo}.
 */
public static ModelMBeanNotificationInfo convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) {
	String[] notifTypes = notificationInfo.getNotificationTypes();
	if (ObjectUtils.isEmpty(notifTypes)) {
		throw new IllegalArgumentException("Must specify at least one notification type");
	}

	String name = notificationInfo.getName();
	if (!StringUtils.hasText(name)) {
		throw new IllegalArgumentException("Must specify notification name");
	}

	String description = notificationInfo.getDescription();
	return new ModelMBeanNotificationInfo(notifTypes, name, description);
}
 
/**
 * 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 =
			obtainAttributeSource().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;
}
 
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;
}
 
@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 项目: java-technology-stack   文件: JmxMetadataUtils.java
/**
 * Convert the supplied {@link ManagedNotification} into the corresponding
 * {@link javax.management.modelmbean.ModelMBeanNotificationInfo}.
 */
public static ModelMBeanNotificationInfo convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) {
	String[] notifTypes = notificationInfo.getNotificationTypes();
	if (ObjectUtils.isEmpty(notifTypes)) {
		throw new IllegalArgumentException("Must specify at least one notification type");
	}

	String name = notificationInfo.getName();
	if (!StringUtils.hasText(name)) {
		throw new IllegalArgumentException("Must specify notification name");
	}

	String description = notificationInfo.getDescription();
	return new ModelMBeanNotificationInfo(notifTypes, name, description);
}
 
/**
 * 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 =
			obtainAttributeSource().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;
}
 
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;
}
 
@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]);
}
 
源代码12 项目: activiti6-boot2   文件: MBeanInfoAssembler.java
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);
    }
  }
}
 
源代码13 项目: lams   文件: JmxMetadataUtils.java
/**
 * Convert the supplied {@link ManagedNotification} into the corresponding
 * {@link javax.management.modelmbean.ModelMBeanNotificationInfo}.
 */
public static ModelMBeanNotificationInfo convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) {
	String[] notifTypes = notificationInfo.getNotificationTypes();
	if (ObjectUtils.isEmpty(notifTypes)) {
		throw new IllegalArgumentException("Must specify at least one notification type");
	}

	String name = notificationInfo.getName();
	if (!StringUtils.hasText(name)) {
		throw new IllegalArgumentException("Must specify notification name");
	}

	String description = notificationInfo.getDescription();
	return new ModelMBeanNotificationInfo(notifTypes, name, description);
}
 
源代码14 项目: lams   文件: MetadataMBeanInfoAssembler.java
/**
 * 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;
}
 
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;
}
 
@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]);
}
 
源代码17 项目: spring4-understanding   文件: JmxMetadataUtils.java
/**
 * 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);
}
 
/**
 * 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;
}
 
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;
}
 
@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]);
}
 
源代码21 项目: flowable-engine   文件: MBeanInfoAssembler.java
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);
        }
    }
}
 
源代码22 项目: cxf   文件: ModelMBeanInfoSupporter.java
public void addModelMBeanNotification(String[] type,
                                      String className,
                                      String description,
                                      Descriptor desc) {
    notifications.put(className,
                       new ModelMBeanNotificationInfo(type, className, description, desc));
}
 
源代码23 项目: activiti6-boot2   文件: MBeanInfoAssembler.java
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())) {
      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;
  }
 
源代码24 项目: flowable-engine   文件: MBeanInfoAssembler.java
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;
    }
 
/**
 * Get the notification metadata for the MBean resource. Subclasses should implement
 * this method to return the appropriate metadata for all notifications that should
 * be exposed in the management interface for the managed resource.
 * <p>Default implementation returns an empty array of {@code ModelMBeanNotificationInfo}.
 * @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 notification metadata
 * @throws JMException in case of errors
 */
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey)
		throws JMException {
	return new ModelMBeanNotificationInfo[0];
}
 
/**
 * Get the notification metadata for the MBean resource. Subclasses should implement
 * this method to return the appropriate metadata for all notifications that should
 * be exposed in the management interface for the managed resource.
 * <p>Default implementation returns an empty array of {@code ModelMBeanNotificationInfo}.
 * @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 notification metadata
 * @throws JMException in case of errors
 */
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey)
		throws JMException {
	return new ModelMBeanNotificationInfo[0];
}
 
源代码27 项目: lams   文件: AbstractMBeanInfoAssembler.java
/**
 * Get the notification metadata for the MBean resource. Subclasses should implement
 * this method to return the appropriate metadata for all notifications that should
 * be exposed in the management interface for the managed resource.
 * <p>Default implementation returns an empty array of {@code ModelMBeanNotificationInfo}.
 * @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 notification metadata
 * @throws JMException in case of errors
 */
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey)
		throws JMException {
	return new ModelMBeanNotificationInfo[0];
}
 
/**
 * Get the notification metadata for the MBean resource. Subclasses should implement
 * this method to return the appropriate metadata for all notifications that should
 * be exposed in the management interface for the managed resource.
 * <p>Default implementation returns an empty array of {@code ModelMBeanNotificationInfo}.
 * @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 notification metadata
 * @throws JMException in case of errors
 */
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey)
		throws JMException {
	return new ModelMBeanNotificationInfo[0];
}
 
 类所在包
 同包方法