Package javax.management.modelmbean

Examples of javax.management.modelmbean.ModelMBeanOperationInfo


                    (new IllegalArgumentException("Inconsistent arguments and signature"),
                     "Inconsistent arguments and signature");

            // Acquire the ModelMBeanOperationInfo information for
            // the requested operation
            ModelMBeanOperationInfo opInfo = info.getOperation(name);
            if (opInfo == null)
                throw new MBeanException
                    (new ServiceNotFoundException("Cannot find operation " + name),
                     "Cannot find operation " + name);
View Full Code Here


        ModelMBeanNotificationInfo notifications[] =
            new ModelMBeanNotificationInfo[notifs.length];
        for (int i = 0; i < notifs.length; i++)
            notifications[i] = notifs[i].createNotificationInfo();
        OperationInfo opers[] = getOperations();
        ModelMBeanOperationInfo operations[] =
            new ModelMBeanOperationInfo[opers.length];
        for (int i = 0; i < opers.length; i++)
            operations[i] = opers[i].createOperationInfo();

        /*
 
View Full Code Here

        else if ("ACTION_INFO".equals(getImpact()))
            impact = ModelMBeanOperationInfo.ACTION_INFO;
        else if ("INFO".equals(getImpact()))
            impact = ModelMBeanOperationInfo.INFO;

        info = new ModelMBeanOperationInfo
            (getName(), getDescription(), parameters,
             getReturnType(), impact);
        Descriptor descriptor = info.getDescriptor();
        descriptor.removeField("class");
        descriptor.setField("role", getRole());
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, Set<ManagedOperationInfo> operations, Set<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

   }

   private ModelMBeanOperationInfo buildOperationInfo(Method method, String description, Role role,
      Collection<ManagedMethodParameterMetaData> parametersMD, ImpactType impactType)
   {
      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);
      }

      //
      int jmxImpact;
      switch (impactType)
      {
         case READ:
            jmxImpact = MBeanOperationInfo.INFO;
            break;
         case IDEMPOTENT_WRITE:
         case WRITE:
            jmxImpact = MBeanOperationInfo.ACTION;
            break;
         default:
            throw new AssertionError();
      }

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

      //
      return new ModelMBeanOperationInfo(operationInfo.getName(), description, parameterInfos, operationInfo
         .getReturnType(), jmxImpact, 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(), methodMD.getImpact());
         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, ImpactType.READ);
            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, ImpactType.IDEMPOTENT_WRITE);
            operations.add(operationInfo);
         }

         //
View Full Code Here

   }

   private ModelMBeanOperationInfo buildOperationInfo(Method method, String description, Role role,
      Collection<ManagedMethodParameterMetaData> parametersMD, ImpactType impactType)
   {
      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);
      }

      //
      int jmxImpact;
      switch (impactType)
      {
         case READ:
            jmxImpact = MBeanOperationInfo.INFO;
            break;
         case IDEMPOTENT_WRITE:
         case WRITE:
            jmxImpact = MBeanOperationInfo.ACTION;
            break;
         default:
            throw new AssertionError();
      }

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

      //
      return new ModelMBeanOperationInfo(operationInfo.getName(), description, parameterInfos, operationInfo
         .getReturnType(), jmxImpact, 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(), methodMD.getImpact());
         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, ImpactType.READ);
            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, ImpactType.IDEMPOTENT_WRITE);
            operations.add(operationInfo);
         }

         //
View Full Code Here

        
         null,                                  // constructors
        
         new ModelMBeanOperationInfo[]          // operations
         {
            new ModelMBeanOperationInfo(
                  "invoke",                                 // name
                  "Shared interceptor invoke operation.",   // description
                  new MBeanParameterInfo[]                  // arguments
                  {
                     new MBeanParameterInfo(
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.