Package javax.management

Examples of javax.management.MBeanAttributeInfo


            String name,
            String attribute) throws Exception {
        ObjectName oname = new ObjectName(name);
        String mattrType = null;
        MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
        MBeanAttributeInfo attrs[] = minfo.getAttributes();
        if (attrs != null) {
            for (int i = 0; mattrType == null && i < attrs.length; i++) {
                if (attribute.equals(attrs[i].getName()))
                    mattrType = attrs[i].getType();
            }
View Full Code Here


    }

    protected MBeanAttributeInfo[] createMBeanAttributeInfo()
    {
        return new MBeanAttributeInfo[]
        { new MBeanAttributeInfo("Threshold", String.class.getName(),
                "The \"threshold\" state of the logger hierarchy.", true, true, false) };
    }
View Full Code Here

    }

    private void buildDynamicMBeanInfo()
    {
        _attributes.add(new MBeanAttributeInfo("name", "java.lang.String",
                "The name of this Logger.", true, false, false));

        _attributes.add(new MBeanAttributeInfo("priority", "java.lang.String",
                "The priority of this logger.", true, true, false));

        MBeanParameterInfo[] params = new MBeanParameterInfo[2];
        params[0] = new MBeanParameterInfo("class_name", "java.lang.String",
                "add an appender to this logger");
View Full Code Here

            AppenderDynamicMBean appenderMBean = new AppenderDynamicMBean(appender);
            objectName = new ObjectName("log4j", "appender", name);
            getMBeanServer().registerMBean(appenderMBean, objectName);

            _attributes
                    .add(new MBeanAttributeInfo("appender=" + name, "javax.management.ObjectName",
                            "The " + name + " appender.", true, true, false));

        }
        catch (Exception e)
        {
View Full Code Here

     */
    private void addAttribute(List mBeanAttributeInfoList, MethodSignature method,
            Class attributeType, String performanceDataType, String description)
    {
        String attributeName = buildAttributeName(method, performanceDataType);
        MBeanAttributeInfo infoCount = new MBeanAttributeInfo(attributeName, attributeType
                .getName(), description, true, false, false);
        mBeanAttributeInfoList.add(infoCount);
    }
View Full Code Here

        attrInfo=new MBeanAttributeInfo[atts.size()];
        int i=0;
        log.info("Processing class " + instance.getClass());
        log.info("Attributes are:");
        MBeanAttributeInfo info=null;
        for(AttributeEntry entry:atts.values()) {
            info=entry.getInfo();
            attrInfo[i++]=info;
            log.info("Attribute " + info.getName()
                     + "[r="
                     + info.isReadable()
                     + ",w="
                     + info.isWritable()
                     + ",is="
                     + info.isIs()
                     + ",type="
                     + info.getType()
                     + "]");
        }

        opInfo=new MBeanOperationInfo[ops.size()];
        ops.toArray(opInfo);
View Full Code Here

        if(mbean != null && mbean.description() != null && mbean.description().trim().length() > 0) {
            description=mbean.description();
            if(log.isDebugEnabled()) {
                log.debug("@MBean description set - " + mbean.description());
            }
            MBeanAttributeInfo info=new MBeanAttributeInfo(ResourceDMBean.MBEAN_DESCRITION,
                                                           "java.lang.String",
                                                           "@MBean description",
                                                           true,
                                                           false,
                                                           false);
View Full Code Here

                        log.warn("method name " + methodName
                                 + " doesn't start with \"get\", \"set\", or \"is\""
                                 + ", but is annotated with @ManagedAttribute: will be ignored");
                }
                else {
                    MBeanAttributeInfo info=null;
                    //Is name field of @ManagedAttributed used?
                    String attributeName=attr.name().length()>0?attr.name().trim():null;
                    boolean writeAttribute=false;
                    if(isSetMethod(method)) { // setter
                        attributeName=(attributeName==null)?methodName.substring(3):attributeName;
                        info=new MBeanAttributeInfo(attributeName,
                                                    method.getParameterTypes()[0].getCanonicalName(),
                                                    attr.description(),
                                                    true,
                                                    true,
                                                    false);
                        writeAttribute=true;
                    }
                    else { // getter
                        if(method.getParameterTypes().length == 0 && method.getReturnType() != java.lang.Void.TYPE) {
                            boolean hasSetter=atts.containsKey(attributeName);
                            //we found is method
                            if(methodName.startsWith("is")) {
                                attributeName=(attributeName==null)?methodName.substring(2):attributeName;
                                info=new MBeanAttributeInfo(attributeName,
                                                            method.getReturnType().getCanonicalName(),
                                                            attr.description(),
                                                            true,
                                                            hasSetter,
                                                            true);
                            }
                            else {
                                //this has to be get
                                attributeName=(attributeName==null)?methodName.substring(3):attributeName;
                                info=new MBeanAttributeInfo(attributeName,
                                                            method.getReturnType().getCanonicalName(),
                                                            attr.description(),
                                                            true,
                                                            hasSetter,
                                                            false);
                            }
                        }
                        else {
                            if(log.isWarnEnabled()) {
                                log.warn("Method " + method.getName()
                                         + " must have a valid return type and zero parameters");
                            }
                            continue;
                        }
                    }                                     
                   
                    if(log.isDebugEnabled()) {
                        log.debug("@Attr found for method " + method.getName()
                                  + " and registered as "
                                  + attributeName);
                    }

                    AttributeEntry ae=atts.get(attributeName);
                    //is it a read method?
                    if(!writeAttribute) {
                        //we already have annotated field as read
                        if(ae instanceof FieldAttributeEntry && ae.getInfo().isReadable()) {
                            log.warn("not adding annotated method " + method
                                     + " since we already have read attribute");
                        }
                        //we already have annotated set method
                        else if(ae instanceof MethodAttributeEntry) {
                            MethodAttributeEntry mae=(MethodAttributeEntry)ae;
                            if(mae.hasSetMethod()) {
                                atts.put(attributeName,
                                         new MethodAttributeEntry(mae.getInfo(), mae.getSetMethod(), method));
                            }
                        } //we don't have such entry
                        else {
                            atts.put(attributeName, new MethodAttributeEntry(info, null, method));
                        }
                    }//is it a set method?
                    else {                       
                        if(ae instanceof FieldAttributeEntry) {
                            //we already have annotated field as write
                            if(ae.getInfo().isWritable()) {
                                log.warn("Not adding annotated method " + methodName
                                         + " since we already have writable attribute");
                            }
                            else {
                                //we already have annotated field as read
                                //lets make the field writable
                                Field f = ((FieldAttributeEntry)ae).getField();
                                MBeanAttributeInfo i=new MBeanAttributeInfo(ae.getInfo().getName(),
                                                                            f.getType().getCanonicalName(),
                                                                            attr.description(),
                                                                            true,
                                                                            Modifier.isFinal(f.getModifiers())? false: true,
                                                                            false);                              
View Full Code Here

            Field[] fields=clazz.getDeclaredFields();
            for(Field field:fields) {
                ManagedAttribute attr=field.getAnnotation(ManagedAttribute.class);
                if(attr != null) {
                    String fieldName = renameToJavaCodingConvention(field.getName());
                    MBeanAttributeInfo info=new MBeanAttributeInfo(fieldName,
                                                                   field.getType().getCanonicalName(),
                                                                   attr.description(),
                                                                   true,
                                                                   Modifier.isFinal(field.getModifiers())? false: attr.writable(),
                                                                   false);
View Full Code Here

            result=new Attribute(ResourceDMBean.MBEAN_DESCRITION, this.description);
        }
        else {
            AttributeEntry entry=atts.get(name);
            if(entry != null) {
                MBeanAttributeInfo i=entry.getInfo();
                try {
                    result=new Attribute(name, entry.invoke(null));
                    if(log.isDebugEnabled())
                        log.debug("Attribute " + name
                                  + " has r="
                                  + i.isReadable()
                                  + ",w="
                                  + i.isWritable()
                                  + ",is="
                                  + i.isIs()
                                  + " and value "
                                  + result.getValue());
                }
                catch(Exception e) {
                    log.warn("Exception while reading value of attribute " + name, e);
View Full Code Here

TOP

Related Classes of javax.management.MBeanAttributeInfo

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.