[jboss-cvs] JBossAS SVN: r66172 - projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 16 05:59:06 EDT 2007


Author: alesj
Date: 2007-10-16 05:59:06 -0400 (Tue, 16 Oct 2007)
New Revision: 66172

Modified:
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/MockProfileService.java
Log:
Get ref name check.

Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/MockProfileService.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/MockProfileService.java	2007-10-16 09:31:27 UTC (rev 66171)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/support/MockProfileService.java	2007-10-16 09:59:06 UTC (rev 66172)
@@ -48,6 +48,7 @@
 import org.jboss.metatype.api.values.ArrayValue;
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.MetaValue;
 
 /**
  * Mock profile service for testing implementation details.
@@ -170,8 +171,7 @@
          ManagementObjectID id = (ManagementObjectID) prop.getAnnotations().get(ManagementObjectID.class.getName());
          if (id != null)
          {
-            SimpleValue refValue = (SimpleValue) prop.getValue();
-            String refName = (String) refValue.getValue();
+            Object refName = getRefName(prop.getValue());
             if (refName == null)
                refName = id.name();
             String propKey = refName + "/" + id.type();
@@ -186,8 +186,7 @@
          {
             // The reference key is the prop value + ref.type()
             log.debug("Property("+prop.getName()+") references: "+ref);
-            SimpleValue refValue = (SimpleValue) prop.getValue();
-            String refName = (String) refValue.getValue();
+            Object refName = getRefName(prop.getValue());
             if (refName == null)
                refName = ref.name();
             String targetKey = refName + "/" + ref.type();
@@ -234,6 +233,18 @@
       }
    }
 
+   protected Object getRefName(Object value)
+   {
+      if (value instanceof MetaValue)
+      {
+         MetaValue metaValue = (MetaValue)value;
+         if (metaValue.getMetaType().isSimple() == false)
+            throw new IllegalArgumentException("Can only get ref from simple value: " + value);
+         return ((SimpleValue)metaValue).getValue();
+      }
+      return value;
+   }
+
    public Map<String, Set<ManagedProperty>> getUnresolvedRefs()
    {
       return unresolvedRefs;




More information about the jboss-cvs-commits mailing list