Examples of ArrayValueSupport


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

      Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
      JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
      ManagementView managementView = context.getProfileService();
      ManagedOperation operation = ManagementSupport.getOperation(managementView, JMSConstants.Queue.COMPONENT_NAME, "getJMSQueues", JMSConstants.Queue.COMPONENT_TYPE);

      ArrayValueSupport value = (ArrayValueSupport) operation.invoke();

      for (int i = 0; i < value.getLength(); i++)
      {
         SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
         ResourceType resourceType = resourceDiscoveryContext.getResourceType();
         String queueName = "jms.queue." + queue.getValue();
         set.add(new DiscoveredResourceDetails(resourceType,
             queueName,
             queueName,
View Full Code Here

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

      Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
      JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
      ManagementView managementView = context.getProfileService();
      ManagedOperation operation = ManagementSupport.getOperation(managementView, COMPONENT_NAME, "getJMSConnectionFactories", COMPONENT_TYPE);

      ArrayValueSupport value = (ArrayValueSupport) operation.invoke();

      for (int i = 0; i < value.getLength(); i++)
      {
         SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
         ResourceType resourceType = resourceDiscoveryContext.getResourceType();
         String queueName = queue.getValue().toString();
         set.add(new DiscoveredResourceDetails(resourceType,
             queueName,
             queueName,
View Full Code Here

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

      JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
      ManagementView managementView = context.getProfileService();
      ManagedOperation operation = ManagementSupport.getOperation(managementView, JMSConstants.Topic.COMPONENT_NAME,
            "getJMSTopics", JMSConstants.Topic.COMPONENT_TYPE);

      ArrayValueSupport value = (ArrayValueSupport) operation.invoke();

      for (int i = 0; i < value.getLength(); i++)
      {
         SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
         ResourceType resourceType = resourceDiscoveryContext.getResourceType();
         String queueName = "jms.topic." + queue.getValue();
         set.add(new DiscoveredResourceDetails(resourceType,
             queueName,
             queueName,
View Full Code Here

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

   public ArrayValue createArrayValue(ArrayMetaType type, Object value, Map<Object, MetaValue> mapping)
   {
      if (value == null)
         return null;

      ArrayValueSupport result = new ArrayValueSupport(type);
      mapping.put(value, result);
     
      Object[] array;
     
      MetaType elementType = type.getElementType();
      int dimension = type.getDimension();
     
      Object[] oldArray;
      Class<?> componentType;
      try
      {
         componentType = Class.forName(type.getClassName());
      }
      catch (Exception e)
      {
         throw new RuntimeException("Unable to determine component type for " + type, e);
      }
     
      ClassInfo classInfo = configuration.getClassInfo(value.getClass());
      if (classInfo.isArray())
      {
         // See if this is a primitive array
         ArrayInfo arrayInfo = ArrayInfo.class.cast(classInfo);
         TypeInfo compInfo = arrayInfo.getComponentType();
         while(compInfo instanceof ArrayInfo)
         {
            arrayInfo = ArrayInfo.class.cast(compInfo);
            compInfo = arrayInfo.getComponentType();
         }
         // Translate
         if (compInfo.isPrimitive())
            oldArray = convertPrimativeArray(classInfo, value);
         else
            oldArray = (Object[]) value;
      }
      else if (classInfo.isCollection())
      {
         Collection c = (Collection) value;
         oldArray = c.toArray();
      }
      else
         throw new UnsupportedOperationException("Cannot construct array for " + value.getClass());
     
      array = createArray(elementType, componentType.getComponentType(), dimension, oldArray);
      result.setValue(array);
      return result;
   }
View Full Code Here

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

   public void testSimpleArray() throws Exception
   {
      String[] array = { "Hello", "Goodbye" };
      ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
      MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
      getLog().debug("Array Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

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

            SimpleValueSupport.wrap('e'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('o')
      };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
      getLog().debug("Array Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

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

            SimpleValueSupport.wrap('o'),
            SimpleValueSupport.wrap('r'),
            SimpleValueSupport.wrap('l'),
            SimpleValueSupport.wrap('d')}              
      };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);

      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
      getLog().debug("Array Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

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

      MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") };
      CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
      itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") };
      CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
      MetaValue[] metaArray = { helloValue, goodbyeValue };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
      getLog().debug("Array Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

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

   public void testMultipleArray() throws Exception
   {
      String[][] array = { { "Hello" }, { "Goodbye" } };
      ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
      Object[][] metaArray = { { SimpleValueSupport.wrap("Hello") }, { SimpleValueSupport.wrap("Goodbye") } };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
      getLog().debug("Array Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

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

   public void testCharArray() throws Exception
   {
      ArrayMetaType type = new ArrayMetaType(1, SimpleMetaType.CHARACTER);
      char[] value = {'h', 'e', 'l', 'l', 'o'};
      ArrayValueSupport avs = new ArrayValueSupport(type, value);
      // Use getValue(int) accessor
      for(int n = 0; n < avs.getLength(); n ++)
      {
         Object element = avs.getValue(n);
         assertEquals(value[n], element);
      }
      // Use typesafe foreach Iterable
      int i = 0;
      for(Object c : avs)
      {
         assertEquals("["+i+"]", value[i++], c);        
      }
      // Validate the primative array
      char[] raw = (char[]) avs.getValue();
      for(int n = 0; n < value.length; n ++)
      {
         assertEquals(value[n], raw[n]);
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.