Package org.jboss.metatype.api.values

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


   protected void setPortValue(String name, CollectionValue values, int port)
   {
      boolean found = false;
      for(MetaValue v : values.getElements())
      {
         MapCompositeValueSupport c = (MapCompositeValueSupport) v;
         SimpleValue bindingName = (SimpleValue)c.get("bindingName");
         if(bindingName != null && bindingName.getValue().equals(name))
         {
            found = true;
            c.put("port", SimpleValueSupport.wrap(port));
         }
      }
      assertTrue("found "+ name, found);
   }
View Full Code Here


         Map<String, MetaValue> map = new HashMap<String, MetaValue>();
         for (String key : type.keySet())
         {
            map.put(key, toClone.get(key));
         }
         return new MapCompositeValueSupport(map, type);
      }
   }
View Full Code Here

         Map<String, MetaValue> map = new HashMap<String, MetaValue>();
         for (String key : type.keySet())
         {
            map.put(key, toClone.get(key));
         }
         return new MapCompositeValueSupport(map, type);
      }
   }
View Full Code Here

      MetaValue metaValue = this.compositeValueMap(xaProps);
      propValues.put("config-property", metaValue);

      propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
      propValues.put("config-property",
            new MapCompositeValueSupport(new HashMap<String, MetaValue>(),
                  new MapCompositeMetaType(SimpleMetaType.STRING)));
      // todo: how to set the specific domain?
      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
      //props.get("security-domain").setValue(secDomain);

      ComponentType compType = new ComponentType("ConnectionFactory", "NoTx");
      createComponentTest("NoTxConnectionFactoryTemplate", propValues, "testNoTxCf", compType, jndiName);

      // Validate the config-property
      ManagementView mgtView = getManagementView();
      ManagedComponent dsMC = getManagedComponent(mgtView, compType, jndiName);
      ManagedProperty configProperty = dsMC.getProperty("config-property");
      assertNotNull(configProperty);
      MetaValue value = configProperty.getValue();
      assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
     
      MapCompositeValueSupport cValue = (MapCompositeValueSupport) value;
      cValue.put("testKey", new SimpleValueSupport(SimpleMetaType.STRING, "testValue"));
     
      mgtView.updateComponent(dsMC);

      mgtView = getManagementView();
      dsMC = getManagedComponent(mgtView, compType, jndiName);
      configProperty = dsMC.getProperty("config-property");
      assertNotNull(configProperty);
      cValue = (MapCompositeValueSupport) configProperty.getValue();
      assertNotNull(cValue.get("testKey"));
   }
View Full Code Here

   public MapCompositeValueSupport compositeValueMap(Map<String,String> map)
   {
      // TODO: update MetaValueFactory for MapCompositeMetaType
      // MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
      MapCompositeValueSupport metaValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
      for(String key : map.keySet())
      {
         MetaValue value = SimpleValueSupport.wrap(map.get(key));
         metaValue.put(key, value);
      }

      return metaValue;
   }
View Full Code Here

         assertNotNull(queue);
        
         Map<String, MetaValue> values = new HashMap<String, MetaValue>();
         values.put("admin", createCompositeValue(true, true, true));
         values.put("user", createCompositeValue(false, false, false));
         MapCompositeValueSupport map = new MapCompositeValueSupport(values, securityConfType);
        
         ManagedProperty p = queue.getProperty("securityConfig");
         assertNotNull("security config property", p);
         MetaValue v = p.getValue();
         assertNotNull("securityConfig", v);
         //
         assertTrue("security equals", map.equals(v));
      }
      finally
      {
         undeployPackage(new String[] { deploymentName });
      }
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);
View Full Code Here

      map.put("bindingName", SimpleValueSupport.wrap("bindingName"));
      map.put("description", SimpleValueSupport.wrap("description"));
      map.put("port", SimpleValueSupport.wrap(12345));
      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);
     
View Full Code Here

         Map<String, MetaValue> map = new HashMap<String, MetaValue>();
         for (String key : type.keySet())
         {
            map.put(key, toClone.get(key));
         }
         return new MapCompositeValueSupport(map, type);
      }
   }
View Full Code Here

      ManagedComponent queue = mgtView.getComponent("testQueueTemplate", type);
      assertNotNull(queue);
      assertEquals("testQueueTemplate", queue.getName());
     
      // Test with a empty value
      queue.getProperty("securityConfig").setValue(new MapCompositeValueSupport(new HashMap<String, MetaValue>(), securityConfType));
      mgtView.updateComponent(queue);
     
      //
      mgtView = getManagementView();
      queue = mgtView.getComponent("testQueueTemplate", type);
     
      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
      values.put("admin", createCompositeValue(true, true, true));
      values.put("publisher", createCompositeValue(true, true, false));
      values.put("user", createCompositeValue(false, false, false));
      MapCompositeValueSupport map= new MapCompositeValueSupport(values, securityConfType);

      // Test a normal value
      queue.getProperty("securityConfig").setValue(map);
      mgtView.updateComponent(queue);

      mgtView = getManagementView();
      queue = mgtView.getComponent("testQueueTemplate", type);
      MapCompositeValueSupport securityConfig = (MapCompositeValueSupport) queue.getProperty("securityConfig").getValue();
      assertEquals(map, securityConfig);
     
      securityConfig.remove("publisher");
     
      // Test remove
      mgtView.updateComponent(queue);
      securityConfig = (MapCompositeValueSupport) queue.getProperty("securityConfig").getValue();
      assertNotNull(securityConfig);
      assertNull(securityConfig.get("publisher"));
     
   }
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.