javax.management.MBeanConstructorInfo Java Examples

The following examples show how to use javax.management.MBeanConstructorInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MustBeValidCommand.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #2
Source File: MXBeanInteropTest2.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
 
Example #3
Source File: MustBeValidCommand.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #4
Source File: MXBeanInteropTest2.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
 
Example #5
Source File: MustBeValidCommand.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #6
Source File: MBeanCommand.java    From arthas with Apache License 2.0 6 votes vote down vote up
private void drawMetaInfo(MBeanInfo mBeanInfo, ObjectName objectName, TableElement table) {
    table.row(new LabelElement("MBeanInfo").style(Decoration.bold.fg(Color.red)));
    table.row(new LabelElement("Info:").style(Decoration.bold.fg(Color.yellow)));
    table.row("ObjectName", objectName.toString());
    table.row("ClassName", mBeanInfo.getClassName());
    table.row("Description", mBeanInfo.getDescription());
    drawDescriptorInfo("Info Descriptor:", mBeanInfo, table);
    MBeanConstructorInfo[] constructors = mBeanInfo.getConstructors();
    if (constructors.length > 0) {
        for (int i = 0; i < constructors.length; i++) {
            table.row(new LabelElement("Constructor-" + i).style(Decoration.bold.fg(Color.yellow)));
            table.row("Name", constructors[i].getName());
            table.row("Description", constructors[i].getDescription());
        }
    }
}
 
Example #7
Source File: MustBeValidCommand.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #8
Source File: MXBeanInteropTest2.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
 
Example #9
Source File: MustBeValidCommand.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #10
Source File: MustBeValidCommand.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #11
Source File: TimedJmxDynamicMBean.java    From NoraUi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public MBeanInfo getMBeanInfo() {
    MBeanParameterInfo[] withoutParamInfo = new MBeanParameterInfo[0];

    MBeanAttributeInfo attributs[] = new MBeanAttributeInfo[value.size()];
    int i = 0;
    for (Entry<String, Long> entry : value.entrySet()) {
        attributs[i] = new MBeanAttributeInfo(entry.getKey(), "long", "Timed of " + entry.getKey(), true, true, false);
        i++;
    }

    MBeanConstructorInfo[] constructeurs = new MBeanConstructorInfo[1];
    constructeurs[0] = new MBeanConstructorInfo("TimedJmxDynamicMBean", "Constructor by default", withoutParamInfo);

    MBeanOperationInfo[] operations = new MBeanOperationInfo[1];
    operations[0] = new MBeanOperationInfo("refresh", "Refresh data", withoutParamInfo, void.class.getName(), MBeanOperationInfo.ACTION);

    return new MBeanInfo(getClass().getName(), "TimedJmxDynamicMBean", attributs, constructeurs, operations, null);
}
 
Example #12
Source File: MustBeValidCommand.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
 
Example #13
Source File: MXBeanInteropTest2.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
 
Example #14
Source File: ModelMBeanInfoSupport.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ModelMBeanConstructorInfo requested by name.
 * If no ModelMBeanConstructorInfo exists for this name null is returned.
 *
 * @param inName the name of the constructor.
 *
 * @return the constructor info for the named constructor, or null
 * if there is none.
 *
 * @exception MBeanException Wraps a distributed communication Exception.
 * @exception RuntimeOperationsException Wraps an IllegalArgumentException
 *            for a null constructor name.
 */

public ModelMBeanConstructorInfo getConstructor(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanConstructorInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Constructor name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanConstructorInfo of the MBean");
    }
    MBeanConstructorInfo[] consList = modelMBeanConstructors; //this.getConstructors();
    int numCons = 0;
    if (consList != null) numCons = consList.length;

    for (int i=0; (i < numCons) && (retInfo == null); i++) {
        if (inName.equals(consList[i].getName())) {
            retInfo = ((ModelMBeanConstructorInfo) consList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Exit");
    }

    return retInfo;
}
 
Example #15
Source File: OpenMBeanInfoSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanConstructorInfo[]
        constructorArray(OpenMBeanConstructorInfo[] src) {
    if (src == null)
        return null;
    MBeanConstructorInfo[] dst = new MBeanConstructorInfo[src.length];
    System.arraycopy(src, 0, dst, 0, src.length);
    // may throw an ArrayStoreException
    return dst;
}
 
Example #16
Source File: ModelMBeanInfoSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
 */
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
    if (compat) {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
        modelMBeanDescriptor =
                (Descriptor) fields.get("modelMBeanDescriptor", null);
        if (fields.defaulted("modelMBeanDescriptor")) {
            throw new NullPointerException("modelMBeanDescriptor");
        }
        modelMBeanAttributes =
                (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
        if (fields.defaulted("mmbAttributes")) {
            throw new NullPointerException("mmbAttributes");
        }
        modelMBeanConstructors =
                (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
        if (fields.defaulted("mmbConstructors")) {
            throw new NullPointerException("mmbConstructors");
        }
        modelMBeanNotifications =
                (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
        if (fields.defaulted("mmbNotifications")) {
            throw new NullPointerException("mmbNotifications");
        }
        modelMBeanOperations =
                (MBeanOperationInfo[]) fields.get("mmbOperations", null);
        if (fields.defaulted("mmbOperations")) {
            throw new NullPointerException("mmbOperations");
        }
    } else {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
    }
}
 
Example #17
Source File: ModelMBeanInfoSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ModelMBeanConstructorInfo requested by name.
 * If no ModelMBeanConstructorInfo exists for this name null is returned.
 *
 * @param inName the name of the constructor.
 *
 * @return the constructor info for the named constructor, or null
 * if there is none.
 *
 * @exception MBeanException Wraps a distributed communication Exception.
 * @exception RuntimeOperationsException Wraps an IllegalArgumentException
 *            for a null constructor name.
 */

public ModelMBeanConstructorInfo getConstructor(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanConstructorInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Constructor name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanConstructorInfo of the MBean");
    }
    MBeanConstructorInfo[] consList = modelMBeanConstructors; //this.getConstructors();
    int numCons = 0;
    if (consList != null) numCons = consList.length;

    for (int i=0; (i < numCons) && (retInfo == null); i++) {
        if (inName.equals(consList[i].getName())) {
            retInfo = ((ModelMBeanConstructorInfo) consList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Exit");
    }

    return retInfo;
}
 
Example #18
Source File: ModelMBeanInfoSupport.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
 */
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
    if (compat) {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
        modelMBeanDescriptor =
                (Descriptor) fields.get("modelMBeanDescriptor", null);
        if (fields.defaulted("modelMBeanDescriptor")) {
            throw new NullPointerException("modelMBeanDescriptor");
        }
        modelMBeanAttributes =
                (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
        if (fields.defaulted("mmbAttributes")) {
            throw new NullPointerException("mmbAttributes");
        }
        modelMBeanConstructors =
                (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
        if (fields.defaulted("mmbConstructors")) {
            throw new NullPointerException("mmbConstructors");
        }
        modelMBeanNotifications =
                (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
        if (fields.defaulted("mmbNotifications")) {
            throw new NullPointerException("mmbNotifications");
        }
        modelMBeanOperations =
                (MBeanOperationInfo[]) fields.get("mmbOperations", null);
        if (fields.defaulted("mmbOperations")) {
            throw new NullPointerException("mmbOperations");
        }
    } else {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
    }
}
 
Example #19
Source File: MBeanIntrospector.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanConstructorInfo[] findConstructors(Class<?> c) {
    Constructor<?>[] cons = c.getConstructors();
    MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
    for (int i = 0; i < cons.length; i++) {
        final String descr = "Public constructor of the MBean";
        mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
    }
    return mbc;
}
 
Example #20
Source File: ModelMBeanInfoSupport.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns the ModelMBeanConstructorInfo requested by name.
 * If no ModelMBeanConstructorInfo exists for this name null is returned.
 *
 * @param inName the name of the constructor.
 *
 * @return the constructor info for the named constructor, or null
 * if there is none.
 *
 * @exception MBeanException Wraps a distributed communication Exception.
 * @exception RuntimeOperationsException Wraps an IllegalArgumentException
 *            for a null constructor name.
 */

public ModelMBeanConstructorInfo getConstructor(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanConstructorInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Constructor name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanConstructorInfo of the MBean");
    }
    MBeanConstructorInfo[] consList = modelMBeanConstructors; //this.getConstructors();
    int numCons = 0;
    if (consList != null) numCons = consList.length;

    for (int i=0; (i < numCons) && (retInfo == null); i++) {
        if (inName.equals(consList[i].getName())) {
            retInfo = ((ModelMBeanConstructorInfo) consList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Exit");
    }

    return retInfo;
}
 
Example #21
Source File: AnnotationTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void check(MBeanServer mbs, ObjectName on) throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);

    // check the MBean itself
    check(mbi);

    // check attributes
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    for (MBeanAttributeInfo attr : attrs) {
        check(attr);
        if (attr.getName().equals("ReadOnly"))
            check("@Full", attr.getDescriptor(), expectedFullDescriptor);
    }

    // check operations
    MBeanOperationInfo[] ops = mbi.getOperations();
    for (MBeanOperationInfo op : ops) {
        check(op);
        check(op.getSignature());
    }

    MBeanConstructorInfo[] constrs = mbi.getConstructors();
    for (MBeanConstructorInfo constr : constrs) {
        check(constr);
        check(constr.getSignature());
    }
}
 
Example #22
Source File: MBeanIntrospector.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static MBeanConstructorInfo[] findConstructors(Class<?> c) {
    Constructor<?>[] cons = c.getConstructors();
    MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
    for (int i = 0; i < cons.length; i++) {
        final String descr = "Public constructor of the MBean";
        mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
    }
    return mbc;
}
 
Example #23
Source File: MustBeValidCommand.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static private MBeanConstructorInfo[] makeCtorInfos(String[][] spec) {
    final MBeanConstructorInfo[] result =
        new MBeanConstructorInfo[spec.length];
    final MBeanParameterInfo[] pars = makeParInfos(parameters);
    for (int i=0;i<result.length;i++) {
        System.out.println("\tCreate an MBeanConstructorInfo: " +
                           spec[i][0]);
        final MBeanConstructorInfo item =
            new MBeanConstructorInfo(spec[i][1],spec[i][0],pars);
        result[i]=item;
    }
    return result;
}
 
Example #24
Source File: OpenMBeanInfoSupport.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanConstructorInfo[]
        constructorArray(OpenMBeanConstructorInfo[] src) {
    if (src == null)
        return null;
    MBeanConstructorInfo[] dst = new MBeanConstructorInfo[src.length];
    System.arraycopy(src, 0, dst, 0, src.length);
    // may throw an ArrayStoreException
    return dst;
}
 
Example #25
Source File: ModelMBeanInfoSupport.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
 */
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
    if (compat) {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
        modelMBeanDescriptor =
                (Descriptor) fields.get("modelMBeanDescriptor", null);
        if (fields.defaulted("modelMBeanDescriptor")) {
            throw new NullPointerException("modelMBeanDescriptor");
        }
        modelMBeanAttributes =
                (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
        if (fields.defaulted("mmbAttributes")) {
            throw new NullPointerException("mmbAttributes");
        }
        modelMBeanConstructors =
                (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
        if (fields.defaulted("mmbConstructors")) {
            throw new NullPointerException("mmbConstructors");
        }
        modelMBeanNotifications =
                (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
        if (fields.defaulted("mmbNotifications")) {
            throw new NullPointerException("mmbNotifications");
        }
        modelMBeanOperations =
                (MBeanOperationInfo[]) fields.get("mmbOperations", null);
        if (fields.defaulted("mmbOperations")) {
            throw new NullPointerException("mmbOperations");
        }
    } else {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
    }
}
 
Example #26
Source File: OpenMBeanInfoSupport.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanConstructorInfo[]
        constructorArray(OpenMBeanConstructorInfo[] src) {
    if (src == null)
        return null;
    MBeanConstructorInfo[] dst = new MBeanConstructorInfo[src.length];
    System.arraycopy(src, 0, dst, 0, src.length);
    // may throw an ArrayStoreException
    return dst;
}
 
Example #27
Source File: MBeanIntrospector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanConstructorInfo[] findConstructors(Class<?> c) {
    Constructor<?>[] cons = c.getConstructors();
    MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
    for (int i = 0; i < cons.length; i++) {
        final String descr = "Public constructor of the MBean";
        mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
    }
    return mbc;
}
 
Example #28
Source File: MBeanIntrospector.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanConstructorInfo[] findConstructors(Class<?> c) {
    Constructor<?>[] cons = c.getConstructors();
    MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
    for (int i = 0; i < cons.length; i++) {
        final String descr = "Public constructor of the MBean";
        mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
    }
    return mbc;
}
 
Example #29
Source File: ModelMBeanInfoSupport.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ModelMBeanConstructorInfo requested by name.
 * If no ModelMBeanConstructorInfo exists for this name null is returned.
 *
 * @param inName the name of the constructor.
 *
 * @return the constructor info for the named constructor, or null
 * if there is none.
 *
 * @exception MBeanException Wraps a distributed communication Exception.
 * @exception RuntimeOperationsException Wraps an IllegalArgumentException
 *            for a null constructor name.
 */

public ModelMBeanConstructorInfo getConstructor(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanConstructorInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Constructor name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanConstructorInfo of the MBean");
    }
    MBeanConstructorInfo[] consList = modelMBeanConstructors; //this.getConstructors();
    int numCons = 0;
    if (consList != null) numCons = consList.length;

    for (int i=0; (i < numCons) && (retInfo == null); i++) {
        if (inName.equals(consList[i].getName())) {
            retInfo = ((ModelMBeanConstructorInfo) consList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Exit");
    }

    return retInfo;
}
 
Example #30
Source File: StatisticsExposingMBean.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
protected MBeanInfo createMBeanInfoFromTagNames(Collection<String> tagNames) {
   MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[tagNames.size() * this.getStatsValueRetrievers().size()];
   int i = 0;
   Iterator i$ = tagNames.iterator();

   while(i$.hasNext()) {
      String tagName = (String)i$.next();

      String statName;
      StatsValueRetriever statsValueRetriever;
      for(Iterator i$ = this.getStatsValueRetrievers().entrySet().iterator(); i$.hasNext(); attributes[i++] = new MBeanAttributeInfo(tagName + statName, statsValueRetriever.getValueClass().getName(), "Returns " + statName + " for tag " + tagName, true, false, false)) {
         Entry<String, StatsValueRetriever> statNameAndValueRetriever = (Entry)i$.next();
         statName = (String)statNameAndValueRetriever.getKey();
         statsValueRetriever = (StatsValueRetriever)statNameAndValueRetriever.getValue();
      }
   }

   MBeanOperationInfo[] operations = new MBeanOperationInfo[]{new MBeanOperationInfo("exposeTag", "Allows the caller to add a monitored tag at runtime", new MBeanParameterInfo[]{new MBeanParameterInfo("tagName", String.class.getName(), "The name of the tag to expose")}, "void", 1), new MBeanOperationInfo("removeTag", "Allows the caller to remove a monitored tag at runtime", new MBeanParameterInfo[]{new MBeanParameterInfo("tagName", String.class.getName(), "The name of the tag to remove")}, "boolean", 1)};
   MBeanNotificationInfo[] notificationInfos;
   if (this.acceptableRanges.isEmpty()) {
      notificationInfos = new MBeanNotificationInfo[0];
   } else {
      notificationInfos = new MBeanNotificationInfo[]{new MBeanNotificationInfo(new String[]{"org.perf4j.threshold.exceeded"}, Notification.class.getName(), "Notification sent if any statistics move outside of the specified acceptable ranges")};
   }

   return new MBeanInfo(this.getClass().getName(), "Timing Statistics", attributes, (MBeanConstructorInfo[])null, operations, notificationInfos);
}