Package org.jboss.metatype.api.values

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


   {
      Map<String, ProtocolStackConfigInfo> map = factory.getProtocolStackConfigurations();
     
      ProtocolStackConfigurationsMapper testee = new ProtocolStackConfigurationsMapper();
     
      MetaValue metaValue = testee.createMetaValue(ProtocolStackConfigurationsMapper.TYPE, map);
      ManagedObjectTestUtil.validateProtocolStackConfigurations(metaValue, new String[]{"unshared1", "shared1"});
     
      Map<String, ProtocolStackConfigInfo> restored = testee.unwrapMetaValue(metaValue);
      assertEquals(map.keySet(), restored.keySet());
     
View Full Code Here


         }
      }
     
      ManagedProperty prop = mc.getProperty("domain");
      assertNotNull("ChannelFactory has property domain", prop);
      MetaValue metaVal = prop.getValue();
      assertTrue(metaVal instanceof SimpleValue);
      Object val = ((SimpleValue) metaVal).getValue();
      assertEquals("jboss.jgroups", val);
     
      prop = mc.getProperty("exposeChannels");
View Full Code Here

   public void testUpdateProtocolStackConfigurations() throws Exception
   {
      ManagedComponent component = getChannelFactoryManagedComponent();
      ManagedProperty prop = component.getProperty("protocolStackConfigurations");
      MetaValue mapValue = prop.getValue();
      assertTrue(mapValue instanceof CompositeValue);
      MetaValue stackValue = ((CompositeValue) mapValue).get("udp-async");
      assertTrue(stackValue instanceof CompositeValue);
      MetaValue configurationValue = ((CompositeValue) stackValue).get("configuration");
      assertTrue(configurationValue instanceof CollectionValue);
      MetaValue[] protocols = ((CollectionValue) configurationValue).getElements();
      MetaValue udp = protocols[0];
      assertTrue(udp instanceof CompositeValue);
      MetaValue parametersValue = ((CompositeValue) udp).get("protocolParameters");
      assertTrue(parametersValue instanceof CompositeValue);
      Set<String> params = ((CompositeValue) parametersValue).getMetaType().keySet();
      int maxThreads = -1;
      MapCompositeValueSupport newVal = null;
      for (String name : params)
View Full Code Here

         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, e);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue = null;
         try
         {
            PropertyInfo property = beanInfo.getProperty(name);
            if (property.isReadable())
               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

      MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE);

      for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
      {
         Map.Entry entry = i.next();
         MetaValue key = internalCreate(entry.getKey(), null, keyType);
         MetaValue val = internalCreate(entry.getValue(), null, valType);
         CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
         table.put(data);
      }

      return table;
View Full Code Here

            return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);           
         }
         else if(clazz.isAssignableFrom(ObjectName.class))
         {
            // TODO: this should be handled more generically
            MetaValue domain = compositeValue.get("domain");
            String domainUnwrap = (String) unwrap(domain, String.class);
            MetaValue keys = compositeValue.get("keyPropertyList");
            Hashtable keysUnwrap = null;
            if(keys instanceof PropertiesMetaValue)
               keysUnwrap = (PropertiesMetaValue) keys;
            ObjectName name = new ObjectName(domainUnwrap, keysUnwrap);
            return name;
         }

         Object bean = createNewInstance(beanInfo);
         for (String name : compositeMetaType.itemSet())
         {
            MetaValue itemValue = compositeValue.get(name);
            PropertyInfo propertyInfo = beanInfo.getProperty(name);
            Object value = unwrap(itemValue, propertyInfo.getType());
            propertyInfo.set(bean, value);
         }
         return bean;
View Full Code Here

   {
      HashMap map = new HashMap();
      CompositeMetaType metaType = compositeValue.getMetaType();
      for(String key : metaType.itemSet())
      {
         MetaValue mv = compositeValue.get(key);
         Object value = unwrap(mv);
         map.put(key, value);
      }
      return map;
   }
View Full Code Here

      }
      else
      {
         // Check the existing mapping
         mapping = mappingStack.get().peek();
         MetaValue result = mapping.get(value);
         // Seen this before
         if (result != null)
            return result;
      }

      try
      {
         MetaValue result = isBuilder(metaType, type, value, mapping);

         if (result == null)
         {
            MetaMapper<Object> mapper = (MetaMapper) MetaMapper.getMetaMapper(type);
            if (mapper != null)
View Full Code Here

         if (weak != null)
            builder = weak.get();
      }
      if (builder == null)
         return null;
      MetaValue result = builder.buildMetaValue(metaType, value);
      if (result != null)
         mapping.put(value, result);
     
      return result;
   }
View Full Code Here

   public ObjectName unwrapMetaValue(MetaValue metaValue)
   {
      CompositeValue compositeValue = (CompositeValue) metaValue;
      SimpleValue domain = (SimpleValue) compositeValue.get("domain");
      String domainUnwrap = domain.toString();
      MetaValue keys = compositeValue.get("keyPropertyList");
      Hashtable keysUnwrap = null;
      if(keys instanceof PropertiesMetaValue)
         keysUnwrap = (PropertiesMetaValue) keys;
      try
      {
View Full Code Here

TOP

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

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.