Package javax.management.modelmbean

Examples of javax.management.modelmbean.ModelMBeanOperationInfo


                setters.put(name, types);
            }
            types.add(paramInfo[0].getType());
         }

         ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(
            name, description, paramInfo, type, operImpact, descr);

         infos.add(info);
      }

      // Add operations for get/setMethod that aren't already present

      for (Iterator it = attributes.iterator(); it.hasNext();)
      {
         Element attr = (Element) it.next();
         String name = attr.getChildTextTrim("name");
         String type = attr.getChildTextTrim("type");
         String getMethod = attr.getAttributeValue(GET_METHOD);
         String setMethod = attr.getAttributeValue(SET_METHOD);
         // Fabricate a getter operation
         if (getMethod != null)
         {

            Object getterOpType = getters.get(getMethod);
            if (getterOpType == null || getterOpType.equals(type) == false)
            {     
               Descriptor getterDescriptor = new DescriptorSupport();
               getterDescriptor.setField(NAME, getMethod);
               getterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
               getterDescriptor.setField(ROLE, GETTER);
               ModelMBeanOperationInfo info = new ModelMBeanOperationInfo
               (
                  getMethod,
                  "getMethod operation for '" + name + "' attribute.",
                  new MBeanParameterInfo[0],
                  type,
                  MBeanOperationInfo.INFO,
                  getterDescriptor
               );
               infos.add(info);
            }
         }

         // Fabricate a setter operation
        
         if (setMethod != null)
         {
            HashSet setterOpTypes = (HashSet) setters.get(setMethod);
            if (setterOpTypes == null || setterOpTypes.contains(type) == false)
            {     
               Descriptor setterDescriptor = new DescriptorSupport();
               setterDescriptor.setField(NAME, setMethod);
               setterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
               setterDescriptor.setField(ROLE, SETTER);
               ModelMBeanOperationInfo info = new ModelMBeanOperationInfo
               (
                  setMethod,
                  "setMethod operation for '" + name + "' attribute.",
                  new MBeanParameterInfo[]
                  {
View Full Code Here


               getterDescriptor.setField(NAME, getterOperationName);
               getterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
               getterDescriptor.setField(ROLE, GETTER);
              
               // create the new management operation
               ModelMBeanOperationInfo opInfo = new ModelMBeanOperationInfo(
                     getterOperationName,
                     "Read accessor operation for '" + attributes[i].getName() + "' attribute.",
                     new MBeanParameterInfo[0],    // void signature
                     attributes[i].getType(),      // return type
                     MBeanOperationInfo.INFO,      // impact
                     getterDescriptor
               );

               // modify the attributes descriptor to map the read operation
               // to the above created management operation
               Descriptor attrDescriptor = mmbAttributes[i].getDescriptor();
               attrDescriptor.setField(GET_METHOD, getterOperationName);
               mmbAttributes[i].setDescriptor(attrDescriptor);
              
               accessorOperations.add(opInfo);
            }
           
            // figure out the setter
            if (attributes[i].isWritable())
            {
               setterOperationName = "set" + attributes[i].getName();  
              
               // create a descriptor for 'setter' mgmt operation
               setterDescriptor = new DescriptorSupport();
               setterDescriptor.setField(NAME, setterOperationName);
               setterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
               setterDescriptor.setField(ROLE, SETTER);
              
               // create the new management operation
               ModelMBeanOperationInfo opInfo = new ModelMBeanOperationInfo(
                     setterOperationName,
                     "Write accessor operation for '" + attributes[i].getName() + "' attribute.",
                    
                     new MBeanParameterInfo[] {
                        new MBeanParameterInfo("value", attributes[i].getType(), "Attribute's value.")
                     },
                    
                     Void.TYPE.getName(),
                     MBeanOperationInfo.ACTION,
                     setterDescriptor
               );
              
               // modify the attributes descriptor to map the read operation
               // to the above created management operation
               Descriptor attrDescriptor = mmbAttributes[i].getDescriptor();
               attrDescriptor.setField(SET_METHOD, setterOperationName);
               mmbAttributes[i].setDescriptor(attrDescriptor);
              
               accessorOperations.add(opInfo);
            }
         }           
      }

      // deal with the basic manaement operations (non-getter and setter types)
      MBeanOperationInfo[] operations = info.getOperations();
      ModelMBeanOperationInfo[] mmbOperations = new ModelMBeanOperationInfo[operations.length + accessorOperations.size()];

      for (int i = 0; i < operations.length; ++i)
      {
         mmbOperations[i] = new ModelMBeanOperationInfo(
            operations[i].getName(),
            operations[i].getDescription(),
            operations[i].getSignature(),
            operations[i].getReturnType(),
            operations[i].getImpact()
View Full Code Here

      for (int i = 0; i < attributes.length; i++)
      {
         if (attributes[i].isReadable() && (attributes[i].getDescriptor().getFieldValue("getMethod") != null))
         {
            String key = MethodMapper.getterSignature(attributes[i]);
            ModelMBeanOperationInfo opinfo = (ModelMBeanOperationInfo) opsMap.get(key);
            String role = (String) opinfo.getDescriptor().getFieldValue("role");
            if ("getter".equals(role) || stripAllRoles)
            {
               opsMap.remove(key);
            }
         }

         if (attributes[i].isWritable() && (attributes[i].getDescriptor().getFieldValue("setMethod") != null))
         {
            String key = MethodMapper.setterSignature(attributes[i]);
            ModelMBeanOperationInfo opinfo = (ModelMBeanOperationInfo) opsMap.get(key);
           
            String role = (String) opinfo.getDescriptor().getFieldValue("role");
            if ("setter".equals(role) || stripAllRoles)
            {
               opsMap.remove(key);
            }
         }
View Full Code Here

         // default return-type is void
         if (type == null)
            type = "void";

         ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(
            name, descr, paramInfo, type, operImpact
         );

         infos.add(info);
      }
View Full Code Here

             "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(),
View Full Code Here

   {
      return new ModelMBeanInfoSupport(LogManager.class.getName(), "System Log Manager",
            null, null,
            new ModelMBeanOperationInfo[]
            {
               new ModelMBeanOperationInfo(
                     "createLogger", "",
                     new MBeanParameterInfo[]
                     {
                          new MBeanParameterInfo(
                              "clazz",
                              Class.class.getName(),
                              ""
                          )
                     },
                     ObjectName.class.getName(),
                     MBeanOperationInfo.ACTION
               ),
              
               new ModelMBeanOperationInfo(
                     "createLogger", "",
                     new MBeanParameterInfo[]
                     {
                           new MBeanParameterInfo(
                              "name",
                              String.class.getName(),
                              ""
                           )
                     },
                     ObjectName.class.getName(),
                     MBeanOperationInfo.ACTION
                ),
               
                new ModelMBeanOperationInfo(
                     "getLogger", "",
                     new MBeanParameterInfo[]
                     {
                           new MBeanParameterInfo(
                              "clazz",
                              Class.class.getName(),
                              ""
                           )
                     },
                     Logger.class.getName(),
                     MBeanOperationInfo.ACTION
                ),
               
                new ModelMBeanOperationInfo(
                     "getLogger", "",
                     new MBeanParameterInfo[]
                     {
                           new MBeanParameterInfo(
                              "name",
View Full Code Here

         ModelMBeanAttributeInfo info = getAttribute((String)descr.getFieldValue(ModelMBeanConstants.NAME));
         info.setDescriptor(descr);
      }
      else if (descrType.equalsIgnoreCase(ModelMBeanConstants.OPERATION_DESCRIPTOR))
      {
         ModelMBeanOperationInfo info = getOperation((String)descr.getFieldValue(ModelMBeanConstants.NAME));
         info.setDescriptor(descr);
      }
      else if (descrType.equalsIgnoreCase(ModelMBeanConstants.CONSTRUCTOR_DESCRIPTOR))
      {
         ModelMBeanConstructorInfo info = getConstructor((String)descr.getFieldValue(ModelMBeanConstants.NAME));
         info.setDescriptor(descr);
      }
      else if (descrType.equalsIgnoreCase(ModelMBeanConstants.NOTIFICATION_DESCRIPTOR))
      {
         ModelMBeanNotificationInfo info = getNotification((String)descr.getFieldValue(ModelMBeanConstants.NAME));
         info.setDescriptor(descr);
      }
      else
         throw new RuntimeOperationsException(new IllegalArgumentException("unknown descriptor type: " + descrType));
   }
View Full Code Here

              
               null,
              
               new ModelMBeanOperationInfo[]
               {
                  new ModelMBeanOperationInfo(
                        "getName", "", null,
                        String.class.getName(),
                        MBeanOperationInfo.INFO
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "setLevel", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "level", int.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "getLevel", "", null,
                        int.class.getName(),
                        MBeanOperationInfo.INFO
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "getUnderlyingLogger", "", null,
                        Object.class.getName(),
                        MBeanOperationInfo.INFO
                  ),
                       
                  new ModelMBeanOperationInfo(
                        "isDebugEnabled", "", null,
                        boolean.class.getName(),
                        MBeanOperationInfo.INFO
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "isErrorEnabled", "", null,
                        boolean.class.getName(),
                        MBeanOperationInfo.INFO
                  ),

                  new ModelMBeanOperationInfo(
                        "isFatalEnabled", "", null,
                        boolean.class.getName(),
                        MBeanOperationInfo.INFO
                  ),

                  new ModelMBeanOperationInfo(
                        "isTraceEnabled", "", null,
                        boolean.class.getName(),
                        MBeanOperationInfo.INFO
                  ),

                  new ModelMBeanOperationInfo(
                        "isInfoEnabled", "", null,
                        boolean.class.getName(),
                        MBeanOperationInfo.INFO
                  ),

                  new ModelMBeanOperationInfo(
                        "isWarnEnabled", "", null,
                        boolean.class.getName(),
                        MBeanOperationInfo.INFO
                  ),

                  new ModelMBeanOperationInfo(
                     "isEnabled", "",
                    
                     new MBeanParameterInfo[]
                     {
                        new MBeanParameterInfo(
                              "level", int.class.getName(), ""
                        )
                     },
                    
                     boolean.class.getName(),
                     MBeanOperationInfo.INFO
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "debug", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "debug", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "error", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "error", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "fatal", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "fatal", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "trace", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "trace", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "info", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "info", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "warn", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "warn", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "log", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "level", int.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "log", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "level", int.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "msg", String.class.getName(), ""
                           ),
                           new MBeanParameterInfo(
                                 "exception", Throwable.class.getName(), ""
                           ),
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),

                  new ModelMBeanOperationInfo(
                        "setLoggerAdapter", "",
                       
                        new MBeanParameterInfo[]
                        {
                           new MBeanParameterInfo(
                                 "Logger Adapter", LoggerAdapter.class.getName(), ""
                           )
                        },
                       
                        void.class.getName(),
                        MBeanOperationInfo.ACTION
                  ),
                 
                  new ModelMBeanOperationInfo(
                        "getLoggerAdapter", "", null,
                        LoggerAdapter.class.getName(),
                        MBeanOperationInfo.ACTION
                  )
                 
View Full Code Here

         )
      };
     
      ModelMBeanOperationInfo[] operations = new ModelMBeanOperationInfo[]
      {
         new ModelMBeanOperationInfo(
               "doOperation", "description", null, "java.lang.Object", 1
         )
      };
     
      ModelMBeanInfoSupport info = new ModelMBeanInfoSupport(
View Full Code Here

        // Create the associated ModelMBeanInfo
        ModelMBeanInfo info = http.createMBeanInfo();
        assertNotNull("Found HttpConnector ModelMBeanInfo", info);

        // Retrieve the specified ModelMBeanOperationInfo
        ModelMBeanOperationInfo mmoinfo = info.getOperation("initialize");
        assertNotNull("Found HttpConnector initialize info", mmoinfo);

        // Get the Descriptor
        Descriptor desc = mmoinfo.getDescriptor();
        assertNotNull("Found HttpConnector initialize descriptor", desc);

        // Check the configured fields
        checkDescriptor(desc, "field1", "HttpConnector.initialize/field1");
        checkDescriptor(desc, "field2", "HttpConnector.initialize/field2");
View Full Code Here

TOP

Related Classes of javax.management.modelmbean.ModelMBeanOperationInfo

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.