[jboss-cvs] JBossAS SVN: r87523 - in projects/jboss-man/trunk: managed/src/main/java/org/jboss/managed/api/annotation and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 18 22:19:21 EDT 2009


Author: scott.stark at jboss.org
Date: 2009-04-18 22:19:21 -0400 (Sat, 18 Apr 2009)
New Revision: 87523

Added:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/CustomPropsBuilder.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/DefaultsBean.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigDecimalDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigIntegerDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanPrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ByteDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BytePrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharPrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoubleDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoublePrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatPrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntPrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongPrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ObjectNameDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesCompositeObjectNameDefaultBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesObjectNameDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortPrimitiveDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/SimpleDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringDefaultValueBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringObjectNameDefaultBuilder.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java
Modified:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/Fields.java
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
   projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java
Log:
JBMAN-77, add a default value notion to ManagedProperty

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/Fields.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/Fields.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/Fields.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -53,6 +53,9 @@
    String LEGAL_VALUES = "legalValues";
 
    /** The minimum value */
+   String DEFAULT_VALUE = "defaultValue";
+
+   /** The minimum value */
    String MINIMUM_VALUE = "minValue";
 
    /** The maximum value */

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -172,6 +172,12 @@
    Set<MetaValue> getLegalValues();
 
    /**
+    * Get the property default value if one exists.
+    * @return the default value if one exists, null otherwise.
+    */
+   MetaValue getDefaultValue();
+
+   /**
     * Get the minimum value
     * 
     * @return the minimum value, a MetaValue implementing Comparable

Added: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+
+/**
+ * An annotation describing the DefaultValueBuilder implementation
+ * for a property.
+ * This can be used on fields, methods for an individual property
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at Target({ElementType.METHOD, ElementType.FIELD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface DefaultValueBuilderFactory
+{
+   /** The constraints, allowed values populator factory */
+   Class<? extends DefaultValueBuilder> value();
+}

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -28,8 +28,14 @@
 import java.lang.annotation.Target;
 
 /**
- * ManagementProperty annotation for describing a ManagedProperty
+ * ManagementProperty annotation for describing a ManagedProperty. Additional
+ * annotations that can be used on a property to control the behavior of the
+ * property include:
  * 
+ * {@linkplain ConstraintsPopulatorFactory}
+ * {@linkplain Masked}
+ * {@linkplain org.jboss.metatype.api.annotations.MetaMapping}
+ * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @author Scott.Stark at jboss.org
  * @version $Revision$
@@ -65,6 +71,10 @@
    /** Whether this property should be included in a deployment template */
    boolean includeInTemplate() default false;
 
+   /** A string representation of the property default value if not empty
+    */
+   String defaultValue() default AnnotationDefaults.EMPTY_STRING;
+
    /** The views this property should be used in */
    ViewUse[] use() default {ViewUse.CONFIGURATION};
 

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -358,6 +358,12 @@
       setField(Fields.LEGAL_VALUES, (Serializable)values);
    }
 
+   public MetaValue getDefaultValue()
+   {
+      MetaValue field = getField(Fields.DEFAULT_VALUE, MetaValue.class);
+      return field;
+   }
+
    public Comparable<MetaValue> getMinimumValue()
    {
       return getField(Fields.MINIMUM_VALUE, Comparable.class);

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -47,6 +47,7 @@
 import org.jboss.managed.api.annotation.ActivationPolicy;
 import org.jboss.managed.api.annotation.AnnotationDefaults;
 import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
+import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
 import org.jboss.managed.api.annotation.FieldsFactory;
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementConstants;
@@ -88,7 +89,30 @@
 import org.jboss.metatype.api.types.GenericMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.plugins.values.defaults.BigDecimalDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BigIntegerDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BooleanDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BooleanPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.ByteDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BytePrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.CharDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.CharPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.DoubleDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.DoublePrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.FloatDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.FloatPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.IntDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.IntPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.LongDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.LongPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.PropertiesDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.ShortDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.ShortPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.StringDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.StringObjectNameDefaultBuilder;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
 import org.jboss.metatype.spi.values.MetaMapper;
 import org.jboss.metatype.spi.values.MetaMapperFactory;
 import org.jboss.reflect.spi.AnnotatedInfo;
@@ -131,6 +155,9 @@
    /** The instance to class factories */
    private Map<Class<?>, InstanceClassFactory<?>> instanceFactories = new WeakHashMap<Class<?>, InstanceClassFactory<?>>();
 
+   /** The default value builders */
+   private Map<MetaType, DefaultValueBuilder> defaultBuilders = new HashMap<MetaType, DefaultValueBuilder>();
+
    /**
     * Create a ManagedProperty by looking to the factory for ctor(Fields)
     * @param factory - the ManagedProperty implementation class
@@ -168,6 +195,7 @@
       defaultInstanceFactory = icf;
       // Create an AbstractManagedObjectPopulator as the default
       defaultManagedObjectPopulator = new AbstractManagedObjectPopulator<Serializable>(configuration, icf, instanceFactories);
+      initDefaultValueBuilders();
    }
    /**
     * Create an AbstractManagedObjectFactory the given factories, supporting
@@ -193,6 +221,7 @@
       this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
       this.builders = builders;
       this.instanceFactories = instanceFactories;
+      initDefaultValueBuilders();
    }
 
    /**
@@ -221,6 +250,29 @@
       setBuilder(definition.getType(), null);
    }
 
+   public void addDefaultValueBuilder(DefaultValueBuilder builder)
+   {
+      if(builder == null)
+         throw new IllegalArgumentException("Null DefaultValueBuilder");
+      setDefaultsBuilder(builder.getType(), builder);
+   }
+   public void setDefaultsBuilder(MetaType type, DefaultValueBuilder builder)
+   {
+      synchronized (defaultBuilders)
+      {
+         if (builder == null)
+            defaultBuilders.remove(type);
+         else
+            defaultBuilders.put(type, builder);
+      }
+   }
+   public void removeDefaltValueBuilder(DefaultValueBuilder builder)
+   {
+      if (builder == null)
+         return;
+      setDefaultsBuilder(builder.getType(), null);
+   }
+
    /**
     * Get the configuration
     * 
@@ -485,7 +537,11 @@
          if (attachmentName.length() == 0)
             attachmentName = classInfo.getName();
          // Check for a component specification
-         ManagementComponent mc = managementObject.componentType();
+         ManagementComponent mc = null;
+         if (metaData != null )
+            mc = metaData.getAnnotation(ManagementComponent.class);
+         if (mc == null)
+            mc = managementObject.componentType();
          // Work around JBMDR-51 by checking type/subtype
          // if (mc.equals(AnnotationDefaults.COMP_TYPE) == false)
          if (mc.type().length() > 0 || mc.subtype().length() > 0)
@@ -547,6 +603,7 @@
             ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
             RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
             Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
+            DefaultValueBuilderFactory defaultsFactory = getAnnotation(DefaultValueBuilderFactory.class, propertyInfo, metaData);
             HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
             if (managementProperty != null)
                propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
@@ -674,7 +731,6 @@
                   apolicy = managementProperty.activationPolicy();
                }
                fields.setField(Fields.ACTIVATION_POLICY, apolicy);
-               
                // The managed property type
                MetaMapper[] mapperReturn = {null};
                MetaType metaType = this.getMetaType(propertyInfo, propertyInfo.getType(), metaData, false, mapperReturn);
@@ -698,6 +754,45 @@
                   }
                }
                fields.setField(Fields.META_TYPE, metaType);
+
+               // Default value
+               if(managementProperty != null)
+               {
+                  String defaultValue = managementProperty.defaultValue();
+                  if(defaultValue.length() > 0)
+                  {
+                     try
+                     {
+                       // Check for a DefaultValueBuilderFactory
+                        DefaultValueBuilder builder = null;
+                        if(defaultsFactory != null)
+                        {
+                              Class<? extends DefaultValueBuilder> factoryClass = defaultsFactory.value();
+                              builder = factoryClass.newInstance();
+                        }
+                        // Lookup the builder by metaType
+                        if(builder == null)
+                        {
+                           builder = defaultBuilders.get(metaType);
+                        }
+                        if(builder != null)
+                        {
+                           MetaValue defaultMV = builder.buildMetaValue(defaultValue);
+                           if(defaultMV != null)
+                              fields.setField(Fields.DEFAULT_VALUE, defaultMV);
+                        }
+                        else
+                        {
+                           log.warn("Failed to find DefaultValueBuilder for type: "+metaType);
+                        }
+                     }
+                     catch(Exception e)
+                     {
+                        log.warn("Failed to create default value for: "+propertyInfo, e);
+                     }
+                  }
+               }
+
                // Property annotations
                if (propAnnotations.isEmpty() == false)
                   fields.setField(Fields.ANNOTATIONS, propAnnotations);
@@ -993,6 +1088,33 @@
    }
 
    /**
+    * Initialize the DefaultValueBuilder map with known implementations
+    */
+   protected void initDefaultValueBuilders()
+   {
+      addDefaultValueBuilder(new BigDecimalDefaultValueBuilder());
+      addDefaultValueBuilder(new BigIntegerDefaultValueBuilder());
+      addDefaultValueBuilder(new DoubleDefaultValueBuilder());
+      addDefaultValueBuilder(new DoublePrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new FloatDefaultValueBuilder());
+      addDefaultValueBuilder(new FloatPrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new CharDefaultValueBuilder());
+      addDefaultValueBuilder(new CharPrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new IntDefaultValueBuilder());
+      addDefaultValueBuilder(new IntPrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new ShortDefaultValueBuilder());
+      addDefaultValueBuilder(new ShortPrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new LongDefaultValueBuilder());
+      addDefaultValueBuilder(new LongPrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new ByteDefaultValueBuilder());
+      addDefaultValueBuilder(new BytePrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new BooleanDefaultValueBuilder());
+      addDefaultValueBuilder(new BooleanPrimitiveDefaultValueBuilder());
+      addDefaultValueBuilder(new PropertiesDefaultValueBuilder());
+      addDefaultValueBuilder(new StringDefaultValueBuilder());
+   }
+
+   /**
     * Get the populator for a class
     * 
     * @param clazz the class

Modified: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -21,6 +21,9 @@
  */
 package org.jboss.test.managed.factory.support;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
 import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementProperty;
@@ -96,4 +99,5 @@
    {
       this.day = day;
    }
+   
 }

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/CustomPropsBuilder.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/CustomPropsBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/CustomPropsBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.managed.factory.support.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A custom DefaultValueBuilder that parses key/value pairs based on a ';' separator
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class CustomPropsBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      PropertiesMetaValue metaValue = new PropertiesMetaValue();
+      String[] pairs = value.split(";");
+      for(int n = 0; n < pairs.length; n ++)
+      {
+         String[] kv = pairs[n].split("=");
+         metaValue.put(kv[0], kv[1]);
+      }
+      return metaValue;
+   }
+
+   public MetaType getType()
+   {
+      return PropertiesMetaType.INSTANCE;
+   }
+
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/DefaultsBean.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/DefaultsBean.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/DefaultsBean.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,316 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.managed.factory.support.defaults;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
+import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.plugins.constraints.NumberConstraintsPopulatorFactory;
+import org.jboss.managed.plugins.constraints.StringLegalValuesPopulatorFactory;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.plugins.values.defaults.PropertiesCompositeObjectNameDefaultBuilder;
+import org.jboss.metatype.plugins.values.defaults.PropertiesObjectNameDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.StringObjectNameDefaultBuilder;
+import org.jboss.metatype.plugins.values.mappers.PropertiesMetaMapper;
+import org.jboss.metatype.plugins.values.mappers.PropertiesObjectNameMetaMapper;
+import org.jboss.metatype.plugins.values.mappers.StringObjectNameMetaMapper;
+
+/**
+ * Test bean for validating defaults on managed properties
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 81573 $
+ */
+ at ManagementObject
+public class DefaultsBean
+{
+   private float temperature;
+   private Float pi;
+   private double temperatureD;
+   private Double piD;
+   private Short dayOfYear;
+   private int day;
+   private Integer century;
+   private String month;
+   private Properties props;
+   private Properties props2;
+   private long propLongPrimitive;
+   private Long propLong;
+   private BigDecimal propBD;
+   private BigInteger propBI;
+   private char propCharPrimitive;
+   private Character propChar;
+   private short propShortPrimitive;
+   private byte propBytePrimitive;
+   private Byte propByte;
+   private boolean propBooleanPrimitive;
+   private Boolean propBoolean;
+   private ObjectName nameAsString;
+   private ObjectName nameAsProperties;
+   private ObjectName nameAsDefault;
+
+   @ManagementProperty(defaultValue="domain1:key1=value1,key2=value2")
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   @DefaultValueBuilderFactory(StringObjectNameDefaultBuilder.class)
+   public ObjectName getNameAsString()
+   {
+      return nameAsString;
+   }
+   public void setNameAsString(ObjectName nameAsString)
+   {
+      this.nameAsString = nameAsString;
+   }
+   @ManagementProperty(defaultValue="domain1:key1=value1,key2=value2")
+   @MetaMapping(PropertiesObjectNameMetaMapper.class)
+   @DefaultValueBuilderFactory(PropertiesObjectNameDefaultValueBuilder.class)
+   public ObjectName getNameAsProperties()
+   {
+      return nameAsProperties;
+   }
+   public void setNameAsProperties(ObjectName nameAsProperties)
+   {
+      this.nameAsProperties = nameAsProperties;
+   }
+
+   @ManagementProperty(defaultValue="domain1:key1=value1,key2=value2")
+   @DefaultValueBuilderFactory(PropertiesCompositeObjectNameDefaultBuilder.class)
+   public ObjectName getNameAsDefault()
+   {
+      return nameAsDefault;
+   }
+   public void setNameAsDefault(ObjectName nameAsDefault)
+   {
+      this.nameAsDefault = nameAsDefault;
+   }
+
+   @ManagementProperty(defaultValue="60")
+   @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+         min="0",max="100")
+   public float getTemperature()
+   {
+      return temperature;
+   }
+   public void setTemperature(float temperature)
+   {
+      this.temperature = temperature;
+   }
+   @ManagementProperty(defaultValue="3.14")
+   @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+         min="3",max="3.14159")
+   public Float getPi()
+   {
+      return pi;
+   }
+   public void setPi(Float pi)
+   {
+      this.pi = pi;
+   }
+   @ManagementProperty(defaultValue="1")
+   @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+         min="1",max="365")
+   public Short getDayOfYear()
+   {
+      return dayOfYear;
+   }
+   public void setDayOfYear(Short dayOfYear)
+   {
+      this.dayOfYear = dayOfYear;
+   }
+   @ManagementProperty(defaultValue="JAN")
+   @ConstraintsPopulatorFactory(value=StringLegalValuesPopulatorFactory.class,
+         legalValues={"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"})
+   public String getMonth()
+   {
+      return month;
+   }
+   public void setMonth(String month)
+   {
+      this.month = month;
+   }
+   @ManagementProperty(defaultValue="1")
+   @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+         min="1",max="31")
+   public int getDay()
+   {
+      return day;
+   }
+   public void setDay(int day)
+   {
+      this.day = day;
+   }
+   @ManagementProperty(defaultValue="2000")
+   public Integer getCentury()
+   {
+      return century;
+   }
+   public void setCentury(Integer century)
+   {
+      this.century = century;
+   }
+   @ManagementProperty(defaultValue="key1=value1,key2=value2")
+   @MetaMapping(PropertiesMetaMapper.class)
+   public Properties getProps()
+   {
+      return props;
+   }
+   public void setProps(Properties props)
+   {
+      this.props = props;
+   }
+   @ManagementProperty(defaultValue="key1=props2-value1;key2=props2-value2")
+   @MetaMapping(PropertiesMetaMapper.class)
+   @DefaultValueBuilderFactory(CustomPropsBuilder.class)
+   public Properties getProps2()
+   {
+      return props2;
+   }
+   public void setProps2(Properties props2)
+   {
+      this.props2 = props2;
+   }
+   
+   @ManagementProperty(defaultValue="60.5")
+   public double getTemperatureD()
+   {
+      return temperatureD;
+   }
+   public void setTemperatureD(double temperatureD)
+   {
+      this.temperatureD = temperatureD;
+   }
+   @ManagementProperty(defaultValue="3.14159265358979")
+   public Double getPiD()
+   {
+      return piD;
+   }
+   public void setPiD(Double piD)
+   {
+      this.piD = piD;
+   }
+   @ManagementProperty(defaultValue="123456789")
+   public long getPropLongPrimitive()
+   {
+      return propLongPrimitive;
+   }
+   public void setPropLongPrimitive(long propLongPrimitive)
+   {
+      this.propLongPrimitive = propLongPrimitive;
+   }
+   @ManagementProperty(defaultValue="123456789")
+   public Long getPropLong()
+   {
+      return propLong;
+   }
+   public void setPropLong(Long propLong)
+   {
+      this.propLong = propLong;
+   }
+   @ManagementProperty(defaultValue="123456789.987654321")
+   public BigDecimal getPropBD()
+   {
+      return propBD;
+   }
+   public void setPropBD(BigDecimal propBD)
+   {
+      this.propBD = propBD;
+   }
+   @ManagementProperty(defaultValue="123456789987654321")
+   public BigInteger getPropBI()
+   {
+      return propBI;
+   }
+   public void setPropBI(BigInteger propBI)
+   {
+      this.propBI = propBI;
+   }
+   @ManagementProperty(defaultValue="c")
+   public char getPropCharPrimitive()
+   {
+      return propCharPrimitive;
+   }
+   public void setPropCharPrimitive(char propCharPrimitive)
+   {
+      this.propCharPrimitive = propCharPrimitive;
+   }
+   @ManagementProperty(defaultValue="C")
+   public Character getPropChar()
+   {
+      return propChar;
+   }
+   public void setPropChar(Character propChar)
+   {
+      this.propChar = propChar;
+   }
+   @ManagementProperty(defaultValue="1234")
+   public short getPropShortPrimitive()
+   {
+      return propShortPrimitive;
+   }
+   public void setPropShortPrimitive(short propShortPrimitive)
+   {
+      this.propShortPrimitive = propShortPrimitive;
+   }
+   @ManagementProperty(defaultValue="10")
+   public byte getPropBytePrimitive()
+   {
+      return propBytePrimitive;
+   }
+   public void setPropBytePrimitive(byte propBytePrimitive)
+   {
+      this.propBytePrimitive = propBytePrimitive;
+   }
+   @ManagementProperty(defaultValue="10")
+   public Byte getPropByte()
+   {
+      return propByte;
+   }
+   public void setPropByte(Byte propByte)
+   {
+      this.propByte = propByte;
+   }
+   @ManagementProperty(defaultValue="true")
+   public boolean isPropBooleanPrimitive()
+   {
+      return propBooleanPrimitive;
+   }
+   public void setPropBooleanPrimitive(boolean propBooleanPrimitive)
+   {
+      this.propBooleanPrimitive = propBooleanPrimitive;
+   }
+   @ManagementProperty(defaultValue="true")
+   public Boolean getPropBoolean()
+   {
+      return propBoolean;
+   }
+   public void setPropBoolean(Boolean propBoolean)
+   {
+      this.propBoolean = propBoolean;
+   }
+
+   
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,368 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.managed.factory.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.ObjectNameTypeBuilder;
+import org.jboss.metatype.plugins.values.mappers.PropertiesCompositeObjectNameMetaMapper;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.defaults.DefaultsBean;
+
+/**
+ * Tests of specifying defaults on managed properties
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PropertyDefaultsUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+
+   public PropertyDefaultsUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testFloatDefaults()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+
+      // Test the temperature constraints
+      ManagedProperty temperature = managedObject.getProperty("temperature");
+      SimpleValue defaultValue = (SimpleValue) temperature.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("temperature default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(60f));
+      assertTrue("temperature == 60; "+compare, compare == 0);
+
+      ManagedProperty pi = managedObject.getProperty("pi");
+      defaultValue = (SimpleValue) pi.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("pi default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(3.14f));
+      assertTrue("pi == 3.14; "+compare, compare == 0);
+   }
+   /**
+    * Test default value for Double property types
+    */
+   public void testDoubleDefaults()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+   
+      // Test the temperature constraints
+      ManagedProperty temperature = managedObject.getProperty("temperatureD");
+      SimpleValue defaultValue = (SimpleValue) temperature.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("temperature default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(60.5));
+      assertTrue("temperature == 60; "+compare, compare == 0);
+   
+      ManagedProperty pi = managedObject.getProperty("piD");
+      defaultValue = (SimpleValue) pi.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("pi default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(3.14159265358979));
+      assertTrue("pi == 3.14159265358979 "+compare, compare == 0);
+   }
+   /**
+    * Test default value for Long property types
+    */
+   public void testLongDefaults()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+   
+      // Test the temperature constraints
+      ManagedProperty temperature = managedObject.getProperty("propLong");
+      SimpleValue defaultValue = (SimpleValue) temperature.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("propLong default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(123456789l));
+      assertTrue("propLong == 123456789; "+compare, compare == 0);
+   
+      ManagedProperty pi = managedObject.getProperty("propLongPrimitive");
+      defaultValue = (SimpleValue) pi.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("propLongPrimitive default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(123456789l));
+      assertTrue("propLongPrimitive == 123456789 "+compare, compare == 0);
+   }
+   /**
+    * Test default value for String property types
+    */
+   public void testStringDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty month = managedObject.getProperty("month");
+      SimpleValue defaultValue = (SimpleValue) month.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("month default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap("JAN"));
+      assertTrue("month == JAN; "+compare, compare == 0);
+   }
+   /**
+    * Test default value for BigDecimal property types
+    */
+   public void testBigDecimalDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty month = managedObject.getProperty("propBD");
+      SimpleValue defaultValue = (SimpleValue) month.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("propBD default: "+defaultValue);
+      BigDecimal bd = new BigDecimal("123456789.987654321");
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(bd));
+      assertTrue("propBD == 123456789.987654321; "+compare, compare == 0);
+   }
+   /**
+    * Test default value for BigInteger property types
+    */
+   public void testBigIntegerDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty propBI = managedObject.getProperty("propBI");
+      SimpleValue defaultValue = (SimpleValue) propBI.getDefaultValue();
+      assertEquals(SimpleMetaType.BIGINTEGER, defaultValue.getMetaType());
+      assertNotNull(defaultValue);
+      getLog().debug("propBI default: "+defaultValue);
+      BigInteger bd = new BigInteger("123456789987654321");
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(bd));
+      assertEquals("propBI == 123456789987654321; "+compare, 0, compare);
+   }
+
+   /**
+    * Test default value for Char property types
+    */
+   public void testCharDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty propCharPrimitive = managedObject.getProperty("propCharPrimitive");
+      SimpleValue defaultValue = (SimpleValue) propCharPrimitive.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.CHARACTER_PRIMITIVE, defaultValue.getMetaType());
+      getLog().debug("propCharPrimitive default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap('c'));
+      assertEquals("propCharPrimitive == c; ", 0, compare);
+
+      ManagedProperty propChar = managedObject.getProperty("propChar");
+      defaultValue = (SimpleValue) propChar.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.CHARACTER, defaultValue.getMetaType());
+      getLog().debug("propChar default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(new Character('C')));
+      assertTrue("propChar == c; "+compare, compare == 0);
+   }
+
+   /**
+    * Test default value for Integer property types
+    */
+   public void testIntDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty day = managedObject.getProperty("day");
+      SimpleValue defaultValue = (SimpleValue) day.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("day default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(1));
+      assertTrue("day == 1; "+compare, compare == 0);
+
+      ManagedProperty century = managedObject.getProperty("century");
+      defaultValue = (SimpleValue) century.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("century default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(2000));
+      assertTrue("century == 2000; "+compare, compare == 0);
+   }
+   /**
+    * Test default value for Byte property types
+    */
+   public void testByteDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty propByte = managedObject.getProperty("propByte");
+      SimpleValue defaultValue = (SimpleValue) propByte.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.BYTE, defaultValue.getMetaType());
+      getLog().debug("propByte default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(10));
+      assertTrue("propByte == 1; "+compare, compare == 0);
+
+      ManagedProperty propBytePrimitive = managedObject.getProperty("propBytePrimitive");
+      defaultValue = (SimpleValue) propBytePrimitive.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.BYTE_PRIMITIVE, defaultValue.getMetaType());
+      getLog().debug("propBytePrimitive default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(10));
+      assertEquals("propBytePrimitive == 10; ", 0, compare);
+   }
+   /**
+    * Test default value for Short property types
+    */
+   public void testShortDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty dayOfYear = managedObject.getProperty("dayOfYear");
+      SimpleValue defaultValue = (SimpleValue) dayOfYear.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("dayOfYear default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(1));
+      assertTrue("dayOfYear == 1; "+compare, compare == 0);
+
+      ManagedProperty propShortPrimitive = managedObject.getProperty("propShortPrimitive");
+      defaultValue = (SimpleValue) propShortPrimitive.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.SHORT_PRIMITIVE, defaultValue.getMetaType());
+      getLog().debug("propShortPrimitive default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(1234));
+      assertTrue("propShortPrimitive == 1234; "+compare, compare == 0);
+   }
+   /**
+    * Test default value for Boolean property types
+    */
+   public void testBooleanDefaults()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty propBoolean = managedObject.getProperty("propBoolean");
+      SimpleValue defaultValue = (SimpleValue) propBoolean.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.BOOLEAN, defaultValue.getMetaType());
+      getLog().debug("propBoolean default: "+defaultValue);
+      int compare = defaultValue.compareTo(SimpleValueSupport.wrap(Boolean.TRUE));
+      assertTrue("propBoolean == true; "+compare, compare == 0);
+
+      ManagedProperty propBooleanPrimitive = managedObject.getProperty("propBooleanPrimitive");
+      defaultValue = (SimpleValue) propBooleanPrimitive.getDefaultValue();
+      assertNotNull(defaultValue);
+      assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, defaultValue.getMetaType());
+      getLog().debug("propBooleanPrimitive default: "+defaultValue);
+      compare = defaultValue.compareTo(SimpleValueSupport.wrap(true));
+      assertEquals("propBooleanPrimitive == true; ", 0, compare);
+   }
+   /**
+    * Test default value for a Properties type
+    */
+   public void testPropertiesDefault()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty props = managedObject.getProperty("props");
+      MetaValue defaultValue = props.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("props default: "+defaultValue);
+      Properties expected = new Properties();
+      expected.put("key1", "value1");
+      expected.put("key2", "value2");
+      assertEquals(expected, defaultValue);      
+   }
+   /**
+    * Test default value for a Properties type with a DefaultValueBuilderFactory
+    */
+   public void testOverridenPropertiesDefault()
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty props = managedObject.getProperty("props2");
+      MetaValue defaultValue = props.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("props default: "+defaultValue);
+      Properties expected = new Properties();
+      expected.put("key1", "props2-value1");
+      expected.put("key2", "props2-value2");
+      assertEquals(expected, defaultValue);   
+   }
+   /**
+    * Test default value for a ObjectName type with SimpleMetaType.STRING type
+    */
+   public void testStringObjectNameDefault()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty nameAsString = managedObject.getProperty("nameAsString");
+      MetaValue defaultValue = nameAsString.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("nameAsString default: "+defaultValue);
+      MetaValue expected = SimpleValueSupport.wrap("domain1:key1=value1,key2=value2");
+      assertEquals(expected, defaultValue);      
+   }
+   /**
+    * Test default value for a ObjectName type with PropertiesMetaType
+    */
+   public void testPropertiesObjectNameDefault()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty nameAsProperties = managedObject.getProperty("nameAsProperties");
+      MetaValue defaultValue = nameAsProperties.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("nameAsProperties default: "+defaultValue);
+      Properties p = new Properties();
+      p.setProperty("domain", "domain1");
+      p.setProperty("key1", "value1");
+      p.setProperty("key2", "value2");
+      PropertiesMetaValue expected = new PropertiesMetaValue(p);
+      assertEquals(expected, defaultValue);      
+   }
+   /**
+    * Test default value for a ObjectName type with default meta type
+    */
+   public void testDefaultObjectNameDefault()
+      throws Exception
+   {
+      DefaultsBean bean = new DefaultsBean();
+      ManagedObject managedObject = super.initManagedObject(bean);
+      ManagedProperty nameAsProperties = managedObject.getProperty("nameAsDefault");
+      MetaValue defaultValue = nameAsProperties.getDefaultValue();
+      assertNotNull(defaultValue);
+      getLog().debug("nameAsProperties default: "+defaultValue);
+      assertEquals(ObjectNameTypeBuilder.META_TYPE, defaultValue.getMetaType());
+      PropertiesCompositeObjectNameMetaMapper mapper = new PropertiesCompositeObjectNameMetaMapper();
+      MetaValue expected = mapper.createMetaValue(null, new ObjectName("domain1:key1=value1,key2=value2"));
+      assertEquals(expected, defaultValue);      
+   }
+}


Property changes on: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -82,4 +82,19 @@
    {
       return obj instanceof PropertiesMetaValue;
    }
+
+   /**
+    * Equality of PropertiesMetaType is just based on the class
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      return obj instanceof PropertiesMetaType;
+   }
+   @Override
+   public int hashCode()
+   {
+      return getClass().hashCode();
+   }
+   
 }

Modified: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -78,7 +78,8 @@
     */
    public PropertiesMetaValue(Properties props, PropertiesMetaType type)
    {
-      super.putAll(props);
+      if(props != null)
+         super.putAll(props);
       this.type = type;
    }
 

Modified: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -197,6 +197,12 @@
          Boolean v2 = Boolean.class.cast(sv.getValue());
          compare = v1.compareTo(v2);
       }
+      else if(getMetaType() == SimpleMetaType.BOOLEAN_PRIMITIVE && sv.getMetaType() == SimpleMetaType.BOOLEAN_PRIMITIVE)
+      {
+         Boolean v1 = Boolean.class.cast(value);
+         Boolean v2 = Boolean.class.cast(sv.getValue());
+         compare = v1.compareTo(v2);
+      }
       else if(getMetaType() == SimpleMetaType.BYTE && sv.getMetaType() == SimpleMetaType.BYTE)
       {
          Byte v1 = Byte.class.cast(value);
@@ -209,6 +215,12 @@
          Character v2 = Character.class.cast(sv.getValue());
          compare = v1.compareTo(v2);
       }
+      else if(getMetaType() == SimpleMetaType.CHARACTER_PRIMITIVE && sv.getMetaType() == SimpleMetaType.CHARACTER_PRIMITIVE)
+      {
+         Character v1 = Character.class.cast(value);
+         Character v2 = Character.class.cast(sv.getValue());
+         compare = v1.compareTo(v2);
+      }
       else if(getMetaType() == SimpleMetaType.DATE && sv.getMetaType() == SimpleMetaType.DATE)
       {
          Date v1 = Date.class.cast(value);

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigDecimalDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigDecimalDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigDecimalDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import java.math.BigDecimal;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.BIGDECIMAL
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BigDecimalDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      BigDecimal jvalue = new BigDecimal(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.BIGDECIMAL;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigIntegerDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigIntegerDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BigIntegerDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import java.math.BigInteger;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.BIGINTEGER
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BigIntegerDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      BigInteger jvalue = new BigInteger(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.BIGINTEGER;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.BOOLEAN
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BooleanDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Boolean jvalue = new Boolean(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.BOOLEAN;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanPrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanPrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BooleanPrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.BOOLEAN_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BooleanPrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Boolean jvalue = Boolean.valueOf(value);
+      boolean primitive = jvalue.booleanValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.BOOLEAN_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ByteDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ByteDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ByteDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.BYTE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ByteDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Byte jvalue = Byte.valueOf(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.BYTE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BytePrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BytePrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/BytePrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.BYTE_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BytePrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Byte jvalue = Byte.valueOf(value);
+      byte primitive = jvalue.byteValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.BYTE_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.CHARACTER
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class CharDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Character jvalue = Character.valueOf(value.charAt(0));
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.CHARACTER;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharPrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharPrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/CharPrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.CHARACTER_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class CharPrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      char primitive = value.charAt(0);
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.CHARACTER_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoubleDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoubleDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoubleDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.DOUBLE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DoubleDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Double jvalue = Double.valueOf(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.DOUBLE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoublePrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoublePrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/DoublePrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.DOUBLE_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DoublePrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Double jvalue = Double.valueOf(value);
+      double primitive = jvalue.doubleValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.DOUBLE_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.FLOAT
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class FloatDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Float jvalue = Float.valueOf(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.FLOAT;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatPrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatPrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/FloatPrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.FLOAT_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class FloatPrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Float jvalue = Float.valueOf(value);
+      float primitive = jvalue.floatValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.FLOAT_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.INTEGER
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class IntDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Integer jvalue = Integer.valueOf(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.INTEGER;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntPrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntPrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/IntPrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.INTEGER_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class IntPrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Integer jvalue = Integer.valueOf(value);
+      int primitive = jvalue.intValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.INTEGER_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.LONG
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class LongDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Long jvalue = Long.valueOf(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.LONG;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongPrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongPrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/LongPrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.LONG_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class LongPrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Long jvalue = Long.valueOf(value);
+      long primitive = jvalue.longValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.LONG_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ObjectNameDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ObjectNameDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ObjectNameDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import javax.management.ObjectName;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.plugins.types.ObjectNameTypeBuilder;
+import org.jboss.metatype.plugins.values.mappers.PropertiesCompositeObjectNameMetaMapper;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for ObjectName types of MetaValues. This handles
+ * MetaTypes for the known MetaMapper<ObjectName> implementations.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ObjectNameDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+   public MetaType getType()
+   {
+      return ObjectNameTypeBuilder.META_TYPE;
+   }
+
+   public MetaValue buildMetaValue(String value)
+      throws Exception
+   {
+      ObjectName ovalue = new ObjectName(value);
+      PropertiesCompositeObjectNameMetaMapper mapper = new PropertiesCompositeObjectNameMetaMapper();
+      MetaValue mvalue = mapper.createMetaValue(getType(), ovalue);         
+      return mvalue;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesCompositeObjectNameDefaultBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesCompositeObjectNameDefaultBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesCompositeObjectNameDefaultBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import javax.management.ObjectName;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.plugins.values.mappers.PropertiesCompositeObjectNameMetaMapper;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for ObjectNames that are built using a
+ * PropertiesCompositeObjectNameMetaMapper
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PropertiesCompositeObjectNameDefaultBuilder
+   implements DefaultValueBuilder
+{
+   private PropertiesCompositeObjectNameMetaMapper mapper = new PropertiesCompositeObjectNameMetaMapper();
+
+   public MetaType getType()
+   {
+      return mapper.getMetaType();
+   }
+
+   public MetaValue buildMetaValue(String value)
+      throws Exception
+   {
+      ObjectName ovalue = new ObjectName(value);
+      MetaValue mvalue = mapper.createMetaValue(mapper.getMetaType(), ovalue);
+      return mvalue;
+   }
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import java.util.Properties;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for java.util.Properties
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PropertiesDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+   public MetaType getType()
+   {
+      return PropertiesMetaType.INSTANCE;
+   }
+   /**
+    * @param metaType - a PropertiesMetaType
+    * @param value - a comma separated list of key=value pairs
+    */
+   public MetaValue buildMetaValue(String value)
+         throws Exception
+   {
+      Properties props = new Properties();
+      String[] pairs = value.split(",");
+      for(int n = 0; n < pairs.length; n ++)
+      {
+         String[] kv = pairs[n].split("=");
+         props.put(kv[0], kv[1]);
+      }
+      PropertiesMetaValue metaValue = new PropertiesMetaValue(props);
+      return metaValue;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesObjectNameDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesObjectNameDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/PropertiesObjectNameDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import java.util.Properties;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for ObjectName with PropertiesMetaType
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PropertiesObjectNameDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+   public MetaType getType()
+   {
+      return PropertiesMetaType.INSTANCE;
+   }
+   /**
+    * @param metaType - a PropertiesMetaType
+    * @param value - a comma separated list of key=value pairs
+    */
+   public MetaValue buildMetaValue(String value)
+         throws Exception
+   {
+      Properties props = new Properties();
+      String[] pairs = value.split(",");
+      for(int n = 0; n < pairs.length; n ++)
+      {
+         String[] kv = pairs[n].split("=");
+         String key = kv[0];
+         int colon = key.indexOf(':');
+         if(colon >= 0 )
+         {
+            // This key has the domain prefix
+            String domain = key.substring(0, colon);
+            key = key.substring(colon+1);
+            props.setProperty("domain", domain);
+         }
+         props.setProperty(key, kv[1]);
+      }
+      PropertiesMetaValue metaValue = new PropertiesMetaValue(props);
+      return metaValue;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.SHORT
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ShortDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Short jvalue = Short.valueOf(value);
+      MetaValue mvalue = SimpleValueSupport.wrap(jvalue);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.SHORT;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortPrimitiveDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortPrimitiveDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/ShortPrimitiveDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.SHORT_PRIMITIVE
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ShortPrimitiveDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(String value) throws Exception
+   {
+      Short jvalue = Short.valueOf(value);
+      short primitive = jvalue.shortValue();
+      MetaValue mvalue = SimpleValueSupport.wrap(primitive);
+      return mvalue;
+   }
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.SHORT_PRIMITIVE;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/SimpleDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/SimpleDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/SimpleDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaTypes
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SimpleDefaultValueBuilder
+{
+
+   public MetaValue buildMetaValue(MetaType metaType, String value)
+   {
+      MetaValue mvalue = null;
+      if(metaType.equals(SimpleMetaType.BOOLEAN))
+      {
+         Boolean jvalue = Boolean.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.BOOLEAN_PRIMITIVE))
+      {
+         Boolean jvalue = Boolean.valueOf(value);
+         boolean primitive = jvalue.booleanValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.BYTE))
+      {
+         Byte jvalue = Byte.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.BYTE_PRIMITIVE))
+      {
+         Byte jvalue = Byte.valueOf(value);
+         byte primitive = jvalue.byteValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.CHARACTER))
+      {
+         Character jvalue = Character.valueOf(value.charAt(0));
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.CHARACTER_PRIMITIVE))
+      {
+         mvalue = SimpleValueSupport.wrap(value.charAt(0));
+      }
+      else if(metaType.equals(SimpleMetaType.DATE))
+      {
+         Date jvalue = new Date(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.DOUBLE))
+      {
+         Double jvalue = Double.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.DOUBLE_PRIMITIVE))
+      {
+         Double jvalue = Double.valueOf(value);
+         double primitive = jvalue.doubleValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.FLOAT))
+      {
+         Float jvalue = Float.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.FLOAT_PRIMITIVE))
+      {
+         Float jvalue = Float.valueOf(value);
+         float primitive = jvalue.floatValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.INTEGER))
+      {
+         Integer jvalue = Integer.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.INTEGER_PRIMITIVE))
+      {
+         Integer jvalue = Integer.valueOf(value);
+         int primitive = jvalue.intValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.LONG))
+      {
+         Long jvalue = Long.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.LONG_PRIMITIVE))
+      {
+         Long jvalue = Long.valueOf(value);
+         long primitive = jvalue.longValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.SHORT))
+      {
+         Short jvalue = Short.valueOf(value);
+         mvalue = SimpleValueSupport.wrap(jvalue);
+      }
+      else if(metaType.equals(SimpleMetaType.SHORT_PRIMITIVE))
+      {
+         Short jvalue = Short.valueOf(value);
+         short primitive = jvalue.shortValue();
+         mvalue = SimpleValueSupport.wrap(primitive);
+      }
+      else if(metaType.equals(SimpleMetaType.STRING))
+      {
+         mvalue = SimpleValueSupport.wrap(value);
+      }
+      else
+      {
+         throw new IllegalStateException("Unknown metaType: "+metaType);
+      }
+      return mvalue;
+   }
+   
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringDefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringDefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringDefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for SimpleMetaType.STRING SimpleValues.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StringDefaultValueBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.STRING;
+   }
+
+   public MetaValue buildMetaValue(String value)
+      throws Exception
+   {
+      return SimpleValueSupport.wrap(value);
+   }
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringObjectNameDefaultBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringObjectNameDefaultBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/StringObjectNameDefaultBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.defaults;
+
+import javax.management.ObjectName;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+/**
+ * A DefaultValueBuilder for ObjectNames that are represented using a
+ * SimpleMetaType.STRING SimpleValue.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StringObjectNameDefaultBuilder
+   implements DefaultValueBuilder
+{
+
+   public MetaType getType()
+   {
+      return SimpleMetaType.STRING;
+   }
+
+   public MetaValue buildMetaValue(String value)
+      throws Exception
+   {
+      ObjectName ovalue = new ObjectName(value);
+      String str = ovalue.getCanonicalName();
+      return SimpleValueSupport.wrap(str);
+   }
+}

Modified: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java	2009-04-18 21:14:50 UTC (rev 87522)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -65,7 +65,7 @@
          Object value = object.getKeyProperty((String)key);
          keyValues.put(key, value);
       }
-      MetaValue[] itemValues = {SimpleValueSupport.wrap(object.getDomain()), };
+      MetaValue[] itemValues = {SimpleValueSupport.wrap(object.getDomain()), keyValues};
       CompositeValueSupport mv = new CompositeValueSupport(ObjectNameTypeBuilder.META_TYPE,
             itemNames, itemValues);
       return mv;

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.plugins.values.mappers;
+
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * An Properties MetaMapper that maps to a PropertiesMetaType/PropertiesMetaValue
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 81575 $
+ */
+public class PropertiesMetaMapper extends MetaMapper<Properties>
+{
+   PropertiesMetaType type;
+
+   public PropertiesMetaMapper()
+   {
+      this((String[])null);
+   }
+   public PropertiesMetaMapper(String... args)
+   {
+      Map<String, String> propertyNameDescriptions = Collections.emptyMap();
+      if(args != null)
+      {
+         if(((args.length %2) == 0) == false)
+            throw new IllegalStateException("args counts must be 2*n for n key,key-description pairs");
+         propertyNameDescriptions = new HashMap<String,String>();
+         for(int n = 0; n < args.length; n += 2)
+         {
+            String key = args[n];
+            String description = args[n+1];
+            propertyNameDescriptions.put(key, description);
+         }
+      }
+
+      type = new PropertiesMetaType("java.util.Properties", propertyNameDescriptions);
+   }
+
+   @Override
+   public MetaType getMetaType()
+   {
+      return type;
+   }
+
+   @Override
+   public Type mapToType()
+   {
+      return ObjectName.class;
+   }
+
+   @Override
+   public MetaValue createMetaValue(MetaType metaType, Properties object)
+   {
+      PropertiesMetaValue map = new PropertiesMetaValue(object);
+      return map;
+   }
+
+   @Override
+   public Properties unwrapMetaValue(MetaValue metaValue)
+   {
+      PropertiesMetaValue map = (PropertiesMetaValue) metaValue;
+      return map;
+   }
+
+}

Added: projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java
===================================================================
--- projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java	                        (rev 0)
+++ projects/jboss-man/trunk/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java	2009-04-19 02:19:21 UTC (rev 87523)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.spi.values;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * Convert a string representation of a default value into a MetaValue
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DefaultValueBuilder
+{
+   public MetaType getType();
+   public MetaValue buildMetaValue(String value)
+      throws Exception;
+}




More information about the jboss-cvs-commits mailing list