Package org.jboss.metatype.api.values

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


         return null;
     
      if (value instanceof Serializable == false)
         throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());

      GenericValue result = new GenericValueSupport(type, (Serializable) value);
      mapping.put(value, result);
      return result;
   }
View Full Code Here


      ManagedProperty destinationsMP = mo.getProperty("destinations");
      assertNotNull(destinationsMP);
      CollectionValue destinationsValue = (CollectionValue) destinationsMP.getValue();
      assertNotNull(destinationsValue);
      assertEquals(1, destinationsValue.getSize());
      GenericValue q1GV = (GenericValue) destinationsValue.getElements()[0];
      assertNotNull(q1GV);
      ManagedObject q1MO = (ManagedObject) q1GV.getValue();
      assertNotNull(q1MO);

      ComponentType type = new ComponentType("JMSDestination", "queue");
      RunStateMapper stateMapper = null;
      ManagedComponentImpl mc = new ManagedComponentImpl(type, md, q1MO, stateMapper);
View Full Code Here

         return null;
     
      if (value instanceof Serializable == false)
         throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());

      GenericValue result = new GenericValueSupport(type, (Serializable) value);
      mapping.put(value, result);
      return result;
   }
View Full Code Here

    */
   public void testGeneric() throws Exception
   {
      TestGeneric test = new TestGeneric("Hello");
      GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
      GenericValue expected = new GenericValueSupport(generic, test);
     
      MetaValue result = createMetaValue(test);
      GenericValue actual = assertInstanceOf(result, GenericValue.class);
      getLog().debug("Generic: " + actual);
      assertEquals(expected, actual);
   }
View Full Code Here

   {
      TestGeneric test = new TestGeneric("Hello");
      TestGenericComposite composite = new TestGenericComposite();
      composite.setGeneric(test);
      GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
      GenericValue genericValue = new GenericValueSupport(generic, test);
      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestGenericComposite.class.getName(), TestGenericComposite.class.getName());
      compositeType.addItem("generic", "generic", generic);
      compositeType.freeze();
      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
      expected.set("generic", genericValue);
View Full Code Here

   public void setValue(BeanInfo beanInfo, ManagedProperty property,
         JmsDestination object, MetaValue value)
   {
      if(property.getName().equals("domain"))
      {
         GenericValue gv = (GenericValue) value;
         ManagedObject mo = (ManagedObject) gv.getValue();
         // Create the correct type of
         ManagedProperty type = mo.getProperty("securityDeploymentType");
         ManagedProperty domain = mo.getProperty("domain");
         String domainName = ((SimpleValue) domain.getValue()).getValue().toString();
         EnumValue typeValue = (EnumValue) type.getValue();
View Full Code Here

      ManagedProperty destinationsMP = managedObject.getProperty("destinations");
      assertNotNull(destinationsMP);
      CollectionValue destinationsValue = (CollectionValue) destinationsMP.getValue();
      assertNotNull(destinationsValue);
      assertEquals(1, destinationsValue.getSize());
      GenericValue q1GV = (GenericValue) destinationsValue.getElements()[0];
      assertNotNull(q1GV);

      ManagedObject q1MO = (ManagedObject) q1GV.getValue();
      assertNotNull(q1MO);
      ManagedProperty domain = q1MO.getProperty("domain");
      getLog().info(domain);
      GenericValue domainGV = (GenericValue) domain.getValue();
      assertNotNull(domainGV);
      ManagedObject domainMO = (ManagedObject) domainGV.getValue();
      assertNotNull(domainMO);

      ManagedProperty domainName = domainMO.getProperty("domain");
      assertEquals(SimpleValueSupport.wrap("java:/jaas/JMS"), domainName.getValue());

      ManagedObject domainUpdateMO = initManagedObject(new SecurityDomain("java:/jaas/JMS2"));
      DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory(mof);
      GenericValue domainUpdateGV = icf.getManagedObjectValue(domain, domainUpdateMO);
      assertNotNull(domainUpdateGV.getValue());
      domain.setValue(domainUpdateGV);
      // Validate this has been written through
      assertEquals("java:/jaas/JMS2", q1.getDomain().getDomain());
   }
View Full Code Here

      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());
      assertEquals(mcfMO, mo.getParent());

      // Validate the security-domain
      ManagedProperty secDomain = mo.getProperty("security-domain");
      assertNotNull("security-domain", secDomain);
      GenericValue sdGV = (GenericValue) secDomain.getValue();
      assertNotNull("security-domain.GV", sdGV);
      ManagedObject secDomainMO = (ManagedObject) sdGV.getValue();

      assertNotNull("security-domain.MO", secDomainMO);
      assertEquals(mo, secDomainMO.getParent());
      ManagedProperty domainName = secDomainMO.getProperty("domain");
      assertNotNull("security-domain.MO.domain", domainName);
View Full Code Here

      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());

      ManagedProperty cpMP = mo.getProperty("config-property");
      assertNotNull("config-property", cpMP);
      assertTrue("config-property("+cpMP+") isa ConnectionFactoryProperty", cpMP instanceof ConnectionFactoryProperty);
View Full Code Here

     
      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

TOP

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

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.