Package javax.management.modelmbean

Examples of javax.management.modelmbean.ModelMBeanOperationInfo


      }
      if (method.getDeclaringClass().equals(Object.class)) {
        continue;
      }

      ModelMBeanOperationInfo info = null;
      PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
      if (pd != null) {
        if ((method.equals(pd.getReadMethod()) && includeReadAttribute(method, beanKey)) ||
            (method.equals(pd.getWriteMethod()) && includeWriteAttribute(method, beanKey))) {
          // Attributes need to have their methods exposed as
          // operations to the JMX server as well.
          info = createModelMBeanOperationInfo(method, pd.getName(), beanKey);
          Descriptor desc = info.getDescriptor();
          if (method.equals(pd.getReadMethod())) {
            desc.setField(FIELD_ROLE, ROLE_GETTER);
          }
          else {
            desc.setField(FIELD_ROLE, ROLE_SETTER);
          }
          desc.setField(FIELD_VISIBILITY, ATTRIBUTE_OPERATION_VISIBILITY);
          if (isExposeClassDescriptor()) {
            desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
          }
          info.setDescriptor(desc);
        }
      }

      // allow getters and setters to be marked as operations directly
      if (info == null && includeOperation(method, beanKey)) {
        info = createModelMBeanOperationInfo(method, method.getName(), beanKey);
        Descriptor desc = info.getDescriptor();
        desc.setField(FIELD_ROLE, ROLE_OPERATION);
        if (isExposeClassDescriptor()) {
          desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
        }
        populateOperationDescriptor(desc, method, beanKey);
        info.setDescriptor(desc);
      }

      if (info != null) {
        infos.add(info);
      }
View Full Code Here


   * @return the <code>ModelMBeanOperationInfo</code>
   */
  protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
      return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
      return new ModelMBeanOperationInfo(name,
        getOperationDescription(method, beanKey),
        getOperationParameters(method, beanKey),
        method.getReturnType().getName(),
        MBeanOperationInfo.UNKNOWN);
    }
View Full Code Here

  }

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

    ModelMBeanOperationInfo get = info.getOperation("getName");
    assertNotNull("get operation should not be null", get);
    assertEquals("get operation should have visibility of four",
        (Integer) get.getDescriptor().getFieldValue("visibility"),
        new Integer(4));
    assertEquals("get operation should have role \"getter\"", "getter", get.getDescriptor().getFieldValue("role"));

    ModelMBeanOperationInfo set = info.getOperation("setName");
    assertNotNull("set operation should not be null", set);
    assertEquals("set operation should have visibility of four",
        (Integer) set.getDescriptor().getFieldValue("visibility"),
        new Integer(4));
    assertEquals("set operation should have role \"setter\"", "setter", set.getDescriptor().getFieldValue("role"));
  }
View Full Code Here

    assertEquals("Role should be \"operation\"", "operation", desc.getFieldValue("role"));
  }

  public void testOperationParameterMetadata() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();
    ModelMBeanOperationInfo oper = info.getOperation("add");
    MBeanParameterInfo[] params = oper.getSignature();

    assertEquals("Invalid number of params", 2, params.length);
    assertEquals("Incorrect name for x param", "x", params[0].getName());
    assertEquals("Incorrect type for x param", int.class.getName(), params[0].getType());
View Full Code Here

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

                                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

     */
    private ModelMBeanOperationInfo buildOperationInfo( final MethodDescriptor method,
                                                        final Configuration config )
        throws ConfigurationException
    {
        ModelMBeanOperationInfo info;

        if( config == null )
        {
            info = new ModelMBeanOperationInfo( method.getDisplayName(),
                                                method.getMethod() );

        }
        else
        {
            final String name = method.getName();
            final String type = method.getMethod().getReturnType().getName();
            final String description =
                config.getAttribute( "description",
                                     method.getDisplayName() );
            final int impact =
                config.getAttributeAsInteger( "impact",
                                              ModelMBeanOperationInfo.UNKNOWN );

            final Configuration[] paramConfig =
                config.getChildren( "param" );
            final MBeanParameterInfo[] params =
                new MBeanParameterInfo[ paramConfig.length ];
            for( int i = 0; i < paramConfig.length; i++ )
            {
                params[ i ] = buildParameterInfo( paramConfig[ i ] );
            }

            info = new ModelMBeanOperationInfo( name, description, params, type, impact );
        }

        // additional info needed for modelMbean to work
        final Descriptor descriptor = info.getDescriptor();
        // TODO: might want to make this configurable. It controls the caching behavior
        // of the invoke results. MX4J appears to cache this per operation regardless
        // of what the invoke parameters are *SIGH* - PR
        descriptor.setField( "currencyTimeLimit", new Integer( 0 ) );
        info.setDescriptor( descriptor );
        return info;
    }
View Full Code Here

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

                                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

                true, false, false));
    }
   
    @Override
    protected void addExtraOperations(List<ModelMBeanOperationInfo> operations) {
        operations.add(new ModelMBeanOperationInfo(
                "addFilterFirst", "addFilterFirst", new MBeanParameterInfo[] {
                        new MBeanParameterInfo(
                                "name", String.class.getName(), "the new filter name"),
                        new MBeanParameterInfo(
                                "filter", ObjectName.class.getName(), "the ObjectName reference to the filter")
                }, void.class.getName(), ModelMBeanOperationInfo.ACTION));

        operations.add(new ModelMBeanOperationInfo(
                "addFilterLast", "addFilterLast", new MBeanParameterInfo[] {
                        new MBeanParameterInfo(
                                "name", String.class.getName(), "the new filter name"),
                        new MBeanParameterInfo(
                                "filter", ObjectName.class.getName(), "the ObjectName reference to the filter")
                }, void.class.getName(), ModelMBeanOperationInfo.ACTION));

        operations.add(new ModelMBeanOperationInfo(
                "addFilterBefore", "addFilterBefore", new MBeanParameterInfo[] {
                        new MBeanParameterInfo(
                                "baseName", String.class.getName(), "the next filter name"),
                        new MBeanParameterInfo(
                                "name", String.class.getName(), "the new filter name"),
                        new MBeanParameterInfo(
                                "filter", ObjectName.class.getName(), "the ObjectName reference to the filter")
                }, void.class.getName(), ModelMBeanOperationInfo.ACTION));

        operations.add(new ModelMBeanOperationInfo(
                "addFilterAfter", "addFilterAfter", new MBeanParameterInfo[] {
                        new MBeanParameterInfo(
                                "baseName", String.class.getName(), "the previous filter name"),
                        new MBeanParameterInfo(
                                "name", String.class.getName(), "the new filter name"),
                        new MBeanParameterInfo(
                                "filter", ObjectName.class.getName(), "the ObjectName reference to the filter")
                }, void.class.getName(), ModelMBeanOperationInfo.ACTION));
       
        operations.add(new ModelMBeanOperationInfo(
                "removeFilter", "removeFilter", new MBeanParameterInfo[] {
                        new MBeanParameterInfo(
                                "name", String.class.getName(), "the name of the filter to be removed"),
                }, void.class.getName(), ModelMBeanOperationInfo.ACTION));
    }
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.