[jboss-cvs] JBossAS SVN: r78035 - projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 4 20:42:36 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-09-04 20:42:36 -0400 (Thu, 04 Sep 2008)
New Revision: 78035

Modified:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractInstanceClassFactory.java
Log:
Add a setManagedObject stub method that is called by setValue if the unwrapValue instanceof ManagedObject.

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractInstanceClassFactory.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractInstanceClassFactory.java	2008-09-05 00:40:52 UTC (rev 78034)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractInstanceClassFactory.java	2008-09-05 00:42:36 UTC (rev 78035)
@@ -51,10 +51,16 @@
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.NotImplementedException;
 
 /**
- * A base InstanceClassFactory implementation that 
+ * A base InstanceClassFactory implementation that uses jboss reflection to
+ * get/set values on the underlying property object.
  * 
+ * Runtime component names are handled via a mapping from TypeInfo to
+ * {@linkplain RuntimeComponentNameTransformer} using property ManagementRuntimeRef
+ * information.
+ * 
  * @param <T> the instance type
  * @author Scott.Stark at jboss.org
  * @version $Revision$
@@ -270,7 +276,13 @@
       Object unwrapValue = unwrapValue(beanInfo, property, value);
       try
       {
-         setValue(beanInfo, propertyInfo, object, unwrapValue);
+         if(unwrapValue instanceof ManagedObject)
+         {
+            ManagedObject mo = (ManagedObject) unwrapValue;
+            setManagedObject(beanInfo, propertyInfo, object, mo);
+         }
+         else
+            setValue(beanInfo, propertyInfo, object, unwrapValue);
       }
       catch(Throwable t)
       {
@@ -278,6 +290,11 @@
       }
    }
 
+   public GenericValue getManagedObjectValue(ManagedProperty property, ManagedObject value)
+   {
+      return getManagedObjectValue(null, property, value);
+   }
+
    protected GenericValue getManagedObjectValue(BeanInfo beanInfo, ManagedProperty property, Object value)
    {
       if (value instanceof Serializable == false)
@@ -286,7 +303,11 @@
       ManagementObjectRef ref = (ManagementObjectRef) property.getAnnotations().get(ManagementObjectRef.class.getName());
       String moName = (ref != null ? ref.name() : value.getClass().getName());
       String moNameType = (ref != null ? ref.type() : "");
-      ManagedObject mo = mof.initManagedObject((Serializable) value, moName, moNameType);
+      ManagedObject mo;
+      if(value instanceof ManagedObject)
+         mo = ManagedObject.class.cast(value);
+      else
+         mo = mof.initManagedObject((Serializable) value, moName, moNameType);
       return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
    }
    protected List<GenericValue> getManagedObjectArray(BeanInfo beanInfo, ManagedProperty property, Object value)
@@ -305,6 +326,23 @@
    {
       return metaValueFactory.create(value, propertyInfo.getType());
    }
+   /**
+    * Currently just a stub method subclasses have to override to avoid
+    * the NotImplementedException.
+    * 
+    * TODO: how to map the managed properties onto the corresponding attachment
+    * object, create another ManagedObject?
+    *
+    * @param beanInfo
+    * @param propertyInfo
+    * @param object
+    * @param mo
+    */
+   protected void setManagedObject(BeanInfo beanInfo, PropertyInfo propertyInfo,
+         T object, ManagedObject mo)
+   {
+      throw new NotImplementedException("Use a custom InstanceClassFactory for now");
+   }
 
    /**
     * Get component name transformer.




More information about the jboss-cvs-commits mailing list