org.jsesoft.mmbi
Class ModelMBeanHelpers

java.lang.Object
  extended by org.jsesoft.mmbi.ModelMBeanHelpers

public class ModelMBeanHelpers
extends java.lang.Object

Provides helpers for model mbeans.


Field Summary
static java.lang.String DESCRIPTION
           
static java.lang.String DESCRIPTOR_TYPE
           
static java.lang.String DISPLAY_NAME
           
static java.lang.String DOT
           
static java.lang.String EVENT_TYPE
           
static java.lang.String FORWARDER
           
static java.lang.String METHOD
           
static java.lang.String NAME
           
static java.lang.String NOTIFICATION
           
static java.lang.String OPERATION
           
static java.lang.String ROLE
           
static java.lang.String SEVERITY
           
static java.lang.String SLASH
           
 
Constructor Summary
ModelMBeanHelpers()
           
 
Method Summary
static javax.management.Descriptor getDescriptor(java.lang.String className, JMX annotation, java.beans.FeatureDescriptor feature, java.lang.String defaultName, java.lang.String defaultDisplayName, java.lang.String defaultDescription, java.lang.String descriptorType, java.lang.String role)
          Creates a JMX descriptor from the specified information.
static JMX getJMXAnnotation(java.lang.annotation.Annotation[] annotations)
          Inquires the JMX annotation.
static javax.management.modelmbean.ModelMBeanInfo getMBeanInfo(MMBIPassBack passBack)
          Gets the created MBeanInfo.
static java.beans.MethodDescriptor getMethodDescriptor(java.beans.MethodDescriptor[] features, java.lang.reflect.Method method)
          Gets the JavaBeans method descriptor for the method.
static javax.management.MBeanParameterInfo[] getParameterInfos(java.lang.Class<?>[] types, java.lang.annotation.Annotation[][] annotations, java.beans.ParameterDescriptor[] features)
          Gets MBean parameter info.
static void handleBeanInfoEvents(MMBIPassBack passBack)
          Handles BeanInfo events.
static void handleConstructor(java.lang.reflect.Constructor<?> constructor, MMBIPassBack passBack)
          Handles Constructor analysis.
static void handleField(java.lang.reflect.Field field, MMBIPassBack passBack)
          Handles field analysis.
static void handleJMXNotificationAnnotations(java.lang.annotation.Annotation[] annotations, java.util.Vector<javax.management.modelmbean.ModelMBeanNotificationInfo> notificationInfos)
          Handles the JMXNotification annotations.
static void handleMethod(java.lang.reflect.Method method, MMBIPassBack passBack)
          Handle MMBI method analysis and info.
static java.util.EventListener makeEventListener(java.lang.Class<?> eventType, java.lang.reflect.Method[] methods, MMBIPassBack passBack)
          Makes an event listener class, possibly creates new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_NAME

public static final java.lang.String DISPLAY_NAME
See Also:
Constant Field Values

SEVERITY

public static final java.lang.String SEVERITY
See Also:
Constant Field Values

NOTIFICATION

public static final java.lang.String NOTIFICATION
See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

ROLE

public static final java.lang.String ROLE
See Also:
Constant Field Values

OPERATION

public static final java.lang.String OPERATION
See Also:
Constant Field Values

DESCRIPTION

public static final java.lang.String DESCRIPTION
See Also:
Constant Field Values

DESCRIPTOR_TYPE

public static final java.lang.String DESCRIPTOR_TYPE
See Also:
Constant Field Values

SLASH

public static final java.lang.String SLASH
See Also:
Constant Field Values

DOT

public static final java.lang.String DOT
See Also:
Constant Field Values

EVENT_TYPE

public static final java.lang.String EVENT_TYPE
See Also:
Constant Field Values

FORWARDER

public static final java.lang.String FORWARDER
See Also:
Constant Field Values

METHOD

public static final java.lang.String METHOD
See Also:
Constant Field Values
Constructor Detail

ModelMBeanHelpers

public ModelMBeanHelpers()
Method Detail

handleJMXNotificationAnnotations

public static void handleJMXNotificationAnnotations(java.lang.annotation.Annotation[] annotations,
                                                    java.util.Vector<javax.management.modelmbean.ModelMBeanNotificationInfo> notificationInfos)
                                             throws java.lang.Exception
Handles the JMXNotification annotations.

Parameters:
annotations - the annotations to be looked up for the JMX annotation
notificationInfos - the notification infos to fill
Throws:
java.lang.Exception - if descriptor cannot be created

getJMXAnnotation

public static JMX getJMXAnnotation(java.lang.annotation.Annotation[] annotations)
Inquires the JMX annotation.

Parameters:
annotations - the annotations to be looked up for the JMX annotation
Returns:
JMX

getParameterInfos

public static javax.management.MBeanParameterInfo[] getParameterInfos(java.lang.Class<?>[] types,
                                                                      java.lang.annotation.Annotation[][] annotations,
                                                                      java.beans.ParameterDescriptor[] features)
                                                               throws java.lang.NoSuchMethodException,
                                                                      java.lang.reflect.InvocationTargetException,
                                                                      java.lang.IllegalAccessException
Gets MBean parameter info.

Parameters:
types - the types
annotations - the annotations
features - the features
Returns:
the MBean parameter info
Throws:
java.lang.NoSuchMethodException - on failure
java.lang.reflect.InvocationTargetException - on failure
java.lang.IllegalAccessException - on failure

getDescriptor

public static javax.management.Descriptor getDescriptor(java.lang.String className,
                                                        JMX annotation,
                                                        java.beans.FeatureDescriptor feature,
                                                        java.lang.String defaultName,
                                                        java.lang.String defaultDisplayName,
                                                        java.lang.String defaultDescription,
                                                        java.lang.String descriptorType,
                                                        java.lang.String role)
                                                 throws javax.management.MBeanException,
                                                        javax.management.modelmbean.XMLParseException
Creates a JMX descriptor from the specified information.

Default information can be overruled by annotation information

Note: Though this was designed as a helper function, it might be useful for customers, too.

Parameters:
annotation - the JMX annotation containing overriding info
feature - the Javabeans feature descriptor containing overriding info
defaultName - the default name
defaultDisplayName - the default display name
defaultDescription - the default description
descriptorType - the type of the descriptor to create
role - the role field of the descripto
Returns:
the created descriptor
Throws:
javax.management.MBeanException - if descriptor cannot be created
javax.management.modelmbean.XMLParseException - if the annotation's XML is not valid

getMethodDescriptor

public static java.beans.MethodDescriptor getMethodDescriptor(java.beans.MethodDescriptor[] features,
                                                              java.lang.reflect.Method method)
Gets the JavaBeans method descriptor for the method.

Parameters:
features - the BeanInfo MethodDescriptors
method - the Method
Returns:
the MethodDescriptor, null if none

handleMethod

public static void handleMethod(java.lang.reflect.Method method,
                                MMBIPassBack passBack)
                         throws java.lang.NoSuchMethodException,
                                java.lang.reflect.InvocationTargetException,
                                java.lang.IllegalAccessException,
                                javax.management.MBeanException,
                                javax.management.modelmbean.XMLParseException
Handle MMBI method analysis and info.

Parameters:
method - the method to analyze
passBack - the passback object
Throws:
java.lang.NoSuchMethodException - on failure
java.lang.reflect.InvocationTargetException - on failure
java.lang.IllegalAccessException - on failure
javax.management.MBeanException - on failure
javax.management.modelmbean.XMLParseException - on failure

handleConstructor

public static void handleConstructor(java.lang.reflect.Constructor<?> constructor,
                                     MMBIPassBack passBack)
                              throws java.lang.Exception
Handles Constructor analysis.

Parameters:
constructor - the constructor to analyze
passBack - the pass back object
Throws:
java.lang.Exception - on failure

handleField

public static void handleField(java.lang.reflect.Field field,
                               MMBIPassBack passBack)
                        throws javax.management.MBeanException,
                               javax.management.modelmbean.XMLParseException,
                               javax.management.IntrospectionException,
                               javax.management.RuntimeOperationsException
Handles field analysis.

Parameters:
field - the field to analyze
passBack - on failure
Throws:
javax.management.MBeanException - on failure
javax.management.modelmbean.XMLParseException - on failure
javax.management.IntrospectionException - on failure
javax.management.RuntimeOperationsException - on failure

getMBeanInfo

public static javax.management.modelmbean.ModelMBeanInfo getMBeanInfo(MMBIPassBack passBack)
Gets the created MBeanInfo.

This function creates the MBean Info, if not already done.

Parameters:
passBack - the pass back object
Returns:
ModelMBeanInfo

handleBeanInfoEvents

public static void handleBeanInfoEvents(MMBIPassBack passBack)
                                 throws java.lang.Exception
Handles BeanInfo events.

Parameters:
passBack - the pass back object
Throws:
java.lang.Exception - on failure

makeEventListener

public static java.util.EventListener makeEventListener(java.lang.Class<?> eventType,
                                                        java.lang.reflect.Method[] methods,
                                                        MMBIPassBack passBack)
                                                 throws java.lang.Exception
Makes an event listener class, possibly creates new one.

Parameters:
eventType - the event to listen for
methods - the methods
passBack - the pass back object
Returns:
the event listener
Throws:
java.lang.Exception - on failure


Copyright © 2010 JSESoft. All Rights Reserved.