Examples of DescriptorSupport


Examples of javax.management.modelmbean.DescriptorSupport

      validate(names, values, false);
   }

   private void validate(String[] names, Object[] values, boolean valid)
   {
      DescriptorSupport descriptor = null;
      RuntimeOperationsException caught = null;
      boolean descriptorValid = false;
      try
      {
         descriptor = new DescriptorSupport(names, values);
         descriptorValid = descriptor.isValid();
      }
      catch (RuntimeOperationsException e)
      {
         caught = e;
      }
      if (valid && caught != null)
         throw caught;
      assertEquals("Expected "+ valid + " for new Descriptor(String[], String[]) names=" +
              Arrays.asList(names) + " values=" + Arrays.asList(values), valid, descriptorValid);

      caught = null;
      descriptorValid = false;
      try
      {
         String[] fields = new String[names.length];
         for (int i = 0; i < fields.length; i++)
         {
            if (values[i] == null)
               fields[i] = names[i] + "=";
            else
               fields[i] = names[i] + "=" + values[i].toString();
         }
         descriptor = new DescriptorSupport(names, values);
         descriptorValid = descriptor.isValid();
      }
      catch (RuntimeOperationsException e)
      {
         caught = e;
      }
      if (valid && caught != null)
         throw caught;
      assertEquals("Expected "+ valid + " for new Descriptor(String[], String[]) names=" +
         Arrays.asList(names) + " values=" + Arrays.asList(values), valid, descriptorValid);

      caught = null;
      descriptorValid = false;
      try
      {
         descriptor = new DescriptorSupport();
         for (int i = 0; i < names.length; i++)
            descriptor.setField(names[i], values[i]);
         descriptorValid = descriptor.isValid();
      }
      catch (RuntimeOperationsException e)
      {
         caught = e;
      }
      if (valid && caught != null)
         throw caught;
      assertEquals("Expected "+ valid + " for new Descriptor(String[], String[]) names=" +
         Arrays.asList(names) + " values=" + Arrays.asList(values), valid, descriptorValid);

      caught = null;
      descriptorValid = false;
      try
      {
         descriptor = new DescriptorSupport();
         descriptor.setFields(names, values);
         descriptorValid = descriptor.isValid();
      }
      catch (RuntimeOperationsException e)
      {
         caught = e;
      }
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

   {
      try
      {
         MBeanServer server = MBeanServerFactory.createMBeanServer();

         Descriptor descriptor = new DescriptorSupport();
         descriptor.setField(NAME, "Active");
         descriptor.setField(DESCRIPTOR_TYPE, ATTRIBUTE_DESCRIPTOR);
         descriptor.setField(PERSIST_POLICY, PP_ON_TIMER);
         descriptor.setField(PERSIST_PERIOD, "1000");

         ModelMBeanAttributeInfo attrInfo = new ModelMBeanAttributeInfo(
               "Active",
               boolean.class.getName(),
               "Test Attribute",
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

      final boolean READABLE = true;
      final boolean WRITABLE = true;
      final boolean BOOLEAN  = true;
     
      // build 'RoomName' read-write attribute
      Descriptor descr1 = new DescriptorSupport();
      descr1.setField("name", "Room");
      descr1.setField("descriptorType", "attribute");
      descr1.setField("displayName", "Room Number");
      descr1.setField("default", "D325");

      ModelMBeanAttributeInfo roomNameInfo =
         new ModelMBeanAttributeInfo(
            "Room",                        // attribute name
            String.class.getName(),        // attribute type
            "Room name or number.",        // description
            READABLE, WRITABLE, !BOOLEAN,  // read write
            descr1                         // descriptor
         );


      // build 'Active' read-only attribute
      Descriptor descr2 = new DescriptorSupport();
      descr2.setField("name", "Active");
      descr2.setField("descriptorType", "attribute");
      descr2.setField("getMethod", "isActive");
      descr2.setField("currencyTimeLimit", "10");

      ModelMBeanAttributeInfo activeInfo =
         new ModelMBeanAttributeInfo(
            "Active",
            boolean.class.getName(),
            "Printer state.",
            READABLE, !WRITABLE, !BOOLEAN,
            descr2
         );

      // build 'isActive' getter operation
      Descriptor descr3 = new DescriptorSupport();
      descr3.setField("name", "isActive");
      descr3.setField("descriptorType", "operation");
      descr3.setField("role", "getter");

      ModelMBeanOperationInfo isActiveInfo =
         new ModelMBeanOperationInfo(
            "isActive",                   // name & description
            "Checks if the printer is currently active.",
            null,                         // signature
            boolean.class.getName(),      // return type
            MBeanOperationInfo.INFO,      // impact
            descr3                        // descriptor
         );

      // MBean descriptor
      Descriptor descr4 = new DescriptorSupport();
      descr4.setField("name", RequiredModelMBean.class.getName());
      descr4.setField("descriptorType", "MBean");

      // create ModelMBeanInfo
      ModelMBeanInfo info = new ModelMBeanInfoSupport(
                               RequiredModelMBean.class.getName()// class name
                               "Printer",                           // description
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

      final boolean READABLE = true;
      final boolean WRITABLE = true;
      final boolean BOOLEAN  = true;
     
      // build 'pojoAttribute' read-write attribute
      Descriptor descr2 = new DescriptorSupport();
      descr2.setField("name", "pojoAttribute");
      descr2.setField("descriptorType", "attribute");
      descr2.setField("getMethod", "getpojoAttribute");
      descr2.setField("setMethod", "setpojoAttribute");

      ModelMBeanAttributeInfo pojoAttributeInfo =
         new ModelMBeanAttributeInfo(
            "pojoAttribute",
            int.class.getName(),
            "A simple integer attribute.",
            READABLE, WRITABLE, !BOOLEAN,
            descr2
         );

      // JBAS-3614 - the jdk implementation of RequiredModelMBean
      // requires the attribute to be declared as operation(s), too.
      // This is not a requirement of the JMX 1.2 spec, though.
     
      // build 'getpojoAttribute' operation
      Descriptor descr21 = new DescriptorSupport();
      descr21.setField("name", "getpojoAttribute");
      descr21.setField("descriptorType", "operation");
     
      ModelMBeanOperationInfo getpojoAttributeOperation =
         new ModelMBeanOperationInfo(
            "getpojoAttribute",           // name
            "A simple operation.",        // description
            null,                         // signature
            int.class.getName(),          // return type
            MBeanOperationInfo.INFO,      // impact
            descr21                       // descriptor
         );
     
      // build 'setpojoAttribute' operation
      Descriptor descr22 = new DescriptorSupport();
      descr22.setField("name", "setpojoAttribute");
      descr22.setField("descriptorType", "operation");
     
      ModelMBeanOperationInfo setpojoAttributeOperation =
         new ModelMBeanOperationInfo(
            "setpojoAttribute",           // name
            "A simple operation.",        // description
            new MBeanParameterInfo[]      // signature
                  { new MBeanParameterInfo("int", int.class.getName(), "int setter") },
            void.class.getName(),         // return type
            MBeanOperationInfo.ACTION,    // impact
            descr22                       // descriptor
         );
     
      // build 'pojoOperation' operation
      Descriptor descr3 = new DescriptorSupport();
      descr3.setField("name", "pojoOperation");
      descr3.setField("descriptorType", "operation");

      ModelMBeanOperationInfo pojoOperationInfo =
         new ModelMBeanOperationInfo(
            "pojoOperation",              // name & description
            "A simple operation.",
            null,                         // signature
            boolean.class.getName(),      // return type
            MBeanOperationInfo.ACTION,    // impact
            descr3                        // descriptor
         );

      // MBean descriptor
      Descriptor descr4 = new DescriptorSupport();
      descr4.setField("name", RequiredModelMBean.class.getName());
      descr4.setField("descriptorType", "MBean");

      // create ModelMBeanInfo
      ModelMBeanInfo info = new ModelMBeanInfoSupport(
                               RequiredModelMBean.class.getName()// class name
                               "POJO",                              // description
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

    /**
     * @return notificationInfo
     */
    public MBeanNotificationInfo[] getNotificationInfo() {
        MBeanNotificationInfo[] result = new MBeanNotificationInfo[2];
        Descriptor genericDescriptor = new DescriptorSupport(new String[]{"name=GENERIC",
                "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.modelmbean.generic"});
        result[0] = new ModelMBeanNotificationInfo(new String[]{"jmx.modelmbean.generic"}, "GENERIC",
                "A text notification has been issued by the managed resource", genericDescriptor);
        Descriptor attributeDescriptor = new DescriptorSupport(new String[]{"name=ATTRIBUTE_CHANGE",
                "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.attribute.change"});
        result[1] = new ModelMBeanNotificationInfo(new String[]{"jmx.attribute.change"}, "ATTRIBUTE_CHANGE",
                "Signifies that an observed MBean attribute value has changed", attributeDescriptor);
        return result;
    }
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

    /**
     * @return notificationInfo
     */
    public final MBeanNotificationInfo[] getNotificationInfo() {
        MBeanNotificationInfo[] result = new MBeanNotificationInfo[2];
        Descriptor genericDescriptor = new DescriptorSupport(new String[] {
            "name=GENERIC", "descriptorType=notification", "LOGGER=T",
            "severity=5", "displayName=jmx.modelmbean.generic" });
        result[0] = new ModelMBeanNotificationInfo(new String[] {"jmx.modelmbean.generic" }, "GENERIC",
            "A text notification has been issued by the managed resource", genericDescriptor);
        Descriptor attributeDescriptor = new DescriptorSupport(new String[] {"name=ATTRIBUTE_CHANGE", "descriptorType=notification",
            "LOGGER=T", "severity=5", "displayName=jmx.attribute.change" });
        result[1] = new ModelMBeanNotificationInfo(new String[] {"jmx.attribute.change" }, "ATTRIBUTE_CHANGE",
            "Signifies that an observed MBean attribute value has changed", attributeDescriptor);
        return result;
    }
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

      assertSame(descriptor.getFieldValue("notification"), notification.getDescriptor().getFieldValue("notification"));
   }

   public void testCaseInsensitiveDescriptorType()
   {
      DescriptorSupport ds = new DescriptorSupport(new String[]{
         "name=badthing",
         "descriptorType=NOTification",
         "severity=1"
      });
      ModelMBeanNotificationInfo info =
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

      Constructor bobctor =
              ModelMBeanConstructorInfoTest.Bob.class.getConstructor(new Class[]{String.class});
      String[] fields = {"name", "descriptorType", "displayName", "role"};
      String[] values =
              {bobctor.getName(), "operation", "bob maker", "constructor"};
      DescriptorSupport ds = new DescriptorSupport(fields, values);
      ModelMBeanConstructorInfo ctorinfo =
              new ModelMBeanConstructorInfo("BobBuilder", bobctor, ds);
   }
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

   {
      Constructor bobctor =
              ModelMBeanConstructorInfoTest.Bob.class.getConstructor(new Class[]{String.class});
      String[] fields = {"name", "descriptorType", "role"};
      String[] values = {bobctor.getName(), "operation", "constructor"};
      DescriptorSupport ds = new DescriptorSupport(fields, values);
      ModelMBeanConstructorInfo ctorinfo =
              new ModelMBeanConstructorInfo("BobBuilder", bobctor, ds);
      Descriptor d = ctorinfo.getDescriptor();
      String dispname = (String)d.getFieldValue("displayName");
      assertTrue("Unexpected displayName",
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

                 ModelMBeanConstructorInfoTest.Bob.class.getConstructor(new Class[]{String.class});
         String[] fields =
                 {"name", "descriptorType", "displayName", "role"};
         String[] values =
                 {bobctor.getName(), "operation", "bob maker", "getter"};
         DescriptorSupport ds = new DescriptorSupport(fields, values);
         ModelMBeanConstructorInfo ctorinfo =
                 new ModelMBeanConstructorInfo("BobBuilder", bobctor, ds);
         fail("Expecting RuntimeOperationsException");
      }
      catch (RuntimeOperationsException x)
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.