Package org.jboss.metatype.api.values

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


      ManagedObjectFactory mof = getMOF();
      ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null);
      ManagedProperty deployments = mcfMO.getProperty("deployments");
      Object dvalue = deployments.getValue();
      assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue);
      CollectionValue cv = (CollectionValue) dvalue;
      assertEquals(1, cv.getSize());
      Object cv0 = cv.iterator().next();
      assertTrue(cv0 instanceof GenericValue);
      GenericValue gv0 = (GenericValue) cv0;
      assertTrue(gv0.getValue() instanceof ManagedObject);
      ManagedObject mo = (ManagedObject) gv0.getValue();
      assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName());
View Full Code Here


      mof.addInstanceClassFactory(dsicf);
      ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null);
      ManagedProperty deployments = mcfMO.getProperty("deployments");
      Object dvalue = deployments.getValue();
      assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue);
      CollectionValue cv = (CollectionValue) dvalue;
      assertEquals(1, cv.getSize());
      Object cv0 = cv.iterator().next();
      assertTrue(cv0 instanceof GenericValue);
      GenericValue gv0 = (GenericValue) cv0;
      assertTrue(gv0.getValue() instanceof ManagedObject);
      ManagedObject mo = (ManagedObject) gv0.getValue();
      assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName());
View Full Code Here

      assertNotNull("beanFactories MP", beanFactoriesMP);
      Object beanFactoriesMPValue = beanFactoriesMP.getValue();
      getLog().debug("beanFactories MP value: "+beanFactoriesMPValue);
      assertTrue(beanFactoriesMPValue instanceof CollectionValue);
      // The beanFactories
      CollectionValue cv = CollectionValue.class.cast(beanFactoriesMPValue);
      MetaValue[] cvs = cv.getElements();

     
      assertEquals(3, cv.getSize());
      // ABeanMetaData ManagedObject for SimpleBean#1
      MetaValue mv0 = cvs[0];
      assertTrue(mv0 instanceof GenericValue);
      GenericValue gv0 = GenericValue.class.cast(mv0);
      Object gv0Value = gv0.getValue();
      assertTrue(gv0Value instanceof ManagedObject);
      ManagedObject mo0 = ManagedObject.class.cast(gv0Value);
      assertEquals(bean1, mo0.getAttachment());
      ManagedProperty bigDecimalValueMP = mo0.getProperty("bigDecimalValue");
      assertNotNull(bigDecimalValueMP);
      assertEquals(SimpleValueSupport.wrap(new BigDecimal(123456)), bigDecimalValueMP.getValue());
      bigDecimalValueMP.setValue(SimpleValueSupport.wrap(new BigDecimal(987654)));
      assertEquals(new BigDecimal(987654), simple1.getBigDecimalValue());

      // ABeanMetaData ManagedObject for SimpleBean#2
      MetaValue mv1 = cvs[1];
      assertTrue(mv1 instanceof GenericValue);
      GenericValue gv1 = GenericValue.class.cast(mv1);
      Object gv1Value = gv1.getValue();
      assertTrue(gv1Value instanceof ManagedObject);
      ManagedObject mo1 = ManagedObject.class.cast(gv1Value);
      ManagedProperty bigDecimalValueMP1 = mo1.getProperty("bigDecimalValue");
      assertNotNull(bigDecimalValueMP1);
      assertEquals(SimpleValueSupport.wrap(new BigDecimal(222222)), bigDecimalValueMP1.getValue());
      bigDecimalValueMP1.setValue(SimpleValueSupport.wrap(new BigDecimal(12222221)));
      assertEquals(new BigDecimal(12222221), simple2.getBigDecimalValue());
     
      // ABeanMetaData ManagedObject for SimpleUnannotated#3
      MetaValue mv2 = cvs[2];
      assertTrue(mv2 instanceof GenericValue);
      GenericValue gv2 = GenericValue.class.cast(mv2);
      Object gv2Value = gv2.getValue();
      assertTrue(gv2Value instanceof ManagedObject);
      ManagedObject mo2 = ManagedObject.class.cast(gv2Value);
      ManagedProperty properties = mo2.getProperty("properties");
      assertNotNull(properties);
      assertTrue(properties.getMetaType().isCollection());
      CollectionMetaType amt = (CollectionMetaType) properties.getMetaType();
      MetaType etype = amt.getElementType();
      if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
      {
         CollectionValue avalue = (CollectionValue) properties.getValue();
         assertNotNull(avalue);
         MetaValue[] elements = avalue.getElements();
         for(int n = 0; n < avalue.getSize(); n ++)
         {
            GenericValue gv = (GenericValue) elements[n];
            ManagedObject propMO = (ManagedObject) gv.getValue();
            //...
         }
View Full Code Here

         {
            CollectionMetaType amt = (CollectionMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               CollectionValue avalue = (CollectionValue) prop.getValue();
               MetaValue[] elements = avalue.getElements();
               for(int n = 0; n < avalue.getSize(); n ++)
               {
                  GenericValue gv = (GenericValue) elements[n];
                  ManagedObject propMO = (ManagedObject) gv.getValue();
                  processManagedObject(propMO, md);
               }
View Full Code Here

      assertEquals("annotated-beans.xml has 1 ManagedObject", 1, mos.size());
      ManagedObject kdMO = mos.values().iterator().next();
      log.info("KernelDeployment.ManagedProperties: "+kdMO.getProperties());
      ManagedProperty beanFactories = kdMO.getProperty("beanFactories");
      assertNotNull(beanFactories);
      CollectionValue beanFactoriesAV = CollectionValue.class.cast(beanFactories.getValue());
      beanFactoriesAV.getMetaType();
      assertEquals("BeanFactories size", 2, beanFactoriesAV.getSize());
      GenericValue beanFactoriesGV = (GenericValue) beanFactoriesAV.getElements()[0];
      log.info("BeanFactories[0].GV: "+beanFactoriesGV);
      ManagedObject beanFactoriesMO = (ManagedObject) beanFactoriesGV.getValue();
      assertNotNull(beanFactoriesMO);
      log.info("beanFactories.ManagedProperties: "+beanFactoriesMO.getProperties());
      ManagedProperty properties = beanFactoriesMO.getProperty("properties");
      assertNotNull(properties);
      CollectionValue propertiesArray = CollectionValue.class.cast(properties.getValue());
      assertNotNull(propertiesArray);
   }
View Full Code Here

      ManagedProperty deployments = propsMap.get("deployments");
      assertNotNull(deployments);
      assertEquals("The DS connection factories", deployments.getDescription());
      MetaType deploymentsType = new CollectionMetaType(List.class.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
      assertEquals(deploymentsType, deployments.getMetaType());
      CollectionValue value = CollectionValue.class.cast(deployments.getValue());
      CollectionMetaType valueType = value.getMetaType();
      assertEquals(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, valueType.getElementType());

      assertEquals(1, value.getSize());
      // Validate the ConnMetaData ManagedObject
      GenericValue localConnMOGV = GenericValue.class.cast(value.getElements()[0]);
      ManagedObject localConnMO = ManagedObject.class.cast(localConnMOGV.getValue());
      assertEquals(ConnMetaData.class.getName(), localConnMO.getName());
      propsMap = localConnMO.getProperties();
      assertEquals(10, propsMap.size());
      log.info("ConnMetaData properties: "+propsMap);
View Full Code Here

      ManagedProperty dsDeployments = propsMap.get("deployments");
      assertNotNull(deployments);
      assertEquals("The DS connection factories", dsDeployments.getDescription());
      MetaType deploymentsType = new CollectionMetaType(List.class.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
      assertEquals(deploymentsType, dsDeployments.getMetaType());
      CollectionValue value = CollectionValue.class.cast(dsDeployments.getValue());
      CollectionMetaType valueType = value.getMetaType();
      assertEquals(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, valueType.getElementType());

      assertEquals(2, value.getSize());
      ManagedObject localConnMO = null;
      ManagedObject xaConnMO = null;
      for(Object md : value)
      {
         GenericValue tmpGV = GenericValue.class.cast(md);
View Full Code Here

         // recalculate element info, since usually more deterministic
         TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass());
         MetaType metaType = metaTypeFactory.resolve(typeInfo);
         elements[i++] = internalCreate(ce, typeInfo, metaType);            
      }
      CollectionValue result = new CollectionValueSupport(type, elements);
      mapping.put(value, result);
      return result;
   }
View Full Code Here

         CompositeValue compositeValue = (CompositeValue)metaValue;
         return unwrapComposite(compositeValue, type);
      }
      else if (metaType.isCollection())
      {
         CollectionValue collectionValue = (CollectionValue)metaValue;
         return unwrapCollection(collectionValue, type);
      }
      else if (metaType.isTable())
      {
         TableValue tableValue = (TableValue)metaValue;
View Full Code Here

      if (obj instanceof Collection == false && (obj instanceof CollectionValue) == false)
         return false;

      if (obj instanceof CollectionValue)
      {
         CollectionValue cv = (CollectionValue)obj;
         return equals(cv.getMetaType());
      }

      Collection collection = (Collection)obj;
      for(Object element : collection)
      {
View Full Code Here

TOP

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

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.