[jboss-cvs] JBossAS SVN: r80090 - in projects/jboss-man/trunk/managed/src: main/java/org/jboss/managed/plugins/factory and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 27 00:29:42 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-10-27 00:29:42 -0400 (Mon, 27 Oct 2008)
New Revision: 80090

Added:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/Utility.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/ABeanMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AFeatureMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AKernelDeployment.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/APropertyMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractTypeMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractValueMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/BeanMetaDataICF.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/DirectAnnotationMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IAnnotationMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaDataFactory.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IKernelDeployment.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IPropertyMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IValueMetaData.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/SecurityActions.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/StringValueMetaData.java
Modified:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectFactory.java
   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/AbstractManagedObjectPopulator.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
Log:
JBMAN-27, JBMAN-28 deal better with InstanceClassFactory mappings based on interfaces and collections

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectFactory.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectFactory.java	2008-10-27 04:16:58 UTC (rev 80089)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectFactory.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -53,7 +53,7 @@
    /**
     * Create a managed object from the given object
     * 
-    * @param object the object
+    * @param instance - the object to build the ManagedObject from
     * @param name - the name of the managed object. If null, the name will
     *    be derived from the object annotations or attachment name.
     * @param nameType - the name of the managed object. If null, the name will
@@ -64,10 +64,27 @@
     * @return the managed object
     * @throws IllegalArgumentException for a null object
     */
-   public abstract ManagedObject initManagedObject(Object object, String name, String nameType);
-   public abstract ManagedObject initManagedObject(Serializable object, String name, String nameType);
+   public abstract ManagedObject initManagedObject(Object instance, String name, String nameType);
+   public abstract ManagedObject initManagedObject(Serializable instance, String name, String nameType);
 
    /**
+    * Create a managed object from the given object
+    * 
+    * @param instance - the object to build the ManagedObject from
+    * @param instanceType - the type to determine InstanceClassFactory registration from
+    * @param name - the name of the managed object. If null, the name will
+    *    be derived from the object annotations or attachment name.
+    * @param nameType - the name of the managed object. If null, the name will
+    *    be derived from the object annotations or default to "".
+    * 
+    * @see ManagementObjectID
+    * 
+    * @return the managed object
+    */
+   public abstract ManagedObject initManagedObject(Object instance, Class<?> instanceType,
+         String name, String nameType);
+
+   /**
     * Create a shell managed object from the given class
     *
     * @param <T> the 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	2008-10-27 04:16:58 UTC (rev 80089)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -284,24 +284,29 @@
    }
 
    @Override
-   public ManagedObject initManagedObject(Serializable object, String name, String nameType)
+   public ManagedObject initManagedObject(Serializable instance, String name, String nameType)
    {
-      Object obj = object;
+      Object obj = instance;
       return initManagedObject(obj, name, nameType);
    }
    @Override
    @SuppressWarnings("unchecked")
-   public ManagedObject initManagedObject(Object object, String name, String nameType)
+   public ManagedObject initManagedObject(Object instance, String name, String nameType)
    {
-      if (object == null)
+      return initManagedObject(instance, instance.getClass(), name, nameType);
+   }
+   public ManagedObject initManagedObject(Object instance, Class<?> instanceType,
+         String name, String nameType)
+   {
+      if (instance == null)
          throw new IllegalArgumentException("Null object");
 
-      Class<?> clazz = object.getClass();
+      Class<?> clazz = instance.getClass();
       InstanceClassFactory icf = getInstanceClassFactory(clazz);
       Class<Object> moClass;
       try
       {
-         moClass = icf.getManagedObjectClass(object);
+         moClass = icf.getManagedObjectClass(instance);
       }
       catch(ClassNotFoundException e)
       {
@@ -317,7 +322,7 @@
       {
          MutableManagedObject mmo = (MutableManagedObject) result;
          ManagedObjectPopulator<Object> populator = getPopulator(moClass);
-         populator.populateManagedObject(mmo, object);
+         populator.populateManagedObject(mmo, instance);
       }
 
       return result;
@@ -754,19 +759,9 @@
    @SuppressWarnings("unchecked")
    public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz)
    {
-      synchronized (instanceFactories)
-      {
-         Class<?> c = clazz;
-         InstanceClassFactory factory = instanceFactories.get(c);
-         while(factory == null && c != Object.class)
-         {
-            c = c.getSuperclass();
-            factory = instanceFactories.get(c);
-         }
-         if (factory != null)
-            return factory;
-      }
-      InstanceClassFactory<X> factory = (InstanceClassFactory<X>) defaultInstanceFactory;
+      InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
+         Utility.getInstanceClassFactory(clazz, instanceFactories,
+            defaultInstanceFactory);
       return factory;
    }
 

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java	2008-10-27 04:16:58 UTC (rev 80089)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -132,13 +132,9 @@
    @SuppressWarnings("unchecked")
    public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz)
    {
-      synchronized (instanceFactories)
-      {
-         InstanceClassFactory factory = instanceFactories.get(clazz);
-         if (factory != null)
-            return factory;
-      }
-      InstanceClassFactory<X> factory = (InstanceClassFactory<X>) defaultInstanceFactory;
+      InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
+      Utility.getInstanceClassFactory(clazz, instanceFactories,
+         defaultInstanceFactory);
       return factory;
    }
 

Added: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/Utility.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/Utility.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/Utility.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,81 @@
+/*
+ * 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.managed.plugins.factory;
+
+import java.util.Map;
+
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+
+/**
+ * Common untility methods used by the factory plugins.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Utility
+{
+   /**
+    * Get the instance factory for a class
+    * 
+    * @param clazz the class
+    * @param instanceFactories - the registered mapping of classes to InstanceClassFactorys
+    * @param defaultInstanceFactory - the default InstanceClassFactory to use
+    *    if no class match is found.
+    * @return the InstanceClassFactory
+    */
+   @SuppressWarnings("unchecked")
+   public static InstanceClassFactory getInstanceClassFactory(Class<?> clazz,
+         Map<Class<?>, InstanceClassFactory<?>> instanceFactories,
+         InstanceClassFactory defaultInstanceFactory)
+   {
+      synchronized (instanceFactories)
+      {
+         Class<?> c = clazz;
+         InstanceClassFactory factory = instanceFactories.get(c);
+         while(factory == null && c != Object.class)
+         {
+            // First check for interfaces
+            Class<?>[] ifaces = c.getInterfaces();
+            if(ifaces != null)
+            {
+               for(Class<?> i : ifaces)
+               {
+                  factory = instanceFactories.get(i);
+                  if(factory != null)
+                     break;
+               }
+            }
+            // Next look at superclasses
+            if(factory == null)
+            {
+               c = c.getSuperclass();
+               factory = instanceFactories.get(c);
+            }
+         }
+         if (factory != null)
+            return factory;
+      }
+      InstanceClassFactory factory = defaultInstanceFactory;
+      return factory;
+   }
+
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/ABeanMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/ABeanMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/ABeanMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,122 @@
+/*
+ * 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.beans;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject(properties = ManagementProperties.EXPLICIT)
+ at XmlRootElement(name="bean")
+ at XmlType(name="beanType", propOrder={"aliasMetaData", "related", "annotations", "classLoader", "constructor", "properties", "create", "start", "stop", "destroy", "depends", "demands", "supplies", "installs", "uninstalls", "installCallbacks", "uninstallCallbacks"})
+public class ABeanMetaData extends AFeatureMetaData
+   implements IBeanMetaData, IBeanMetaDataFactory
+{
+   private static final long serialVersionUID = 1;
+   private String bean;
+   private String name;
+   /** The properties configuration Set<PropertyMetaData> */
+   private Set<IPropertyMetaData> properties;
+
+   public String getBean()
+   {
+      return bean;
+   }
+   public void setBean(String bean)
+   {
+      this.bean = bean;
+   }
+   public String getName()
+   {
+      return name;
+   }
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   /**
+    * Get a property
+    *
+    * @param name the name
+    * @return the property name
+    */
+   public IPropertyMetaData getProperty(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      if (properties != null && properties.size() > 0)
+      {
+         for (IPropertyMetaData prop : properties)
+         {
+            if (name.equals(prop.getName()))
+               return prop;
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Add a property
+    *
+    * @param property the property
+    */
+   public void addProperty(IPropertyMetaData property)
+   {
+      if (property == null)
+         throw new IllegalArgumentException("Null property");
+      if (properties == null)
+         properties = new HashSet<IPropertyMetaData>();
+      properties.add(property);
+   }
+
+   /**
+    * Set the propertiess.
+    *
+    * @param properties Set<PropertyMetaData>
+    */
+   @ManagementProperty(managed=true)
+   @XmlElement(name="property", type=APropertyMetaData.class)
+   public void setProperties(Set<IPropertyMetaData> properties)
+   {
+      this.properties = properties;
+   }
+   public List<IBeanMetaData> getBeans()
+   {
+      ArrayList<IBeanMetaData> beans = new ArrayList<IBeanMetaData>();
+      beans.add(this);
+      return beans;
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AFeatureMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AFeatureMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AFeatureMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,120 @@
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+import java.util.Set;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * General metadata.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 71794 $
+ */
+public abstract class AFeatureMetaData extends JBossObject
+   implements Serializable
+{
+   private static final long serialVersionUID = 2L;
+
+   /** The description */
+   private String description;
+
+   /** The annotations */
+   private Set<IAnnotationMetaData> annotations;
+
+   /**
+    * Create a new meta data
+    */
+   public AFeatureMetaData()
+   {
+   }
+   
+   /**
+    * Set the description.
+    * 
+    * @param description the description.
+    */
+   public void setDescription(String description)
+   {
+      this.description = description;
+      flushJBossObjectCache();
+   }
+
+   /**
+    * Set the annotations.
+    * 
+    * @param annotations Set<AnnotationMetaData>
+    */
+   @XmlElement(name="annotation", type=DirectAnnotationMetaData.class)
+   public void setAnnotations(Set<IAnnotationMetaData> annotations)
+   {
+      this.annotations = annotations;
+      flushJBossObjectCache();
+   }
+   
+   public String getDescription()
+   {
+      return description;
+   }
+   
+   public Set<IAnnotationMetaData> getAnnotations()
+   {
+      return annotations;
+   }
+
+   protected TypeInfo applyCollectionOrMapCheck(TypeInfo typeInfo) throws Throwable
+   {
+      // cannot determine on map, since we don't know if we are key or value
+      if (typeInfo instanceof ClassInfo)
+      {
+         ClassInfo classInfo = (ClassInfo)typeInfo;
+         TypeInfo componentType = classInfo.getComponentType();
+         if (componentType != null)
+            return componentType;
+      }
+      if (typeInfo.isCollection() || typeInfo.isMap())
+      {
+         throw new IllegalArgumentException("Should not be here - set element/value class type in collection/map: " + this);
+      }
+      return typeInfo;
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      if (description != null)
+         buffer.append("description=").append(description);
+      if (annotations != null)
+         buffer.append(" annotations=").append(annotations);
+   }
+   
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(description);
+   }
+
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AKernelDeployment.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AKernelDeployment.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AKernelDeployment.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,143 @@
+/*
+ * 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.beans;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * An abstract kernel deployment.
+ * 
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 71557 $
+ */
+ at ManagementObject(properties = ManagementProperties.EXPLICIT) // TODO - explicitly add props we want to manage 
+ at XmlRootElement(name="deployment")
+ at XmlType(name="deploymentType", propOrder={"annotations", "classLoader", "beanFactories", "create", "start", "stop", "destroy", "aliases"})
+public class AKernelDeployment extends JBossObject
+   implements IKernelDeployment, Serializable
+{
+   private static final long serialVersionUID = 3l;
+
+   /** The name of the deployment */
+   protected String name;
+
+   /** Whether it is installed */
+   protected boolean installed;
+
+   /** Is deployment scoped */
+   protected Boolean scoped;
+
+   /** The beans List<BeanMetaDataFactory> */
+   protected List<IBeanMetaDataFactory> beanFactories;
+
+   /**
+    * Create a new kernel deployment
+    */
+   public AKernelDeployment()
+   {
+   }
+
+   /**
+    * Set the bean factories.
+    *
+    * @deprecated use setBeanFactories
+    * @param beans a List<BeanMetaData>.
+    */
+   @SuppressWarnings("unchecked")
+   public void setBeans(List beans)
+   {
+      this.beanFactories = beans;
+      flushJBossObjectCache();
+   }
+
+   public List<IBeanMetaDataFactory> getBeanFactories()
+   {
+      return beanFactories;
+   }
+   /**
+    * Set the bean factories.
+    * 
+    * @param beanFactories a List<BeanMetaDataFactory>.
+    */
+   @ManagementProperty(managed=true)
+   @XmlElements
+   ({
+      @XmlElement(name="bean", type=ABeanMetaData.class)
+   })
+   @XmlAnyElement
+   public void setBeanFactories(List<IBeanMetaDataFactory> beanFactories)
+   {
+      this.beanFactories = beanFactories;
+      flushJBossObjectCache();
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   @XmlAttribute
+   public void setName(String name)
+   {
+      this.name = name;
+      flushJBossObjectCache();
+   }
+
+   public boolean isInstalled()
+   {
+      return installed;
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("name=").append(name);
+      buffer.append(" installed=").append(installed);
+      if (beanFactories != null)
+         buffer.append(" beanFactories=").append(beanFactories);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(name);
+   }
+
+}
\ No newline at end of file

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/APropertyMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/APropertyMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/APropertyMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,246 @@
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * Metadata for a property.
+ * 
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 76911 $
+ */
+ at XmlType(name="propertyType", propOrder={"annotations", "value"})
+public class APropertyMetaData extends AFeatureMetaData
+   implements IPropertyMetaData, Serializable
+{
+   private static final long serialVersionUID = 3L;
+
+   /** The property name */
+   protected String name;
+
+   /** The preinstantiate */
+   protected boolean preInstantiate = true;
+
+   /** The property value */
+   protected IValueMetaData value;
+
+   /** The property type */
+   protected String type;
+   
+   /** The property replace */
+   private Boolean replace;
+   
+   /** Whether to trim */
+   private Boolean trim;
+   
+   /**
+    * Create a new property meta data
+    */
+   public APropertyMetaData()
+   {
+   }
+
+   /**
+    * Create a new property meta data
+    * 
+    * @param name the name
+    * @param value the value
+    */
+   public APropertyMetaData(String name, Object value)
+   {
+      this.name = name;
+      this.value = new AbstractValueMetaData(value);
+   }
+
+   /**
+    * Create a new property meta data
+    * 
+    * @param name the name
+    * @param value the string value
+    */
+   public APropertyMetaData(String name, String value)
+   {
+      this.name = name;
+      this.value = new StringValueMetaData(value);
+   }
+
+   /**
+    * Create a new attribute meta data
+    * 
+    * @param name the name
+    * @param value the value meta data
+    */
+   public APropertyMetaData(String name, IValueMetaData value)
+   {
+      this.name = name;
+      this.value = value;
+   }
+
+   /**
+    * Create a new property meta data
+    * 
+    * @param name the name
+    * @param value the string value
+    * @param type the type
+    */
+   public APropertyMetaData(String name, String value, String type)
+   {
+      this.name = name;
+      StringValueMetaData svmd = new StringValueMetaData(value);
+      svmd.setType(type);
+      this.value = svmd;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Set the name
+    * 
+    * @param name the name
+    */
+   @XmlAttribute
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public String getType()
+   {
+      if (value instanceof AbstractTypeMetaData)
+      {
+         return ((AbstractTypeMetaData)value).getType();
+      }
+      return null;
+   }
+
+   public boolean isPreInstantiate()
+   {
+      return preInstantiate;
+   }
+
+   @XmlAttribute(name="preinstantiate")
+   public void setPreInstantiate(boolean preInstantiate)
+   {
+      this.preInstantiate = preInstantiate;
+   }
+
+   public IValueMetaData getValue()
+   {
+      return value;
+   }
+
+   public void setValue(IValueMetaData value)
+   {
+      this.value = value;
+   }
+
+   @XmlAnyElement
+   @ManagementProperty(ignored = true)
+   public void setValueObject(Object value)
+   {
+      if (value == null)
+         setValue(null);
+      else if (value instanceof IValueMetaData)
+         setValue((IValueMetaData) value);
+      else
+         setValue(new AbstractValueMetaData(value));
+   }
+
+   @XmlValue
+   @ManagementProperty(ignored = true)
+   public void setValueString(String value)
+   {
+      if (value == null)
+         setValue(null);
+      else
+      {
+         IValueMetaData valueMetaData = getValue();
+         if (valueMetaData instanceof StringValueMetaData)
+         {
+            ((StringValueMetaData) valueMetaData).setValue(value);
+         }
+         else
+         {
+            StringValueMetaData stringValue = new StringValueMetaData(value);
+            stringValue.setType(getType());
+            setValue(stringValue);
+         }
+      }
+   }
+
+   public String getPropertyType()
+   {
+      return type;
+   }
+   
+   @XmlAttribute(name="class")
+   @ManagementProperty(ignored = true)
+   public void setPropertyType(String type)
+   {
+      this.type = type;
+   }
+
+   @XmlAttribute(name="replace")
+   @ManagementProperty(ignored = true)
+   public void setPropertyReplace(boolean replace)
+   {
+      this.replace = replace;
+   }
+
+   @XmlAttribute(name="trim")
+   @ManagementProperty(ignored = true)
+   public void setPropertyTrim(boolean trim)
+   {
+      this.trim = trim;
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("name=").append(name);
+      if (value != null)
+         buffer.append(" value=").append(value);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(name);
+   }
+
+   public APropertyMetaData clone()
+   {
+      APropertyMetaData clone = (APropertyMetaData)super.clone();
+      return clone;
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractTypeMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractTypeMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractTypeMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,254 @@
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+import java.util.Stack;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.joinpoint.spi.Joinpoint;
+
+/**
+ * A typed value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 76173 $
+ */
+public abstract class AbstractTypeMetaData extends AbstractValueMetaData
+   implements Serializable
+{
+   private static final long serialVersionUID = 3L;
+
+   /**
+    * The type
+    */
+   protected String type;
+
+   /**
+    * The property name
+    */
+   protected String propertyName;
+
+   /**
+    * The bean name
+    */
+   protected String beanName;
+
+   /**
+    * Create a new typed value
+    */
+   public AbstractTypeMetaData()
+   {
+   }
+
+   /**
+    * Create a new typed value
+    *
+    * @param value the value
+    */
+   public AbstractTypeMetaData(String value)
+   {
+      super(value);
+   }
+
+   /**
+    * Set the type
+    *
+    * @param type the type
+    */
+   @XmlAttribute(name="class")
+   public void setType(String type)
+   {
+      this.type = type;
+   }
+
+   public String getType()
+   {
+      return type;
+   }
+
+   /**
+    * Check result for class compatibility.
+    *
+    * @param <T> the expected type
+    * @param result the result
+    * @param expected expected class
+    * @return casted result
+    * @throws ClassCastException if result cannot be casted into expected parameter
+    */
+   protected <T> T checkResult(Object result, Class<T> expected)
+   {
+      if (result != null && expected.isAssignableFrom(result.getClass()) == false)
+         throw new ClassCastException(result.getClass() + " is not a " + expected.getName());
+      return expected.cast(result);
+   }
+
+   /**
+    * Create new instance from type field.
+    * Fall back to info parameter if no type field is set.
+    *
+    * @param <T> expected type
+    * @param info the type of reference we are about to set
+    * @param cl the classloader to use
+    * @param expected the expected class
+    * @param explicit is type explicit
+    * @return class instance or null if type is too broad
+    * @throws Throwable on any error
+    */
+   protected <T> T createInstance(TypeInfo info, ClassLoader cl, Class<T> expected, boolean explicit) throws Throwable
+   {
+      if (info == null || Object.class.getName().equals(info.getName()))
+         return null;
+
+      if (info instanceof ClassInfo == false)
+      {
+         if (explicit)
+            throw new IllegalArgumentException(info.getName() + " is not a class");
+         else
+            return null;
+      }
+
+      if (((ClassInfo) info).isInterface())
+      {
+         if (explicit)
+            throw new IllegalArgumentException(info.getName() + " is an interface");
+         else
+            return null;
+      }
+
+      Object result = null;
+
+      if (expected.isAssignableFrom(result.getClass()) == false)
+         throw new ClassCastException(result.getClass() + " is not a " + expected.getName());
+
+      return expected.cast(result);
+   }
+
+   /**
+    * Create the class instance
+    *
+    * @param <T> expected type
+    * @param info the request type
+    * @param cl the classloader
+    * @param expected the expected class
+    * @return the class instance
+    * @throws Throwable for any error
+    */
+   protected <T> T getTypeInstance(TypeInfo info, ClassLoader cl, Class<T> expected) throws Throwable
+   {
+      return getTypeInstance(info, cl, expected, true);
+   }
+
+   /**
+    * Create the class instance
+    *
+    * @param <T> expected type
+    * @param info the request type
+    * @param cl the classloader
+    * @param expected the expected class
+    * @param preInstantiatedLookup  whether to do the preinstantiated lookup
+    * @return the class instance
+    * @throws Throwable for any error
+    */
+   protected <T> T getTypeInstance(TypeInfo info, ClassLoader cl, Class<T> expected, boolean preInstantiatedLookup) throws Throwable
+   {
+      T result = null;
+
+      TypeInfo typeInfo = getClassInfo(cl);
+      // we have explicitly set type
+      if (typeInfo != null)
+         result = createInstance(typeInfo, cl, expected, true);
+
+      if (result == null)
+      {
+         // try info param
+         if (result == null)
+         {
+            result = createInstance(info, cl, expected, false);
+            // get default
+            if (result == null)
+               result = expected.cast(getDefaultInstance());
+         }
+      }
+
+      return result;
+   }
+
+   /**
+    * Get the default instance.
+    *
+    * @return the default instance
+    */
+   protected abstract Object getDefaultInstance();
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      if (type != null)
+         buffer.append(" type=").append(type);
+   }
+
+   /**
+    * Get the class info for this type
+    *
+    * @param cl classloader
+    * @return the class info
+    * @throws Throwable for any error
+    */
+   protected ClassInfo getClassInfo(ClassLoader cl) throws Throwable
+   {
+      return getClassInfo(type, cl);
+   }
+
+   protected ClassInfo getClassInfo(String classType, ClassLoader cl) throws Throwable
+   {
+      return null;
+   }
+
+   /**
+    * Get the type info for this type
+    *
+    * @param cl classloader
+    * @return the type info
+    * @throws Throwable for any error
+    */
+   protected TypeInfo getTypeInfo(ClassLoader cl) throws Throwable
+   {
+      return getTypeInfo(type, cl);
+   }
+
+   protected TypeInfo getTypeInfo(String classType, ClassLoader cl) throws Throwable
+   {
+      if (classType == null)
+         return null;
+
+      return null;
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractValueMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractValueMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractValueMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,117 @@
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Plain value.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 76863 $
+ */
+ at XmlType
+public class AbstractValueMetaData extends JBossObject
+   implements IValueMetaData, Serializable
+{
+   private static final long serialVersionUID = 2L;
+
+   /**
+    * The value
+    */
+   private Object value;
+
+   /**
+    * Create a new plain value
+    */
+   public AbstractValueMetaData()
+   {
+   }
+
+   /**
+    * Create a new plain value
+    *
+    * @param value the value
+    */
+   public AbstractValueMetaData(Object value)
+   {
+      setValue(value);
+   }
+
+   public Object getValue()
+   {
+      return value;
+   }
+
+   public void setValue(Object value)
+   {
+      Object jmxHack = null;
+      if (jmxHack != null)
+         this.value = jmxHack;
+      else
+         this.value = value;
+      
+      flushJBossObjectCache();
+   }
+
+   public Object getUnderlyingValue()
+   {
+      return value;
+   }
+
+   /**
+    * Do we use jmx object name fix.
+    *
+    * @return do we use jmx object name fix
+    */
+   protected boolean isUseJMXObjectNameFix()
+   {
+      return true;
+   }
+
+   public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
+   {
+      return info != null ? info.convertValue(value) : value;
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("value=").append(value);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(value);
+   }
+
+   public AbstractValueMetaData clone()
+   {
+      AbstractValueMetaData clone = (AbstractValueMetaData)super.clone();
+      return clone;
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/BeanMetaDataICF.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/BeanMetaDataICF.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/BeanMetaDataICF.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,205 @@
+/*
+ * 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.beans;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementObjectClass;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+
+/**
+ * An InstanceClassFactory for BeanMetaData
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BeanMetaDataICF
+   implements InstanceClassFactory<IBeanMetaData>
+{
+   private static final Logger log = Logger.getLogger(BeanMetaDataICF.class);
+   /** The meta value factory */
+   private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); 
+   private static HashMap<String, Object> beanMap = new HashMap<String, Object>();
+
+   public MetaValueFactory getMetaValueFactory()
+   {
+      return metaValueFactory;
+   }
+   public void setMetaValueFactory(MetaValueFactory metaValueFactory)
+   {
+      this.metaValueFactory = metaValueFactory;
+   }
+
+   public static Object getBean(String name)
+   {
+      return beanMap.get(name);
+   }
+   public static void setBean(String name, Object bean)
+   {
+      beanMap.put(name, bean);
+   }
+
+   public Object locateBean(String beanName)
+   {
+      return beanMap.get(beanName);
+   }
+
+   public Object getComponentName(BeanInfo beanInfo, ManagedProperty property,
+         IBeanMetaData attachment, MetaValue value)
+   {
+      return attachment.getName();
+   }
+
+   public Class<?> getManagedObjectClass(IBeanMetaData attachment)
+      throws ClassNotFoundException
+   {
+      Class<?> mocClass = null;
+
+      // Look for a ManagementObjectClass annotation
+      Set<IAnnotationMetaData> annotations = attachment.getAnnotations();
+      if(annotations != null)
+      {
+         for(IAnnotationMetaData amd : annotations)
+         {
+            Annotation ann = amd.getAnnotationInstance();
+            if(ann instanceof ManagementObjectClass)
+            {
+               ManagementObjectClass moc = (ManagementObjectClass) ann;
+               mocClass = moc.code();
+            }
+         }
+      }
+      // Use the bean from the metadata
+      if(mocClass == null)
+      {
+         String beanClassName = attachment.getBean();
+         if(beanClassName != null && beanClassName.length() > 0)
+         {
+            // TODO: TCL may not be correct
+            ClassLoader loader = getClassLoader(attachment);
+            mocClass = loader.loadClass(beanClassName);
+         }
+      }
+      return mocClass;
+   }
+
+   public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+         IBeanMetaData attachment)
+   {
+      // Get the property from the bean
+      // First look to the mapped name
+      String name = property.getMappedName();
+      if (name == null)
+         property.getName();
+      PropertyInfo propertyInfo = beanInfo.getProperty(name);
+      Object bean = locateBean(attachment.getName());
+      Object value = null;
+      MetaValue mvalue = null;
+
+      try
+      {
+         value = propertyInfo.get(bean);
+         mvalue = metaValueFactory.create(value, propertyInfo.getType());
+      }
+      catch(Throwable e)
+      {
+         log.debug("Failed to get property value for bean: "+beanInfo.getName()
+               +", property: "+propertyInfo.getName(), e);
+         mvalue = metaValueFactory.create(null, propertyInfo.getType());
+         return mvalue;
+      }
+
+      return mvalue;
+   }
+
+   public void setValue(BeanInfo beanInfo, ManagedProperty property,
+         IBeanMetaData attachment, MetaValue value)
+   {
+      ClassLoader prevLoader = SecurityActions.getContextClassLoader();
+      String beanName = attachment.getName();
+      // First look to the mapped name
+      String name = property.getMappedName();
+      if (name == null)
+         property.getName();
+
+      // See if this is a RUNTIME property
+      Map<String, Annotation> annotations = property.getAnnotations();
+      boolean isRuntime = false;
+      if(annotations != null)
+      {
+         ManagementProperty annotation = (ManagementProperty) annotations.get(ManagementProperty.class);
+         if(annotation != null)
+         {
+            ViewUse[] uses = annotation.use();
+            for(ViewUse use : uses)
+            {
+               if(use == ViewUse.RUNTIME)
+                  isRuntime = true;
+            }
+         }
+      }
+
+      try
+      {
+         ClassLoader loader = getClassLoader(attachment);
+         // Set the mbean class loader as the TCL
+         SecurityActions.setContextClassLoader(loader);
+
+         PropertyInfo propertyInfo = beanInfo.getProperty(name);
+         if(propertyInfo == null)
+            throw new IllegalArgumentException("No matching property found: " + name + "/" + beanName);
+
+         Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
+         Object bean = locateBean(beanName);
+         propertyInfo.set(bean, plainValue);
+      }
+      catch(Throwable e)
+      {
+         throw new IllegalStateException("Failed to set property value: "+name + "/" + beanName, e);
+      }
+      finally
+      {
+         SecurityActions.setContextClassLoader(prevLoader);
+      }
+   }
+
+   protected ClassLoader getClassLoader(IBeanMetaData deployment)
+   {
+      ClassLoader loader = null;
+      // TODO...
+      // Fallback to TCL if there is no
+      if(loader == null)
+         loader = SecurityActions.getContextClassLoader();
+      return loader;
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/DirectAnnotationMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/DirectAnnotationMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/DirectAnnotationMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,88 @@
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Metadata for an annotation.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DirectAnnotationMetaData extends JBossObject
+   implements IAnnotationMetaData, Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   private Annotation annotation;
+
+   public DirectAnnotationMetaData(Annotation annotation)
+   {
+      if (annotation == null)
+         throw new IllegalArgumentException("Null annotation");
+
+      this.annotation = annotation;
+   }
+
+   public Annotation getAnnotationInstance()
+   {
+      return annotation;
+   }
+
+   public Annotation getAnnotationInstance(ClassLoader cl)
+   {
+      return annotation;
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("annotationr=").append(annotation);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(annotation);
+   }
+
+   protected int getHashCode()
+   {
+      return annotation.hashCode();
+   }
+
+   public boolean equals(Object object)
+   {
+      if (object == null || object instanceof DirectAnnotationMetaData == false)
+         return false;
+
+      DirectAnnotationMetaData damd = (DirectAnnotationMetaData)object;
+      return annotation.equals(damd.annotation);
+   }
+
+   public DirectAnnotationMetaData clone()
+   {
+      return (DirectAnnotationMetaData)super.clone();
+   }
+}
\ No newline at end of file

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IAnnotationMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IAnnotationMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IAnnotationMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,47 @@
+/*
+ * 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.beans;
+
+import java.lang.annotation.Annotation;
+
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IAnnotationMetaData
+{
+   /**
+    * Get the annotation using passed in classloader
+    * @param classloader The classloader
+    * @return The annotation instance
+    */
+   Annotation getAnnotationInstance(ClassLoader classloader);
+
+   /**
+    * Get the annotation using the thread context classloader
+    * @return The annotation instance
+    */
+   @XmlTransient
+   Annotation getAnnotationInstance();
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,48 @@
+/*
+ * 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.beans;
+
+import java.util.Set;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IBeanMetaData
+{
+   /**
+    * Get the bean.
+    * 
+    * @return the bean.
+    */
+   String getBean();
+
+   /**
+    * Get the name
+    * 
+    * @return the name
+    */
+   String getName();
+
+   
+   Set<IAnnotationMetaData> getAnnotations();
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaDataFactory.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaDataFactory.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaDataFactory.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,33 @@
+/*
+ * 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.beans;
+
+import java.util.List;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IBeanMetaDataFactory
+{
+   public List<IBeanMetaData> getBeans();
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IKernelDeployment.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IKernelDeployment.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IKernelDeployment.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,31 @@
+/*
+ * 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.beans;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IKernelDeployment
+{
+
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IPropertyMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IPropertyMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IPropertyMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,57 @@
+/*
+ * 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.beans;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IPropertyMetaData
+{
+   /**
+    * Get the name.
+    * 
+    * @return the name.
+    */
+   String getName();
+
+   /**
+    * Get property type if possible.
+    *
+    * @return class type if set, otherwise null
+    */
+   String getType();
+
+   /**
+    * Get the preinstantiate flag.
+    *
+    * @return the preinstantiate flag
+    */
+   boolean isPreInstantiate();
+
+   /**
+    * Get the value.
+    * 
+    * @return the value.
+    */
+   IValueMetaData getValue();
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IValueMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IValueMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IValueMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,48 @@
+/*
+ * 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.beans;
+
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IValueMetaData
+{
+   /**
+    * Get the underlying value
+    * 
+    * @return the underlying value
+    */
+   public Object getUnderlyingValue();
+   
+   /**
+    * Get the value.
+    * 
+    * @param info the type info
+    * @param cl the classloader
+    * @return the value.
+    * @throws Throwable for any error
+    */
+   Object getValue(TypeInfo info, ClassLoader cl) throws Throwable;
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/SecurityActions.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/SecurityActions.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/SecurityActions.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,160 @@
+/*
+ * 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.beans;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Package privileged actions
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71039 $
+ */
+class SecurityActions
+{
+   interface TCLAction
+   {
+      class UTIL
+      {
+         static TCLAction getTCLAction()
+         {
+            return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
+         }
+
+         static ClassLoader getContextClassLoader()
+         {
+            return getTCLAction().getContextClassLoader();
+         }
+
+         static ClassLoader getContextClassLoader(Thread thread)
+         {
+            return getTCLAction().getContextClassLoader(thread);
+         }
+
+         static void setContextClassLoader(ClassLoader cl)
+         {
+            getTCLAction().setContextClassLoader(cl);
+         }
+
+         static void setContextClassLoader(Thread thread, ClassLoader cl)
+         {
+            getTCLAction().setContextClassLoader(thread, cl);
+         }
+      }
+
+      TCLAction NON_PRIVILEGED = new TCLAction()
+      {
+         public ClassLoader getContextClassLoader()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+
+         public ClassLoader getContextClassLoader(Thread thread)
+         {
+            return thread.getContextClassLoader();
+         }
+
+         public void setContextClassLoader(ClassLoader cl)
+         {
+            Thread.currentThread().setContextClassLoader(cl);
+         }
+
+         public void setContextClassLoader(Thread thread, ClassLoader cl)
+         {
+            thread.setContextClassLoader(cl);
+         }
+      };
+
+      TCLAction PRIVILEGED = new TCLAction()
+      {
+         private final PrivilegedAction<ClassLoader> getTCLPrivilegedAction = new PrivilegedAction<ClassLoader>()
+         {
+            public ClassLoader run()
+            {
+               return Thread.currentThread().getContextClassLoader();
+            }
+         };
+
+         public ClassLoader getContextClassLoader()
+         {
+            return AccessController.doPrivileged(getTCLPrivilegedAction);
+         }
+
+         public ClassLoader getContextClassLoader(final Thread thread)
+         {
+            return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+            {
+               public ClassLoader run()
+               {
+                  return thread.getContextClassLoader();
+               }
+            });
+         }
+
+         public void setContextClassLoader(final ClassLoader cl)
+         {
+            AccessController.doPrivileged(
+               new PrivilegedAction<ClassLoader>()
+               {
+                  public ClassLoader run()
+                  {
+                     Thread.currentThread().setContextClassLoader(cl);
+                     return null;
+                  }
+               }
+            );
+         }
+
+         public void setContextClassLoader(final Thread thread, final ClassLoader cl)
+         {
+            AccessController.doPrivileged(
+               new PrivilegedAction<ClassLoader>()
+               {
+                  public ClassLoader run()
+                  {
+                     thread.setContextClassLoader(cl);
+                     return null;
+                  }
+               }
+            );
+         }
+      };
+
+      ClassLoader getContextClassLoader();
+
+      ClassLoader getContextClassLoader(Thread thread);
+
+      void setContextClassLoader(ClassLoader cl);
+
+      void setContextClassLoader(Thread thread, ClassLoader cl);
+   }
+
+   static ClassLoader getContextClassLoader()
+   {
+      return TCLAction.UTIL.getContextClassLoader();
+   }
+   static void setContextClassLoader(ClassLoader loader)
+   {
+      TCLAction.UTIL.setContextClassLoader(loader);
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/StringValueMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/StringValueMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/beans/StringValueMetaData.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -0,0 +1,158 @@
+/*
+ * 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.beans;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.logging.Logger;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StringValueMetaData
+   implements IValueMetaData
+{
+   private static final long serialVersionUID = 2L;
+
+   /** The log */
+   private static final Logger log = Logger.getLogger(StringValueMetaData.class);
+   /**
+    * The value
+    */
+   private Object value;
+   /**
+    * The type
+    */
+   protected String type;
+
+   /**
+    * The property name
+    */
+   protected String propertyName;
+
+   /**
+    * The bean name
+    */
+   protected String beanName;
+   /**
+    * Do we replace String with System property,
+    * by default it is true.
+    */
+   private boolean replace = true;
+
+   /**
+    * Do we trim string value before usage,
+    * by default is true.
+    */
+   private boolean trim = true;
+
+   /**
+    * Create a new string value
+    */
+   public StringValueMetaData()
+   {
+   }
+
+   /**
+    * Create a new string value
+    * 
+    * @param value the value
+    */
+   public StringValueMetaData(String value)
+   {
+      this.value = value;
+   }
+
+   public String getValue()
+   {
+      return value.toString();
+   }
+
+   /**
+    * Set the value
+    * 
+    * @param value the value
+    */
+   @XmlValue
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+
+   public void setValue(Object value)
+   {
+      if (value != null && value instanceof String == false)
+         throw new ClassCastException("value is not a String: " + value);
+      this.value = (String) value;
+   }
+
+   protected Object getDefaultInstance()
+   {
+      return null;
+   }
+
+   public boolean isReplace()
+   {
+      return replace;
+   }
+
+   @XmlAttribute(name="replace")
+   public void setReplace(boolean replace)
+   {
+      this.replace = replace;
+   }
+
+   public boolean isTrim()
+   {
+      return trim;
+   }
+
+   public void setTrim(boolean trim)
+   {
+      this.trim = trim;
+   }
+
+   public Object getUnderlyingValue()
+   {
+      return value;
+   }
+
+   public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public StringValueMetaData clone()
+      throws CloneNotSupportedException
+   {
+      return (StringValueMetaData)super.clone();
+   }
+
+   public void setType(String type)
+   {
+      this.type = type;
+   }
+}

Modified: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java	2008-10-27 04:16:58 UTC (rev 80089)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java	2008-10-27 04:29:42 UTC (rev 80090)
@@ -25,6 +25,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import junit.framework.Test;
@@ -37,6 +38,7 @@
 import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
 import org.jboss.metatype.api.values.CollectionValue;
 import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
 import org.jboss.test.managed.factory.support.ManagementObjectChangedName;
@@ -48,6 +50,11 @@
 import org.jboss.test.managed.factory.support.amof.TestICF;
 import org.jboss.test.managed.factory.support.amof.TestMOP;
 import org.jboss.test.managed.factory.support.amof.TestSimpleICF;
+import org.jboss.test.managed.factory.support.beans.ABeanMetaData;
+import org.jboss.test.managed.factory.support.beans.AKernelDeployment;
+import org.jboss.test.managed.factory.support.beans.BeanMetaDataICF;
+import org.jboss.test.managed.factory.support.beans.IBeanMetaData;
+import org.jboss.test.managed.factory.support.beans.IBeanMetaDataFactory;
 import org.jboss.test.managed.factory.support.deployment.JmsDestination;
 import org.jboss.test.managed.factory.support.deployment.JmsDestinationICF;
 import org.jboss.test.managed.factory.support.deployment.JmsDestinations;
@@ -230,6 +237,67 @@
 
    }
 
+   public void testKernelDeployment()
+   {
+      AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+      mof.setInstanceClassFactory(IBeanMetaData.class, new BeanMetaDataICF());
+      testMOF = mof;
+
+      AKernelDeployment ad = new AKernelDeployment();
+      ABeanMetaData bean1 = new ABeanMetaData();
+      bean1.setBean(Simple.class.getName());
+      bean1.setName("SimpleBean#1");
+      ABeanMetaData bean2 = new ABeanMetaData();
+      bean2.setBean(Simple.class.getName());
+      bean2.setName("SimpleBean#2");
+
+      Simple simple1 = new Simple();
+      simple1.setBigDecimalValue(new BigDecimal(123456));
+      Simple simple2 = new Simple();
+      simple2.setBigDecimalValue(new BigDecimal(222222));
+      BeanMetaDataICF.setBean("SimpleBean#1", simple1);
+      BeanMetaDataICF.setBean("SimpleBean#2", simple2);
+      List<IBeanMetaDataFactory> beanFactories = new ArrayList<IBeanMetaDataFactory>();
+      beanFactories.add(bean1);
+      beanFactories.add(bean2);
+      ad.setBeanFactories(beanFactories);
+
+      ManagedObject mo = mof.initManagedObject(ad, "KernelDeployment", null);
+      ManagedProperty beanFactoriesMP = mo.getProperty("beanFactories");
+      assertNotNull("beanFactories MP", beanFactoriesMP);
+      Object beanFactoriesMPValue = beanFactoriesMP.getValue();
+      getLog().debug("beanFactories MP value: "+beanFactoriesMPValue);
+      assertTrue(beanFactoriesMPValue instanceof CollectionValue);
+      CollectionValue cv = CollectionValue.class.cast(beanFactoriesMPValue);
+      MetaValue[] cvs = cv.getElements();
+
+      assertEquals(2, cv.getSize());
+      MetaValue mv0 = cvs[0];
+      assertTrue(mv0 instanceof GenericValue);
+      GenericValue gv0 = GenericValue.class.cast(mv0);
+      Object gv0Value = gv0.getValue();
+      assertTrue(gv0Value instanceof ManagedObject);
+      ManagedObject mo0 = ManagedObject.class.cast(gv0Value);
+      ManagedProperty bigDecimalValueMP = mo0.getProperty("bigDecimalValue");
+      assertNotNull(bigDecimalValueMP);
+      assertEquals(SimpleValueSupport.wrap(new BigDecimal(123456)), bigDecimalValueMP.getValue());
+      bigDecimalValueMP.setValue(SimpleValueSupport.wrap(new BigDecimal(987654)));
+      assertEquals(new BigDecimal(987654), simple1.getBigDecimalValue());
+
+      MetaValue mv1 = cvs[1];
+      assertTrue(mv1 instanceof GenericValue);
+      GenericValue gv1 = GenericValue.class.cast(mv1);
+      Object gv1Value = gv1.getValue();
+      assertTrue(gv1Value instanceof ManagedObject);
+      ManagedObject mo1 = ManagedObject.class.cast(gv1Value);
+      ManagedProperty bigDecimalValueMP2 = mo1.getProperty("bigDecimalValue");
+      assertNotNull(bigDecimalValueMP2);
+      assertEquals(SimpleValueSupport.wrap(new BigDecimal(222222)), bigDecimalValueMP2.getValue());
+      bigDecimalValueMP2.setValue(SimpleValueSupport.wrap(new BigDecimal(12222221)));
+      assertEquals(new BigDecimal(12222221), simple2.getBigDecimalValue());
+      
+   }
+
    /**
     * Override to allow test specific ManagedObjectFactory
     */




More information about the jboss-cvs-commits mailing list