Package org.exoplatform.container.management

Examples of org.exoplatform.container.management.ManagedTypeMetaData$MethodKey


    * @return returns the info
    * @throws IllegalStateException raised by any build time issue
    */
   public ModelMBeanInfo build() throws IllegalStateException
   {
      ManagedTypeMetaData typeMD = metaDataBuilder.build();

      //
      String mbeanDescription = "Exo model mbean";
      if (typeMD.getDescription() != null)
      {
         mbeanDescription = typeMD.getDescription();
      }

      //
      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);
         }

         //
         try
         {
            String attributeDescription =
               propertyMD.getDescription() != null ? propertyMD.getDescription() : ("Managed attribute " + propertyMD
                  .getName());

            //
            ModelMBeanAttributeInfo attributeInfo =
               new ModelMBeanAttributeInfo(propertyMD.getName(), attributeDescription, getter, setter);

            //
            Descriptor attributeDescriptor = attributeInfo.getDescriptor();
            if (getter != null)
            {
               attributeDescriptor.setField("getMethod", getter.getName());
            }
            if (setter != null)
            {
               attributeDescriptor.setField("setMethod", setter.getName());
            }
            attributeDescriptor.setField("currencyTimeLimit", "-1");
            attributeDescriptor.setField("persistPolicy", "Never");
            attributeInfo.setDescriptor(attributeDescriptor);

            //
            ModelMBeanAttributeInfo previous = attributeInfos.put(propertyMD.getName(), attributeInfo);
            if (previous != null)
            {
               throw new IllegalArgumentException();
            }
         }
         catch (IntrospectionException e)
         {
            throw new AssertionError(e);
         }
      }

      //
      return new ModelMBeanInfoSupport(typeMD.getType().getName(), mbeanDescription, attributeInfos.values().toArray(
         new ModelMBeanAttributeInfo[attributeInfos.size()]), new ModelMBeanConstructorInfo[0], operations
         .toArray(new ModelMBeanOperationInfo[operations.size()]), new ModelMBeanNotificationInfo[0]);
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.container.management.ManagedTypeMetaData$MethodKey

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.