Package org.jboss.metatype.api.values

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


            log.warn("Skipping binding: "+ b, e);
         }
        
      }
      MetaValue[] elements = tmp.toArray(new MetaValue[tmp.size()]);
      CollectionValueSupport bindings = new CollectionValueSupport(TYPE, elements);
      return bindings;
   }
View Full Code Here


            }
         }
      }
      MetaValue[] elements = new MetaValue[tmp.size()];
      tmp.toArray(elements);
      CollectionValueSupport msgs = new CollectionValueSupport(TYPE, elements);
      return msgs;
   }
View Full Code Here

      Map<String, MetaValue> metadata = new HashMap<String, MetaValue>();
      metadata.put("serviceName", SimpleValueSupport.wrap("AddedOverrideBinding"));
      metadata.put("description", SimpleValueSupport.wrap("description"));
      metadata.put("port", SimpleValueSupport.wrap(54321));
      MapCompositeValueSupport newMetadata = new MapCompositeValueSupport(metadata, SERVICE_BINDING_METADATA_TYPE);
      CollectionValue overrides = new CollectionValueSupport(new CollectionMetaType(Set.class.getName(), SERVICE_BINDING_METADATA_TYPE), new MetaValue[]{newMetadata});
     
      map.put("overrideBindings", overrides);
      MapCompositeValueSupport newElement = new MapCompositeValueSupport(map, SERVICE_BINDING_SET_TYPE);
      newElements[newElements.length - 1] = newElement;
      CollectionValue newVal = new CollectionValueSupport(new CollectionMetaType(Set.class.getName(), SERVICE_BINDING_SET_TYPE), newElements);
      prop.setValue(newVal);
     
      // Before updating get a ref to the standard bindings so we can use it
      // in later validation
      Map<String, MetaValue> standardBindings = new HashMap<String, MetaValue>();
      prop = properties.get("standardBindings");
      assertNotNull("Missing property standardBindings", prop);
      val =  prop.getValue();
      assertNotNull("property standardBindings has no value", val);
      assertTrue("property standardBindings value is CollectionValue", val instanceof CollectionValue);
      MetaValue[] elements = ((CollectionValue) val).getElements();
      assertNotNull("property standardBindings value has elements", elements);
      for (MetaValue mv : elements)
      {
         standardBindings.put(getSimpleValue(mv, "fullyQualifiedName", String.class), mv);
      }
     
      try
      {
         getManagementView().updateComponent(component);
      }
      catch (Exception e)
      {
         log.error("Failed updating " + component, e);
         throw e;
      }
     
      // B) Validate the addition from A) took effect and then UPDATE the added binding set
     
      component = getServiceBindingManagerManagedComponent()
      properties = component.getProperties();
      assertNotNull(properties);
     
      IndexedArray indexedArray = checkAddedBindingSet(properties, newElements.length, 500, 54321, standardBindings);
     
      prop = properties.get("bindingSets");     
      assertNotNull("Missing property bindingSets", prop);
      val =  prop.getValue();
      assertNotNull("property bindingSets has no value", val);
      assertTrue("property bindingSets value is CollectionValue", val instanceof CollectionValue);
      MetaValue[] updated = newElements.clone();
      MapCompositeValueSupport updatedBindingSet = cloneCompositeValue((CompositeValue) updated[indexedArray.index]);
      updatedBindingSet.put("portOffset", SimpleValueSupport.wrap(400));
     
      MetaValue[] updatedOverrides = ((CollectionValue) updatedBindingSet.get("overrideBindings")).getElements();
      assertEquals("single override binding", 1, updatedOverrides.length);
      MapCompositeValueSupport updatedOverride = cloneCompositeValue((CompositeValue) updatedOverrides[0]);
      updatedOverride.put("port", SimpleValueSupport.wrap(43210));
      updatedBindingSet.put("overrideBindings", new CollectionValueSupport(new CollectionMetaType(Set.class.getName(), SERVICE_BINDING_METADATA_TYPE), new MetaValue[]{updatedOverride}));
     
      updated[indexedArray.index] = updatedBindingSet;
      newVal = new CollectionValueSupport(new CollectionMetaType(Set.class.getName(), SERVICE_BINDING_SET_TYPE), updated);
      prop.setValue(newVal);

      try
      {
         getManagementView().updateComponent(component);
View Full Code Here

      map.put("fixedHostName", SimpleValueSupport.wrap(false));
      map.put("fixedPort", SimpleValueSupport.wrap(false));
      MapCompositeValueSupport newElement = new MapCompositeValueSupport(map, SERVICE_BINDING_METADATA_TYPE);
      newElements[newElements.length - 1] = newElement;
     
      CollectionValue newVal = new CollectionValueSupport((CollectionMetaType) val.getMetaType(), newElements);
      prop.setValue(newVal);
     
      // Before passing the updated component back, store some info about
      // the binding sets so we can use it later
      prop = properties.get("bindingSets");
      assertNotNull("Missing property bindingSets", prop);
      val =  prop.getValue();
      assertNotNull("property bindingSets has no value", val);
      assertTrue("property bindingSets value is CollectionValue", val instanceof CollectionValue);
      MetaValue[] elements = ((CollectionValue) val).getElements();
      assertNotNull(elements);
     
      // Two maps we'll use
      Map<String, Integer> offsets = new HashMap<String, Integer>();
      Map<String, String> hosts = new HashMap<String, String>();
      for (MetaValue mv : elements)
      {
         String name = getSimpleValue(mv, "name", String.class);
         offsets.put(name, getSimpleValue(mv, "portOffset", Integer.class));
         hosts.put(name, getSimpleValue(mv, "defaultHostName", String.class));
      }
     
      try
      {
         getManagementView().updateComponent(component);
      }
      catch (Exception e)
      {
         log.error("Failed updating " + component, e);
         throw e;
      }
     
      // B) Validate the result of A) and MODIFY the element we added in A
     
      component = getServiceBindingManagerManagedComponent();
      properties = component.getProperties();
     
      IndexedArray indexedArray = checkAddedBinding(properties, newElements.length, 12345, offsets, hosts);
      // We'll update the component again using this MetaValue[]
      newElements = new MetaValue[indexedArray.array.length];
      System.arraycopy(indexedArray.array, 0, newElements, 0, newElements.length);
     
      MapCompositeValueSupport update = cloneCompositeValue((CompositeValue) indexedArray.array[indexedArray.index]);
      update.put("port", SimpleValueSupport.wrap(23456));
      newElements[indexedArray.index] = update;     
     
      newVal = new CollectionValueSupport((CollectionMetaType) val.getMetaType(), newElements);
      properties.get("standardBindings").setValue(newVal);
     
      // OK, now update     
      try
      {
View Full Code Here

               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
      }

      return metaValueFactory.create(value, propertyInfo.getType());
   }
View Full Code Here

         {
            List<GenericValue> tmp = getManagedObjectArray(beanInfo, property, metaData, value);
            GenericValue[] mos = new GenericValue[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
            tmp.toArray(mos);
            return new CollectionValueSupport(moType, mos);
         }
      }

      return getNonManagedObjectValue(beanInfo, property, propertyInfo, value);
   }
View Full Code Here

               ManagedObject mo = mof.initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
      }

      return metaValueFactory.create(value, propertyInfo.getType());
   }
View Full Code Here

               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
      }

      return metaValueFactory.create(value, propertyInfo.getType());
   }
View Full Code Here

      else if(type.equalsIgnoreCase("JMSMessage"))
      {
         OperationResult operationResult = new OperationResult();
         Configuration c = operationResult.getComplexResults();
         PropertyList property = new PropertyList("result");
         CollectionValueSupport valueSupport = (CollectionValueSupport) val;
         MetaValue[] msgs =  valueSupport.getElements();
         for (MetaValue mv : msgs)
         {
            CompositeValueSupport msg = (CompositeValueSupport) mv;
            org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
            property.add(p1);
            ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
            Set<String> keys = metaType.keySet();
            for (String key : keys)
            {
               SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
               p1.put(new PropertySimple(key,sattr.getValue()));
            }
         }
         c.put(property);
         return operationResult;
      }
      else if (val instanceof CompositeValueSupport)
      {
         CompositeValueSupport valueSupport = (CompositeValueSupport) val;
         if (valueSupport.containsKey("cause"))
         {
            CompositeValueSupport cause = (CompositeValueSupport) valueSupport.get("cause");
            SimpleValueSupport message = (SimpleValueSupport) cause.get("message");
            Exception exception = new Exception(message.toString());
            throw exception;
         }
         return new OperationResult("not yet");
View Full Code Here

      Method method = getClass().getMethod(methodName);
      Type type = method.getGenericReturnType();

      CollectionMetaType arrayType = assertInstanceOf(resolve(type), CollectionMetaType.class);
      MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") };
      CollectionValueSupport expected = new CollectionValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(collection, type);
      CollectionValue actual = assertInstanceOf(result, CollectionValue.class);
      getLog().debug("Collection Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

TOP

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

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.