Package javax.management.modelmbean

Examples of javax.management.modelmbean.ModelMBeanAttributeInfo


      try
      {
         Method macgetter = BogusNIC.class.getMethod("getMAC", new Class[0]);
         Method macsetter =
                 BogusNIC.class.getMethod("setMAC", new Class[]{int.class});
         ModelMBeanAttributeInfo attrinfo =
                 new ModelMBeanAttributeInfo("MAC",
                                             "MAC Address",
                                             macgetter,
                                             macsetter);
         fail("Expecting an IntrospectionException");
      }
View Full Code Here


      }
   }

   public void testValuelessAttribute() throws Exception
   {
      ModelMBeanAttributeInfo attrinfo =
              new ModelMBeanAttributeInfo("SerialNo",
                                          "NIC Card's serial number",
                                          null,
                                          null);
      attrinfo =
      new ModelMBeanAttributeInfo("SerialNo",
                                  "String",
                                  "NIC Card's serial number",
                                  false,
                                  false,
                                  false);
View Full Code Here

         "name=PreferredWine",
         "descriptorType=Attribute",
         "value=Amarone",
         "default=Red"
      });
      ModelMBeanAttributeInfo attrinfo =
              new ModelMBeanAttributeInfo("PreferredWine",
                                          "String",
                                          "Wine of choice",
                                          true,
                                          false,
                                          false,
View Full Code Here

         "value=Amarone",
         "displayName=PreferredWine",
         "default=Red"
      });

      ModelMBeanAttributeInfo attrinfo =
              new ModelMBeanAttributeInfo("PreferredWine",
                                          "String",
                                          "Wine of choice",
                                          true,
                                          false,
                                          false);
      Descriptor d = attrinfo.getDescriptor();
      assertTrue("Expecting default descriptor", descriptorsEqual(d, defds));

      attrinfo =
      new ModelMBeanAttributeInfo("PreferredWine",
                                  "String",
                                  "Wine of choice",
                                  true,
                                  false,
                                  false,
                                  ds);
      d = attrinfo.getDescriptor();
      assertTrue("Expecting copy of ds", descriptorsEqual(d, ds));
   }
View Full Code Here

   }

   public void testGetDescriptor() throws Exception
   {
      ModelMBeanAttributeInfo[] attributes = new ModelMBeanAttributeInfo[2];
      attributes[0] = new ModelMBeanAttributeInfo("test", "java.lang.String", "A description", true, true, false);
      attributes[1] = new ModelMBeanAttributeInfo("test2", "java.lang.String", "A description", true, true, false);
      // testcase for bug #700905
      ModelMBeanInfoSupport support = new ModelMBeanInfoSupport("somepackage.someclass", "Test case", attributes, null, null, null);
      // this worked ok
      Descriptor descriptor = support.getDescriptor("test", "attribute");
      assertNotNull(descriptor);
View Full Code Here

   }

   public void compareModelMBeanAttributeInfo(Object o1, Object o2)
   {
      compareMBeanAttributeInfo(o1, o2);
      ModelMBeanAttributeInfo a1 = (ModelMBeanAttributeInfo)o1;
      ModelMBeanAttributeInfo a2 = (ModelMBeanAttributeInfo)o2;
      compareDescriptorSupport(a1.getDescriptor(), a2.getDescriptor());
   }
View Full Code Here

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

        if( m==null ) {
            // Look up the actual operation to be used
            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");
            String getMethod = (String) attrDesc.getFieldValue("getMethod");

            if (getMethod == null)
View Full Code Here

        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");

        try {
            // XXX Is it before or after ?
            Object oldValue=null;
            if( getAttMap.get(name) != null )
                oldValue=getAttribute( name );
            sendAttributeChangeNotification(new Attribute( name, oldValue),
                    attribute);
        } catch( Exception ex ) {
            log.error( "Error sending notification " + name, ex );
        }

        // 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

        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

        // 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

TOP

Related Classes of javax.management.modelmbean.ModelMBeanAttributeInfo

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.