Package org.jboss.system.metadata

Examples of org.jboss.system.metadata.ServiceValueMetaData


      assertDependencyListValue(value, new ObjectName[] { TEST1, TEST2 });
   }

   public void testDependencyListNested() throws Exception
   {
      ServiceValueMetaData value = unmarshallSingleValue();
      assertDependencyListValue(value, TEST1);
   }
View Full Code Here


      super(name);
   }

   public void testDependency() throws Exception
   {
      ServiceValueMetaData value = unmarshallSingleValue();
      assertDependencyValue(value, TEST1);
   }
View Full Code Here

      assertDependencyValue(value, TEST1);
   }

   public void testDependencyProxyType() throws Exception
   {
      ServiceValueMetaData value = unmarshallSingleValue();
      assertDependencyValue(value, TEST1, "ProxyType");
   }
View Full Code Here

      assertDependencyValue(value, TEST1, "ProxyType");
   }

   public void testDependencyNested() throws Exception
   {
      ServiceValueMetaData value = unmarshallSingleValue();
      assertDependencyValue(value, TEST1);
   }
View Full Code Here

      super(name);
   }

   public void testText() throws Exception
   {
      ServiceValueMetaData value = unmarshallSingleValue();
      assertTextValue(value, "value");
   }
View Full Code Here

      else
      {
         assertNotNull(restored.getValue());
      }
     
      ServiceValueMetaData value = original.getValue();
      // TODO we need some MetaMapping for attributes
      assertEquals(original.getName(), value.getClass().getName(), restored.getValue().getClass().getName());
   }
View Full Code Here

         String name = property.getMappedName();
         if (name == null)
            property.getName();
  
         // Get the attribute value
         ServiceValueMetaData attributeValue = null;
         for (ServiceAttributeMetaData amd : md.getAttributes())
         {
            // The compare is case-insensitive due to the attribute/javabean case mismatch
            if (amd.getName().equalsIgnoreCase(name))
            {
               attributeValue = amd.getValue();
               break;
            }
         }

         // Unwrap
         PropertyInfo propertyInfo = beanInfo.getProperty(name);
         Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
        
         // There may not be an attribute value, see if there is a matching property
         if (attributeValue == null)
         {
            // FIXME ignore null values
            if(plainValue == null) return;
           
            String aname = mapAttributeName(md, name);
            if(aname != null)
            {
               ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
               attr.setName(aname);
               md.addAttribute(attr);
               attributeValue = new ServiceTextValueMetaData("");
               attr.setValue(attributeValue);
            }
         }
         if (attributeValue != null)
         {
            // Unwrap the ServiceValueMetaData types
            if (attributeValue instanceof ServiceTextValueMetaData)
            {
               ServiceTextValueMetaData text = (ServiceTextValueMetaData) attributeValue;
               text.setText(String.valueOf(plainValue));
            }
            else if (value instanceof ServiceDependencyValueMetaData)
            {
               ServiceDependencyValueMetaData depends = (ServiceDependencyValueMetaData) attributeValue;
               depends.setDependency(String.valueOf(plainValue));
            }
            // TODO: unwrap other ServiceValueMetaData types
            else
            {
               throw new IllegalArgumentException("Unhandled attribute value type: " + name + "/" + md+", class="+attributeValue.getClass());              
            }
         }
         else
            throw new IllegalArgumentException("No matching attribute found: " + name + "/" + md);
      }
View Full Code Here

         String name = property.getMappedName();
         if (name == null)
            property.getName();
  
         // Get the attribute value
         ServiceValueMetaData attributeValue = null;
         for (ServiceAttributeMetaData amd : md.getAttributes())
         {
            // The compare is case-insensitive due to the attribute/javabean case mismatch
            if (amd.getName().equalsIgnoreCase(name))
            {
               attributeValue = amd.getValue();
               break;
            }
         }

         // Unwrap
         PropertyInfo propertyInfo = beanInfo.getProperty(name);
         Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
        
         // There may not be an attribute value, see if there is a matching property
         if (attributeValue == null)
         {
            // FIXME ignore null values
            if(plainValue == null) return;
           
            String aname = mapAttributeName(md, name);
            if(aname != null)
            {
               ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
               attr.setName(aname);
               md.addAttribute(attr);
               attributeValue = new ServiceTextValueMetaData("");
               attr.setValue(attributeValue);
            }
         }
         if (attributeValue != null)
         {
            // Unwrap the ServiceValueMetaData types
            if (attributeValue instanceof ServiceTextValueMetaData)
            {
               ServiceTextValueMetaData text = (ServiceTextValueMetaData) attributeValue;
               text.setText(String.valueOf(plainValue));
            }
            else if (value instanceof ServiceDependencyValueMetaData)
            {
               ServiceDependencyValueMetaData depends = (ServiceDependencyValueMetaData) attributeValue;
               depends.setDependency(String.valueOf(plainValue));
            }
            // TODO: unwrap other ServiceValueMetaData types
            else
            {
               throw new IllegalArgumentException("Unhandled attribute value type: " + name + "/" + md+", class="+attributeValue.getClass());              
            }
         }
         else
            throw new IllegalArgumentException("No matching attribute found: " + name + "/" + md);
      }
View Full Code Here

         String name = property.getMappedName();
         if (name == null)
            name = property.getName();
  
         // Get the attribute value
         ServiceValueMetaData attributeValue = null;
         for (ServiceAttributeMetaData amd : md.getAttributes())
         {
            // The compare is case-insensitive due to the attribute/javabean case mismatch
            if (amd.getName().equalsIgnoreCase(name))
            {
               attributeValue = amd.getValue();
               break;
            }
         }
         // There may not be an attribute value, see if there is a matching property
        
         // Unwrap the value before, so that we can recreate empty values
         Object plainValue = null;
         // Look for a MetaMapper
         MetaType propertyType = property.getMetaType();
         MetaMapper metaMapper = property.getTransientAttachment(MetaMapper.class);
         Type mappedType = null;
         if(metaMapper != null)
         {
            mappedType = metaMapper.mapToType();
            plainValue = metaMapper.unwrapMetaValue(value);
         }
         else
         {
            PropertyInfo propertyInfo = beanInfo.getProperty(name);
            plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
         }

         if (attributeValue == null)
         {
            String aname = mapAttributeName(md, name);
            if(aname != null)
            {
               ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
               attr.setName(aname);
               // Check if this is mapped to a Element
               if(mappedType != null && mappedType.equals(Element.class))
               {
                  attributeValue = new ServiceElementValueMetaData();
               }
               else if(plainValue != null)
               {                
                  // Create a text value
                  String textValue = String.valueOf(plainValue);
                  // Don't create a empty value
                  if(textValue.trim().length() > 0 )
                     attributeValue = new ServiceTextValueMetaData(textValue);
               }
               // Don't create a null serviceAttribute
               if(attributeValue == null)
                  return;
              
               // Add
               attr.setValue(attributeValue);
               md.addAttribute(attr);
            }
         }
         if (attributeValue != null)
         {
            // Unwrap the ServiceValueMetaData types
            if (attributeValue instanceof ServiceTextValueMetaData)
            {
               String textValue = plainValue != null ? String.valueOf(plainValue) : null;
               ServiceTextValueMetaData text = (ServiceTextValueMetaData) attributeValue;
               text.setText(textValue);
            }
            else if (attributeValue instanceof ServiceElementValueMetaData)
            {
               if(plainValue != null)
                  ((ServiceElementValueMetaData) attributeValue).setElement((Element) plainValue);
            }
            else if (attributeValue instanceof ServiceDependencyValueMetaData)
            {
               ServiceDependencyValueMetaData depends = (ServiceDependencyValueMetaData) attributeValue;
               if (plainValue instanceof ObjectName)
                  depends.setObjectName((ObjectName) plainValue);
               else
                  depends.setDependency(String.valueOf(plainValue));
            }
            // TODO: unwrap other ServiceValueMetaData types
            else
            {
               throw new IllegalArgumentException("Unhandled attribute value type: " + name + "/" + md+", class="+attributeValue.getClass());              
            }
         }
         else
            throw new IllegalArgumentException("No matching attribute found: " + name + "/" + md);
      }
View Full Code Here

/* 155 */     String name = property.getMappedName();
/* 156 */     if (name == null) {
/* 157 */       property.getName();
/*     */     }
/*     */
/* 160 */     ServiceValueMetaData attributeValue = null;
/* 161 */     for (ServiceAttributeMetaData amd : md.getAttributes())
/*     */     {
/* 164 */       if (amd.getName().equalsIgnoreCase(name))
/*     */       {
/* 166 */         attributeValue = amd.getValue();
View Full Code Here

TOP

Related Classes of org.jboss.system.metadata.ServiceValueMetaData

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.