Package javax.management.modelmbean

Examples of javax.management.modelmbean.ModelMBeanOperationInfo


        addAttributes(attributes, source);
        addExtraAttributes(attributes);

        addOperations(operations, source);
        addExtraOperations(operations);
        operations.add(new ModelMBeanOperationInfo("unregisterMBean", "unregisterMBean", new MBeanParameterInfo[0],
                void.class.getName(), ModelMBeanOperationInfo.ACTION));

        return new ModelMBeanInfoSupport(className, description,
                attributes.toArray(new ModelMBeanAttributeInfo[attributes.size()]), constructors,
                operations.toArray(new ModelMBeanOperationInfo[operations.size()]), notifications);
View Full Code Here


                signature.add(new MBeanParameterInfo(paramName, convertType(null, null, paramType, true).getName(),
                        paramName));
            }

            Class<?> returnType = convertType(null, null, m.getReturnType(), false);
            operations.add(new ModelMBeanOperationInfo(m.getName(), m.getName(), signature
                    .toArray(new MBeanParameterInfo[signature.size()]), returnType.getName(),
                    ModelMBeanOperationInfo.ACTION));
        }
    }
View Full Code Here

            // 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);
View Full Code Here

        }
    }

    private void extractMbeanOperations(Object managedBean, List<ManagedOperationInfo> operations, List<ModelMBeanOperationInfo> mBeanOperations) {
        for (ManagedOperationInfo info : operations) {
            ModelMBeanOperationInfo mbean = new ModelMBeanOperationInfo(info.getDescription(), info.getOperation());
            mBeanOperations.add(mbean);
            LOG.trace("Assembled operation: {}", mbean);
        }
    }
View Full Code Here

    }
   
    public void testAttributeHasCorrespondingOperations() throws Exception {
        ModelMBeanInfo info = getMBeanInfoFromAssembler();

        ModelMBeanOperationInfo myOperation = info.getOperation("myOperation");
        assertNotNull("get operation should not be null", myOperation);
        assertEquals("Incorrect myOperation return type", "long", myOperation.getReturnType());
               
        ModelMBeanOperationInfo add = info.getOperation("add");               
        assertNotNull("set operation should not be null", add);
        assertEquals("Incorrect add method description", "Add Two Numbers Together", add.getDescription());
               
    }
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

   }

   private ModelMBeanOperationInfo buildOperationInfo(Method method, String description, Role role,
      Collection<ManagedMethodParameterMetaData> parametersMD)
   {
      ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo(description, method);

      //
      if (description == null)
      {
         description = "Management operation";
      }

      //
      MBeanParameterInfo[] parameterInfos = operationInfo.getSignature();
      for (ManagedMethodParameterMetaData parameterMD : parametersMD)
      {
         int i = parameterMD.getIndex();
         MBeanParameterInfo parameterInfo = parameterInfos[i];
         String parameterName = parameterInfo.getName();
         String parameterDescription = operationInfo.getSignature()[i].getDescription();
         if (parameterMD.getName() != null)
         {
            parameterName = parameterMD.getName();
         }
         else if (parameterMD.getDescription() != null)
         {
            parameterDescription = parameterMD.getDescription();
         }
         parameterInfos[i] = new MBeanParameterInfo(parameterName, parameterInfo.getType(), parameterDescription);
      }

      //
      Descriptor operationDescriptor = operationInfo.getDescriptor();
      operationDescriptor.setField("role", role.name);

      //
      return new ModelMBeanOperationInfo(operationInfo.getName(), description, parameterInfos, operationInfo
         .getReturnType(), operationInfo.getImpact(), operationDescriptor);
   }
View Full Code Here

      //
      ArrayList<ModelMBeanOperationInfo> operations = new ArrayList<ModelMBeanOperationInfo>();
      for (ManagedMethodMetaData methodMD : typeMD.getMethods())
      {
         ModelMBeanOperationInfo operationInfo =
            buildOperationInfo(methodMD.getMethod(), methodMD.getDescription(), Role.OP, methodMD.getParameters());
         operations.add(operationInfo);
      }

      //
      Map<String, ModelMBeanAttributeInfo> attributeInfos = new HashMap<String, ModelMBeanAttributeInfo>();
      for (ManagedPropertyMetaData propertyMD : typeMD.getProperties())
      {

         Method getter = propertyMD.getGetter();
         if (getter != null)
         {
            Role role;
            String getterName = getter.getName();
            if (getterName.startsWith("get") && getterName.length() > 3)
            {
               role = Role.GET;
            }
            else if (getterName.startsWith("is") && getterName.length() > 2)
            {
               role = Role.IS;
            }
            else
            {
               throw new AssertionError();
            }
            Collection<ManagedMethodParameterMetaData> blah = Collections.emptyList();
            ModelMBeanOperationInfo operationInfo =
               buildOperationInfo(getter, propertyMD.getGetterDescription(), role, blah);
            operations.add(operationInfo);
         }

         //
         Method setter = propertyMD.getSetter();
         if (setter != null)
         {
            ManagedMethodParameterMetaData s = new ManagedMethodParameterMetaData(0);
            s.setDescription(propertyMD.getSetterParameter().getDescription());
            s.setName(propertyMD.getSetterParameter().getName());
            Collection<ManagedMethodParameterMetaData> blah = Collections.singletonList(s);
            ModelMBeanOperationInfo operationInfo =
               buildOperationInfo(setter, propertyMD.getSetterDescription(), Role.SET, blah);
            operations.add(operationInfo);
         }

         //
View Full Code Here

            desc.setField("mask", info.isMask() ? "true" : "false");
            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());
                Descriptor opDesc = mbeanOperation.getDescriptor();
                opDesc.setField("mask", info.isMask() ? "true" : "false");
                mbeanOperation.setDescriptor(opDesc);
                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);
View Full Code Here

        }
    }

    private void extractMbeanOperations(Object managedBean, Set<ManagedOperationInfo> operations, Set<ModelMBeanOperationInfo> mBeanOperations) {
        for (ManagedOperationInfo info : operations) {
            ModelMBeanOperationInfo mbean = new ModelMBeanOperationInfo(info.getDescription(), info.getOperation());
            Descriptor opDesc = mbean.getDescriptor();
            opDesc.setField("mask", info.isMask() ? "true" : "false");
            mbean.setDescriptor(opDesc);
            mBeanOperations.add(mbean);
            LOG.trace("Assembled operation: {}", mbean);
        }
    }
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.