Examples of DescriptorSupport


Examples of javax.management.modelmbean.DescriptorSupport

         Attribute persistPeriod = attr.getAttribute(PERSIST_PERIOD);
         Attribute setMethod = attr.getAttribute(SET_METHOD);
         Attribute getMethod = attr.getAttribute(GET_METHOD);
         Attribute currTimeLimit = attr.getAttribute(CURRENCY_TIME_LIMIT);

         Descriptor descr = new DescriptorSupport();
         descr.setField("name", name);
         descr.setField("descriptorType", "attribute");

         if (persistPolicy != null)
            descr.setField(PERSIST_POLICY, persistPolicy.getValue());
         if (persistPeriod != null)
            descr.setField(PERSIST_PERIOD, persistPeriod.getValue());
         if (setMethod != null)
            descr.setField(SET_METHOD, setMethod.getValue());
         if (getMethod != null)
            descr.setField(GET_METHOD, getMethod.getValue());
         if (currTimeLimit != null)
            descr.setField(CURRENCY_TIME_LIMIT, currTimeLimit.getValue());

         // if no method mapping, enable caching automatically
         if (setMethod == null && getMethod == null && currTimeLimit == null)
            descr.setField(CURRENCY_TIME_LIMIT, "-1");        
           
         // defaults read-write
         boolean isReadable = true;
         boolean isWritable = true;
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, PM_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;

      // Default Domain attribute
      DescriptorSupport descDefaultDomain = new DescriptorSupport();
      descDefaultDomain.setField("name", "DefaultDomain");
      descDefaultDomain.setField("descriptorType", "attribute");
      descDefaultDomain.setField("displayName", "Default Domain");
      descDefaultDomain.setField("default", getDefaultDomain());
      descDefaultDomain.setField("currencyTimeLimit", "-1");
      ModelMBeanAttributeInfo defaultDomainInfo =
      new ModelMBeanAttributeInfo
      (
         "DefaultDomain", String.class.getName(),
         "The domain to use when an object name has no domain",
         READABLE, !WRITABLE, !BOOLEAN,
         descDefaultDomain
      );

      // Size attribute
      DescriptorSupport descSize = new DescriptorSupport();
      descSize.setField("name", "Size");
      descSize.setField("descriptorType", "attribute");
      descSize.setField("displayName", "Size");
      descSize.setField("getMethod", "getSize");
      ModelMBeanAttributeInfo sizeInfo =
      new ModelMBeanAttributeInfo
      (
         "Size", Integer.TYPE.getName(),
         "The number of MBeans registered in the MBean Server",
         READABLE, !WRITABLE, !BOOLEAN,
         descSize
      );

      // registerMBean operation
      DescriptorSupport descRegisterMBean = new DescriptorSupport();
      descRegisterMBean.setField("name", "registerMBean");
      descRegisterMBean.setField("descriptorType", "operation");
      descRegisterMBean.setField("role", "operation");
      MBeanParameterInfo[] registerMBeanParms =
      new MBeanParameterInfo[]
      {
          new MBeanParameterInfo
          (
             "Resource",
             Object.class.getName(),
             "A compliant MBean to be registered in the MBean Server"
          ),
          new MBeanParameterInfo
          (
             "ObjectName",
             ObjectName.class.getName(),
             "The object name of the MBean"
          ),
          new MBeanParameterInfo
          (
             "ValueMap",
             Map.class.getName(),
             "Values associated with the registration"
          ),
      };
      ModelMBeanOperationInfo registerMBeanInfo =
      new ModelMBeanOperationInfo
      (
         "registerMBean",
         "Adds an MBean in the MBeanServer",
         registerMBeanParms,
         ObjectInstance.class.getName(),
         ModelMBeanOperationInfo.ACTION_INFO,
         descRegisterMBean
      );

      // unregisterMBean operation
      DescriptorSupport descUnregisterMBean = new DescriptorSupport();
      descUnregisterMBean.setField("name", "unregisterMBean");
      descUnregisterMBean.setField("descriptorType", "operation");
      descUnregisterMBean.setField("role", "operation");
      MBeanParameterInfo[] unregisterMBeanParms =
      new MBeanParameterInfo[]
      {
          new MBeanParameterInfo
          (
             "ObjectName",
             ObjectName.class.getName(),
             "The object name of the MBean to remove"
          )
      };
      ModelMBeanOperationInfo unregisterMBeanInfo =
      new ModelMBeanOperationInfo
      (
         "unregisterMBean",
         "Removes an MBean from the MBeanServer",
         unregisterMBeanParms,
         Void.TYPE.getName(),
         ModelMBeanOperationInfo.ACTION,
         descUnregisterMBean
      );

      // getSize operation
      DescriptorSupport descGetSize = new DescriptorSupport();
      descGetSize.setField("name", "getSize");
      descGetSize.setField("descriptorType", "operation");
      descGetSize.setField("role", "operation");
      MBeanParameterInfo[] getSizeParms = new MBeanParameterInfo[0];
      ModelMBeanOperationInfo getSizeInfo =
      new ModelMBeanOperationInfo
      (
         "getSize",
         "Gets the number of MBeans registered",
         getSizeParms,
         Integer.TYPE.getName(),
         ModelMBeanOperationInfo.INFO,
         descGetSize
      );

       // get operation
       DescriptorSupport descGet = new DescriptorSupport();
       descGet.setField("name", "get");
       descGet.setField("descriptorType", "operation");
       descGet.setField("role", "operation");
       MBeanParameterInfo[] getParam = new MBeanParameterInfo[1];
       getParam[0]=new MBeanParameterInfo("ObjectName",ObjectName.class.getName(),"object name to find");
       ModelMBeanOperationInfo getInfo =
       new ModelMBeanOperationInfo
       (
          "get",
          "Gets the MBeanEntry for a given ObjectName",
          getParam,
          MBeanEntry.class.getName(),
          ModelMBeanOperationInfo.INFO,
          descGet
       );

      // getValue operation
      DescriptorSupport descGetValue = new DescriptorSupport();
      descGetValue.setField("name", "getValue");
      descGetValue.setField("descriptorType", "operation");
      descGetValue.setField("role", "operation");
      MBeanParameterInfo[] getValueParms = new MBeanParameterInfo[]
      {
         new MBeanParameterInfo
         (
            "ObjectName",
            ObjectName.class.getName(),
            "The object name of the registered MBean"
         ),
         new MBeanParameterInfo
         (
            "Key",
            String.class.getName(),
            "The key to the value stored"
         )
      };
      ModelMBeanOperationInfo getValueInfo =
      new ModelMBeanOperationInfo
      (
         "getValue",
         "Get a value stored in the MBean's registration",
         getValueParms,
         Object.class.getName(),
         ModelMBeanOperationInfo.INFO,
         descGetValue
      );

      // Construct the modelmbean
      DescriptorSupport descMBean = new DescriptorSupport();
      descMBean.setField("name", "MBeanRegistry");
      descMBean.setField("descriptorType", "MBean");
      ModelMBeanInfoSupport info = new ModelMBeanInfoSupport
      (
         RequiredModelMBean.class.getName(),
         "Managed Bean Registry",
         new ModelMBeanAttributeInfo[]
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

               new ModelMBeanAttributeInfo[]
               {
                  new ModelMBeanAttributeInfo(
                        "Name", String.class.getName(), "",
                        READABLE, !WRITABLE, !ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=Name",
                                 "getMethod=getName"
                           }
                        )
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "Level", int.class.getName(), "",
                        READABLE, WRITABLE, !ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=Level",
                                 "getMethod=getLevel",
                                 "setMethod=setLevel"
                           }
                        )
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "UnderlyingLogger", Object.class.getName(), "",
                        READABLE, !WRITABLE, !ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=UnderLyingLogger",
                                 "getMethod=getUnderlyingLogger"
                           }
                        )
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "DebugEnabled", boolean.class.getName(), "",
                        READABLE, !WRITABLE, ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=DebugEnabled",
                                 "getMethod=isDebugEnabled"
                           }
                        )
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "ErrorEnabled", boolean.class.getName(), "",
                        READABLE, !WRITABLE, ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=ErrorEnabled",
                                 "getMethod=isErrorEnabled"
                           }
                        )
                       
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "FatalEnabled", boolean.class.getName(), "",
                        READABLE, !WRITABLE, ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=FatalEnabled",
                                 "getMethod=isFatalEnabled"
                           }
                        )

                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "InfoEnabled", boolean.class.getName(), "",
                        READABLE, !WRITABLE, ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=InfoEnabled",
                                 "getMethod=isInfoEnabled"
                           }
                        )
                       
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "TraceEnabled", boolean.class.getName(), "",
                        READABLE, !WRITABLE, ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=TraceEnabled",
                                 "getMethod=isTraceEnabled"
                           }
                        )
                       
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "WarnEnabled", boolean.class.getName(), "",
                        READABLE, !WRITABLE, ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=WarnEnabled",
                                 "getMethod=isWarnEnabled"
                           }
                        )
                       
                  ),
                 
                  new ModelMBeanAttributeInfo(
                        "LoggerAdapter", LoggerAdapter.class.getName(), "",
                        READABLE, WRITABLE, !ISIS,
                        new DescriptorSupport(
                           new String[]
                           {
                                 "descriptorType=attribute",
                                 "name=LoggerAdapter",
                                 "getMethod=getLoggerAdapter",
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

    */
   public void testDescriptorSupportDefaultConstructor()
   {
      try
      {
         Descriptor d1 = new DescriptorSupport();
      }
      catch (AssertionFailedError e)
      {
         throw e;
      }
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

    */
   public void testDescriptorSupportInitialSizeConstructor()
   {
      try
      {
         Descriptor d2 = new DescriptorSupport(100);
       
         try
         {
            Descriptor d3 = new DescriptorSupport(0);
           
            // shouldn't reach here
            fail("RuntimeOperationsException should have been thrown when DescriptorSupport is created with zero initial size.");
         }
         catch (RuntimeOperationsException e)
         {
            // this is expected
         }
        
         try
         {
            Descriptor d4 = new DescriptorSupport(-100);
           
            // shouldn't reach here
            fail("RuntimeOperationsException should have been thrown when DescriptorSupport is created with negative initial size.");
         }
         catch (RuntimeOperationsException e)
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

    */
   public void testDescriptorSupportCopyConstructor()
   {
      try
      {
         DescriptorSupport d1 = new DescriptorSupport();
         d1.setField("foo", "bar");
         d1.setField("wombat", new Integer(666));
        
         DescriptorSupport d2 = new DescriptorSupport(d1);
         assertTrue(d2.getFieldValue("foo").equals("bar"));
         assertTrue(d2.getFieldValue("wombat").equals(new Integer(666)));
        
         DescriptorSupport d4 = null;
         DescriptorSupport d3 = new DescriptorSupport(d4);
           
      }
      catch (AssertionFailedError e)
      {
         throw e;
View Full Code Here

Examples of javax.management.modelmbean.DescriptorSupport

    */
   public void testDescriptorSupportClone()
   {
      try
      {
         DescriptorSupport d = new DescriptorSupport();
         d.setField("foo", "bar");
        
         Descriptor clone = (Descriptor)d.clone();
         assertTrue(clone.getFieldValue("foo").equals("bar"));
      }
      catch (AssertionFailedError e)
      {
         throw e;
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

   // JAVAX.MANAGEMENT.MODELMBEAN
   //

   public DescriptorSupport createDescriptorSupport()
   {
      return new DescriptorSupport(new String[]{"name"}, new Object[]{"value"});
   }
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.