Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedObject


   @Override
   protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
   {
      // Note: this is using the TestMgtComponentImpl to get the MO
      ManagedObject mo = (ManagedObject) component.getParent();
      PersistedManagedObject persistedMO = getPersistencePlugin().createPersistedManagedObject(mo);
      PersistedComponent persisted = new PersistedComponent(persistedMO);
      setComponentName(persisted, mo);
      return persisted;
   }
View Full Code Here


      super(name);
   }

   public void test() throws Throwable
   {
      ManagedObject mo = initMO();
     
      ManagedProperty p = mo.getProperty("map");
      assertNotNull(p);
      MapCompositeValueSupport value = (MapCompositeValueSupport) p.getValue();
      assertNotNull(value);
      assertNotNull(value.get("test1"));
      getLog().debug("keys: " + value.getMetaType().itemSet());
     
      enableTrace("org.jboss.system");
      PersistedManagedObject moElement = restore(mo);
      assertNotNull(moElement);
     
      ManagedObject restored = update(new SimpleStringMapMetaData(), moElement);
      assertNotNull(restored);
      SimpleStringMapMetaData metadata = (SimpleStringMapMetaData) restored.getAttachment();
      assertTrue(metadata.getMap().equals(initMap()));
   }
View Full Code Here

      return (PersistedManagedObject) un.unmarshal(file);
   }
  
   protected ManagedObject update(Object attachment, PersistedManagedObject moElement)
   {
      ManagedObject mo = getMOF().initManagedObject(attachment, null);
      return update(mo, moElement);
   }
View Full Code Here

      super(name);
   }
  
   public void testSimpleArray() throws Throwable
   {
      ManagedObject mo = initMO();
      PersistedManagedObject moElement = restore(mo);
     
      assertNotNull(moElement);
      ManagedObject restored = update(new SimpleArrayMetaData(), moElement);
     
      assertNotNull(restored.getProperties());
      assertEquals(3, restored.getProperties().size());
     
      // Test 1D
      ArrayValue test1D = (ArrayValue) restored.getProperty("test1D").getValue();
      assertNotNull(test1D);
     
      char[] unwrapped1D = (char[]) getMVF().unwrap(test1D);
      assertNotNull(unwrapped1D);
      assertTrue(Arrays.equals(init1D(), unwrapped1D));
     
      // Test 2D
      ArrayValue test2D = (ArrayValue) restored.getProperty("test2D").getValue();
      assertNotNull(test2D);
      assertEquals(2, test2D.getMetaType().getDimension());
     
      char[][] unwrapped2D = (char[][]) getMVF().unwrap(test2D);
      assertNotNull(unwrapped2D);
      assertEquals(2, unwrapped2D.length);
      assertEquals('a', unwrapped2D[0][0]);
      assertEquals('f', unwrapped2D[1][1]);

      // Test 3D
      ArrayValue test3D = (ArrayValue) restored.getProperty("test3D").getValue();
      assertNotNull(test3D);
      assertEquals(3, test3D.getMetaType().getDimension());

      char[][][] unwrapped3D = (char[][][]) getMVF().unwrap(test3D);
      assertNotNull(unwrapped3D);
View Full Code Here

      super(name);
   }

   public void test() throws Throwable
   {
      ManagedObject mo = createTestMO();

      CollectionValue collection = (CollectionValue) mo.getProperty("list").getValue();
      ManagedObject child2 = (ManagedObject) ((GenericValue) collection.getElements()[1]).getValue();
      child2.getProperty("string").setValue(SimpleValueSupport.wrap("changedName"));
      // TODO test generic array
     
      PersistedManagedObject moElement = restore(mo);

      ManagedObject restored = update(new GenericSupportMetaData(), moElement);

      GenericSupportMetaData md = (GenericSupportMetaData) restored.getAttachment();
      assertNotNull(md);
     
      SimpleGenericMetaData child = md.getList().get(1);
      assertEquals(child.getString(), "changedName");
   }
View Full Code Here

      super(name);
   }

   public void testSimpleTableValue() throws Throwable
   {
      ManagedObject mo = initMO();
      assertNotNull(mo);

      // Restore
      PersistedManagedObject moElement = restore(mo);
      assertNotNull(moElement);
      assertNotNull(moElement.getProperties());

      // Recreate MO
      ManagedObject restored = update(new SimpleTableMetaData(), moElement);

      // Assert
      ManagedProperty p = restored.getProperty("map");
      assertTrue(p.getValue() instanceof TableValue);
      assertTrue(p.getMetaType() instanceof TableMetaType);
     
      TableValue table = (TableValue) p.getValue();
      assertRow(table, 1, "one");
      assertRow(table, 2, "two");
      assertRow(table, 3, "three");
     
      SimpleTableMetaData metaData = (SimpleTableMetaData) restored.getAttachment();
      assertTrue(metaData.getMap().equals(initMap()));
   }
View Full Code Here

      super(name);
   }

   public void test() throws Throwable
   {
      ManagedObject mo = createNestedMO();
     
      // deployment1
      ManagedObject deployment = getDeployment("testDeployment1", mo);
      assertNotNull(deployment);
      deployment.getProperty("");
     
      ManagedProperty p = deployment.getProperty("primitive");
      assertNotNull(p);
     
      CompositeValue composite = (CompositeValue) p.getValue();
     
      Map<String, MetaValue> valueMap = new HashMap<String, MetaValue>();
      valueMap.put("optionalName",
            new SimpleValueSupport(SimpleMetaType.STRING, "changed"));
      valueMap.put("integer", new SimpleValueSupport(
            SimpleMetaType.INTEGER_PRIMITIVE, 111));

      //
      p.setValue(new CompositeValueSupport(composite.getMetaType(), valueMap));

      ManagedProperty property = deployment.getProperty("name");
      assertNotNull(property);
      property.setValue(SimpleValueSupport.wrap("ChangedName"));
     
      // deployment3
      deployment = getDeployment("testDeployment3", mo);
      assertNotNull(deployment);
     
      property = deployment.getProperty("name");
      assertNotNull(property);
      property.setValue(SimpleValueSupport.wrap("ChangedName3"));

      PersistedManagedObject restored = restore(mo);
      assertNotNull(restored);
      PersistedCollectionValue collection = (PersistedCollectionValue) restored.getProperties().get(0).getValue();
      assertNotNull(collection);
      PersistedManagedObject o = ((PersistedGenericValue) collection.getValues().get(0)).getManagedObject();
      assertNotNull(o);
     
      enableTrace("org.jboss.system.server.profileservice.persistence");

      // Recreate
      mo = update(createNestedTestMetaData(), restored);
     
      deployment = getDeployment("ChangedName", mo);
      assertNotNull("changed name deployment null", deployment);
     
      p = deployment.getProperty("primitive");
      assertNotNull(p);
     
      composite = (CompositeValue) p.getValue();
      assertNotNull(composite);
     
View Full Code Here

      assertNotNull("null collection", collection);
      assertEquals(3, collection.getSize());;
     
      for(MetaValue value : collection)
      {        
         ManagedObject deployment = (ManagedObject) ((GenericValue) value).getValue();
        
         ManagedProperty nameProp = deployment.getProperty("name");
         assertNotNull(nameProp);
        
         String deploymentName = (String) ((SimpleValue) deployment.getProperty("name").getValue()).getValue();
        
         if(name.equals(deploymentName))
            return deployment;
      }
      return null;
View Full Code Here

      TestComponent addComponent = createComponentMetaData("component3",
            new ObjectName("org.jboss:type=testComponent3"),
            createCompositeMetaData("composite3", 'c', new Integer(3)));
     
      ManagedObject temp = getMOF().initManagedObject(addComponent, null);
      ManagedComponent component = new TestMgtComponentImpl(temp);
     
      ManagedObject mo = createDeploymentMO();
      PersistenceRoot root = getPersistenceFactory().addComponent(mo, component);
     
      root = restore(root);
     
      TestDeployment attachment = createDeploymentMetaData();
View Full Code Here

   {
      // Add the component mapper
      addComponentMapper(new TestComponentMapper(getPersistenceFactory()));

      // Get the components
      ManagedObject mo = createDeploymentMO();
      Iterator<?> iterator = ((CollectionValue) mo.getProperty("components").getValue()).iterator();
      ManagedObject component1 = (ManagedObject) ((GenericValue) iterator.next()).getValue();
      ManagedObject component2 = (ManagedObject) ((GenericValue) iterator.next()).getValue();
     
      // create the persistence information
      TestMgtComponentImpl tComp1 = new TestMgtComponentImpl(component1);
      PersistenceRoot root = getPersistenceFactory().updateComponent(mo, tComp1);
      TestMgtComponentImpl tComp2 = new TestMgtComponentImpl(component2);
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.ManagedObject

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.