Examples of ModelMBeanAttributeInfo


Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

        if (name == null)
            throw new RuntimeOperationsException
                (new IllegalArgumentException("Attribute name is null"),
                 "Attribute name is null");

        ModelMBeanAttributeInfo attrInfo=info.getAttribute(name);
        if (attrInfo == null)
            throw new AttributeNotFoundException("Cannot find attribute " + name);

        Descriptor attrDesc=attrInfo.getDescriptor();
        if (attrDesc == null)
            throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");

        Object oldValue=null;
        if( getAttMap.get(name) != null )
            oldValue=getAttribute( name );


        // Extract the method from cache
        Method m=(Method)setAttMap.get( name );

        if( m==null ) {
            // Look up the actual operation to be used
            String setMethod = (String) attrDesc.getFieldValue("setMethod");
            if (setMethod == null)
                throw new AttributeNotFoundException("Cannot find attribute " + name + " set method name");

            String argType=attrInfo.getType();

            Class signature[] = new Class[] { getAttributeClass( argType ) };

            Object object = null;
            NoSuchMethodException exception = null;
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

        // Return our cached information (if any)
        if (info != null)
            return (info);
        if((getMethodObj != null) || (setMethodObj != null) ) {
            try {
                info=new ModelMBeanAttributeInfo(getName(), getDescription(),
                                        getMethodObj,  setMethodObj);
                return info;
            } catch( Exception ex) {
                ex.printStackTrace();
            }
        }

        // Create and return a new information object
        info = new ModelMBeanAttributeInfo
            (getName(), getType(), getDescription(),
             isReadable(), isWriteable(), false);
        Descriptor descriptor = info.getDescriptor();
        if (getDisplayName() != null)
            descriptor.setField("displayName", getDisplayName());
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

        if (info != null)
            return (info);

        // Create subordinate information descriptors as required
        AttributeInfo attrs[] = getAttributes();
        ModelMBeanAttributeInfo attributes[] =
            new ModelMBeanAttributeInfo[attrs.length];
        for (int i = 0; i < attrs.length; i++)
            attributes[i] = attrs[i].createAttributeInfo();
       
        ConstructorInfo consts[] = getConstructors();
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

    private void extractMbeanAttributes(Object managedBean, Map<String, ManagedAttributeInfo> attributes,
                                        Set<ModelMBeanAttributeInfo> mBeanAttributes, Set<ModelMBeanOperationInfo> mBeanOperations) throws IntrospectionException {

        for (ManagedAttributeInfo info : attributes.values()) {
            ModelMBeanAttributeInfo mbeanAttribute = new ModelMBeanAttributeInfo(info.getKey(), info.getDescription(), info.getGetter(), info.getSetter());

            // add missing attribute descriptors, this is needed to have attributes accessible
            Descriptor desc = mbeanAttribute.getDescriptor();
            if (info.getGetter() != null) {
                desc.setField("getMethod", info.getGetter().getName());
                // attribute must also be added as mbean operation
                ModelMBeanOperationInfo mbeanOperation = new ModelMBeanOperationInfo(info.getKey(), info.getGetter());
                mBeanOperations.add(mbeanOperation);
            }
            if (info.getSetter() != null) {
                desc.setField("setMethod", info.getSetter().getName());
                // attribute must also be added as mbean operation
                ModelMBeanOperationInfo mbeanOperation = new ModelMBeanOperationInfo(info.getKey(), info.getSetter());
                mBeanOperations.add(mbeanOperation);
            }
            mbeanAttribute.setDescriptor(desc);

            mBeanAttributes.add(mbeanAttribute);
            LOG.trace("Assembled attribute: {}", mbeanAttribute);
        }
    }
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

            String attributeDescription =
               propertyMD.getDescription() != null ? propertyMD.getDescription() : ("Managed attribute " + propertyMD
                  .getName());

            //
            ModelMBeanAttributeInfo attributeInfo =
               new ModelMBeanAttributeInfo(propertyMD.getName(), attributeDescription, getter, setter);

            //
            Descriptor attributeDescriptor = attributeInfo.getDescriptor();
            if (getter != null)
            {
               attributeDescriptor.setField("getMethod", getter.getName());
            }
            if (setter != null)
            {
               attributeDescriptor.setField("setMethod", setter.getName());
            }
            attributeDescriptor.setField("currencyTimeLimit", "-1");
            attributeDescriptor.setField("persistPolicy", "Never");
            attributeInfo.setDescriptor(attributeDescriptor);

            //
            ModelMBeanAttributeInfo previous = attributeInfos.put(propertyMD.getName(), attributeInfo);
            if (previous != null)
            {
               throw new IllegalArgumentException();
            }
         }
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

            String attributeDescription =
               propertyMD.getDescription() != null ? propertyMD.getDescription() : ("Managed attribute " + propertyMD
                  .getName());

            //
            ModelMBeanAttributeInfo attributeInfo =
               new ModelMBeanAttributeInfo(propertyMD.getName(), attributeDescription, getter, setter);

            //
            Descriptor attributeDescriptor = attributeInfo.getDescriptor();
            if (getter != null)
            {
               attributeDescriptor.setField("getMethod", getter.getName());
            }
            if (setter != null)
            {
               attributeDescriptor.setField("setMethod", setter.getName());
            }
            attributeDescriptor.setField("currencyTimeLimit", "-1");
            attributeDescriptor.setField("persistPolicy", "Never");
            attributeInfo.setDescriptor(attributeDescriptor);

            //
            ModelMBeanAttributeInfo previous = attributeInfos.put(propertyMD.getName(), attributeInfo);
            if (previous != null)
            {
               throw new IllegalArgumentException();
            }
         }
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

      // iterate over all attributes in metadata
      MBeanAttributeInfo[] attrs = metadata.getAttributes();
      for (int i = 0; i < attrs.length; i++)
      {
         /// for each attribute, create a new Attribute object and add it to the collection
         ModelMBeanAttributeInfo attributeInfo = (ModelMBeanAttributeInfo)attrs[i];
         Descriptor attrDesc = attributeInfo.getDescriptor();
         Object name = attrDesc.getFieldValue(ModelMBeanConstants.NAME);
         Object value = attrDesc.getFieldValue(ModelMBeanConstants.VALUE);
         logger().debug("creating attribute.  name: " + name + ", value: " + value);
         Attribute curAttribute = new Attribute(name.toString(), value);
         attributes.add(curAttribute);
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

         else if (access.equalsIgnoreCase("write-only"))
            isReadable = false;


         ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
            name, type, description, isReadable, isWritable, false, descr
         );


         infos.add(info);
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

      List accessorOperations = new ArrayList();
     
      for (int i = 0; i < attributes.length; ++i)
      {
         // add basic info
         ModelMBeanAttributeInfo attrInfo = new ModelMBeanAttributeInfo(
            attributes[i].getName(),
            attributes[i].getType(),
            attributes[i].getDescription(),
            attributes[i].isReadable(),
            attributes[i].isWritable(),
            attributes[i].isIs()
         );
        
         // by default, conversion metadata should not try to cache attributes
         Descriptor d = attrInfo.getDescriptor();
         d.setField(CURRENCY_TIME_LIMIT, CACHE_NEVER);
         attrInfo.setDescriptor(d);
        
         mmbAttributes[i] = attrInfo;

         // if we're doing attribute operation mapping, find the accessor methods
         // from the Standard MBean interface, and create the 'setter' and 'getter'
View Full Code Here

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo

         else if (access.equalsIgnoreCase("write-only"))
            isReadable = false;


         ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
            name, type, description, isReadable, isWritable, false, descr
         );

         infos.add(info);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.