Package org.jboss.metatype.api.values

Examples of org.jboss.metatype.api.values.MapCompositeValueSupport


         {
            // Get the underlying time stat for this method
            final TimeStatistic stat = stats.get(method);

            // Create a composite view of the stat's state
            final MapCompositeValueSupport cvs = new MapCompositeValueSupport(METHOD_STATS_TYPE);
            cvs.put(PROP_NAME_METHODSTATS_COUNT, SimpleValueSupport.wrap(stat.count));
            cvs.put(PROP_NAME_METHODSTATS_MAXTIME, SimpleValueSupport.wrap(stat.maxTime));
            cvs.put(PROP_NAME_METHODSTATS_MINTIME, SimpleValueSupport.wrap(stat.minTime));
            cvs.put(PROP_NAME_METHODSTATS_TOTALTIME, SimpleValueSupport.wrap(stat.totalTime));

            // Add the stat to the method map
            methodMap.put(method, cvs);
         }
      }

      // Make a composite value for the returned MetaType
      final MapCompositeValueSupport root = new MapCompositeValueSupport(TYPE);

      // Set the properties
      root.put(PROP_NAME_ROOT_LAST_RESET_TIME, SimpleValueSupport.wrap(object.lastResetTime));
      root.put(PROP_NAME_ROOT_METHOD_STATS, new MapCompositeValueSupport(methodMap, VALUE_METHOD_STATS_MAP_TYPE));

      // Return
      return root;
   }
View Full Code Here


         if((value instanceof Map) == false)
            throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null"));
         Map<String,?> map = (Map) value;
         MapCompositeMetaType mapType = (MapCompositeMetaType) type;
         MetaType mapValueType = mapType.getValueType();
         MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType);
         for(Entry<String,?> entry : map.entrySet())
         {
            Object entryValue = entry.getValue();
            MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType);
            result.put(entry.getKey(), entryMetaValue);
         }
         mapping.put(value, result);
         return result;
      }

      CompositeValueSupport result = new CompositeValueSupport(type);
      mapping.put(value, result);

      BeanInfo beanInfo;
      try
      {
         ClassLoader cl = value.getClass().getClassLoader();
         if (cl == null)
            beanInfo = configuration.getBeanInfo(value.getClass());
         else
            beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
      }
      catch (Exception e)
      {
         throw new RuntimeException("Error retrieving BeanInfo for " + type);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue;
         try
         {
            itemValue = beanInfo.getProperty(value, name);
         }
         catch (RuntimeException e)
         {
            throw e;
         }
         catch (Error e)
         {
            throw e;
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
         }

         MetaValue item = internalCreate(itemValue, null, itemType);
         result.set(name, item);
      }
     
      return result;
   }
View Full Code Here

         {
            // Get the underlying time stat for this method
            final TimeStatistic stat = stats.get(method);

            // Create a composite view of the stat's state
            final MapCompositeValueSupport cvs = new MapCompositeValueSupport(METHOD_STATS_TYPE);
            cvs.put(PROP_NAME_METHODSTATS_COUNT, SimpleValueSupport.wrap(stat.getCount()));
            cvs.put(PROP_NAME_METHODSTATS_MAXTIME, SimpleValueSupport.wrap(stat.getMaxTime()));
            cvs.put(PROP_NAME_METHODSTATS_MINTIME, SimpleValueSupport.wrap(stat.getMinTime()));
            cvs.put(PROP_NAME_METHODSTATS_TOTALTIME, SimpleValueSupport.wrap(stat.getTotalTime()));

            // Add the stat to the method map
            methodMap.put(method, cvs);
         }
      }

      // Make a composite value for the returned MetaType
      final MapCompositeValueSupport root = new MapCompositeValueSupport(TYPE);

      // Set the properties
      root.put(PROP_NAME_ROOT_LAST_RESET_TIME, SimpleValueSupport.wrap(object.lastResetTime));
      root.put(PROP_NAME_ROOT_METHOD_STATS, new MapCompositeValueSupport(methodMap, VALUE_METHOD_STATS_MAP_TYPE));

      // Return
      return root;
   }
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.values.MapCompositeValueSupport

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.