Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedObject


   {
      // 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();
     
      // create the persistence information
      TestMgtComponentImpl tComp1 = new TestMgtComponentImpl(component1);
      PersistenceRoot root = getPersistenceFactory().removeComponent(mo, tComp1);
      PersistenceRoot persisted = restore(root);
View Full Code Here


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

      // Get the components
      ManagedObject mo = createDeploymentMO();

      PersistenceRoot root = new PersistenceRoot();
     
      TestDeployment deployment = updateName(root, mo, "change1");
      mo = getMOF().initManagedObject(deployment, null);
View Full Code Here

   }
  
   protected TestDeployment updateName(PersistenceRoot root, ManagedObject mo, String name) throws Exception
   {
      Iterator<?> iterator = ((CollectionValue) mo.getProperty("components").getValue()).iterator();
      ManagedObject component = (ManagedObject) ((GenericValue) iterator.next()).getValue();
     
      component.getProperty("name").setValue(SimpleValueSupport.wrap(name));
      root = getPersistenceFactory().updateComponent(root, mo, new TestMgtComponentImpl(component));
      root = restore(root);
     
      TestDeployment deployment = createDeploymentMetaData();
      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
View Full Code Here

      super(name);
   }
  
   public void test() throws Throwable
   {
      ManagedObject mo = getMOF().initManagedObject(createMD(), null);
      assertNotNull(mo);
     
      ManagedProperty p = mo.getProperty("name");
      CompositeValue c = (CompositeValue) p.getValue();
      assertNotNull(c);
      PropertiesMetaValue properties = (PropertiesMetaValue) c.get("keyPropertyList");
      properties.put("v", "value5");

      // Assert xml information
      PersistedManagedObject restoredElement = restore(mo);
      assertNotNull(restoredElement);
     
     
      // The objectName
      PersistedProperty pp = restoredElement.getProperties().get(1);
      assertNotNull(pp);
     
      PersistedCompositeValue pcv = (PersistedCompositeValue) pp.getValue();
      assertNotNull(pcv);
     
      PersistedSimpleValue psv = (PersistedSimpleValue) pcv.getValues().get(0);
      assertEquals("domain", psv.getName());
      assertEquals("org.jboss", psv.getValue());
     
      PersistedPropertiesValue ppv = (PersistedPropertiesValue) pcv.getValues().get(1);
      assertEquals("keyPropertyList", ppv.getName());
      assertEquals(2, ppv.getEntries().size());
     
      // The other object name
      PersistedProperty po = restoredElement.getProperties().get(0);
      assertNotNull(po);
      assertTrue(po.getValue() instanceof PersistedSimpleValue);
     
      //
      ManagedObject restored = update(new ObjectNameMetaData(), restoredElement);
      assertNotNull(restored);
      ObjectNameMetaData metaData = (ObjectNameMetaData) restored.getAttachment();
      assertEquals(createObjectName("value5"), metaData.getName());

   }
View Full Code Here

      super(name);
   }
   public void testPrimitive() throws Throwable
   {
      // Create initial model
      ManagedObject mo = createPrimitiveMO();
      assertNotNull(mo);
     
      ManagedProperty p = mo.getProperty("name");
      assertNotNull(p);
      p.setValue(SimpleValueSupport.wrap("newName"));
     
      p = mo.getProperty("integer");
      p.setValue(SimpleValueSupport.wrap(111));
     
      mo.getProperty("optionalName").setValue(SimpleValueSupport.wrap("optional"));
     
      // Assert the restored information
      PersistedManagedObject restored = restore(mo);
      assertNotNull(restored);
     
      mo = update(new PrimitiveMetaData(), restored);
     
      assertEquals("newName", getMVF().unwrap(mo.getProperty("name").getValue()));
      SimpleValue integer = (SimpleValue) mo.getProperty("integer").getValue();
      assertEquals(111, getMVF().unwrap(integer));
      assertTrue("actual " + integer , SimpleMetaType.INTEGER_PRIMITIVE.isValue(integer));
      assertEquals("optional", ((SimpleValue) mo.getProperty("optionalName").getValue()).getValue());
     
   }
View Full Code Here

     
   }
  
   public void testMetaDataPrimitive() throws Throwable
   {
      ManagedObject mo = createTestMetaDataMO();
      assertNotNull(mo);
      ManagedProperty p = mo.getProperty("primitive");
      assertNotNull(p);
     
      CompositeValue nested = (CompositeValue) p.getValue();
      MetaValue name = nested.get("name");
      assertNotNull(name);
      MetaValue integer = nested.get("integer");
      assertNotNull(integer);

      // Change values
      Map<String, MetaValue> changedMap = new HashMap<String, MetaValue>();
      changedMap.put("name", new SimpleValueSupport(
            (SimpleMetaType) name.getMetaType(), "newName"));
      changedMap.put("integer", new SimpleValueSupport(
            (SimpleMetaType) integer.getMetaType(), 111));
     
      // Set new values
      p.setValue(
            new CompositeValueSupport(nested.getMetaType(), changedMap)
            );

      // Save and restore
      PersistedManagedObject restored = restore(mo);
      assertNotNull(restored);
     
      // Create empty
      mo = update(new TestMetaData(), restored);
     
      p = mo.getProperty("primitive");
      nested = (CompositeValue) p.getValue();
      name = nested.get("name");
      assertNotNull(name);
      integer = nested.get("integer");
      assertNotNull(integer);
View Full Code Here

   }
  
  
   public void testMetaDataMap() throws Throwable
   {
      ManagedObject mo = createTestMetaDataMO();
      assertNotNull(mo);
     
      ManagedProperty p = mo.getProperty("testMap");
      assertNotNull(p);
     
      MapCompositeValueSupport composite = (MapCompositeValueSupport) p.getValue();
      assertNotNull(composite);
     
      SimpleValue v = (SimpleValue) composite.get("testString2");
      assertNotNull(v);
     
      composite.put("testString2", SimpleValueSupport.wrap("changedString"));
     
      PersistedManagedObject restored = restore(mo);
      assertNotNull(restored);
     
      mo = update(new TestMetaData(), restored);
     
      p = mo.getProperty("testMap");
      assertNotNull(p);
     
      CompositeValue changedComposite = (CompositeValue) p.getValue();
      assertNotNull(changedComposite);
     
View Full Code Here

      assertEquals("changedString", v.getValue());
   }
  
   public void testPrimitiveArray() throws Throwable
   {
      ManagedObject mo = createTestMetaDataMO();
      assertNotNull(mo);
     
      ManagedProperty p = mo.getProperty("charArray");
      assertNotNull(p);
     
      ArrayValue a = (ArrayValue) p.getValue();
      assertNotNull(a);
     
      SimpleValueSupport svs = (SimpleValueSupport) a.getValue(1);
      assertNotNull(svs);
      svs.setValue('H');
     
      PersistedManagedObject restored = restore(mo);
      assertNotNull(restored);
     
      //
      mo = update(new TestMetaData(), restored);
     
      p = mo.getProperty("charArray");
      assertNotNull(p);
     
      a = (ArrayValue) p.getValue();
      assertNotNull(a);
     
View Full Code Here

      List<PersistedComponent> components = new ArrayList<PersistedComponent>();
      ManagedObjectPersistencePlugin plugin = getPersistenceFactory().getPersistencePlugin();
      for(ServiceMetaData md : deployment.getServices())
      {
         // Bypass the ServiceMetaDataICF...
         ManagedObject mo = getMOF().initManagedObject(md, null);
         PersistedManagedObject persisted = plugin.createPersistedManagedObject(mo);
        
         // Fix the names, as we don't use the ServiceMetaDataICF
         String name = md.getObjectName().getCanonicalName();
         persisted.setName(name);
View Full Code Here

     
      @Override
      protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
      {
         // Note: this is using the TestMgtComponentImpl to get the MO
         ManagedObject mo = (ManagedObject) component.getParent();
         PersistedManagedObject persisted = getPersistencePlugin().createPersistedManagedObject(mo);
         PersistedComponent persistedComponent = new PersistedComponent(persisted);
         setComponentName(persistedComponent, mo);
         return persistedComponent;
      }
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.