[jboss-cvs] JBossAS SVN: r70442 - projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 5 13:03:22 EST 2008
Author: adrian at jboss.org
Date: 2008-03-05 13:03:22 -0500 (Wed, 05 Mar 2008)
New Revision: 70442
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCollectionMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java
Log:
Better support for spotting an unmodifiable collection/map from a getter
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCollectionMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCollectionMetaData.java 2008-03-05 17:30:27 UTC (rev 70441)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCollectionMetaData.java 2008-03-05 18:03:22 UTC (rev 70442)
@@ -112,7 +112,18 @@
for (int i = 0; i < collection.size(); ++i)
{
ValueMetaData vmd = (ValueMetaData) collection.get(i);
- result.add(vmd.getValue(elementTypeInfo, cl));
+ Object value = vmd.getValue(elementTypeInfo, cl);
+ try
+ {
+ result.add(value);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ if (i != 0)
+ throw e;
+ result = getTypeInstance(info, cl, Collection.class, false);
+ result.add(value);
+ }
}
return result;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java 2008-03-05 17:30:27 UTC (rev 70441)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractMapMetaData.java 2008-03-05 18:03:22 UTC (rev 70442)
@@ -121,6 +121,7 @@
if (map.size() > 0)
{
+ boolean first = true;
for (Iterator i = map.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry) i.next();
@@ -128,7 +129,18 @@
ValueMetaData value = (ValueMetaData) entry.getValue();
Object keyValue = key.getValue(keyTypeInfo, cl);
Object valueValue = value.getValue(valueTypeInfo, cl);
- result.put(keyValue, valueValue);
+ try
+ {
+ result.put(keyValue, valueValue);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ if (first == false)
+ throw e;
+ result = getTypeInstance(info, cl, getExpectedClass(), false);
+ result.put(keyValue, valueValue);
+ }
+ first = false;
}
}
return result;
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java 2008-03-05 17:30:27 UTC (rev 70441)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java 2008-03-05 18:03:22 UTC (rev 70442)
@@ -268,6 +268,22 @@
*/
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);
@@ -277,7 +293,8 @@
if (result == null)
{
- result = preinstantiatedLookup(cl, expected);
+ if (preInstantiatedLookup)
+ result = preinstantiatedLookup(cl, expected);
// try info param
if (result == null)
{
More information about the jboss-cvs-commits
mailing list