Package javax.management

Examples of javax.management.Descriptor


        return null;
       
    }
   
    void addAttributeOperation(Method method) {   
        Descriptor operationDescriptor =
            supporter.buildAttributeOperationDescriptor(method.getName());
       
        Class<?>[] types = method.getParameterTypes();                   
       
        String[] paramTypes = new String[types.length];
View Full Code Here


        if (mr == null) {
            // the class is not need to expose to jmx
            return null;
        }           
        // Clazz get all the method which should be managemed
        Descriptor mbeanDescriptor = supporter.buildMBeanDescriptor(mr)
       
        // add the notification
        ManagedNotification[] mns = getManagedNotifications(clazz);
        for (int k = 0; k < mns.length; k++) {            
            supporter.addModelMBeanNotification(mns[k].notificationTypes(),
                                          mns[k].name(),
                                          mns[k].description(), null);
        }
       
        Method[] methods = clazz.getDeclaredMethods();
       
        for (int i = 0; i < methods.length; i++) {
            ManagedAttribute ma = getManagedAttribute(methods[i]);
            //add Attribute to the ModelMBean
            if (ma != null) {
                String attributeName = getAttributeName(methods[i].getName());               
                if (!supporter.checkAttribute(attributeName)) {
                    String attributeType = getAttributeType(methods, attributeName);
                    ManagedAttributeInfo mai = getAttributInfo(methods,
                                                               attributeName,
                                                               attributeType,
                                                               ma);
                    Descriptor attributeDescriptor =
                        supporter.buildAttributeDescriptor(ma,
                                                         attributeName,
                                                         mai.is, mai.read, mai.write);               
               
                    // should setup the description
                    supporter.addModelMBeanAttribute(mai.fname,
                                                   mai.ftype,                                               
                                                   mai.read,
                                                   mai.write,
                                                   mai.is,
                                                   mai.description,
                                                   attributeDescriptor);
                   
                    Method method;
                    // add the attribute methode to operation
                    if (mai.read) {                       
                        if (mai.is) {
                            method = findMethodByName(methods, "is" + attributeName);
                        } else {
                            method = findMethodByName(methods, "get" + attributeName);
                        }
                        addAttributeOperation(method);
                    }
                    if (mai.write) {
                        method = findMethodByName(methods, "set" + attributeName);
                        addAttributeOperation(method);
                    }
                }
             
            } else {  
                // add Operation to the ModelMBean
                ManagedOperation mo = getManagedOperation(methods[i]);
               
                if (mo != null) {
                    Class<?>[] types = methods[i].getParameterTypes();                   
                    ManagedOperationParameter[] mop = getManagedOperationParameters(methods[i]);
                    String[] paramTypes = new String[types.length];
                    String[] paramNames = new String[types.length];                   
                    String[] paramDescs = new String[types.length];
                   
                    for (int j = 0; j < types.length; j++) {
                        paramTypes[j] = types[j].getName();                      
                        if (j < mop.length) {
                            paramDescs[j] = mop[j].description();
                            paramNames[j] = mop[j].name();
                        } else {
                            paramDescs[j] = "";
                            paramNames[j] = types[j].getName();
                        }
                    }                   
                    Descriptor operationDescriptor =
                        supporter.buildOperationDescriptor(mo, methods[i].getName());
                    supporter.addModelMBeanMethod(methods[i].getName(),
                                                paramTypes,
                                                paramNames,
                                                paramDescs,
View Full Code Here

   
   
    public Descriptor buildAttributeDescriptor(
        ManagedAttribute ma, String attributeName, boolean is, boolean read, boolean write) {
        
        Descriptor desc = new DescriptorSupport();

        desc.setField("name", attributeName);
      
        desc.setField("descriptorType", "attribute");
       
        if (read) {
            if (is) {
                desc.setField("getMethod", "is" + attributeName);
            } else {
                desc.setField("getMethod", "get" + attributeName);
            }               
        }
       
        if (write) {
            desc.setField("setMethod", "set" + attributeName);
        }
      
      
        if (ma.currencyTimeLimit() >= -1) {
            desc.setField("currencyTimeLimit", ma.currencyTimeLimit());
        }
          
        if (ma.persistPolicy().length() > 0) {
            desc.setField("persistPolicy", ma.persistPolicy());
        }
          
        if (ma.persistPeriod() >= -1) {
            desc.setField("persistPeriod", ma.persistPeriod());
        }
          
        if (ma.defaultValue() != null) {
            desc.setField("default", ma.defaultValue());
        }
          
        return desc;
   
View Full Code Here

          
        return desc;
   
   
    public Descriptor buildOperationDescriptor(ManagedOperation mo, String operationName) {
        Descriptor desc = new DescriptorSupport();
       
        desc.setField("name", operationName);
       
        desc.setField("descriptorType", "operation");
       
        desc.setField("role", "operation");
       
        if (mo.description() != null) {
            desc.setField("displayName", mo.description());
        }
                   
        if (mo.currencyTimeLimit() >= -1) {
            desc.setField("currencyTimeLimit", mo.currencyTimeLimit());
        }
       
        return desc;
    }
View Full Code Here

        return desc;
    }
   
    public Descriptor buildAttributeOperationDescriptor(String operationName) {
       
        Descriptor desc = new DescriptorSupport();
       
        desc.setField("name", operationName);
       
        desc.setField("descriptorType", "operation");
       
        if (operationName.indexOf("set") == 0) {
            desc.setField("role", "setter");
        } else {
            desc.setField("role", "getter");
        }  
       
        return desc;
    }
View Full Code Here

        return desc;
    }
           
   
    public Descriptor buildMBeanDescriptor(ManagedResource mr) {
        Descriptor desc = new DescriptorSupport();
       
        if (mr.componentName() != null) {
            desc.setField("name", mr.componentName());
        }
       
        desc.setField("descriptorType", "mbean");
       
        if (mr.description() != null) {
            desc.setField("displayName", mr.description());
        }
       
        if (mr.persistLocation() != null) {
            desc.setField("persistLocation", mr.persistLocation());
        }
           
        if (mr.persistName() != null) {
            desc.setField("persistName", mr.persistName());
        }
       
        if (mr.log()) {
            desc.setField("log", "true");
        } else {
            desc.setField("log", "false");
        }
           
        if (mr.persistPolicy() != null) {
            desc.setField("persistPolicy", mr.persistPolicy());
        }
       
        if (mr.persistPeriod() >= -1) {
            desc.setField("persistPeriod", mr.persistPeriod());
        }
       
        if (mr.logFile() != null) {
            desc.setField("logFile", mr.logFile());
        }
       
        if (mr.currencyTimeLimit() >= -1) {
            desc.setField("currencyTimeLimit", mr.currencyTimeLimit());
        }
       
        return desc;
       
    }   
View Full Code Here

      {
         annotation = metaData.getAnnotation(annotationType);
         if(annotation == null && info instanceof DescriptorAccess)
         {
            DescriptorAccess daccess = (DescriptorAccess) info;
            Descriptor descriptor = daccess.getDescriptor();
            annotation = getAnnotation(annotationType, descriptor);
         }
      }
      return annotation;
   }
View Full Code Here

            for (int i = 0; i < attrs.length; i++)
                System.out.println("  AttributeInfo=" + attrs[i]);
            MBeanConstructorInfo consts[] = info.getConstructors();
            for (int i = 0; i < consts.length; i++)
                System.out.println("  ConstructorInfo=" + consts[i]);
            Descriptor descs[] = info.getDescriptors(null);
            for (int i = 0; i < descs.length; i++)
                System.out.println("  Descriptor=" + descs[i]);
            MBeanNotificationInfo notifs[] = info.getNotifications();
            for (int i = 0; i < notifs.length; i++)
                System.out.println("  Notification=" + notifs[i]);
View Full Code Here

        // Retrieve the specified ModelMBeanAttributeInfo
        ModelMBeanAttributeInfo mmainfo = info.getAttribute("acceptCount");
        assertNotNull("Found HttpConnector acceptCount info", mmainfo);

        // Get the Descriptor
        Descriptor desc = mmainfo.getDescriptor();
        assertNotNull("Found HttpConnector acceptCount descriptor", desc);

        // Check the configured fields
        checkDescriptor(desc, "field1", "HttpConnector.acceptCount/field1");
        checkDescriptor(desc, "field2", "HttpConnector.acceptCount/field2");
View Full Code Here

        // Cast first entry to ModelMBeanConstructorInfo
        ModelMBeanConstructorInfo mmcinfo =
            (ModelMBeanConstructorInfo) mcinfo[0];

        // Get the Descriptor
        Descriptor desc = mmcinfo.getDescriptor();
        assertNotNull("Found HttpConnector constructor descriptor", desc);

        // Check the configured fields
        checkDescriptor(desc, "role", "constructor");
        checkDescriptor(desc, "field1", "HttpConnector.constructor/field1");
View Full Code Here

TOP

Related Classes of javax.management.Descriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.